9
3

Commands.cpp 430 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831
  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. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1792. break;
  1793. }
  1794. case COMMAND_RELOADSTRUCTS: {
  1795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1796. world.SetReloadingSubsystem("Structs");
  1797. configReader.ReloadStructs();
  1798. world.RemoveReloadingSubSystem("Structs");
  1799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1800. break;
  1801. }
  1802. case COMMAND_RELOAD_QUESTS: {
  1803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1804. world.SetReloadingSubsystem("Quests");
  1805. master_quest_list.Reload();
  1806. client_list.ReloadQuests();
  1807. zone_list.ReloadClientQuests();
  1808. world.RemoveReloadingSubSystem("Quests");
  1809. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1810. break;
  1811. }
  1812. case COMMAND_RELOAD_SPAWNS: {
  1813. client->GetCurrentZone()->ReloadSpawns();
  1814. break;
  1815. }
  1816. case COMMAND_RELOAD_SPELLS: {
  1817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1818. world.SetReloadingSubsystem("Spells");
  1819. zone_list.DeleteSpellProcess();
  1820. master_spell_list.Reload();
  1821. if (lua_interface)
  1822. lua_interface->ReloadSpells();
  1823. zone_list.LoadSpellProcess();
  1824. world.RemoveReloadingSubSystem("Spells");
  1825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1826. break;
  1827. }
  1828. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1830. world.SetReloadingSubsystem("GroundSpawns");
  1831. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1832. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1833. world.RemoveReloadingSubSystem("GroundSpawns");
  1834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1835. break;
  1836. }
  1837. case COMMAND_RELOAD_ZONESCRIPTS: {
  1838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1839. world.SetReloadingSubsystem("ZoneScripts");
  1840. world.ResetZoneScripts();
  1841. database.LoadZoneScriptData();
  1842. if (lua_interface)
  1843. lua_interface->DestroyZoneScripts();
  1844. world.RemoveReloadingSubSystem("ZoneScripts");
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1846. break;
  1847. }
  1848. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1850. world.SetReloadingSubsystem("EntityCommands");
  1851. client->GetCurrentZone()->ClearEntityCommands();
  1852. database.LoadEntityCommands(client->GetCurrentZone());
  1853. world.RemoveReloadingSubSystem("EntityCommands");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1855. break;
  1856. }
  1857. case COMMAND_RELOAD_FACTIONS: {
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1859. world.SetReloadingSubsystem("Factions");
  1860. master_faction_list.Clear();
  1861. database.LoadFactionList();
  1862. world.RemoveReloadingSubSystem("Factions");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1864. break;
  1865. }
  1866. case COMMAND_RELOAD_MAIL: {
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1868. zone_list.ReloadMail();
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1870. break;
  1871. }
  1872. case COMMAND_RELOAD_GUILDS: {
  1873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1874. world.ReloadGuilds();
  1875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1876. break;
  1877. }
  1878. case COMMAND_RELOAD_LOCATIONS: {
  1879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1880. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1881. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1883. break;
  1884. }
  1885. case COMMAND_RELOAD_RULES: {
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1887. database.LoadRuleSets(true);
  1888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1889. break;
  1890. }
  1891. case COMMAND_RELOAD_TRANSPORTERS: {
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1893. database.LoadTransporters(client->GetCurrentZone());
  1894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1895. break;
  1896. }
  1897. case COMMAND_RELOAD_STARTABILITIES: {
  1898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1899. world.PurgeStartingLists();
  1900. world.LoadStartingLists();
  1901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1902. break;
  1903. }
  1904. case COMMAND_RELOAD_VOICEOVERS: {
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1906. world.PurgeVoiceOvers();
  1907. world.LoadVoiceOvers();
  1908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1909. break;
  1910. }
  1911. case COMMAND_READ: {
  1912. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1913. if (strcmp(sep->arg[0], "read") == 0) {
  1914. int32 item_index = atol(sep->arg[1]);
  1915. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1916. if (item) {
  1917. Spawn* spawn = cmdTarget;
  1918. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  1919. break;
  1920. }
  1921. }
  1922. }
  1923. break;
  1924. }
  1925. case COMMAND_USEABILITY:{
  1926. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1927. if (client->GetPlayer()->GetHP() == 0) {
  1928. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1929. }
  1930. else {
  1931. int32 spell_id = atoul(sep->arg[0]);
  1932. int8 spell_tier = 0;
  1933. if (sep->arg[1][0] && sep->IsNumber(1))
  1934. spell_tier = atoi(sep->arg[1]);
  1935. else
  1936. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1937. if (!spell_tier)
  1938. spell_tier = 1;
  1939. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1940. if (spell) {
  1941. 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)
  1942. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1943. else
  1944. {
  1945. if (cmdTarget)
  1946. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1947. else
  1948. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1949. }
  1950. }
  1951. }
  1952. }
  1953. else if (cmdTarget && cmdTarget->IsWidget())
  1954. {
  1955. Widget* widget = (Widget*)cmdTarget;
  1956. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1957. }
  1958. else
  1959. {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1961. }
  1962. break;
  1963. }
  1964. case COMMAND_INFO:{
  1965. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1966. if(strcmp(sep->arg[0], "inventory") == 0){
  1967. int32 item_index = atol(sep->arg[1]);
  1968. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1969. if(item){
  1970. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1971. break;
  1972. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1973. //DumpPacket(app);
  1974. client->QueuePacket(app);
  1975. if(item->GetItemScript() && lua_interface)
  1976. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1977. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1978. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1979. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1980. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1981. }
  1982. }
  1983. else
  1984. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1985. }
  1986. else if(strcmp(sep->arg[0], "equipment") == 0){
  1987. int32 item_index = atol(sep->arg[1]);
  1988. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1989. if(item){
  1990. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1991. client->QueuePacket(app);
  1992. if(item->GetItemScript() && lua_interface)
  1993. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1994. }
  1995. else
  1996. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1997. }
  1998. else if(strcmp(sep->arg[0], "appearance") == 0){
  1999. int32 item_index = atol(sep->arg[1]);
  2000. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2001. if(item){
  2002. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2003. client->QueuePacket(app);
  2004. if(item->GetItemScript() && lua_interface)
  2005. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2006. }
  2007. else
  2008. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2009. }
  2010. 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){
  2011. int32 item_id = atoul(sep->arg[1]);
  2012. Item* item = master_item_list.GetItem(item_id);
  2013. if(item){
  2014. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2015. client->QueuePacket(app);
  2016. }
  2017. else
  2018. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  2019. }
  2020. else if (strcmp(sep->arg[0], "spell") == 0) {
  2021. sint32 spell_id = atol(sep->arg[1]);
  2022. int8 tier = atoi(sep->arg[3]);
  2023. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2024. if (outapp)
  2025. client->QueuePacket(outapp);
  2026. else
  2027. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2028. }
  2029. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2030. sint32 spell_id = atol(sep->arg[2]);
  2031. int8 group = atoi(sep->arg[1]);
  2032. AltAdvanceData* data = 0;
  2033. SpellBookEntry* spellentry = 0;
  2034. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2035. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2036. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2037. if (outapp)
  2038. client->QueuePacket(outapp);
  2039. else
  2040. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2041. }
  2042. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2043. sint32 spell_id = atol(sep->arg[1]);
  2044. int32 tier = atoi(sep->arg[2]);
  2045. if (tier > 255) {
  2046. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2047. if (ent)
  2048. tier = ent->tier;
  2049. }
  2050. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2051. if (outapp)
  2052. client->QueuePacket(outapp);
  2053. else
  2054. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2055. }
  2056. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2057. sint32 recipe_id = atol(sep->arg[1]);
  2058. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2059. if(outapp)
  2060. client->QueuePacket(outapp);
  2061. else
  2062. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  2063. }
  2064. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2065. int32 slot = atol(sep->arg[1]);
  2066. int32 spell_id = atol(sep->arg[2]);
  2067. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2068. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2069. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2070. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2071. if(outapp)
  2072. client->QueuePacket(outapp);
  2073. else
  2074. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2075. }
  2076. else if (strcmp(sep->arg[0], "effect") == 0) {
  2077. int32 spell_id = atol(sep->arg[1]);
  2078. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  2079. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2080. int8 type = 0;
  2081. if (client->GetVersion() <= 546)
  2082. type = 1;
  2083. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2084. if (outapp){
  2085. client->QueuePacket(outapp);
  2086. }
  2087. else
  2088. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2089. }
  2090. }
  2091. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2092. Item* item = player->item_list.GetOverflowItem();
  2093. if(item) {
  2094. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2095. client->QueuePacket(app);
  2096. }
  2097. else
  2098. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2099. }
  2100. else
  2101. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2102. break;
  2103. }
  2104. case COMMAND_USE_EQUIPPED_ITEM:{
  2105. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2106. int32 slot_id = atoul(sep->arg[0]);
  2107. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2108. if (item && item->generic_info.usable && item->GetItemScript()) {
  2109. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2110. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2111. }
  2112. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2113. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2114. }
  2115. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2116. client->Message(0, "%s requires a good race.", item->name.c_str());
  2117. }
  2118. else {
  2119. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2120. }
  2121. }
  2122. }
  2123. break;
  2124. }
  2125. case COMMAND_USE_ITEM: {
  2126. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2127. int32 item_index = atoul(sep->arg[0]);
  2128. Item* item = player->item_list.GetItemFromIndex(item_index);
  2129. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2130. }
  2131. break;
  2132. }
  2133. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2134. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2135. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2136. if (item) {
  2137. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2138. if(item->generic_info.item_type == 6) {
  2139. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2140. int8 old_slot = 0;
  2141. if (spell) {
  2142. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2143. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2144. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2145. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2146. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2147. player->RemoveSpellBookEntry(spell->GetSpellID());
  2148. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2149. player->UnlockSpell(spell);
  2150. client->SendSpellUpdate(spell);
  2151. database.DeleteItem(client->GetCharacterID(), item, 0);
  2152. player->item_list.RemoveItem(item, true);
  2153. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2154. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2155. // force purge client cache and display updated spell for hover over
  2156. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2157. client->QueuePacket(app);
  2158. }
  2159. }
  2160. else
  2161. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2162. }
  2163. else if(item->generic_info.item_type == 7){
  2164. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  2165. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  2166. // if valid recipe book and the player doesn't have it
  2167. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  2168. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  2169. safe_delete(recipe_book);
  2170. }
  2171. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  2172. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  2173. // Add recipe book to the players list
  2174. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  2175. // Get a list of all recipes this book contains
  2176. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  2177. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  2178. // Create the packet to send to update the players recipe list
  2179. PacketStruct* packet = 0;
  2180. if (client->GetRecipeListSent()) {
  2181. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  2182. if (packet)
  2183. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  2184. }
  2185. // loop through the list
  2186. vector<Recipe*>::iterator itr;
  2187. int16 i = 0;
  2188. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  2189. // check to see if the player already has this recipe some how
  2190. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  2191. // Player doesn't already have this recipe so lets add it
  2192. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  2193. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  2194. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  2195. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  2196. if (packet && client->GetRecipeListSent()) {
  2197. packet->setArrayDataByName("id", recipe->GetID(), i);
  2198. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  2199. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  2200. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  2201. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  2202. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  2203. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  2204. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  2205. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  2206. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  2207. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  2208. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  2209. i++;
  2210. }
  2211. }
  2212. }
  2213. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  2214. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  2215. database.DeleteItem(client->GetCharacterID(), item, 0);
  2216. client->GetPlayer()->item_list.RemoveItem(item, true);
  2217. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  2218. if (packet && client->GetRecipeListSent())
  2219. client->QueuePacket(packet->serialize());
  2220. safe_delete(packet);
  2221. }
  2222. else {
  2223. if (recipe_book)
  2224. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  2225. safe_delete(recipe_book);
  2226. }
  2227. }
  2228. }
  2229. else
  2230. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2231. }
  2232. break;
  2233. }
  2234. case COMMAND_SUMMONITEM: {
  2235. if (sep && sep->IsNumber(0)) {
  2236. int32 item_id = atol(sep->arg[0]);
  2237. int32 quantity = 1;
  2238. if (sep->arg[1] && sep->IsNumber(1))
  2239. quantity = atoi(sep->arg[1]);
  2240. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2241. client->AddItemToBank(item_id,quantity);
  2242. }
  2243. else {
  2244. client->AddItem(item_id, quantity);
  2245. }
  2246. }
  2247. else {
  2248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2250. }
  2251. break;
  2252. }
  2253. case COMMAND_COLLECTION_ADDITEM: {
  2254. // takes 2 params: collection_id, slot
  2255. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2256. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2257. if (item)
  2258. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2259. else
  2260. 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]));
  2261. }
  2262. else
  2263. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2264. break;
  2265. }
  2266. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2267. // takes 1 param: slot
  2268. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2269. int i = 0;
  2270. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2271. printf("\t%u: %s\n", i, sep->arg[i]);
  2272. i++;
  2273. }
  2274. break;
  2275. }
  2276. case COMMAND_WAYPOINT: {
  2277. bool success = false;
  2278. client->ClearWaypoint();
  2279. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2280. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2281. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2282. }
  2283. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2284. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2285. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2286. }
  2287. else {
  2288. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2289. }
  2290. break;
  2291. }
  2292. case COMMAND_WHO:{
  2293. const char* who = 0;
  2294. if(sep && sep->arg[0]){
  2295. //cout << "Who query: \n";
  2296. who = sep->argplus[0];
  2297. //cout << who << endl;
  2298. }
  2299. zone_list.ProcessWhoQuery(who, client);
  2300. break;
  2301. }
  2302. case COMMAND_SELECT_JUNCTION:{
  2303. 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__);
  2304. int32 choice = 0;
  2305. if(sep && sep->arg[0] && sep->IsNumber(0))
  2306. choice = atoul(sep->arg[0]);
  2307. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  2308. client->HandlePlayerRevive(choice);
  2309. }
  2310. break;
  2311. }
  2312. case COMMAND_SPAWN_MOVE: {
  2313. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2314. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2315. if (packet) {
  2316. float unknown2_3 = 0;
  2317. int8 placement_mode = 0;
  2318. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2319. if (sep && sep->arg[0][0]) {
  2320. if (strcmp(sep->arg[0], "wall") == 0) {
  2321. placement_mode = 2;
  2322. unknown2_3 = 150;
  2323. }
  2324. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2325. placement_mode = 1;
  2326. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2327. {
  2328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2329. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2330. }
  2331. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2332. {
  2333. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2334. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2335. }
  2336. else if (strcmp(sep->arg[0], "myloc") == 0)
  2337. {
  2338. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2339. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2340. safe_delete(packet);
  2341. break;
  2342. }
  2343. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2344. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2345. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2346. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2347. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2348. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2349. safe_delete(packet);
  2350. break;
  2351. }
  2352. }
  2353. packet->setDataByName("placement_mode", placement_mode);
  2354. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2355. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2356. packet->setDataByName("unknown", 1); //size
  2357. packet->setDataByName("unknown2", 1); //size 2
  2358. packet->setDataByName("unknown2", .5, 1); //size 3
  2359. packet->setDataByName("unknown2", 3, 2);
  2360. packet->setDataByName("unknown2", unknown2_3, 3);
  2361. packet->setDataByName("max_distance", 500);
  2362. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2363. client->QueuePacket(packet->serialize());
  2364. safe_delete(packet);
  2365. }
  2366. }
  2367. else {
  2368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2370. }
  2371. break;
  2372. }
  2373. case COMMAND_HAIL:{
  2374. Spawn* spawn = cmdTarget;
  2375. if(spawn && spawn->GetTargetable())
  2376. {
  2377. char tmp[75] = {0};
  2378. sprintf(tmp, "Hail, %s", spawn->GetName());
  2379. bool show_bubble = true;
  2380. if (spawn->IsNPC())
  2381. show_bubble = false;
  2382. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2383. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2384. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2385. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2386. else
  2387. {
  2388. bool pauseRunback = false;
  2389. // prime runback as the heading or anything can be altered when hailing succeeds
  2390. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2391. {
  2392. ((NPC*)spawn)->StartRunback();
  2393. pauseRunback = true;
  2394. }
  2395. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2396. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2397. else if(spawn->IsNPC() && pauseRunback)
  2398. ((NPC*)spawn)->ClearRunback();
  2399. }
  2400. }
  2401. }
  2402. else {
  2403. string tmp = "Hail";
  2404. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2405. }
  2406. break;
  2407. }
  2408. case COMMAND_SAY:{
  2409. if (sep && sep->arg[0][0]) {
  2410. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2411. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2412. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2413. }
  2414. else
  2415. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2416. break;
  2417. }
  2418. case COMMAND_TELL:{
  2419. if(sep && sep->arg[0] && sep->argplus[1]){
  2420. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2421. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2422. }else
  2423. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2424. break;
  2425. }
  2426. case COMMAND_SHOUT:{
  2427. if(sep && sep->arg[0][0])
  2428. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2429. else
  2430. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2431. break;
  2432. }
  2433. case COMMAND_AUCTION:{
  2434. if(sep && sep->arg[0][0])
  2435. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2436. else
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2438. break;
  2439. }
  2440. case COMMAND_OOC:{
  2441. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2442. if(sep && sep->arg[0][0])
  2443. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2444. else
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2446. break;
  2447. }
  2448. case COMMAND_EMOTE:{
  2449. if(sep && sep->arg[0][0])
  2450. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2451. else
  2452. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2453. break;
  2454. }
  2455. case COMMAND_RACE:{
  2456. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2457. if(sep->arg[1][0] && sep->IsNumber(1)){
  2458. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2459. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2460. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2461. client->GetPlayer()->SetCharSheetChanged(true);
  2462. }
  2463. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2464. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2465. //client->QueuePacket(outapp);
  2466. }
  2467. else{
  2468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2470. }
  2471. break;
  2472. }
  2473. case COMMAND_BANK_DEPOSIT:{
  2474. if(client->GetBanker() && sep && sep->arg[0]){
  2475. int64 amount = 0;
  2476. string deposit = string(sep->arg[0]);
  2477. amount = atoi64(deposit.c_str());
  2478. client->BankDeposit(amount);
  2479. }
  2480. break;
  2481. }
  2482. case COMMAND_BANK_WITHDRAWAL:{
  2483. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2484. int64 amount = 0;
  2485. string deposit = string(sep->arg[0]);
  2486. amount = atoi64(deposit.c_str());
  2487. client->BankWithdrawal(amount);
  2488. }
  2489. break;
  2490. }
  2491. case COMMAND_BANK_CANCEL:{
  2492. Spawn* banker = cmdTarget;
  2493. client->Bank(banker, true);
  2494. break;
  2495. }
  2496. case COMMAND_BANK:{
  2497. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2498. Spawn* banker = cmdTarget;
  2499. client->Bank(banker);
  2500. break;
  2501. }
  2502. case COMMAND_GUILD_BANK:{
  2503. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2504. //Spawn* banker = client->GetPlayer()->GetTarget();
  2505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2506. break;
  2507. }
  2508. case COMMAND_START_MAIL: {
  2509. client->SetMailTransaction(cmdTarget);
  2510. client->SendMailList();
  2511. break;
  2512. }
  2513. case COMMAND_CANCEL_MAIL: {
  2514. client->SetMailTransaction(0);
  2515. break;
  2516. }
  2517. case COMMAND_GET_MAIL_MESSAGE: {
  2518. if (sep && sep->arg[0] && sep->IsNumber(0))
  2519. client->DisplayMailMessage(atoul(sep->arg[0]));
  2520. break;
  2521. }
  2522. case COMMAND_ADD_MAIL_PLAT: {
  2523. if (sep && sep->arg[0] && sep->IsNumber(0))
  2524. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2525. break;
  2526. }
  2527. case COMMAND_ADD_MAIL_GOLD: {
  2528. if (sep && sep->arg[0] && sep->IsNumber(0))
  2529. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2530. break;
  2531. }
  2532. case COMMAND_ADD_MAIL_SILVER: {
  2533. if (sep && sep->arg[0] && sep->IsNumber(0))
  2534. client->AddMailCoin(0, atoul(sep->arg[0]));
  2535. break;
  2536. }
  2537. case COMMAND_ADD_MAIL_COPPER: {
  2538. if (sep && sep->arg[0] && sep->IsNumber(0))
  2539. client->AddMailCoin(atoul(sep->arg[0]));
  2540. break;
  2541. }
  2542. case COMMAND_SET_MAIL_ITEM: {
  2543. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2544. {
  2545. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2546. if(item)
  2547. {
  2548. int16 quantity = atoul(sep->arg[1]);
  2549. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2550. {
  2551. return;
  2552. }
  2553. if(item->IsBag())
  2554. {
  2555. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2556. if(bag_items && bag_items->size() > 0)
  2557. {
  2558. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2559. safe_delete(bag_items);
  2560. return;
  2561. }
  2562. safe_delete(bag_items);
  2563. }
  2564. Item* itemtoadd = item;
  2565. if(quantity > 0)
  2566. {
  2567. if(quantity > item->details.count)
  2568. return;
  2569. Item* tmpItem = new Item(item);
  2570. tmpItem->details.count = quantity;
  2571. itemtoadd = tmpItem;
  2572. }
  2573. if(client->AddMailItem(itemtoadd))
  2574. {
  2575. client->RemoveItem(item, quantity, true);
  2576. }
  2577. }
  2578. }
  2579. break;
  2580. }
  2581. case COMMAND_REMOVE_MAIL_PLAT: {
  2582. if (sep && sep->arg[0] && sep->IsNumber(0))
  2583. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2584. break;
  2585. }
  2586. case COMMAND_REMOVE_MAIL_GOLD: {
  2587. if (sep && sep->arg[0] && sep->IsNumber(0))
  2588. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2589. break;
  2590. }
  2591. case COMMAND_REMOVE_MAIL_SILVER: {
  2592. if (sep && sep->arg[0] && sep->IsNumber(0))
  2593. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2594. break;
  2595. }
  2596. case COMMAND_REMOVE_MAIL_COPPER: {
  2597. if (sep && sep->arg[0] && sep->IsNumber(0))
  2598. client->RemoveMailCoin(atoul(sep->arg[0]));
  2599. break;
  2600. }
  2601. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2602. if (sep && sep->arg[0] && sep->IsNumber(0))
  2603. client->TakeMailAttachments(atoul(sep->arg[0]));
  2604. break;
  2605. }
  2606. case COMMAND_CANCEL_SEND_MAIL: {
  2607. client->ResetSendMail();
  2608. break;
  2609. }
  2610. case COMMAND_DELETE_MAIL_MESSAGE: {
  2611. if (sep && sep->arg[0] && sep->IsNumber(0))
  2612. client->DeleteMail(atoul(sep->arg[0]), true);
  2613. break;
  2614. }
  2615. case COMMAND_REPORT_SPAM: {
  2616. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2617. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2618. break;
  2619. }
  2620. case COMMAND_KILL:{
  2621. Spawn* dead = 0;
  2622. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2623. dead=client->GetPlayer();
  2624. client->GetPlayer()->SetHP(0);
  2625. client->GetPlayer()->KillSpawn(dead);
  2626. }else{
  2627. dead= cmdTarget;
  2628. if(dead && dead->IsPlayer() == false){
  2629. dead->SetHP(0);
  2630. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2631. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2632. else
  2633. client->GetPlayer()->KillSpawn(dead);
  2634. }else{
  2635. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2637. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2638. }
  2639. }
  2640. break;
  2641. }
  2642. case COMMAND_LEVEL:{
  2643. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2644. int16 new_level = atoi(sep->arg[ndx]);
  2645. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2646. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2647. else {
  2648. if (new_level < 1)
  2649. new_level = 1;
  2650. if (new_level > 255)
  2651. new_level = 255;
  2652. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2653. }
  2654. }else
  2655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2656. break;
  2657. }
  2658. case COMMAND_SIT: {
  2659. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2660. if(client->GetPlayer()->GetHP() > 0){
  2661. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2663. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2664. }
  2665. break;
  2666. }
  2667. case COMMAND_STAND: {
  2668. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2669. if(client->GetPlayer()->GetHP() > 0){
  2670. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2671. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2672. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2673. }
  2674. break;
  2675. }
  2676. case COMMAND_CLASS:{
  2677. if(sep && sep->arg[ndx][0]){
  2678. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2679. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2680. }else
  2681. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2682. break;
  2683. }
  2684. case COMMAND_GENDER:{
  2685. if(sep && sep->arg[ndx][0]){
  2686. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2687. client->GetPlayer()->SetCharSheetChanged(true);
  2688. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2689. }else{
  2690. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2691. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2692. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2693. }
  2694. break;
  2695. }
  2696. case COMMAND_FLYMODE:{
  2697. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2698. PrintSep(sep, "COMMAND_FLYMODE");
  2699. int8 val = atoi(sep->arg[0]);
  2700. ClientPacketFunctions::SendFlyMode(client, val);
  2701. }
  2702. else{
  2703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2705. }
  2706. break;
  2707. }
  2708. case COMMAND_LOOT_LIST:{
  2709. Spawn* spawn = cmdTarget;
  2710. if(spawn && spawn->IsEntity()){
  2711. if (sep && sep->arg[0]) {
  2712. if (!spawn->GetDatabaseID())
  2713. {
  2714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2715. break;
  2716. }
  2717. else if (!spawn->IsNPC())
  2718. {
  2719. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2720. break;
  2721. }
  2722. bool reloadLoot = false;
  2723. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2724. {
  2725. int32 loottable_id = atoul(sep->arg[1]);
  2726. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2727. {
  2728. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2729. reloadLoot = true;
  2730. }
  2731. else
  2732. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2733. }
  2734. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2735. {
  2736. int32 loottable_id = atoul(sep->arg[1]);
  2737. if (loottable_id > 0)
  2738. {
  2739. database.AddLootTableToSpawn(spawn, loottable_id);
  2740. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2741. reloadLoot = true;
  2742. }
  2743. else
  2744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2745. }
  2746. else if (!stricmp(sep->arg[0], "clearall"))
  2747. {
  2748. if (database.RemoveSpawnLootTable(spawn, 0))
  2749. {
  2750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2751. reloadLoot = true;
  2752. }
  2753. else
  2754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2755. }
  2756. else
  2757. {
  2758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2762. break;
  2763. }
  2764. if (reloadLoot)
  2765. {
  2766. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2767. if (spawn->IsNPC())
  2768. {
  2769. Entity* ent = (Entity*)spawn;
  2770. ent->SetLootCoins(0);
  2771. ent->ClearLoot();
  2772. spawn->GetZone()->AddLoot((NPC*)spawn);
  2773. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2774. }
  2775. }
  2776. break; // nothing further this is the end of these sub commands
  2777. }
  2778. else
  2779. {
  2780. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2781. if (loot_list.size() > 0) {
  2782. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2783. vector<int32>::iterator list_itr;
  2784. LootTable* table = 0;
  2785. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2786. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2787. if (table)
  2788. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2789. }
  2790. }
  2791. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2792. vector<Item*>* items = spawn->GetLootItems();
  2793. if (items) {
  2794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2795. vector<Item*>::iterator itr;
  2796. Item* item = 0;
  2797. for (itr = items->begin(); itr != items->end(); itr++) {
  2798. item = *itr;
  2799. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2800. }
  2801. }
  2802. else
  2803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2804. }
  2805. }
  2806. break;
  2807. }
  2808. case COMMAND_LOOT_SETCOIN:{
  2809. Spawn* spawn = cmdTarget;
  2810. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2811. spawn->SetLootCoins(atoul(sep->arg[0]));
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2813. }
  2814. else
  2815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2816. break;
  2817. }
  2818. case COMMAND_LOOT_ADDITEM:{
  2819. Spawn* spawn = cmdTarget;
  2820. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2821. int16 charges = 1;
  2822. if(sep->arg[1] && sep->IsNumber(1))
  2823. charges = atoi(sep->arg[1]);
  2824. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2826. }
  2827. else
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2829. break;
  2830. }
  2831. case COMMAND_LOOT_REMOVEITEM:{
  2832. Spawn* spawn = cmdTarget;
  2833. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2834. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2835. safe_delete(item);
  2836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2837. }
  2838. else
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2840. break;
  2841. }
  2842. case COMMAND_LOOT_CORPSE:
  2843. case COMMAND_DISARM:
  2844. case COMMAND_LOOT:{
  2845. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2846. {
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2848. break;
  2849. }
  2850. if(cmdTarget && cmdTarget->IsEntity()){
  2851. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2852. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2853. client->OpenChest(cmdTarget, true);
  2854. else
  2855. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2856. if (!(cmdTarget)->HasLoot()){
  2857. if (((Entity*)cmdTarget)->IsNPC())
  2858. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2859. }
  2860. }
  2861. else
  2862. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2863. }
  2864. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2866. break;
  2867. }
  2868. case COMMAND_RELOADSPAWNSCRIPTS:{
  2869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2870. if (lua_interface)
  2871. lua_interface->SetLuaSystemReloading(true);
  2872. world.ResetSpawnScripts();
  2873. database.LoadSpawnScriptData();
  2874. if(lua_interface) {
  2875. lua_interface->DestroySpawnScripts();
  2876. lua_interface->SetLuaSystemReloading(false);
  2877. }
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2879. break;
  2880. }
  2881. case COMMAND_RELOADREGIONSCRIPTS:{
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2883. if(lua_interface) {
  2884. lua_interface->DestroyRegionScripts();
  2885. }
  2886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2887. break;
  2888. }
  2889. case COMMAND_RELOADLUASYSTEM:{
  2890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2891. world.SetReloadingSubsystem("LuaSystem");
  2892. if(lua_interface) {
  2893. lua_interface->SetLuaSystemReloading(true);
  2894. }
  2895. zone_list.DeleteSpellProcess();
  2896. master_spell_list.Reload();
  2897. if (lua_interface)
  2898. lua_interface->ReloadSpells();
  2899. zone_list.LoadSpellProcess();
  2900. if(lua_interface){
  2901. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2902. map<Client*, int32>::iterator itr;
  2903. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2904. if(lua_interface)
  2905. lua_interface->UpdateDebugClients(itr->first);
  2906. }
  2907. }
  2908. world.ResetSpawnScripts();
  2909. database.LoadSpawnScriptData();
  2910. world.ResetZoneScripts();
  2911. database.LoadZoneScriptData();
  2912. if(lua_interface) {
  2913. lua_interface->DestroySpawnScripts();
  2914. lua_interface->DestroyRegionScripts();
  2915. lua_interface->DestroyQuests();
  2916. lua_interface->DestroyItemScripts();
  2917. lua_interface->DestroyZoneScripts();
  2918. }
  2919. int32 quest_count = database.LoadQuests();
  2920. int32 spell_count = 0;
  2921. if(lua_interface) {
  2922. spell_count = database.LoadSpellScriptData();
  2923. lua_interface->SetLuaSystemReloading(false);
  2924. }
  2925. world.RemoveReloadingSubSystem("LuaSystem");
  2926. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2927. break;
  2928. }
  2929. case COMMAND_DECLINE_QUEST:{
  2930. int32 quest_id = 0;
  2931. if(sep && sep->arg[0] && sep->IsNumber(0))
  2932. quest_id = atoul(sep->arg[0]);
  2933. if(quest_id > 0){
  2934. Quest* quest = client->GetPendingQuest(quest_id);
  2935. if(quest){
  2936. client->RemovePendingQuest(quest);
  2937. if(lua_interface)
  2938. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2939. safe_delete(quest);
  2940. client->GetCurrentZone()->SendQuestUpdates(client);
  2941. }
  2942. }
  2943. break;
  2944. }
  2945. case COMMAND_DELETE_QUEST:{
  2946. int32 quest_id = 0;
  2947. if(sep && sep->arg[0] && sep->IsNumber(0))
  2948. quest_id = atoul(sep->arg[0]);
  2949. if(quest_id > 0){
  2950. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2951. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2952. if (quest)
  2953. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2954. }
  2955. client->RemovePlayerQuest(quest_id);
  2956. client->GetCurrentZone()->SendQuestUpdates(client);
  2957. }
  2958. break;
  2959. }
  2960. case COMMAND_ACCEPT_QUEST:{
  2961. int32 quest_id = 0;
  2962. if(sep && sep->arg[0] && sep->IsNumber(0))
  2963. quest_id = atoul(sep->arg[0]);
  2964. if(quest_id > 0){
  2965. client->AcceptQuest(quest_id);
  2966. }
  2967. break;
  2968. }
  2969. case COMMAND_NAME:{
  2970. if(sep && sep->arg[ndx][0]){
  2971. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2972. client->GetPlayer()->SetCharSheetChanged(true);
  2973. }else
  2974. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2975. break;
  2976. }
  2977. case COMMAND_GROUPSAY:{
  2978. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2979. if(sep && sep->arg[0] && gmi)
  2980. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  2981. break;
  2982. }
  2983. case COMMAND_GROUPINVITE: {
  2984. Entity* target = 0;
  2985. Client* target_client = 0;
  2986. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2987. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2988. return;
  2989. }
  2990. // name provided with command so it has to be a player, npc not supported here
  2991. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2992. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2993. if (target_client) {
  2994. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2995. target = 0;
  2996. else
  2997. target = target_client->GetPlayer();
  2998. }
  2999. }
  3000. // if name was not provided use the players target, npc or player supported here
  3001. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3002. target = (Entity*)client->GetPlayer()->GetTarget();
  3003. if (target->IsPlayer()) {
  3004. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  3005. }
  3006. }
  3007. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3008. if (result == 0) {
  3009. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3010. if (target_client) {
  3011. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3012. if (packet) {
  3013. packet->setDataByName("type", 1);
  3014. packet->setDataByName("name", client->GetPlayer()->GetName());
  3015. packet->setDataByName("unknown2", 1);
  3016. target_client->QueuePacket(packet->serialize());
  3017. safe_delete(packet);
  3018. }
  3019. }
  3020. }
  3021. else if (result == 1)
  3022. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3023. else if (result == 2)
  3024. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3025. else if (result == 3)
  3026. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3027. else if (result == 4)
  3028. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3029. else if (result == 5)
  3030. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3031. else if (result == 6)
  3032. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3033. else
  3034. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3035. break;
  3036. }
  3037. case COMMAND_GROUPDISBAND: {
  3038. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3039. if (gmi) { // TODO: Leader check
  3040. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3041. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3042. }
  3043. break;
  3044. }
  3045. case COMMAND_GROUP_LEAVE: {
  3046. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3047. if (gmi) {
  3048. int32 group_id = gmi->group_id;
  3049. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3050. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3051. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3052. }
  3053. else {
  3054. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3055. }
  3056. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3057. }
  3058. break;
  3059. }
  3060. case COMMAND_FRIEND_ADD:{
  3061. string name = "";
  3062. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3063. name = database.GetPlayerName(sep->arg[0]);
  3064. else if(cmdTarget && cmdTarget->IsPlayer())
  3065. name = string(cmdTarget->GetName());
  3066. if(name.length() > 0){
  3067. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3068. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3069. client->GetPlayer()->RemoveIgnore(name.c_str());
  3070. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3071. client->SendChatRelationship(3, name.c_str());
  3072. }
  3073. client->GetPlayer()->AddFriend(name.c_str(), true);
  3074. client->SendChatRelationship(0, name.c_str());
  3075. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3076. if(zone_list.GetClientByCharName(name))
  3077. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3078. }
  3079. else
  3080. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3081. }
  3082. else
  3083. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3084. break;
  3085. }
  3086. case COMMAND_FRIEND_REMOVE:{
  3087. string name = "";
  3088. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3089. name = database.GetPlayerName(sep->arg[0]);
  3090. else if(cmdTarget && cmdTarget->IsPlayer())
  3091. name = string(cmdTarget->GetName());
  3092. if(name.length() > 0){
  3093. client->GetPlayer()->RemoveFriend(name.c_str());
  3094. client->SendChatRelationship(1, name.c_str());
  3095. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3096. }
  3097. else
  3098. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3099. break;
  3100. }
  3101. case COMMAND_FRIENDS:{
  3102. break;
  3103. }
  3104. case COMMAND_IGNORE_ADD:{
  3105. string name = "";
  3106. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3107. name = database.GetPlayerName(sep->arg[0]);
  3108. else if(cmdTarget && cmdTarget->IsPlayer())
  3109. name = string(cmdTarget->GetName());
  3110. if(name.length() > 0){
  3111. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3112. if(client->GetPlayer()->IsFriend(name.c_str())){
  3113. client->GetPlayer()->RemoveFriend(name.c_str());
  3114. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3115. client->SendChatRelationship(1, name.c_str());
  3116. }
  3117. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3118. client->SendChatRelationship(2, name.c_str());
  3119. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3120. }
  3121. else
  3122. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3123. }
  3124. else
  3125. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3126. break;
  3127. }
  3128. case COMMAND_IGNORE_REMOVE:{
  3129. string name = "";
  3130. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3131. name = database.GetPlayerName(sep->arg[0]);
  3132. else if(cmdTarget && cmdTarget->IsPlayer())
  3133. name = string(cmdTarget->GetName());
  3134. if(name.length() > 0){
  3135. client->GetPlayer()->RemoveIgnore(name.c_str());
  3136. client->SendChatRelationship(3, name.c_str());
  3137. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3138. }
  3139. break;
  3140. }
  3141. case COMMAND_IGNORES:{
  3142. break;
  3143. }
  3144. case COMMAND_GROUP_KICK:{
  3145. Entity* kicked = 0;
  3146. Client* kicked_client = 0;
  3147. int32 group_id = 0;
  3148. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3149. return;
  3150. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  3151. if (sep && sep->arg[0]) {
  3152. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3153. if (kicked_client)
  3154. kicked = kicked_client->GetPlayer();
  3155. }
  3156. else if (cmdTarget && cmdTarget->IsEntity()) {
  3157. kicked = (Entity*)cmdTarget;
  3158. }
  3159. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3160. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3161. if (kicked)
  3162. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3163. if(send_kicked_message)
  3164. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3165. else
  3166. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3167. if (kicked_client)
  3168. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3169. break;
  3170. }
  3171. case COMMAND_GROUP_MAKE_LEADER:{
  3172. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3173. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3174. return;
  3175. }
  3176. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3177. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3178. if (new_leader) {
  3179. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3180. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  3181. }
  3182. }
  3183. else
  3184. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3185. }
  3186. else if (cmdTarget && cmdTarget->IsPlayer())
  3187. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  3188. else
  3189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3190. break;
  3191. }
  3192. case COMMAND_GROUP_ACCEPT_INVITE: {
  3193. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3194. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3195. if (result == 0)
  3196. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3197. else if (result == 1)
  3198. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3199. else if (result == 2)
  3200. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3201. else
  3202. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3203. }
  3204. break;
  3205. }
  3206. case COMMAND_GROUP_DECLINE_INVITE: {
  3207. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3208. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3209. }
  3210. break;
  3211. }
  3212. case COMMAND_SUMMON:{
  3213. char* search_name = 0;
  3214. if(sep && sep->arg[0][0])
  3215. search_name = sep->arg[0];
  3216. if(!search_name && !cmdTarget){
  3217. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3218. 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.");
  3219. }
  3220. else{
  3221. if(!client->Summon(search_name))
  3222. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3223. }
  3224. break;
  3225. }
  3226. case COMMAND_GOTO:{
  3227. const char* search_name = 0;
  3228. if(sep && sep->arg[0][0])
  3229. search_name = sep->argplus[0];
  3230. if(!search_name && !cmdTarget){
  3231. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3232. 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.");
  3233. }
  3234. else{
  3235. if(!client->GotoSpawn(search_name))
  3236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3237. }
  3238. break;
  3239. }
  3240. case COMMAND_MOVE:{
  3241. bool success = false;
  3242. try{
  3243. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3244. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3245. if(app){
  3246. client->QueuePacket(app);
  3247. success = true;
  3248. }
  3249. }
  3250. }
  3251. catch(...){}
  3252. if(!success){
  3253. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3254. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3255. }
  3256. break;
  3257. }
  3258. case COMMAND_SETTIME:{
  3259. if(sep && sep->arg[0]){
  3260. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3261. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3262. if(sep->arg[1] && sep->IsNumber(1))
  3263. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3264. if(sep->arg[2] && sep->IsNumber(2))
  3265. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3266. if(sep->arg[3] && sep->IsNumber(3))
  3267. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3268. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3269. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3270. }
  3271. else{
  3272. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3273. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3274. }
  3275. break;
  3276. }
  3277. case COMMAND_VERSION:{
  3278. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3279. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3280. break;
  3281. }
  3282. case COMMAND_ZONE:{
  3283. int32 instanceID = 0;
  3284. string zone;
  3285. int32 zone_id = 0;
  3286. bool listSearch = false;
  3287. bool isInstance = false;
  3288. ZoneServer* zsZone = 0;
  3289. if(sep && sep->arg[0][0])
  3290. {
  3291. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3292. listSearch = true;
  3293. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3294. {
  3295. zone_list.SendZoneList(client);
  3296. break;
  3297. }
  3298. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3299. {
  3300. if(sep->IsNumber(1))
  3301. instanceID = atol(sep->arg[1]);
  3302. }
  3303. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3304. {
  3305. PrintSep(sep, "ZONE LOCK");
  3306. if(sep->IsNumber(1))
  3307. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3308. else
  3309. zsZone = zone_list.Get(sep->arg[1], false);
  3310. if( zsZone )
  3311. {
  3312. zsZone->SetZoneLockState(true);
  3313. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3314. }
  3315. else
  3316. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3317. break;
  3318. }
  3319. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3320. {
  3321. PrintSep(sep, "ZONE UNLOCK");
  3322. if(sep->IsNumber(1))
  3323. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3324. else
  3325. zsZone = zone_list.Get(sep->arg[1], false);
  3326. if( zsZone )
  3327. {
  3328. zsZone->SetZoneLockState(false);
  3329. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3330. }
  3331. else
  3332. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3333. break;
  3334. }
  3335. else
  3336. {
  3337. if(sep->IsNumber(0))
  3338. {
  3339. zone_id = atoul(sep->arg[0]);
  3340. string zonename = database.GetZoneName(zone_id);
  3341. if(zonename.length() > 0)
  3342. zone = zonename;
  3343. }
  3344. else
  3345. zone = sep->arg[0];
  3346. }
  3347. if(instanceID > 0)
  3348. {
  3349. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3350. if(zsInstance != NULL)
  3351. {
  3352. instanceID = zsInstance->GetInstanceID();
  3353. zone = zsInstance->GetZoneName();
  3354. zone_id = zsInstance->GetZoneID();
  3355. isInstance = true;
  3356. }
  3357. }
  3358. }
  3359. if(!listSearch)
  3360. {
  3361. if(zone.length() == 0)
  3362. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3363. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3364. zone_id != client->GetCurrentZone()->GetZoneID())
  3365. {
  3366. const char* zonestr = zone.c_str();
  3367. if(database.VerifyZone(zonestr))
  3368. {
  3369. if(client->CheckZoneAccess(zonestr))
  3370. {
  3371. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3372. if(isInstance)
  3373. client->Zone(instanceID,true,true,false);
  3374. else
  3375. client->Zone(zonestr);
  3376. }
  3377. }
  3378. else
  3379. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3380. }
  3381. else
  3382. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3383. }
  3384. else
  3385. {
  3386. const char* name = 0;
  3387. if(sep && sep->arg[1][0])
  3388. {
  3389. map<int32, string>* zone_names;
  3390. name = sep->argplus[1];
  3391. sint16 status = client->GetAdminStatus();
  3392. if( status > 0 )
  3393. {
  3394. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3395. zone_names = database.GetZoneList(name, true);
  3396. }
  3397. else
  3398. zone_names = database.GetZoneList(name);
  3399. if(!zone_names)
  3400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3401. else
  3402. {
  3403. map<int32, string>::iterator itr;
  3404. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3405. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3406. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3407. safe_delete(zone_names);
  3408. }
  3409. }
  3410. else
  3411. {
  3412. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3413. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3414. }
  3415. }
  3416. break;
  3417. }
  3418. case COMMAND_USE: {
  3419. Spawn* target = cmdTarget;
  3420. if (target && target->IsWidget())
  3421. ((Widget*)target)->HandleUse(client, "use");
  3422. break;
  3423. }
  3424. case COMMAND_OPEN: {
  3425. Spawn* target = cmdTarget;
  3426. if (target && target->IsWidget())
  3427. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3428. break;
  3429. }
  3430. case COMMAND_CASTSPELL: {
  3431. if (sep && sep->arg[0] && sep->IsNumber(0))
  3432. {
  3433. int8 tier = 1;
  3434. if (sep->arg[1] && sep->IsNumber(1))
  3435. tier = atoul(sep->arg[1]);
  3436. int8 self = 1;
  3437. if (sep->arg[1] && sep->IsNumber(2))
  3438. {
  3439. self = atoul(sep->arg[2]);
  3440. if(self != 1 && !cmdTarget->IsEntity())
  3441. {
  3442. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3443. self = 1;
  3444. }
  3445. }
  3446. int32 spellid = atoul(sep->arg[0]);
  3447. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3448. if (spell)
  3449. {
  3450. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3451. SpellProcess* spellProcess = 0;
  3452. // Get the current zones spell process
  3453. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3454. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3455. }
  3456. else
  3457. {
  3458. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3459. }
  3460. }
  3461. else if (sep && sep->arg[0])
  3462. {
  3463. database.FindSpell(client, (char*)sep->argplus[0]);
  3464. }
  3465. else
  3466. {
  3467. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3468. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3469. }
  3470. break;
  3471. }
  3472. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3473. if (client->GetVersion() <= 546)
  3474. break;
  3475. if (sep && sep->GetArgNumber() == 4)
  3476. {
  3477. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3478. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3479. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3480. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3481. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3482. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3483. ClientPacketFunctions::SendSkillSlotMappings(client);
  3484. }
  3485. else
  3486. {
  3487. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3488. }
  3489. break;
  3490. }
  3491. case COMMAND_MOVE_ITEM:
  3492. {
  3493. int32 id = 0;
  3494. if (sep && sep->IsNumber(0))
  3495. id = atoul(sep->arg[0]);
  3496. Spawn* spawn = 0;
  3497. if (id == 0)
  3498. {
  3499. spawn = cmdTarget;
  3500. }
  3501. else
  3502. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3503. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3504. break;
  3505. client->SendMoveObjectMode(spawn, 0);
  3506. break;
  3507. }
  3508. case COMMAND_PICKUP:
  3509. {
  3510. int32 id = 0;
  3511. if (sep && sep->IsNumber(0))
  3512. id = atoul(sep->arg[0]);
  3513. Spawn* spawn = 0;
  3514. if (id == 0)
  3515. {
  3516. spawn = cmdTarget;
  3517. }
  3518. else
  3519. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3520. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3521. break;
  3522. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3523. Query query;
  3524. 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());
  3525. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3526. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3527. }
  3528. // we had a UI Window displayed, update the house items
  3529. if ( id > 0 )
  3530. client->GetCurrentZone()->SendHouseItems(client);
  3531. }
  3532. break;
  3533. }
  3534. case COMMAND_HOUSE_DEPOSIT:
  3535. {
  3536. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3537. // arg0 = ??? (set to 3)
  3538. // arg1 = coin (in copper)
  3539. // arg2 = status? (not implemented yet)
  3540. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3541. if (ph && sep && sep->IsNumber(1))
  3542. {
  3543. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3544. int32 outValStatus = 0;
  3545. if(sep->IsNumber(2))
  3546. {
  3547. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3548. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3549. outValStatus = 0; // cheat check
  3550. }
  3551. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3552. {
  3553. if(outValStatus)
  3554. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3555. char query[256];
  3556. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3557. if (itr != ph->depositsMap.end())
  3558. {
  3559. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, 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());
  3560. }
  3561. else
  3562. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3563. if (database.RunQuery(query, strnlen(query, 256)))
  3564. {
  3565. ph->escrow_coins += outValCoin;
  3566. ph->escrow_status += outValStatus;
  3567. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3568. database.LoadDeposits(ph);
  3569. client->PlaySound("coin_cha_ching");
  3570. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3571. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3572. }
  3573. else
  3574. {
  3575. if(outValCoin)
  3576. client->GetPlayer()->AddCoins(outValCoin);
  3577. if(outValStatus)
  3578. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3579. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3580. }
  3581. }
  3582. }
  3583. break;
  3584. }
  3585. case COMMAND_HOUSE:
  3586. {
  3587. if (sep && sep->IsNumber(0))
  3588. {
  3589. int32 unique_id = atoi(sep->arg[0]);
  3590. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3591. HouseZone* hz = 0;
  3592. if (ph)
  3593. hz = world.GetHouseZone(ph->house_id);
  3594. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3595. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3596. }
  3597. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3598. {
  3599. // inside a house or something? Send the access window
  3600. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3601. HouseZone* hz = 0;
  3602. if ( ph )
  3603. hz = world.GetHouseZone(ph->house_id);
  3604. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3605. client->GetCurrentZone()->SendHouseItems(client);
  3606. }
  3607. break;
  3608. }
  3609. case COMMAND_HOUSE_UI:
  3610. {
  3611. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3612. {
  3613. int32 unique_id = atoi(sep->arg[0]);
  3614. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3615. HouseZone* hz = 0;
  3616. if ( ph )
  3617. hz = world.GetHouseZone(ph->house_id);
  3618. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3619. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3620. }
  3621. break;
  3622. }
  3623. case COMMAND_PLACE_HOUSE_ITEM: {
  3624. if (sep && sep->IsNumber(0))
  3625. {
  3626. int32 uniqueid = atoi(sep->arg[0]);
  3627. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3628. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3629. if (item && item->IsHouseItem())
  3630. {
  3631. if (!client->HasOwnerOrEditAccess())
  3632. {
  3633. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3634. break;
  3635. }
  3636. else if (!item->generic_info.appearance_id)
  3637. {
  3638. 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);
  3639. break;
  3640. }
  3641. if (client->GetTempPlacementSpawn())
  3642. {
  3643. Spawn* tmp = client->GetTempPlacementSpawn();
  3644. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3645. client->SetTempPlacementSpawn(nullptr);
  3646. }
  3647. Object* obj = new Object();
  3648. Spawn* spawn = (Spawn*)obj;
  3649. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3650. strcpy(spawn->appearance.name, "temp");
  3651. spawn->SetX(client->GetPlayer()->GetX());
  3652. spawn->SetY(client->GetPlayer()->GetY());
  3653. spawn->SetZ(client->GetPlayer()->GetZ());
  3654. spawn->appearance.pos.collision_radius = 32;
  3655. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3656. spawn->SetSpawnOrigX(spawn->GetX());
  3657. spawn->SetSpawnOrigY(spawn->GetY());
  3658. spawn->SetSpawnOrigZ(spawn->GetZ());
  3659. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3660. spawn->appearance.targetable = 1;
  3661. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3662. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3663. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3664. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3665. spawn->SetZone(client->GetCurrentZone());
  3666. client->SetTempPlacementSpawn(spawn);
  3667. client->SetPlacementUniqueItemID(uniqueid);
  3668. client->GetCurrentZone()->AddSpawn(spawn);
  3669. }
  3670. }
  3671. break;
  3672. }
  3673. case COMMAND_GM:
  3674. {
  3675. if (sep && sep->arg[0] && sep->arg[1])
  3676. {
  3677. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3678. if (strcmp(sep->arg[0], "vision") == 0)
  3679. {
  3680. client->GetPlayer()->SetGMVision(onOff);
  3681. #if defined(__GNUC__)
  3682. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3683. #else
  3684. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3685. #endif
  3686. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3687. if (onOff)
  3688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3689. else
  3690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3691. }
  3692. else if (strcmp(sep->arg[0], "tag") == 0)
  3693. {
  3694. int32 value = 0;
  3695. int16 tag_icon = 0;
  3696. // groundspawn has special exception -1 argument so it needs to be handled here
  3697. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3698. value = atoul(sep->arg[2]);
  3699. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3700. if(!value) {
  3701. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3702. break;
  3703. }
  3704. if(!tag_icon) {
  3705. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3706. break;
  3707. }
  3708. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3709. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3710. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3711. }
  3712. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3713. if(value>0) {
  3714. value = 1;
  3715. }
  3716. if(!tag_icon) {
  3717. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3718. break;
  3719. }
  3720. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3721. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3722. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3723. }
  3724. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3725. if(!value) {
  3726. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3727. break;
  3728. }
  3729. if(!tag_icon) {
  3730. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3731. break;
  3732. }
  3733. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3734. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3735. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3736. }
  3737. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3738. // one less argument value field not tag_icon for this one
  3739. if(!value) {
  3740. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3741. break;
  3742. }
  3743. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3744. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3745. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3746. }
  3747. }
  3748. else {
  3749. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3750. client->GetPlayer()->ClearGMVisualFilters();
  3751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3752. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3753. }
  3754. else {
  3755. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3758. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3763. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3764. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3765. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3766. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3767. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3768. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3769. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3770. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3771. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3772. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3773. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3774. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3775. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3776. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3777. "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");
  3778. }
  3779. }
  3780. }
  3781. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3782. {
  3783. client->SetRegionDebug(onOff);
  3784. #if defined(__GNUC__)
  3785. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3786. #else
  3787. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3788. #endif
  3789. if (onOff)
  3790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3791. else
  3792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3793. }
  3794. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3795. {
  3796. client->SetLuaDebugClient(onOff);
  3797. #if defined(__GNUC__)
  3798. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3799. #else
  3800. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3801. #endif
  3802. if (onOff)
  3803. {
  3804. if (lua_interface)
  3805. lua_interface->UpdateDebugClients(client);
  3806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3807. }
  3808. else
  3809. {
  3810. if (lua_interface)
  3811. lua_interface->RemoveDebugClients(client);
  3812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3813. }
  3814. }
  3815. }
  3816. break;
  3817. }
  3818. case COMMAND_ATTACK:
  3819. case COMMAND_AUTO_ATTACK:{
  3820. int8 type = 1;
  3821. Player* player = client->GetPlayer();
  3822. if(!player)
  3823. break;
  3824. bool incombat = player->EngagedInCombat();
  3825. if(sep && sep->arg[0] && sep->IsNumber(0))
  3826. type = atoi(sep->arg[0]);
  3827. if(client->GetPlayer()->GetHP() == 0){
  3828. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3829. break;
  3830. }
  3831. if(type == 0){
  3832. if(incombat)
  3833. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3834. player->StopCombat(type);
  3835. }
  3836. else {
  3837. if(type == 2){
  3838. player->InCombat(false);
  3839. if(incombat && player->GetRangeAttack()){
  3840. player->StopCombat(type);
  3841. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3842. }
  3843. else{
  3844. player->SetRangeAttack(true);
  3845. player->InCombat(true, true);
  3846. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3847. }
  3848. }
  3849. else {
  3850. player->InCombat(false, true);
  3851. player->SetRangeAttack(false);
  3852. player->InCombat(true);
  3853. if(!incombat)
  3854. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3855. }
  3856. /*else
  3857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3858. }
  3859. player->SetCharSheetChanged(true);
  3860. break;
  3861. }
  3862. case COMMAND_DEPOP:{
  3863. bool allow_respawns = false;
  3864. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3865. if(atoi(sep->arg[0]) == 1)
  3866. allow_respawns = true;
  3867. }
  3868. client->GetCurrentZone()->Depop(allow_respawns);
  3869. break;
  3870. }
  3871. case COMMAND_REPOP:{
  3872. client->GetCurrentZone()->Depop(false, true);
  3873. break;
  3874. }
  3875. case COMMAND_BUYBACK:{
  3876. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3877. // 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
  3878. int64 id = atoi64(sep->arg[0]);
  3879. // get the first int32, the item id
  3880. //int32 item_id = (int32)id;
  3881. // get the second int32, the unique id
  3882. int32 unique_id = (int32)(id>>32);
  3883. int8 quantity = atoi(sep->arg[1]);
  3884. if(quantity == 255)
  3885. quantity = 1;
  3886. client->BuyBack(unique_id, quantity);
  3887. }
  3888. break;
  3889. }
  3890. case COMMAND_MERCHANT_BUY:{
  3891. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3892. int32 item_id = atoul(sep->arg[0]);
  3893. int8 quantity = atoi(sep->arg[1]);
  3894. client->BuyItem(item_id, quantity);
  3895. }
  3896. else
  3897. Command_SendMerchantWindow(client, sep);
  3898. break;
  3899. }
  3900. case COMMAND_MERCHANT_SELL:{
  3901. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3902. // 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
  3903. int64 id = atoi64(sep->arg[0]);
  3904. // get the first int32, the item id
  3905. int32 item_id = (int32)id;
  3906. // get the second int32, the unique id
  3907. int32 unique_id = (int32)(id>>32);
  3908. int8 quantity = atoi(sep->arg[1]);
  3909. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3910. client->SellItem(item_id, quantity, unique_id);
  3911. }
  3912. break;
  3913. }
  3914. case COMMAND_MENDER_REPAIR: {
  3915. if (sep && sep->arg[0] && sep->IsNumber(0))
  3916. client->RepairItem(atoul(sep->arg[0]));
  3917. break;
  3918. }
  3919. case COMMAND_MENDER_REPAIR_ALL: {
  3920. client->RepairAllItems();
  3921. break;
  3922. }
  3923. case COMMAND_CANCEL_MERCHANT:{
  3924. client->SetMerchantTransaction(0);
  3925. break;
  3926. }
  3927. case COMMAND_START_MERCHANT:{
  3928. break;
  3929. }
  3930. case COMMAND_INVULNERABLE:{
  3931. sint8 val = -1;
  3932. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3933. val = atoi(sep->arg[0]);
  3934. //devn00b: Fix for linux builds
  3935. #if defined(__GNUC__)
  3936. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3937. #else
  3938. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3939. #endif
  3940. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3941. client->GetPlayer()->SetInvulnerable(val==1);
  3942. if(client->GetPlayer()->GetInvulnerable())
  3943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3944. else
  3945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3946. }
  3947. if(val == -1)
  3948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3949. break;
  3950. }
  3951. case COMMAND_REPAIR: {
  3952. Spawn* spawn = cmdTarget;
  3953. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3954. client->SendHailCommand(spawn);
  3955. client->SetMerchantTransaction(spawn);
  3956. client->SendRepairList();
  3957. }
  3958. break;
  3959. }
  3960. case COMMAND_LOTTO: {
  3961. Spawn* spawn = cmdTarget;
  3962. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3963. client->SetMerchantTransaction(spawn);
  3964. client->ShowLottoWindow();
  3965. }
  3966. break;
  3967. }
  3968. case COMMAND_ACCEPT_REWARD:{
  3969. int32 unknown = 0;
  3970. int32 selectable_item_id = 0;
  3971. //Quest *quest = 0;
  3972. Collection *collection = 0;
  3973. /* no idea what the first argument is for (faction maybe?)
  3974. if the reward has a selectable item reward, it's sent as the second argument
  3975. if neither of these are included in the reward, there is no sep
  3976. 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
  3977. only 1 quest or collection reward may be displayed at a time */
  3978. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3979. unknown = atoul(sep->arg[0]);
  3980. selectable_item_id = atoul(sep->arg[1]);
  3981. }
  3982. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  3983. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  3984. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  3985. */
  3986. int32 item_id = 0;
  3987. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3988. item_id = atoul(sep->arg[0]);
  3989. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3990. if(quest){
  3991. client->AcceptQuestReward(quest, item_id);
  3992. break;
  3993. }
  3994. bool collectedItems = false;
  3995. if (client->GetPlayer()->HasPendingItemRewards()) {
  3996. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3997. if (items.size() > 0) {
  3998. collectedItems = true;
  3999. for (int i = 0; i < items.size(); i++) {
  4000. client->GetPlayer()->AddItem(new Item(items[i]));
  4001. }
  4002. client->GetPlayer()->ClearPendingItemRewards();
  4003. client->GetPlayer()->SetActiveReward(false);
  4004. }
  4005. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  4006. if (selectable_item.size() > 0) {
  4007. collectedItems = true;
  4008. map<int32, Item*>::iterator itr;
  4009. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  4010. client->GetPlayer()->AddItem(new Item(itr->second));
  4011. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  4012. }
  4013. client->GetPlayer()->SetActiveReward(false);
  4014. }
  4015. }
  4016. else if (collection = player->GetPendingCollectionReward())
  4017. {
  4018. client->AcceptCollectionRewards(collection, (selectable_item_id > 0) ? selectable_item_id : item_id);
  4019. collectedItems = true;
  4020. }
  4021. if (collectedItems) {
  4022. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4023. if (outapp)
  4024. client->QueuePacket(outapp);
  4025. }
  4026. else
  4027. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4028. break;
  4029. }
  4030. case COMMAND_BUY_FROM_BROKER:{
  4031. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4032. int32 item_id = atoul(sep->arg[0]);
  4033. int16 quantity = atoul(sep->arg[1]);
  4034. Item* item = master_item_list.GetItem(item_id);
  4035. if(item && item->generic_info.max_charges > 1)
  4036. quantity = item->generic_info.max_charges;
  4037. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4038. }
  4039. break;
  4040. }
  4041. case COMMAND_SEARCH_STORES_PAGE:{
  4042. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4043. int32 page = atoul(sep->arg[0]);
  4044. client->SearchStore(page);
  4045. }
  4046. break;
  4047. }
  4048. case COMMAND_SEARCH_STORES:{
  4049. if(sep && sep->arg[0][0]){
  4050. const char* values = sep->argplus[0];
  4051. if(values){
  4052. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4053. map<string, string> str_values = TranslateBrokerRequest(values);
  4054. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4055. if(items){
  4056. client->SetItemSearch(items);
  4057. client->SearchStore(0);
  4058. }
  4059. }
  4060. }
  4061. break;
  4062. }
  4063. case COMMAND_LUADEBUG:{
  4064. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4065. client->SetLuaDebugClient(true);
  4066. if(lua_interface)
  4067. lua_interface->UpdateDebugClients(client);
  4068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4069. }
  4070. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4071. client->SetLuaDebugClient(false);
  4072. if(lua_interface)
  4073. lua_interface->RemoveDebugClients(client);
  4074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4075. }
  4076. else{
  4077. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4079. }
  4080. break;
  4081. }
  4082. case COMMAND_SPAWN_GROUP:
  4083. {
  4084. Spawn* target = cmdTarget;
  4085. if(target && target->IsPlayer() == false)
  4086. {
  4087. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4088. {
  4089. if(target->GetSpawnLocationPlacementID() > 0)
  4090. {
  4091. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4092. {
  4093. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4094. if(id > 0)
  4095. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4096. else
  4097. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4098. target->SetSpawnGroupID(id);
  4099. target->AddSpawnToGroup(target);
  4100. }
  4101. else
  4102. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4103. }
  4104. else
  4105. 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.");
  4106. }
  4107. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4108. {
  4109. if(sep->arg[1] && sep->IsNumber(1))
  4110. {
  4111. int32 group_id = atoul(sep->arg[1]);
  4112. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4113. if(leader)
  4114. {
  4115. leader->AddSpawnToGroup(target);
  4116. target->SetSpawnGroupID(group_id);
  4117. if(database.SpawnGroupAddSpawn(target, group_id))
  4118. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4119. else
  4120. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4121. }
  4122. else
  4123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4124. }
  4125. else
  4126. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4127. }
  4128. else if(target->GetSpawnGroupID() == 0)
  4129. {
  4130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4131. }
  4132. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4133. {
  4134. int32 group_id = target->GetSpawnGroupID();
  4135. target->RemoveSpawnFromGroup();
  4136. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4137. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4138. else
  4139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4140. }
  4141. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4142. {
  4143. int32 group_id = target->GetSpawnGroupID();
  4144. if(sep->arg[1] && sep->IsNumber(1))
  4145. {
  4146. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4147. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4148. else
  4149. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4150. }
  4151. else
  4152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4153. }
  4154. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4155. {
  4156. int32 group_id = target->GetSpawnGroupID();
  4157. if(sep->arg[1] && sep->IsNumber(1))
  4158. {
  4159. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4160. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4161. else
  4162. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4163. }
  4164. else
  4165. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4166. }
  4167. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4168. {
  4169. if(sep->arg[1] && sep->IsNumber(1))
  4170. {
  4171. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4172. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4173. else
  4174. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4175. }
  4176. else
  4177. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4178. }
  4179. else
  4180. {
  4181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4182. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4183. }
  4184. }
  4185. else
  4186. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4187. break;
  4188. }
  4189. case COMMAND_SPAWN_COMBINE:{
  4190. Spawn* spawn = cmdTarget;
  4191. float radius = 0;
  4192. bool failed = true;
  4193. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4194. failed = false;
  4195. if(spawn->GetSpawnGroupID() > 0){
  4196. 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.");
  4197. }
  4198. else if(sep->IsNumber(0)){
  4199. radius = atof(sep->arg[0]);
  4200. client->CombineSpawns(radius, spawn);
  4201. }
  4202. else{
  4203. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4204. client->AddCombineSpawn(spawn);
  4205. }
  4206. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4207. client->RemoveCombineSpawn(spawn);
  4208. }
  4209. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4210. const char* name = 0;
  4211. if(sep->arg[1] && sep->arg[1][0])
  4212. name = sep->argplus[1];
  4213. client->SaveCombineSpawns(name);
  4214. }
  4215. else
  4216. failed = true;
  4217. }
  4218. }
  4219. if(failed){
  4220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4221. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4222. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4223. }
  4224. break;
  4225. }
  4226. case COMMAND_SPAWN_CREATE:{
  4227. Spawn* spawn = 0;
  4228. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4229. spawn = new Object();
  4230. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4231. }
  4232. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4233. spawn = new GroundSpawn();
  4234. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4235. }
  4236. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4237. spawn = new Sign();
  4238. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4239. }
  4240. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4241. spawn = new NPC();
  4242. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4243. spawn->appearance.pos.collision_radius = 32;
  4244. spawn->secondary_command_list_id = 0;
  4245. spawn->primary_command_list_id = 0;
  4246. spawn->appearance.display_name = 1;
  4247. spawn->appearance.show_level = 1;
  4248. spawn->appearance.attackable = 1;
  4249. }
  4250. else{
  4251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4254. break;
  4255. }
  4256. spawn->SetID(Spawn::NextID());
  4257. spawn->SetX(client->GetPlayer()->GetX());
  4258. spawn->SetY(client->GetPlayer()->GetY());
  4259. spawn->SetZ(client->GetPlayer()->GetZ());
  4260. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4261. spawn->SetSpawnOrigX(spawn->GetX());
  4262. spawn->SetSpawnOrigY(spawn->GetY());
  4263. spawn->SetSpawnOrigZ(spawn->GetZ());
  4264. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4265. if(spawn->IsSign())
  4266. {
  4267. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4268. ((Sign*)spawn)->SetSignDistance(20.0f);
  4269. ((Sign*)spawn)->SetIncludeLocation(1);
  4270. ((Sign*)spawn)->SetIncludeHeading(1);
  4271. ((Sign*)spawn)->SetInitialState(1);
  4272. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4273. ((Sign*)spawn)->SetActivityStatus(64);
  4274. spawn->appearance.race = 0;
  4275. spawn->SetLevel(0);
  4276. spawn->SetHP(0);
  4277. spawn->SetTotalHP(0);
  4278. spawn->SetPower(0);
  4279. spawn->SetTotalPower(0);
  4280. spawn->SetEncounterLevel(0);
  4281. spawn->SetTargetable(0);
  4282. spawn->SetSogaModelType(0);
  4283. spawn->SetCollisionRadius(19);
  4284. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4285. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4286. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4287. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4288. spawn->appearance.model_type = atoul(sep->arg[1]);
  4289. }
  4290. else
  4291. {
  4292. spawn->appearance.targetable = 1;
  4293. spawn->appearance.race = 255;
  4294. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4295. spawn->SetModelType(atoi(sep->arg[1]));
  4296. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4297. spawn->SetLevel(atoi(sep->arg[3]));
  4298. spawn->SetName(sep->arg[4]);
  4299. if(sep->arg[5][0] && sep->IsNumber(5))
  4300. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  4301. if(sep->arg[6][0] && sep->IsNumber(6))
  4302. spawn->size = atoi(sep->arg[6]);
  4303. if(spawn->GetTotalHP() == 0){
  4304. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4305. spawn->SetHP(25*spawn->GetLevel() + 1);
  4306. }
  4307. if(spawn->GetTotalPower() == 0){
  4308. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4309. spawn->SetPower(25*spawn->GetLevel() + 1);
  4310. }
  4311. }
  4312. client->GetCurrentZone()->AddSpawn(spawn);
  4313. break;
  4314. }
  4315. case COMMAND_SPAWN_EQUIPMENT:{
  4316. Spawn* spawn = cmdTarget;
  4317. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4318. int8 slot = atoi(sep->arg[0]);
  4319. int16 type = atoi(sep->arg[1]);
  4320. int8 red = 0;
  4321. int8 green = 0;
  4322. int8 blue = 0;
  4323. int8 h_red = 0;
  4324. int8 h_green = 0;
  4325. int8 h_blue = 0;
  4326. if(sep->arg[2])
  4327. red = atoi(sep->arg[2]);
  4328. if(sep->arg[3])
  4329. green = atoi(sep->arg[3]);
  4330. if(sep->arg[4])
  4331. blue = atoi(sep->arg[4]);
  4332. if(sep->arg[5])
  4333. h_red = atoi(sep->arg[5]);
  4334. if(sep->arg[6])
  4335. h_green = atoi(sep->arg[6]);
  4336. if(sep->arg[7])
  4337. h_blue = atoi(sep->arg[7]);
  4338. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4339. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4340. }
  4341. else{
  4342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4343. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4344. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4345. }
  4346. break;
  4347. }
  4348. case COMMAND_SPAWN_DETAILS: {
  4349. Spawn* spawn = cmdTarget;
  4350. if (sep && sep->arg[0][0]) {
  4351. if (cmdTarget)
  4352. {
  4353. if (ToLower(string(sep->arg[0])) == "los")
  4354. {
  4355. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4356. if (hasLOS)
  4357. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4358. else
  4359. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4360. break;
  4361. }
  4362. else if (ToLower(string(sep->arg[0])) == "bestz")
  4363. {
  4364. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4365. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4366. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4367. break;
  4368. }
  4369. else if (ToLower(string(sep->arg[0])) == "inwater")
  4370. {
  4371. if (cmdTarget->GetRegionMap() == nullptr)
  4372. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4373. else
  4374. {
  4375. bool inWater = cmdTarget->InWater();
  4376. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4377. }
  4378. break;
  4379. }
  4380. else if (ToLower(string(sep->arg[0])) == "inlava")
  4381. {
  4382. if (cmdTarget->GetRegionMap() == nullptr)
  4383. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4384. else
  4385. {
  4386. bool inLava = cmdTarget->InLava();
  4387. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4388. }
  4389. break;
  4390. }
  4391. else if (ToLower(string(sep->arg[0])) == "regions")
  4392. {
  4393. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4394. if (cmdTarget->GetRegionMap() == nullptr)
  4395. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4396. else
  4397. {
  4398. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4399. }
  4400. break;
  4401. }
  4402. else if (ToLower(string(sep->arg[0])) == "behind")
  4403. {
  4404. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4405. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4406. break;
  4407. }
  4408. else if (ToLower(string(sep->arg[0])) == "infront")
  4409. {
  4410. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4411. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4412. break;
  4413. }
  4414. else if (ToLower(string(sep->arg[0])) == "flank")
  4415. {
  4416. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4417. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4418. break;
  4419. }
  4420. }
  4421. if (sep->IsNumber(0))
  4422. {
  4423. float radius = atof(sep->arg[0]);
  4424. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4426. break;
  4427. }
  4428. }
  4429. if (spawn) {
  4430. const char* type = "NPC";
  4431. if (spawn->IsObject())
  4432. type = "Object";
  4433. else if (spawn->IsSign())
  4434. type = "Sign";
  4435. else if (spawn->IsWidget())
  4436. type = "Widget";
  4437. else if (spawn->IsGroundSpawn())
  4438. type = "GroundSpawn";
  4439. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4440. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4441. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4442. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4443. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4444. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4445. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4446. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4447. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4448. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4449. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4450. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  4451. 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());
  4452. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  4453. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4454. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4455. if (spawn->IsEntity()) {
  4456. 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());
  4457. 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());
  4458. }
  4459. 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);
  4460. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4461. 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());
  4462. 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);
  4463. if (spawn->IsNPC())
  4464. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4465. if (spawn->IsNPC()){
  4466. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4467. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4468. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4469. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4470. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4471. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4472. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4473. }
  4474. string details;
  4475. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4476. details += "Type: " + string(type) + "\n";
  4477. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4478. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4479. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4480. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4481. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4482. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4483. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4484. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4485. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4486. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  4487. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  4488. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  4489. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4490. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4491. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4492. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4493. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4494. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4495. char x[16];
  4496. sprintf(x, "%.2f", spawn->GetX());
  4497. char y[16];
  4498. sprintf(y, "%.2f", spawn->GetY());
  4499. char z[16];
  4500. sprintf(z, "%.2f", spawn->GetZ());
  4501. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4502. string details2;
  4503. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4504. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4505. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4506. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4507. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4508. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4509. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4510. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4511. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4512. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4513. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4514. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4515. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4516. details2 += "Race Type: " + to_string(race_type) + "\n";
  4517. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4518. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4519. details2 += "Model Name: " + std::string(modelname) + "\n";
  4520. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4521. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4522. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4523. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4524. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4525. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4526. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4527. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4528. string details3;
  4529. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4530. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4531. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4532. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4533. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4534. if(spawn->IsSign()) {
  4535. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4536. }
  4537. if(spawn->IsEntity())
  4538. {
  4539. Entity* ent = (Entity*)spawn;
  4540. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4541. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4542. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4543. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4544. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4545. }
  4546. string details4;
  4547. if (spawn->IsEntity()) {
  4548. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4549. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4550. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4551. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4552. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4553. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4554. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4555. if (spawn->IsNPC()) {
  4556. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4557. }
  4558. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4559. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4560. }
  4561. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4562. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4563. }
  4564. else {
  4565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4566. 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.");
  4567. }
  4568. break;
  4569. }
  4570. case COMMAND_SPAWN_TARGET:{
  4571. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4572. int32 spawn_id = atoul(sep->arg[0]);
  4573. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4574. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4575. }
  4576. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4577. float distance = atof(sep->arg[1]);
  4578. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4579. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4580. }
  4581. else{
  4582. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4584. }
  4585. break;
  4586. }
  4587. case COMMAND_SPAWN_SET:
  4588. {
  4589. Spawn* spawn = cmdTarget;
  4590. sint16 set_type = -1;
  4591. string type_str;
  4592. if (spawn)
  4593. {
  4594. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4595. 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)
  4596. {
  4597. // set the type, which will be 0 if location or list or invalid
  4598. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4599. }
  4600. if(set_type > 0)
  4601. {
  4602. // check if spawn set is NOT a char update, or not location, or isn't a number
  4603. 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)
  4604. {
  4605. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4606. }
  4607. else
  4608. {
  4609. string name = string(spawn->GetName());
  4610. bool customSetSpawn = false;
  4611. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4612. {
  4613. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4614. // override the standard setspawncommand, we pass arguments different!
  4615. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4616. customSetSpawn = true;
  4617. }
  4618. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4619. {
  4620. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4621. {
  4622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4623. }
  4624. else if (set_type == SPAWN_SET_VALUE_NAME)
  4625. {
  4626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4627. }
  4628. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4629. {
  4630. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4631. }
  4632. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4633. {
  4634. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4635. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4636. }
  4637. else
  4638. {
  4639. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4640. }
  4641. switch (set_type)
  4642. {
  4643. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4644. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4645. case SPAWN_SET_VALUE_FACTION:
  4646. case SPAWN_SET_AAXP_REWARDS:
  4647. case SPAWN_SET_CHEEK_TYPE:
  4648. case SPAWN_SET_CHIN_TYPE:
  4649. case SPAWN_SET_EAR_TYPE:
  4650. case SPAWN_SET_EYE_BROW_TYPE:
  4651. case SPAWN_SET_EYE_TYPE:
  4652. case SPAWN_SET_LIP_TYPE:
  4653. case SPAWN_SET_NOSE_TYPE:
  4654. case SPAWN_SET_BODY_SIZE:
  4655. case SPAWN_SET_BODY_AGE:
  4656. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4657. case SPAWN_SET_SOGA_CHIN_TYPE:
  4658. case SPAWN_SET_SOGA_EAR_TYPE:
  4659. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4660. case SPAWN_SET_SOGA_EYE_TYPE:
  4661. case SPAWN_SET_SOGA_LIP_TYPE:
  4662. case SPAWN_SET_SOGA_NOSE_TYPE:
  4663. case SPAWN_SET_SOGA_BODY_SIZE:
  4664. case SPAWN_SET_SOGA_BODY_AGE:
  4665. case SPAWN_SET_ATTACK_TYPE:
  4666. case SPAWN_SET_RACE_TYPE:
  4667. {
  4668. // not applicable already ran db command
  4669. break;
  4670. }
  4671. default:
  4672. {
  4673. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4674. break;
  4675. }
  4676. }
  4677. 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))
  4678. {
  4679. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4680. {
  4681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4682. }
  4683. else if(spawn->GetSpawnLocationID() > 0)
  4684. {
  4685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4686. }
  4687. }
  4688. else
  4689. {
  4690. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4691. {
  4692. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4693. }
  4694. else if(spawn->GetDatabaseID() > 0)
  4695. {
  4696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4697. }
  4698. }
  4699. }
  4700. }
  4701. }
  4702. else if(set_type == 0)
  4703. {
  4704. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4705. map<string, int8>::iterator itr;
  4706. int i=0;
  4707. string list;
  4708. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4709. {
  4710. if(i==10)
  4711. {
  4712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4713. i = 0;
  4714. }
  4715. if(i>0)
  4716. {
  4717. list.append(", ").append(itr->first);
  4718. }
  4719. else
  4720. {
  4721. list = itr->first;
  4722. }
  4723. }
  4724. if(list.length() > 0)
  4725. {
  4726. // if 1 or more, display in client.
  4727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4728. }
  4729. }
  4730. else
  4731. {
  4732. // syntax fail
  4733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4734. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4736. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4737. }
  4738. }
  4739. break;
  4740. }
  4741. case COMMAND_SPAWN_REMOVE:{
  4742. Spawn* spawn = cmdTarget;
  4743. if(spawn && !spawn->IsPlayer()){
  4744. if(spawn->GetSpawnLocationID() > 0){
  4745. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4746. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4747. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4748. }
  4749. else
  4750. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4751. }
  4752. else
  4753. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4754. }
  4755. else{
  4756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4758. }
  4759. break;
  4760. }
  4761. case COMMAND_SPAWN_LIST:{
  4762. if(sep && sep->arg[0][0]){
  4763. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4764. vector<string>::iterator itr;
  4765. if(results){
  4766. for(itr=results->begin();itr!=results->end();itr++){
  4767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4768. }
  4769. safe_delete(results);
  4770. }
  4771. else
  4772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4773. }
  4774. else{
  4775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4776. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4778. }
  4779. break;
  4780. }
  4781. case COMMAND_SPAWN_ADD:{
  4782. Spawn* spawn = cmdTarget;
  4783. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4784. if(spawn->GetSpawnLocationID() > 0){
  4785. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4786. break;
  4787. }
  4788. if(spawn->GetDatabaseID() == 0){
  4789. if(database.SaveSpawnInfo(spawn)) {
  4790. char spawn_type[32];
  4791. memset(spawn_type, 0, sizeof(spawn_type));
  4792. if (spawn->IsNPC())
  4793. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4794. else if (spawn->IsObject())
  4795. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4796. else if (spawn->IsSign())
  4797. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4798. else if (spawn->IsGroundSpawn())
  4799. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4800. else
  4801. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4802. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4803. }
  4804. else
  4805. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4806. }
  4807. int32 spawn_group_id = 0;
  4808. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4809. spawn_group_id = database.GetNextSpawnLocation();
  4810. else
  4811. spawn_group_id = atol(sep->arg[0]);
  4812. int8 percent = 100;
  4813. if(sep->arg[2] && sep->IsNumber(2))
  4814. percent = atoi(sep->arg[2]);
  4815. spawn->SetSpawnLocationID(spawn_group_id);
  4816. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4817. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4818. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4819. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4820. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4821. else
  4822. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4823. }
  4824. else{
  4825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4828. }
  4829. break;
  4830. }
  4831. case COMMAND_SPAWN:{
  4832. int32 id = 0;
  4833. Spawn* spawn = 0;
  4834. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4835. id = atol(sep->arg[0]);
  4836. spawn = client->GetCurrentZone()->GetSpawn(id);
  4837. }
  4838. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4839. id = 0;
  4840. if(!id || !spawn){
  4841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4844. safe_delete(sep);
  4845. return;
  4846. }
  4847. if(sep && sep->arg[1][0]){
  4848. float x = atof(sep->arg[1]);
  4849. spawn->appearance.pos.X = x;
  4850. }
  4851. else
  4852. spawn->SetX(client->GetPlayer()->GetX(), false);
  4853. if(sep && sep->arg[2][0]){
  4854. float y = atof(sep->arg[2]);
  4855. spawn->appearance.pos.Y = y;
  4856. }
  4857. else
  4858. spawn->SetY(client->GetPlayer()->GetY(), false);
  4859. if(sep && sep->arg[3][0]){
  4860. float z = atof(sep->arg[3]);
  4861. spawn->appearance.pos.Z = z;
  4862. }
  4863. else
  4864. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4865. if(sep && sep->arg[4][0]){
  4866. float heading = atof(sep->arg[4]);
  4867. spawn->SetHeading(heading);
  4868. }
  4869. else
  4870. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4871. spawn->SetSpawnOrigX(spawn->GetX());
  4872. spawn->SetSpawnOrigY(spawn->GetY());
  4873. spawn->SetSpawnOrigZ(spawn->GetZ());
  4874. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4875. if(sep && sep->arg[5][0])
  4876. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4877. else
  4878. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4879. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4880. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4881. spawn->SetHP(spawn->GetTotalHP());
  4882. }
  4883. if(spawn->GetTotalPower() == 0){
  4884. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4885. spawn->SetPower(spawn->GetTotalPower());
  4886. }
  4887. const char* script = world.GetSpawnScript(id);
  4888. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4889. spawn->SetSpawnScript(string(script));
  4890. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4891. client->GetCurrentZone()->AddSpawn(spawn);
  4892. if(spawn->IsNPC())
  4893. spawn->GetZone()->AddLoot((NPC*)spawn);
  4894. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4895. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4896. break;
  4897. }
  4898. case COMMAND_ADMINFLAG:
  4899. {
  4900. if(sep && sep->arg[0]){
  4901. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4902. sint16 new_status = atoi(sep->arg[1]);
  4903. if(tmp_status == -10)
  4904. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4905. else if(tmp_status >= client->GetAdminStatus())
  4906. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4907. else if (new_status > client->GetAdminStatus())
  4908. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4909. else{
  4910. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4911. if (!client2)
  4912. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4913. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4914. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4915. if (client2) {
  4916. client2->SetAdminStatus(new_status);
  4917. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4918. }
  4919. }
  4920. else
  4921. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4922. }
  4923. }else{
  4924. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4925. if(status != client->GetAdminStatus())
  4926. {
  4927. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4928. client->SetAdminStatus(status);
  4929. }
  4930. else
  4931. {
  4932. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4934. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  4935. }
  4936. }
  4937. break;
  4938. }
  4939. case COMMAND_CANNEDEMOTE:{
  4940. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4941. break;
  4942. }
  4943. case COMMAND_BROADCAST: {
  4944. if (sep && sep->arg[0])
  4945. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4946. else
  4947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4948. break;
  4949. }
  4950. case COMMAND_ANNOUNCE: {
  4951. if (sep && sep->arg[0])
  4952. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4953. else
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4955. break;
  4956. }
  4957. case COMMAND_RELOAD_ITEMS:{
  4958. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4959. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4960. database.ReloadItemList();
  4961. database.LoadMerchantInformation();
  4962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4963. break;
  4964. }
  4965. case COMMAND_ENABLE_ABILITY_QUE:{
  4966. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4967. if(app)
  4968. client->QueuePacket(app);
  4969. break;
  4970. }
  4971. case COMMAND_ITEMSEARCH:
  4972. case COMMAND_FROMBROKER:{
  4973. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4974. if (packet) {
  4975. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4976. //packet->setDataByName("unknown", 1);
  4977. packet->setDataByName("unknown2", 5, 0);
  4978. packet->setDataByName("unknown2", 20, 1);
  4979. packet->setDataByName("unknown2", 58, 3);
  4980. packet->setDataByName("unknown2", 40, 4);
  4981. client->QueuePacket(packet->serialize());
  4982. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4983. if (packet2) {
  4984. packet2->setDataByName("char_id", client->GetCharacterID());
  4985. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4986. safe_delete(packet2);
  4987. }
  4988. safe_delete(packet);
  4989. }
  4990. break;
  4991. }
  4992. case COMMAND_ANIMTEST:{
  4993. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4994. if(command_packet){
  4995. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4996. if (cmdTarget)
  4997. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4998. command_packet->setDataByName ( "spawn_id" , id);
  4999. int animID = 1;
  5000. if(sep && sep->arg[0] && sep->IsNumber(0))
  5001. animID = atoi(sep->arg[0]);
  5002. VisualState* vs = NULL;
  5003. if(animID == 0)
  5004. {
  5005. vs = visual_states.FindVisualState(sep->arg[0]);
  5006. }
  5007. char msg[128];
  5008. sprintf(msg,"Animation Test ID: %i",animID);
  5009. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5010. if(vs != NULL)
  5011. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5012. else
  5013. command_packet->setDataByName ( "anim_type", animID );
  5014. command_packet->setDataByName ( "unknown0", 0 );
  5015. EQ2Packet* outapp = command_packet->serialize();
  5016. client->QueuePacket(outapp);
  5017. safe_delete(command_packet);
  5018. }
  5019. break;
  5020. }
  5021. case COMMAND_KICK:
  5022. {
  5023. if( sep == 0 || sep->arg[0] == 0)
  5024. {
  5025. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5026. }
  5027. else
  5028. {
  5029. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5030. if ( kickClient == client )
  5031. {
  5032. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5033. break;
  5034. }
  5035. else if(kickClient != NULL)
  5036. {
  5037. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5038. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5039. {
  5040. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5041. break;
  5042. }
  5043. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5044. kickClient->Disconnect();
  5045. }
  5046. else
  5047. {
  5048. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5049. }
  5050. }
  5051. break;
  5052. }
  5053. case COMMAND_LOCK:
  5054. {
  5055. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5056. int worldLocked = atoi(sep->arg[0]);
  5057. net.world_locked = worldLocked;
  5058. if ( worldLocked )
  5059. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5060. else
  5061. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5062. }
  5063. else
  5064. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5065. break;
  5066. }
  5067. case COMMAND_BAN:{
  5068. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5069. {
  5070. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5071. }
  5072. else
  5073. {
  5074. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5075. if ( kickClient == client )
  5076. {
  5077. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5078. break;
  5079. }
  5080. else if(kickClient != NULL)
  5081. {
  5082. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5083. if ( maxStatus > client->GetAdminStatus( ) ||
  5084. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5085. {
  5086. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5087. break;
  5088. }
  5089. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5090. int perm = atol(sep->arg[1]);
  5091. if ( perm == 1 )
  5092. database.UpdateAdminStatus(sep->arg[0],-2);
  5093. else
  5094. database.UpdateAdminStatus(sep->arg[0],-1);
  5095. kickClient->Disconnect();
  5096. }
  5097. else
  5098. {
  5099. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5100. }
  5101. }
  5102. break;
  5103. }
  5104. case COMMAND_SET_COMBAT_VOICE:{
  5105. int32 value = 0;
  5106. if(sep && sep->arg[0] && sep->IsNumber(0))
  5107. value = atoi(sep->arg[0]);
  5108. client->GetPlayer()->SetCombatVoice(value);
  5109. break;
  5110. }
  5111. case COMMAND_SET_EMOTE_VOICE:{
  5112. int32 value = 0;
  5113. if(sep && sep->arg[0] && sep->IsNumber(0))
  5114. value = atoi(sep->arg[0]);
  5115. client->GetPlayer()->SetEmoteVoice(value);
  5116. break;
  5117. }
  5118. case COMMAND_GIVEITEM:{
  5119. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5120. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5121. if ( itemToClient == NULL )
  5122. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5123. else
  5124. {
  5125. int32 item_id = atol(sep->arg[1]);
  5126. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5127. itemToClient->AddItem(item_id);
  5128. }
  5129. }
  5130. else
  5131. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5132. break;
  5133. }
  5134. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5135. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5136. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5137. case COMMAND_SKILL :
  5138. case COMMAND_SKILL_ADD :
  5139. case COMMAND_SKILL_REMOVE :
  5140. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5141. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5142. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5143. case COMMAND_ENTITYCOMMAND :
  5144. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5145. case COMMAND_MERCHANT :
  5146. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5147. case COMMAND_APPEARANCE :
  5148. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5149. case COMMAND_TRACK : { Command_Track(client); break; }
  5150. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5151. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5152. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5153. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5154. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5155. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5156. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5157. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5158. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5159. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5160. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5161. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5162. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5163. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5164. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5165. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5166. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5167. case COMMAND_LOCATION : { Command_Location(client); break; }
  5168. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5169. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5170. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5171. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5172. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5173. case COMMAND_GRID : { Command_Grid(client); break; }
  5174. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5175. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  5176. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5177. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5178. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5179. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5180. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5181. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5182. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5183. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5184. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5185. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5186. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5187. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5188. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5189. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5190. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5191. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5192. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5193. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5194. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5195. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5196. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5197. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5198. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5199. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5200. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5201. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5202. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5203. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5204. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5205. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5206. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5207. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5208. case COMMAND_TITLE : { Command_Title(client); break; }
  5209. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5210. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5211. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5212. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5213. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5214. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5215. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5216. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5217. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5218. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5219. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5220. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5221. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5222. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5223. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5224. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5225. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5226. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5227. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5228. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5229. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5230. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5231. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5232. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5233. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5234. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5235. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5236. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5237. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5238. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5239. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5240. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5241. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5242. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5243. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5244. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5245. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5246. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5247. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5248. //devn00b
  5249. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5250. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5251. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5252. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5253. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5254. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5255. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5256. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5257. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5258. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5259. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5260. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5261. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5262. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5263. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5264. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5265. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5266. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5267. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5268. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5269. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5270. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5271. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5272. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5273. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5274. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5275. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5276. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5277. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5278. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5279. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5280. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5281. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5282. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5283. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5284. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5285. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5286. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5287. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5288. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5289. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5290. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5291. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5292. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5293. case ADD_AA : { Add_AA(client, sep); break; }
  5294. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5295. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5296. case BACK_AA : { Back_AA(client, sep); break; }
  5297. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5298. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5299. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5300. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5301. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5302. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5303. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5304. case COMMAND_CRAFTITEM: {
  5305. Item* item = 0;
  5306. if (sep && sep->IsNumber(0)) {
  5307. int32 item_id = atol(sep->arg[0]);
  5308. int32 quantity = 1;
  5309. if (sep->arg[1] && sep->IsNumber(1))
  5310. quantity = atoi(sep->arg[1]);
  5311. item = new Item(master_item_list.GetItem(item_id));
  5312. if (!item) {
  5313. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5314. }
  5315. else {
  5316. item->details.count = quantity;
  5317. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5318. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5319. bool itemDeleted = false;
  5320. client->AddItem(item, &itemDeleted);
  5321. //Check for crafting quest updates
  5322. int8 update_amt = 0;
  5323. if (!itemDeleted && item->stack_count > 1)
  5324. update_amt = 1;
  5325. else
  5326. update_amt = quantity;
  5327. if(!itemDeleted)
  5328. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5329. }
  5330. }
  5331. else {
  5332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5333. }
  5334. break;
  5335. }
  5336. case COMMAND_UNMENTOR:
  5337. case COMMAND_MENTOR: {
  5338. client->GetPlayer()->MentorTarget();
  5339. break;
  5340. }
  5341. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5342. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5343. default:
  5344. {
  5345. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5346. break;
  5347. }
  5348. }
  5349. safe_delete(sep);
  5350. }
  5351. /******************** New COMMAND Handler Functions ********************/
  5352. /*
  5353. Started breaking apart the huge switch() for commands into sepErate
  5354. functions so it is easier to locate the blocks of code by command
  5355. -- JA 2012.03.03
  5356. */
  5357. // sample function header
  5358. /*
  5359. Function:
  5360. Purpose :
  5361. Params :
  5362. Dev :
  5363. Example :
  5364. */
  5365. //void Commands::Command()
  5366. //{
  5367. //}
  5368. /*
  5369. Function: Command_AcceptAdvancement()
  5370. Purpose : Player accepts a new advancement option
  5371. Params : Spell ID
  5372. Dev : Jabantiz
  5373. */
  5374. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5375. {
  5376. Player *player = client->GetPlayer();
  5377. if (sep && sep->IsSet(0)) {
  5378. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5379. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5380. if (!player->HasSpell(trait->spellID, 0, true))
  5381. {
  5382. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5383. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5384. }
  5385. else
  5386. {
  5387. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5388. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5389. player->RemoveSpellBookEntry(spell->GetSpellID());
  5390. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5391. player->UnlockSpell(spell);
  5392. client->SendSpellUpdate(spell);
  5393. }
  5394. // Spell book update
  5395. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5396. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5397. }
  5398. }
  5399. /*
  5400. Function:
  5401. Purpose :
  5402. Params :
  5403. Dev :
  5404. Example :
  5405. */
  5406. void Commands::Command_AFK(Client* client, Seperator* sep)
  5407. {
  5408. Player* player = client->GetPlayer();
  5409. player->toggle_character_flag(CF_AFK);
  5410. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5411. if (player->get_character_flag(CF_AFK))
  5412. {
  5413. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  5414. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  5415. if (sep && sep->argplus[0])
  5416. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5417. else
  5418. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5419. string message = string(player->GetName()) + " is going afk.";
  5420. Spawn* target = player->GetTarget();
  5421. if (target && target != player)
  5422. {
  5423. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5424. player->GetGender() == 1 ? message += "he" : message += "she";
  5425. message += " is going afk.";
  5426. }
  5427. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5428. }
  5429. /*else
  5430. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  5431. }
  5432. /*
  5433. Function: Command_Appearance()
  5434. Purpose : Handles /appearance commands
  5435. Params : list
  5436. Dev : Scatman
  5437. Example : /appearance list
  5438. */
  5439. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5440. {
  5441. if( handler == COMMAND_APPEARANCE )
  5442. {
  5443. // /appearance command by itself shows help (to be extended)
  5444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5445. return;
  5446. }
  5447. else if( handler == COMMAND_APPEARANCE_LIST )
  5448. {
  5449. // /appearance list command expects "name" param
  5450. if (sep && sep->arg[0])
  5451. {
  5452. const char* appearance_name = sep->argplus[0];
  5453. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5454. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5455. if (appearances)
  5456. {
  5457. vector<int16>::iterator itr;
  5458. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5459. {
  5460. int16 id = *itr;
  5461. string name = database.GetAppearanceName(id);
  5462. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5463. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5464. }
  5465. safe_delete(appearances);
  5466. }
  5467. }
  5468. else // no param
  5469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5470. }
  5471. }
  5472. /*
  5473. Function: Command_Claim()
  5474. Purpose :
  5475. Params :
  5476. Dev :
  5477. Example :
  5478. */
  5479. void Commands::Command_Claim(Client* client, Seperator* sep)
  5480. {
  5481. if (sep && sep->arg[0] && sep->IsNumber(0))
  5482. {
  5483. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  5485. }
  5486. else
  5487. client->ShowClaimWindow();
  5488. }
  5489. /*
  5490. Function: Command_ClearAllQueued()
  5491. Purpose :
  5492. Params :
  5493. Dev :
  5494. Example :
  5495. */
  5496. void Commands::Command_ClearAllQueued(Client* client)
  5497. {
  5498. ZoneServer* zone = client->GetPlayer()->GetZone();
  5499. if (zone && zone->GetSpellProcess())
  5500. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5501. }
  5502. /*
  5503. Function: Command_CancelMaintained()
  5504. Purpose : Cancels maintained spells
  5505. Params : Maintained Spell Index
  5506. Dev : Zcoretri
  5507. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5508. */
  5509. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5510. {
  5511. if (sep && sep->arg[0] && sep->IsNumber(0))
  5512. {
  5513. int32 spell_index = atoul(sep->arg[0]);
  5514. if(spell_index > 29)
  5515. return;
  5516. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5517. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5518. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5519. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false, true))
  5520. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5521. }
  5522. }
  5523. /*
  5524. Function: Command_Create()
  5525. Purpose : Handler for starting Tradeskilling table
  5526. Params :
  5527. Dev : Zcoretri
  5528. Example :
  5529. */
  5530. void Commands::Command_Create(Client* client, Seperator* sep)
  5531. {
  5532. PrintSep(sep, "COMMAND_CREATE");
  5533. client->SendRecipeList();
  5534. client->ShowRecipeBook();
  5535. }
  5536. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5537. {
  5538. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5539. if (sep && sep->arg[0] && sep->IsNumber(0))
  5540. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5541. }
  5542. /*
  5543. Function: Command_Distance()
  5544. Purpose : Displays distance from targeted spawn
  5545. Params :
  5546. Dev : Scatman
  5547. Example : /distance
  5548. */
  5549. void Commands::Command_Distance(Client* client)
  5550. {
  5551. Spawn* target = client->GetPlayer()->GetTarget();
  5552. if (target)
  5553. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5554. else
  5555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5556. }
  5557. /*
  5558. Function: Command_Duel()
  5559. Purpose : Handle the /duel commands - not yet implemented
  5560. Params : unknown
  5561. Dev :
  5562. Example :
  5563. */
  5564. void Commands::Command_Duel(Client* client, Seperator* sep)
  5565. {
  5566. PrintSep(sep, "COMMAND_DUEL");
  5567. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5568. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5569. }
  5570. /*
  5571. Function: Command_DuelBet()
  5572. Purpose : Handle the /duel commands - not yet implemented
  5573. Params : unknown
  5574. Dev :
  5575. Example :
  5576. */
  5577. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5578. {
  5579. PrintSep(sep, "COMMAND_DUELBET");
  5580. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5581. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5582. }
  5583. /*
  5584. Function: Command_DuelAccept()
  5585. Purpose : Handle the /duel commands - not yet implemented
  5586. Params : unknown
  5587. Dev :
  5588. Example :
  5589. */
  5590. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5591. {
  5592. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5593. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5594. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5595. }
  5596. /*
  5597. Function: Command_DuelDecline()
  5598. Purpose : Handle the /duel commands - not yet implemented
  5599. Params : unknown
  5600. Dev :
  5601. Example :
  5602. */
  5603. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5604. {
  5605. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5606. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5607. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5608. }
  5609. /*
  5610. Function: Command_DuelSurrender()
  5611. Purpose : Handle the /duel commands - not yet implemented
  5612. Params : unknown
  5613. Dev :
  5614. Example :
  5615. */
  5616. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5617. {
  5618. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5619. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5620. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5621. // JA, just messin around ;)
  5622. char surrender[64];
  5623. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5624. zone_list.HandleGlobalAnnouncement(surrender);
  5625. }
  5626. /*
  5627. Function: Command_DuelToggle()
  5628. Purpose : Handle the /duel commands - not yet implemented
  5629. Params : unknown
  5630. Dev :
  5631. Example :
  5632. */
  5633. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5634. {
  5635. PrintSep(sep, "COMMAND_DUEL");
  5636. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5637. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5638. }
  5639. /*
  5640. Function:
  5641. Purpose :
  5642. Params :
  5643. Dev :
  5644. Example :
  5645. */
  5646. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5647. {
  5648. if( handler == COMMAND_ENTITYCOMMAND )
  5649. {
  5650. // /entitycommand command by itself shows help (to be extended)
  5651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5652. return;
  5653. }
  5654. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5655. {
  5656. // /entitycommand list command expects "name" param
  5657. if (sep && sep->arg[0])
  5658. {
  5659. const char* entity_command_name = sep->argplus[0];
  5660. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5661. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5662. map<int32, vector<EntityCommand*>*>::iterator itr;
  5663. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5664. {
  5665. vector<EntityCommand*>* entity_command_list = itr->second;
  5666. vector<EntityCommand*>::iterator itr2;
  5667. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5668. {
  5669. EntityCommand* entity_command = *itr2;
  5670. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5671. 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);
  5672. }
  5673. }
  5674. }
  5675. else // no command name
  5676. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5677. }
  5678. }
  5679. /*
  5680. Function: Command_Follow()
  5681. Purpose : Handle the /follow command - not yet implemented
  5682. Params :
  5683. Dev :
  5684. Example :
  5685. */
  5686. void Commands::Command_Follow(Client* client, Seperator* sep)
  5687. {
  5688. PrintSep(sep, "COMMAND_FOLLOW");
  5689. // flag to toggle if the players target is in the players group
  5690. bool targetInGroup = false;
  5691. // get a pointer to the players group
  5692. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5693. // If the player has a group and has a target
  5694. if (gmi && client->GetPlayer()->GetTarget()) {
  5695. deque<GroupMemberInfo*>::iterator itr;
  5696. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5697. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5698. if (group)
  5699. {
  5700. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5701. deque<GroupMemberInfo*>* members = group->GetMembers();
  5702. // Loop through the group members
  5703. for (itr = members->begin(); itr != members->end(); itr++) {
  5704. // If a group member matches a target
  5705. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5706. // toggle the flag and break the loop
  5707. targetInGroup = true;
  5708. break;
  5709. }
  5710. }
  5711. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5712. }
  5713. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5714. }
  5715. if (targetInGroup) {
  5716. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5717. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5718. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5719. client->GetPlayer()->info_changed = true;
  5720. client->GetPlayer()->changed = true;
  5721. }
  5722. else
  5723. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5724. }
  5725. /*
  5726. Function: Command_StopFollow()
  5727. Purpose : Handle the /stop_follow command - not yet implemented
  5728. Params :
  5729. Dev :
  5730. Example :
  5731. */
  5732. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5733. {
  5734. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5735. if (client->GetPlayer()->GetFollowTarget()) {
  5736. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5737. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5738. client->GetPlayer()->SetFollowTarget(0);
  5739. client->GetPlayer()->info_changed = true;
  5740. client->GetPlayer()->changed = true;
  5741. }
  5742. }
  5743. /*
  5744. Function: Command_Grid()
  5745. Purpose : Show player's current Grid ID
  5746. Params :
  5747. Dev : Scatman
  5748. Example : /grid
  5749. */
  5750. void Commands::Command_Grid(Client* client)
  5751. {
  5752. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5753. if (client->GetPlayer()->GetMap() != nullptr) {
  5754. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5755. uint32 GridID = 0;
  5756. float new_z = client->GetPlayer()->GetMap()->FindBestZ(loc, nullptr, &GridID);
  5757. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f", GridID, new_z);
  5758. }
  5759. }
  5760. /*
  5761. Function: Command_Guild()
  5762. Purpose : Handler for all UI-related guild commands
  5763. Dev : Scatman
  5764. */
  5765. void Commands::Command_Guild(Client* client, Seperator* sep)
  5766. {
  5767. Guild* guild = client->GetPlayer()->GetGuild();
  5768. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5769. {
  5770. const char* command = sep->arg[0];
  5771. int32 length = strlen(command);
  5772. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5773. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5774. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5775. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5776. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5777. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5778. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5779. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5780. guild->KickGuildMember(client, sep->arg[1]);
  5781. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5782. guild->DemoteGuildMember(client, sep->arg[1]);
  5783. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5784. guild->PromoteGuildMember(client, sep->arg[1]);
  5785. else if (strncmp(command, "points", length) == 0 && guild)
  5786. {
  5787. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5788. {
  5789. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5790. {
  5791. float points = atof(sep->arg[2]);
  5792. const char* option = sep->arg[3];
  5793. const char* comment = sep->argplus[4];
  5794. if (strncmp(option, "all", strlen(option)) == 0)
  5795. guild->AddPointsToAll(client, points, comment);
  5796. else if (strncmp(option, "online", strlen(option)) == 0)
  5797. guild->AddPointsToAllOnline(client, points, comment);
  5798. else if (strncmp(option, "group", strlen(option)) == 0)
  5799. guild->AddPointsToGroup(client, points, comment);
  5800. else if (strncmp(option, "raid", strlen(option)) == 0)
  5801. guild->AddPointsToRaid(client, points, comment);
  5802. else
  5803. guild->AddPointsToGuildMember(client, points, option, comment);
  5804. }
  5805. }
  5806. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5807. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5808. else
  5809. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5810. }
  5811. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5812. guild->SetMOTD(sep->argplus[1]);
  5813. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5814. {
  5815. if (sep->arg[1])
  5816. {
  5817. const char* option = sep->arg[1];
  5818. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5819. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5820. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5821. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5822. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5823. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5824. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5825. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5826. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5827. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5828. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5829. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5830. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5831. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5832. else
  5833. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5834. }
  5835. else
  5836. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5837. }
  5838. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5839. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5840. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5841. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5842. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5843. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5844. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5845. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5846. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5847. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5848. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5849. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5850. else if (strncmp(command, "invite", length) == 0 && guild)
  5851. {
  5852. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5853. guild->InvitePlayer(client, sep->arg[1]);
  5854. else
  5855. {
  5856. Spawn* target = client->GetPlayer()->GetTarget();
  5857. if (target)
  5858. {
  5859. if (target->IsPlayer())
  5860. guild->InvitePlayer(client, target->GetName());
  5861. else
  5862. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5863. }
  5864. }
  5865. }
  5866. else if (strncmp(command, "accept", length) == 0)
  5867. {
  5868. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5869. if (pgi && pgi->guild && pgi->invited_by)
  5870. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5871. client->SetPendingGuildInvite(0);
  5872. }
  5873. else if (strncmp(command, "decline", length) == 0)
  5874. {
  5875. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5876. if (pgi && pgi->guild && pgi->invited_by)
  5877. {
  5878. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5879. if (client_inviter)
  5880. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5881. }
  5882. client->SetPendingGuildInvite(0);
  5883. }
  5884. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5885. {
  5886. const char* guild_name = sep->argplus[1];
  5887. if (!guild_list.GetGuild(guild_name))
  5888. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5889. else
  5890. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5891. }
  5892. else if (strncmp(command, "search", length) == 0)
  5893. client->ShowGuildSearchWindow();
  5894. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5895. {
  5896. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5897. if (to_guild)
  5898. to_guild->SendGuildRecruitingDetails(client);
  5899. }
  5900. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5901. {
  5902. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5903. if (to_guild)
  5904. to_guild->SendGuildRecruitingImages(client);
  5905. }
  5906. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5907. {
  5908. if (sep->arg[1])
  5909. {
  5910. const char* option = sep->arg[1];
  5911. if (strncmp(option, "toggle", strlen(option)) == 0)
  5912. guild->ToggleGuildRecruiterAdventureClass(client);
  5913. }
  5914. else
  5915. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5916. }
  5917. else if (strncmp(command, "display_heraldry", length) == 0)
  5918. {
  5919. // JA: not sure this is right...
  5920. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5921. client->GetPlayer()->SetCharSheetChanged(true);
  5922. }
  5923. else
  5924. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5925. }
  5926. }
  5927. /*
  5928. Function: Command_GuildCreate()
  5929. Purpose : Display's in-game Guild Creation window
  5930. Dev : Scatman
  5931. */
  5932. void Commands::Command_CreateGuild(Client* client)
  5933. {
  5934. client->SendGuildCreateWindow();
  5935. }
  5936. /*
  5937. Function: Command_SetGuildOfficerNote()
  5938. Purpose :
  5939. Dev : Scatman
  5940. */
  5941. void Commands::Command_SetGuildOfficerNote(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->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5948. }
  5949. }
  5950. /*
  5951. Function: Command_SetGuildMemberNote()
  5952. Purpose :
  5953. Dev : Scatman
  5954. */
  5955. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5956. {
  5957. if (sep && sep->arg[0] && sep->arg[1])
  5958. {
  5959. Guild* guild = client->GetPlayer()->GetGuild();
  5960. if (guild)
  5961. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5962. }
  5963. }
  5964. /*
  5965. Function: Command_GuildSay()
  5966. Purpose :
  5967. Dev : Scatman
  5968. */
  5969. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5970. {
  5971. Guild* guild = client->GetPlayer()->GetGuild();
  5972. if (guild)
  5973. {
  5974. if (sep && sep->arg[0])
  5975. guild->HandleGuildSay(client, sep->argplus[0]);
  5976. }
  5977. else
  5978. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5979. }
  5980. /*
  5981. Function: Command_OfficerSay()
  5982. Purpose :
  5983. Dev : Scatman
  5984. */
  5985. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5986. {
  5987. Guild* guild = client->GetPlayer()->GetGuild();
  5988. if (guild)
  5989. {
  5990. if (sep && sep->arg[0])
  5991. guild->HandleOfficerSay(client, sep->argplus[0]);
  5992. }
  5993. else
  5994. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5995. }
  5996. /*
  5997. Function: Command_Guilds()
  5998. Purpose : Shows help for /guild command
  5999. Params :
  6000. Dev : Scatman
  6001. Example :
  6002. */
  6003. void Commands::Command_Guilds(Client* client)
  6004. {
  6005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6006. }
  6007. /*
  6008. Function: Command_GuildsAdd()
  6009. Purpose : Add's players to a guild
  6010. Params : guild_name|guild_id, player name
  6011. Dev : Scatman
  6012. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6013. */
  6014. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6015. {
  6016. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6017. {
  6018. Guild* guild = 0;
  6019. bool found = true;
  6020. if (sep->IsNumber(0))
  6021. {
  6022. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6023. if (!guild)
  6024. {
  6025. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6026. found = false;
  6027. }
  6028. }
  6029. else
  6030. {
  6031. guild = guild_list.GetGuild(sep->arg[0]);
  6032. if (!guild)
  6033. {
  6034. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6035. found = false;
  6036. }
  6037. }
  6038. if (found)
  6039. {
  6040. Client* to_client = 0;
  6041. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6042. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6043. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6044. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6045. if (to_client)
  6046. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6047. else
  6048. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6049. }
  6050. }
  6051. else
  6052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6053. }
  6054. /*
  6055. Function: Command_GuildsCreate()
  6056. Purpose : Creates a guild
  6057. Params : guild_name, player_name (optional)
  6058. Dev : Scatman
  6059. Example : /guilds create [guild name] (player name)
  6060. */
  6061. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6062. {
  6063. if (sep && sep->arg[0])
  6064. {
  6065. const char* guild_name = sep->arg[0];
  6066. if (!guild_list.GetGuild(guild_name))
  6067. {
  6068. bool ret = false;
  6069. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6070. {
  6071. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6072. if (to_client)
  6073. {
  6074. world.CreateGuild(guild_name, to_client);
  6075. ret = true;
  6076. }
  6077. else
  6078. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6079. }
  6080. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6081. {
  6082. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6083. if (to_client)
  6084. {
  6085. world.CreateGuild(guild_name, to_client);
  6086. ret = true;
  6087. }
  6088. }
  6089. else
  6090. {
  6091. world.CreateGuild(guild_name);
  6092. ret = true;
  6093. }
  6094. if (ret)
  6095. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6096. else
  6097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6098. }
  6099. else
  6100. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6101. }
  6102. else
  6103. 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.");
  6104. }
  6105. /*
  6106. Function: Command_GuildsDelete()
  6107. Purpose : Delete's a guild
  6108. Params : guild name
  6109. Dev : Scatman
  6110. Example : /guilds delete Test
  6111. */
  6112. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6113. {
  6114. if (sep && sep->arg[0])
  6115. {
  6116. Guild* guild = 0;
  6117. bool found = true;
  6118. if (sep->IsNumber(0))
  6119. {
  6120. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6121. if (!guild)
  6122. {
  6123. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6124. found = false;
  6125. }
  6126. }
  6127. else
  6128. {
  6129. guild = guild_list.GetGuild(sep->arg[0]);
  6130. if (!guild)
  6131. {
  6132. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6133. found = false;
  6134. }
  6135. }
  6136. if (found)
  6137. {
  6138. guild->RemoveAllGuildMembers();
  6139. database.DeleteGuild(guild);
  6140. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6141. guild_list.RemoveGuild(guild, true);
  6142. }
  6143. }
  6144. else
  6145. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6146. }
  6147. /*
  6148. Function: Command_GuildsList()
  6149. Purpose : Lists current guilds on server
  6150. Params :
  6151. Dev : Scatman
  6152. Example : /guilds list
  6153. */
  6154. void Commands::Command_GuildsList(Client* client)
  6155. {
  6156. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6157. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6159. if (guilds->size() == 0)
  6160. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6161. else {
  6162. while (itr.Next()) {
  6163. Guild* guild = itr.second;
  6164. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6165. }
  6166. }
  6167. }
  6168. /*
  6169. Function: Command_GuildsRemove()
  6170. Purpose : Removes a player from a guild
  6171. Params : guild name|guild id, player name
  6172. Dev : Scatman
  6173. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6174. */
  6175. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6176. {
  6177. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6178. {
  6179. Guild* guild = 0;
  6180. bool found = true;
  6181. if (sep->IsNumber(0))
  6182. {
  6183. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6184. if (!guild)
  6185. {
  6186. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6187. found = false;
  6188. }
  6189. }
  6190. else
  6191. {
  6192. guild = guild_list.GetGuild(sep->arg[0]);
  6193. if (!guild)
  6194. {
  6195. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6196. found = false;
  6197. }
  6198. }
  6199. if (found)
  6200. {
  6201. Client* to_client = 0;
  6202. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6203. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6204. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6205. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6206. if (to_client)
  6207. {
  6208. Player* to_player = to_client->GetPlayer();
  6209. if (to_player->GetGuild())
  6210. {
  6211. if (to_player->GetGuild() == guild)
  6212. {
  6213. guild->KickGuildMember(client, to_player->GetName());
  6214. }
  6215. else
  6216. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6217. }
  6218. else
  6219. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6220. }
  6221. else
  6222. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6223. }
  6224. }
  6225. else
  6226. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6227. }
  6228. /*
  6229. Function: Command_InspectPlayer()
  6230. Purpose : Handle the Inspect functions
  6231. Params : Client to inspect
  6232. Dev : Scatman
  6233. Example : /inspect Scatman
  6234. */
  6235. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6236. {
  6237. if (sep && sep->arg[0])
  6238. {
  6239. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6240. if (inspect_client)
  6241. client->InspectPlayer(inspect_client->GetPlayer());
  6242. }
  6243. else
  6244. {
  6245. Spawn* target = client->GetPlayer()->GetTarget();
  6246. if (target && target->IsPlayer())
  6247. client->InspectPlayer((Player*)target);
  6248. }
  6249. }
  6250. /*
  6251. Function: Command_Inventory()
  6252. Purpose : Handle changes in player inventory
  6253. Params : <TBD>
  6254. Dev : All
  6255. Example : /inventory delete item_id
  6256. */
  6257. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6258. {
  6259. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6260. Player* player = client->GetPlayer();
  6261. if(sep && sep->arg[0][0])
  6262. {
  6263. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6264. if(client->GetPlayer()->GetHP() == 0)
  6265. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6266. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6267. {
  6268. int16 index = atoi(sep->arg[1]);
  6269. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6270. if(item)
  6271. {
  6272. if(item->details.item_locked) {
  6273. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6274. return;
  6275. }
  6276. else if(item->CheckFlag(NO_DESTROY)) {
  6277. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6278. return;
  6279. }
  6280. if(item->GetItemScript() && lua_interface)
  6281. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6282. //reobtain item make sure it wasn't removed
  6283. item = player->item_list.GetItemFromIndex(index);
  6284. int32 bag_id = 0;
  6285. if(item){
  6286. bag_id = item->details.inv_slot_id;
  6287. database.DeleteItem(client->GetCharacterID(), item, 0);
  6288. }
  6289. client->GetPlayer()->item_list.DestroyItem(index);
  6290. client->GetPlayer()->UpdateInventory(bag_id);
  6291. }
  6292. }
  6293. 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))
  6294. {
  6295. int16 from_index = atoi(sep->arg[1]);
  6296. sint16 to_slot = atoi(sep->arg[2]);
  6297. sint32 bag_id = atol(sep->arg[3]);
  6298. int8 charges = atoi(sep->arg[4]);
  6299. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6300. if(!item) {
  6301. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6302. return;
  6303. }
  6304. if(item->details.item_locked)
  6305. {
  6306. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6307. return;
  6308. }
  6309. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6310. {
  6311. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6312. return;
  6313. }
  6314. sint32 old_inventory_id = 0;
  6315. if(item)
  6316. old_inventory_id = item->details.inv_slot_id;
  6317. //autobank
  6318. if (bag_id == -3 && to_slot == -1)
  6319. {
  6320. if (player->HasFreeBankSlot())
  6321. to_slot = player->FindFreeBankSlot();
  6322. else
  6323. {
  6324. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6325. return;
  6326. }
  6327. }
  6328. //auto inventory
  6329. if (bag_id == 0 && to_slot == -1)
  6330. {
  6331. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6332. {
  6333. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6334. return;
  6335. }
  6336. }
  6337. bool item_deleted = false;
  6338. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6339. client->QueuePacket(outapp);
  6340. if(item_deleted)
  6341. item = nullptr;
  6342. //removed from bag send update
  6343. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6344. {
  6345. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6346. if(outapp)
  6347. client->QueuePacket(outapp);
  6348. }
  6349. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6350. {
  6351. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6352. if(outapp)
  6353. client->QueuePacket(outapp);
  6354. }
  6355. }
  6356. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6357. {
  6358. if(client->GetPlayer()->EngagedInCombat())
  6359. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6360. else
  6361. {
  6362. int16 index = atoi(sep->arg[1]);
  6363. int8 slot_id = 255;
  6364. int8 unk3 = 0;
  6365. int8 appearance_equip = 0;
  6366. if(sep->arg[2][0] && sep->IsNumber(2))
  6367. slot_id = atoi(sep->arg[2]);
  6368. if(sep->arg[3][0] && sep->IsNumber(3))
  6369. unk3 = atoul(sep->arg[3]);
  6370. if(sep->arg[4][0] && sep->IsNumber(4))
  6371. appearance_equip = atoul(sep->arg[4]);
  6372. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6373. EQ2Packet* outapp = 0;
  6374. for(int32 i=0;i<packets.size();i++)
  6375. {
  6376. outapp = packets[i];
  6377. if(outapp)
  6378. client->QueuePacket(outapp);
  6379. }
  6380. client->GetPlayer()->ChangePrimaryWeapon();
  6381. client->GetPlayer()->ChangeSecondaryWeapon();
  6382. client->GetPlayer()->ChangeRangedWeapon();
  6383. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6384. client->QueuePacket(characterSheetPackets);
  6385. }
  6386. }
  6387. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6388. {
  6389. if (client->GetPlayer()->EngagedInCombat())
  6390. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6391. else {
  6392. int16 index = atoi(sep->arg[1]);
  6393. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6394. if (item) {
  6395. if(item->details.item_locked)
  6396. {
  6397. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6398. return;
  6399. }
  6400. // client->GetPlayer()->item_list.DestroyItem(index);
  6401. if (item->item_sets.size() > 0) {
  6402. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6403. ItemSet* set = item->item_sets[i];
  6404. if (set->item_stack_size == 0)
  6405. set->item_stack_size += 1;
  6406. client->AddItem(set->item_id, set->item_stack_size);
  6407. }
  6408. }
  6409. }
  6410. client->RemoveItem(item, 1);
  6411. }
  6412. }
  6413. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6414. {
  6415. if(client->GetPlayer()->EngagedInCombat())
  6416. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6417. else
  6418. {
  6419. int16 index = atoi(sep->arg[1]);
  6420. sint32 bag_id = -999;
  6421. int8 to_slot = 255;
  6422. if(sep->arg[3][0])
  6423. {
  6424. if(sep->IsNumber(2))
  6425. bag_id = atol(sep->arg[2]);
  6426. if(sep->IsNumber(3))
  6427. to_slot = atoi(sep->arg[3]);
  6428. }
  6429. sint8 unk4 = 0;
  6430. int8 appearance_equip = 0;
  6431. if(sep->arg[4][0] && sep->IsNumber(4))
  6432. unk4 = atoi(sep->arg[4]);
  6433. if(sep->arg[5][0] && sep->IsNumber(5))
  6434. appearance_equip = atoul(sep->arg[5]);
  6435. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6436. EQ2Packet* outapp = 0;
  6437. for(int32 i=0;i<packets.size();i++)
  6438. {
  6439. outapp = packets[i];
  6440. if(outapp)
  6441. client->QueuePacket(outapp);
  6442. }
  6443. client->GetPlayer()->ChangePrimaryWeapon();
  6444. client->GetPlayer()->ChangeSecondaryWeapon();
  6445. client->GetPlayer()->ChangeRangedWeapon();
  6446. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6447. client->QueuePacket(characterSheetPackets);
  6448. }
  6449. }
  6450. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6451. {
  6452. if(client->GetPlayer()->EngagedInCombat()) {
  6453. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6454. }
  6455. else {
  6456. int16 index1 = atoi(sep->arg[1]);
  6457. int16 index2 = atoi(sep->arg[2]);
  6458. int8 type = 0;
  6459. if(sep->IsNumber(3))
  6460. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6461. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6462. if(outapp)
  6463. client->QueuePacket(outapp);
  6464. else
  6465. {
  6466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6467. return;
  6468. }
  6469. }
  6470. }
  6471. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6472. {
  6473. sint16 to_slot = atoi(sep->arg[1]);
  6474. sint32 bag_id = atoi(sep->arg[2]);
  6475. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6476. if (item) {
  6477. //auto inventory
  6478. if (bag_id == 0 && to_slot == -1)
  6479. {
  6480. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6481. {
  6482. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6483. return;
  6484. }
  6485. // Set the slot for the item
  6486. item->details.inv_slot_id = bag_id;
  6487. item->details.slot_id = to_slot;
  6488. // Flag the item so it gets saved in its new location
  6489. item->save_needed = true;
  6490. // Add the item to its new location
  6491. if(player->item_list.AddItem(item)) {
  6492. // Remove the item from the overflow list
  6493. player->item_list.RemoveOverflowItem(item);
  6494. }
  6495. // Send the inventory update packet
  6496. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6497. return;
  6498. }
  6499. else if (bag_id == -3 && to_slot == -1) {
  6500. // Auto Bank
  6501. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6502. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6503. return;
  6504. }
  6505. item->details.inv_slot_id = bag_id;
  6506. item->details.slot_id = to_slot;
  6507. item->save_needed = true;
  6508. if(player->item_list.AddItem(item)) {
  6509. player->item_list.RemoveOverflowItem(item);
  6510. }
  6511. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6512. }
  6513. else if (bag_id == -4) {
  6514. // Shared Bank
  6515. if (!player->item_list.SharedBankAddAllowed(item)) {
  6516. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6517. return;
  6518. }
  6519. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6520. if (tmp_item) {
  6521. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6522. return;
  6523. }
  6524. else {
  6525. item->details.inv_slot_id = bag_id;
  6526. item->details.slot_id = to_slot;
  6527. item->save_needed = true;
  6528. if(player->item_list.AddItem(item)) {
  6529. player->item_list.RemoveOverflowItem(item);
  6530. }
  6531. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6532. return;
  6533. }
  6534. }
  6535. else {
  6536. // Try to get an item from the given bag id and slot id
  6537. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6538. // Check to see if we got an item, if we do send an error,
  6539. // if we don't put the overflow item into this slot
  6540. if (tmp_item) {
  6541. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6542. }
  6543. else {
  6544. item->details.inv_slot_id = bag_id;
  6545. item->details.slot_id = to_slot;
  6546. item->save_needed = true;
  6547. if(player->item_list.AddItem(item)) {
  6548. player->item_list.RemoveOverflowItem(item);
  6549. }
  6550. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6551. return;
  6552. }
  6553. }
  6554. }
  6555. }
  6556. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6557. {
  6558. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6559. int32 character_item_id = (int32) (data >> 32);
  6560. int32 item_id = (int32) (data & 0xffffffffL);
  6561. int8 sale_setting = atoi(sep->arg[2]);
  6562. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6563. if(item)
  6564. {
  6565. item->no_sale = sale_setting;
  6566. item->save_needed = true;
  6567. client->SendSellMerchantList();
  6568. }
  6569. }
  6570. }
  6571. else
  6572. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6573. }
  6574. /*
  6575. Function: Command_IRC()
  6576. Purpose : Handle the IRC functions
  6577. Params : IRC Commands
  6578. Dev : Scatman
  6579. Example : /irc say #Channel Hello World!
  6580. */
  6581. void Commands::Command_IRC(Client* client, Seperator* sep)
  6582. {
  6583. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  6584. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  6585. return;
  6586. }
  6587. if (sep && sep->arg[0][0]) {
  6588. if (strcasecmp(sep->arg[0], "say") == 0) {
  6589. if (sep->arg[1][0] && sep->arg[2][0]) {
  6590. if (sep->IsNumber(sep->arg[1]))
  6591. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  6592. else
  6593. irc.Say(client, sep->arg[1], sep->argplus[2]);
  6594. }
  6595. else
  6596. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  6597. }
  6598. else if (strcasecmp(sep->arg[0], "join") == 0) {
  6599. if (sep->arg[1][0])
  6600. irc.JoinChannel(client, sep->arg[1]);
  6601. else
  6602. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  6603. }
  6604. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  6605. if (sep->arg[1][0])
  6606. irc.LeaveChannel(client, sep->arg[1]);
  6607. else
  6608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  6609. }
  6610. else if (strcasecmp(sep->arg[0], "list") == 0)
  6611. irc.ListChannels(client);
  6612. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  6613. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  6614. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  6615. else
  6616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  6617. }
  6618. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  6619. irc.DisconnectFromServer(client);
  6620. else
  6621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6622. }
  6623. else
  6624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6625. }
  6626. /*
  6627. Function: Command_Languages()
  6628. Purpose : Show's languages the player knows
  6629. Params :
  6630. Dev : Zcoretri
  6631. Example :
  6632. */
  6633. void Commands::Command_Languages(Client* client, Seperator* sep)
  6634. {
  6635. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6636. list<Language*>::iterator itr;
  6637. Language* language;
  6638. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6639. for(itr = languages->begin(); itr != languages->end(); itr++)
  6640. {
  6641. language = *itr;
  6642. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6643. }
  6644. }
  6645. /*
  6646. Function: Command_SetLanguage()
  6647. Purpose : Handles language commands
  6648. Params : Language ID
  6649. Dev : Zcoretri
  6650. Example :
  6651. */
  6652. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6653. {
  6654. Player* player = client->GetPlayer();
  6655. if (sep && sep->arg[0])
  6656. {
  6657. if(!sep->IsNumber(0))
  6658. {
  6659. //String passed in
  6660. const char* value = sep->arg[0];
  6661. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6662. {
  6663. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6664. client->SendLanguagesUpdate(0);
  6665. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6666. }
  6667. else
  6668. {
  6669. if(player->HasLanguage(value))
  6670. {
  6671. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6672. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6673. client->SendLanguagesUpdate(language->GetID());
  6674. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6675. }
  6676. else
  6677. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6678. }
  6679. }
  6680. else
  6681. {
  6682. //Number passed in
  6683. int32 id = atoul(sep->arg[0]);
  6684. if(player->HasLanguage(id))
  6685. {
  6686. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6687. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6688. client->SendLanguagesUpdate(id);
  6689. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6690. }
  6691. else
  6692. {
  6693. Language* language = master_languages_list.GetLanguage(id);
  6694. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6695. }
  6696. }
  6697. }
  6698. else
  6699. {
  6700. //No value was passed in
  6701. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6702. if(id > 0)
  6703. {
  6704. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6705. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6706. }
  6707. else
  6708. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6709. }
  6710. }
  6711. /*
  6712. Function: Command_LastName()
  6713. Purpose : Sets player surname
  6714. Params : Name text
  6715. Dev : theFoof
  6716. Example :
  6717. */
  6718. void Commands::Command_LastName(Client* client, Seperator* sep)
  6719. {
  6720. if (!client)
  6721. return;
  6722. if (sep && sep->arg[0])
  6723. {
  6724. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6725. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6726. return;
  6727. }
  6728. client->RemovePendingLastName();
  6729. uchar* checkname = (uchar*)sep->arg[0];
  6730. bool valid_name = true;
  6731. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6732. if (!alpha_check(checkname[i])) {
  6733. valid_name = false;
  6734. break;
  6735. }
  6736. }
  6737. if (!valid_name) {
  6738. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6739. return;
  6740. }
  6741. string last_name = (string)sep->arg[0];
  6742. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6743. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6744. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6745. client->SetPendingLastName(last_name);
  6746. client->SendLastNameConfirmation();
  6747. }
  6748. else
  6749. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6750. }
  6751. }
  6752. /*
  6753. Function: Command_ConfirmLastName()
  6754. Purpose : Confirms setting of player surname
  6755. Params : Name text
  6756. Dev : theFoof
  6757. Example :
  6758. */
  6759. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6760. {
  6761. if (!client)
  6762. return;
  6763. string* name = client->GetPendingLastName();
  6764. if (name){
  6765. Player* player = client->GetPlayer();
  6766. player->SetLastName(name->c_str(), false);
  6767. client->SendTitleUpdate();
  6768. player->SetCharSheetChanged(true);
  6769. client->RemovePendingLastName();
  6770. }
  6771. }
  6772. /*
  6773. Function: Command_Location()
  6774. Purpose : Display's Help for /location commands
  6775. Params :
  6776. Dev : Scatman
  6777. Example : /location = show's help for command
  6778. */
  6779. void Commands::Command_Location(Client* client)
  6780. {
  6781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6785. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6787. }
  6788. /*
  6789. Function: Command_LocationAdd()
  6790. Purpose : Add's a location to an existing location config
  6791. Params : location_id
  6792. Dev : Scatman
  6793. Example : /location add {location_id}
  6794. */
  6795. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6796. {
  6797. if (sep && sep->arg[0] && sep->IsNumber(0))
  6798. {
  6799. int32 location_id = atoul(sep->arg[0]);
  6800. float x = client->GetPlayer()->GetX();
  6801. float y = client->GetPlayer()->GetY();
  6802. float z = client->GetPlayer()->GetZ();
  6803. if (database.AddLocationPoint(location_id, x, y, z))
  6804. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6805. else
  6806. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6807. }
  6808. else
  6809. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6810. }
  6811. /*
  6812. Function: Command_LocationCreate()
  6813. Purpose : Creates a new location config
  6814. Params : location name, 0/1 for include_y (optional)
  6815. Dev : Scatman
  6816. Example : /location create Test 1 = creates a new location named Test with include_y True
  6817. */
  6818. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6819. {
  6820. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6821. {
  6822. const char* name = sep->arg[0];
  6823. bool include_y = false;
  6824. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6825. include_y = true;
  6826. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6827. if (location_id > 0)
  6828. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6829. else
  6830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6831. }
  6832. else
  6833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6834. }
  6835. /*
  6836. Function: Command_LocationDelete()
  6837. Purpose : Delete's a location config and all it's location points
  6838. Params : location_id
  6839. Dev : Scatman
  6840. Example : /location delete {location_id}
  6841. */
  6842. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6843. {
  6844. if (sep && sep->arg[0] && sep->IsNumber(0))
  6845. {
  6846. int32 location_id = atoul(sep->arg[0]);
  6847. if (database.DeleteLocation(location_id))
  6848. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6849. else
  6850. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6851. }
  6852. else
  6853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6854. }
  6855. /*
  6856. Function: Command_LocationList()
  6857. Purpose : Display's a list of location points
  6858. Params : location_id
  6859. Dev : Scatman
  6860. Example : /location list {location_id}
  6861. */
  6862. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6863. {
  6864. if (sep && sep->arg[0])
  6865. {
  6866. const char* option = sep->arg[0];
  6867. if (strncmp(option, "locations", strlen(option)) == 0)
  6868. database.ListLocations(client);
  6869. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6870. {
  6871. int32 location_id = atoul(sep->arg[1]);
  6872. database.ListLocationPoints(client, location_id);
  6873. }
  6874. else
  6875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6876. }
  6877. else
  6878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6879. }
  6880. /*
  6881. Function: Command_LocationRemove()
  6882. Purpose : Removes a single location point from a location config
  6883. Params : location_point_id (gotten from /location list {id})
  6884. Dev : Scatman
  6885. Example : /location remove 1 = will remove location_point_id 1
  6886. */
  6887. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6888. {
  6889. if (sep && sep->arg[0] && sep->IsNumber(0))
  6890. {
  6891. int32 location_point_id = atoul(sep->arg[0]);
  6892. if (database.DeleteLocationPoint(location_point_id))
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6894. else
  6895. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6896. }
  6897. else
  6898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6899. }
  6900. /*
  6901. Function: Command_Merchant()
  6902. Purpose : Handles Merchant commands
  6903. Params : list
  6904. Dev : Scatman
  6905. Example : /merchant list
  6906. */
  6907. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6908. {
  6909. if( handler == COMMAND_MERCHANT )
  6910. {
  6911. // /merchant command by itself shows help (to be extended)
  6912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6913. return;
  6914. }
  6915. else if( handler == COMMAND_MERCHANT_LIST )
  6916. {
  6917. // /merchant list command expects "description" param
  6918. if (sep && sep->arg[0])
  6919. {
  6920. const char* merchant_description = sep->argplus[0];
  6921. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6922. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6923. map<int32, MerchantInfo*>::iterator itr;
  6924. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6925. {
  6926. string description = database.GetMerchantDescription(itr->first);
  6927. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6928. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6929. }
  6930. }
  6931. else // no description
  6932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6933. }
  6934. }
  6935. /*
  6936. Function: Command_Modify()
  6937. Purpose : to replace our other "set" commands
  6938. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6939. Dev : John Adams
  6940. Example : /modify spell set name "Aegolism III"
  6941. */
  6942. void Commands::Command_Modify(Client* client)
  6943. {
  6944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6949. }
  6950. /*
  6951. Function: Command_ModifySpawn()
  6952. Purpose : replace "spawn set" commands
  6953. Params : Action : the action to perform (or special handler)
  6954. : Field : the DB field to change
  6955. : Value : what to set the value to
  6956. : Target : what object to change (my target, or spawn_id)
  6957. Dev : John Adams
  6958. Example : /modify spawn set name "Lady Vox"
  6959. :
  6960. Note : Special Handlers, like "zoneto" for Signs
  6961. : /modify spawn zoneto
  6962. : Will set a sign's zone x/y/z to my current coords
  6963. */
  6964. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6965. {
  6966. PrintSep(sep, "COMMAND_MODIFY");
  6967. // need at least 2 args for a valid command
  6968. if( sep && sep->arg[1] )
  6969. {
  6970. // JA: just a quick implementation because I need it :)
  6971. if (strcmp(sep->arg[0], "zoneto") == 0)
  6972. {
  6973. if( sep->IsNumber(1) )
  6974. {
  6975. int32 spawn_id = atoul(sep->arg[1]);
  6976. float x_coord = client->GetPlayer()->GetX();
  6977. float y_coord = client->GetPlayer()->GetY();
  6978. float z_coord = client->GetPlayer()->GetZ();
  6979. float h_coord = client->GetPlayer()->GetHeading();
  6980. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6981. }
  6982. else
  6983. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6984. }
  6985. }
  6986. else
  6987. Command_Modify(client);
  6988. }
  6989. /*
  6990. Function: Command_ModifyCharacter()
  6991. Purpose : to replace our other "set" commands
  6992. Params : Action : Add, Remove
  6993. : Field : copper, silver, gold, plat
  6994. : Value : min 1, max unlimited
  6995. : Target : Self, Player
  6996. Dev : Cynnar
  6997. Example : /modify character add gold 50
  6998. : /modify character remove silver 25
  6999. */
  7000. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7001. {
  7002. PrintSep(sep, "COMMAND_MODIFY");
  7003. int64 value = 0;
  7004. Player* player = client->GetPlayer();
  7005. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7006. player = (Player*)player->GetTarget();
  7007. // need at least 2 args for a valid command
  7008. if( sep && sep->arg[1] )
  7009. {
  7010. if (strcmp(sep->arg[0], "add") == 0)
  7011. {
  7012. if (strcmp(sep->arg[1], "copper") == 0)
  7013. {
  7014. value = atoi64(sep->arg[2]);
  7015. player->AddCoins(value);
  7016. if (client->GetPlayer() == player)
  7017. {
  7018. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7019. }
  7020. else {
  7021. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7022. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7023. }
  7024. }
  7025. else if (strcmp(sep->arg[1], "silver") == 0)
  7026. {
  7027. value = atoi64(sep->arg[2]) * 100;
  7028. player->AddCoins(value);
  7029. if (client->GetPlayer() == player)
  7030. {
  7031. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7032. }
  7033. else {
  7034. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7035. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7036. }
  7037. }
  7038. else if (strcmp(sep->arg[1], "gold") == 0)
  7039. {
  7040. value = atoi64(sep->arg[2]) * 10000;
  7041. player->AddCoins(value);
  7042. if (client->GetPlayer() == player)
  7043. {
  7044. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7045. }
  7046. else {
  7047. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7048. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7049. }
  7050. }
  7051. else if (strcmp(sep->arg[1], "plat") == 0)
  7052. {
  7053. value = atoi64(sep->arg[2]) * 1000000;
  7054. player->AddCoins(value);
  7055. if (client->GetPlayer() == player)
  7056. {
  7057. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7058. }
  7059. else {
  7060. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7061. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7062. }
  7063. }
  7064. else
  7065. {
  7066. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7067. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7068. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7069. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7070. }
  7071. }
  7072. else if (strcmp(sep->arg[0], "remove") == 0)
  7073. {
  7074. if (strcmp(sep->arg[1], "copper") == 0)
  7075. {
  7076. value = atoi64(sep->arg[2]);
  7077. player->RemoveCoins(value);
  7078. if (client->GetPlayer() == player)
  7079. {
  7080. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7081. }
  7082. else {
  7083. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7084. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7085. }
  7086. }
  7087. else if (strcmp(sep->arg[1], "silver") == 0)
  7088. {
  7089. value = atoi64(sep->arg[2]) * 100;
  7090. player->RemoveCoins(value);
  7091. if (client->GetPlayer() == player)
  7092. {
  7093. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7094. }
  7095. else {
  7096. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7097. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7098. }
  7099. }
  7100. else if (strcmp(sep->arg[1], "gold") == 0)
  7101. {
  7102. value = atoi64(sep->arg[2]) * 10000;
  7103. player->RemoveCoins(value);
  7104. if (client->GetPlayer() == player)
  7105. {
  7106. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7107. }
  7108. else {
  7109. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7110. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7111. }
  7112. }
  7113. else if (strcmp(sep->arg[1], "plat") == 0)
  7114. {
  7115. value = atoi64(sep->arg[2]) * 1000000;
  7116. player->RemoveCoins(value);
  7117. if (client->GetPlayer() == player)
  7118. {
  7119. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7120. }
  7121. else {
  7122. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7123. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7124. }
  7125. }
  7126. else
  7127. {
  7128. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7129. }
  7130. }
  7131. else if (strcmp(sep->arg[0], "set") == 0) {
  7132. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7133. int8 level = atoi(sep->arg[2]);
  7134. if (level > 0 && level < 256) {
  7135. if (player) {
  7136. if (client->GetPlayer() == player)
  7137. client->ChangeTSLevel(player->GetTSLevel(), level);
  7138. else
  7139. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7140. }
  7141. }
  7142. else
  7143. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7144. }
  7145. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7146. int8 tsclass = atoi(sep->arg[2]);
  7147. player->SetTradeskillClass(tsclass);
  7148. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7149. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7150. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7151. player->SetCharSheetChanged(true);
  7152. }
  7153. }
  7154. }
  7155. else
  7156. {
  7157. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7158. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7159. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7160. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7161. }
  7162. }
  7163. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7164. {
  7165. PrintSep(sep, "COMMAND_MODIFY");
  7166. // need at least 2 args for a valid command
  7167. if( sep && sep->arg[1] )
  7168. {
  7169. }
  7170. else
  7171. Command_Modify(client);
  7172. }
  7173. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7174. {
  7175. PrintSep(sep, "COMMAND_MODIFY");
  7176. // need at least 2 args for a valid command
  7177. if( sep && sep->arg[1] )
  7178. {
  7179. }
  7180. else
  7181. Command_Modify(client);
  7182. }
  7183. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7184. {
  7185. PrintSep(sep, "COMMAND_MODIFY");
  7186. // need at least 2 args for a valid command
  7187. if( sep && sep->arg[1] )
  7188. {
  7189. }
  7190. else
  7191. Command_Modify(client);
  7192. }
  7193. /*
  7194. Function: Command_ModifyQuest()
  7195. Purpose : to list players quest and completed quests
  7196. Params : Action : list, completed
  7197. : Target : Self, Player
  7198. Dev : Cynnar
  7199. Example : /modify quest list
  7200. : /modify quest completed
  7201. */
  7202. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7203. {
  7204. PrintSep(sep, "COMMAND_MODIFY");
  7205. int64 value = 0;
  7206. Player* player = client->GetPlayer();
  7207. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7208. player = (Player*)player->GetTarget();
  7209. // need at least 2 args for a valid command
  7210. if (sep && sep->arg[1])
  7211. {
  7212. if (strcmp(sep->arg[0], "list") == 0)
  7213. {
  7214. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7215. map<int32, Quest*>::iterator itr;
  7216. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7217. if (quests->size() == 0)
  7218. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7219. else
  7220. {
  7221. for (itr = quests->begin(); itr != quests->end(); itr++)
  7222. {
  7223. Quest* quest = itr->second;
  7224. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7225. }
  7226. }
  7227. }
  7228. else if (strcmp(sep->arg[0], "completed") == 0)
  7229. {
  7230. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7231. map<int32, Quest*>::iterator itr;
  7232. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7233. if (quests->size() == 0)
  7234. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7235. else
  7236. {
  7237. for (itr = quests->begin(); itr != quests->end(); itr++)
  7238. {
  7239. Quest* quest = itr->second;
  7240. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7241. }
  7242. }
  7243. }
  7244. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7245. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7246. else if (strcmp(sep->arg[0], "remove") == 0)
  7247. {
  7248. int32 quest_id = 0;
  7249. if (sep && sep->arg[1] && sep->IsNumber(1))
  7250. quest_id = atoul(sep->arg[1]);
  7251. if (quest_id > 0)
  7252. {
  7253. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7254. {
  7255. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7256. if (quest)
  7257. if (client->GetPlayer() == player)
  7258. {
  7259. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7260. }
  7261. else
  7262. {
  7263. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7264. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7265. }
  7266. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7267. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7268. }
  7269. client->RemovePlayerQuest(quest_id);
  7270. client->GetCurrentZone()->SendQuestUpdates(client);
  7271. }
  7272. }
  7273. else if (strcmp(sep->arg[0], "advance") == 0)
  7274. {
  7275. int32 quest_id = 0;
  7276. int32 step = 0;
  7277. if (sep && sep->arg[1] && sep->IsNumber(1))
  7278. {
  7279. quest_id = atoul(sep->arg[1]);
  7280. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7281. if(!quest) {
  7282. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7283. return;
  7284. }
  7285. if (sep && sep->arg[2] && sep->IsNumber(1))
  7286. {
  7287. step = atoul(sep->arg[2]);
  7288. if (quest_id > 0 && step > 0)
  7289. {
  7290. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7291. {
  7292. if (client)
  7293. {
  7294. client->AddPendingQuestUpdate(quest_id, step);
  7295. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7296. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7297. }
  7298. }
  7299. }
  7300. else
  7301. {
  7302. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7303. }
  7304. }
  7305. else
  7306. {
  7307. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7308. }
  7309. }
  7310. else
  7311. {
  7312. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7313. }
  7314. }
  7315. else
  7316. {
  7317. Command_Modify(client);
  7318. }
  7319. }
  7320. else
  7321. {
  7322. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7323. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7324. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7325. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7326. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7327. }
  7328. }
  7329. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7330. {
  7331. PrintSep(sep, "COMMAND_MODIFY");
  7332. // need at least 2 args for a valid command
  7333. if( sep && sep->arg[1] )
  7334. {
  7335. if (strcmp(sep->arg[0], "add") == 0) {
  7336. const char* skill_name = sep->argplus[1];
  7337. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7338. if (skill) {
  7339. Player* player = 0;
  7340. Client* to_client = 0;
  7341. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7342. player = (Player*)client->GetPlayer()->GetTarget();
  7343. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7344. }
  7345. else {
  7346. player = client->GetPlayer();
  7347. to_client = client;
  7348. }
  7349. if (player)
  7350. {
  7351. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7352. {
  7353. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7354. if (to_client == client) {
  7355. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7356. }
  7357. else {
  7358. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7359. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7360. }
  7361. }
  7362. else
  7363. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7364. }
  7365. }
  7366. else
  7367. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7368. }
  7369. else if (strcmp(sep->arg[0], "remove") == 0) {
  7370. const char* skill_name = sep->argplus[1];
  7371. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7372. if (skill) {
  7373. Player* player = 0;
  7374. Client* to_client = 0;
  7375. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7376. player = (Player*)client->GetPlayer()->GetTarget();
  7377. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7378. }
  7379. else {
  7380. player = client->GetPlayer();
  7381. to_client = client;
  7382. }
  7383. if (player)
  7384. {
  7385. if (player->GetSkills()->HasSkill(skill->skill_id))
  7386. {
  7387. player->RemoveSkillFromDB(skill, true);
  7388. if (client == to_client) {
  7389. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7390. }
  7391. else {
  7392. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7393. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7394. }
  7395. }
  7396. else {
  7397. if (client == to_client)
  7398. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7399. else
  7400. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7401. }
  7402. }
  7403. }
  7404. else
  7405. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7406. }
  7407. else if (strcmp(sep->arg[0], "set") == 0) {
  7408. if (!sep->IsNumber(2)) {
  7409. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7410. return;
  7411. }
  7412. const char* skill_name = sep->arg[1];
  7413. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7414. if (skill) {
  7415. int16 val = atoi(sep->arg[2]);
  7416. Player* player = 0;
  7417. Client* to_client = 0;
  7418. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7419. player = (Player*)client->GetPlayer()->GetTarget();
  7420. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7421. }
  7422. else {
  7423. player = client->GetPlayer();
  7424. to_client = client;
  7425. }
  7426. if (player)
  7427. {
  7428. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7429. player->GetSkills()->SetSkill(skill->skill_id, val);
  7430. if (client != to_client)
  7431. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7432. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7433. }
  7434. else {
  7435. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7436. }
  7437. }
  7438. }
  7439. else {
  7440. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7441. }
  7442. }
  7443. else {
  7444. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7445. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7446. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7447. }
  7448. }
  7449. else {
  7450. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7451. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7452. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7453. }
  7454. }
  7455. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7456. {
  7457. PrintSep(sep, "COMMAND_MODIFY");
  7458. // need at least 2 args for a valid command
  7459. if( sep && sep->arg[1] )
  7460. {
  7461. }
  7462. else
  7463. Command_Modify(client);
  7464. }
  7465. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7466. {
  7467. PrintSep(sep, "COMMAND_MODIFY");
  7468. // need at least 2 args for a valid command
  7469. if( sep && sep->arg[1] )
  7470. {
  7471. }
  7472. else
  7473. Command_Modify(client);
  7474. }
  7475. /*
  7476. Function: Command_MOTD()
  7477. Purpose : Displays server MOTD
  7478. Params :
  7479. Dev : LethalEncounter
  7480. Example : /motd
  7481. */
  7482. void Commands::Command_MOTD(Client* client)
  7483. {
  7484. if (client)
  7485. ClientPacketFunctions::SendMOTD(client);
  7486. }
  7487. /*
  7488. Function: Command_Pet()
  7489. Purpose : Handle Pet {Command} commands
  7490. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7491. Dev :
  7492. Example : /pet preserve_master
  7493. */
  7494. void Commands::Command_Pet(Client* client, Seperator* sep)
  7495. {
  7496. PrintSep(sep, "COMMAND_PET");
  7497. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7498. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7499. if (!sep || !sep->arg[0])
  7500. return; // should have sep->arg[0] filled
  7501. if (strcmp(sep->arg[0], "hide") == 0) {
  7502. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7503. Entity* pet = client->GetPlayer()->GetDeityPet();
  7504. if (pet) {
  7505. if (pet->IsPrivateSpawn())
  7506. client->GetPlayer()->HideDeityPet(false);
  7507. else
  7508. client->GetPlayer()->HideDeityPet(true);
  7509. }
  7510. pet = client->GetPlayer()->GetCosmeticPet();
  7511. if (pet) {
  7512. if (pet->IsPrivateSpawn())
  7513. client->GetPlayer()->HideCosmeticPet(false);
  7514. else
  7515. client->GetPlayer()->HideCosmeticPet(true);
  7516. }
  7517. return;
  7518. }
  7519. // below is for all combat pets
  7520. if (!client->GetPlayer()->HasPet()) {
  7521. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7522. return;
  7523. }
  7524. if (strcmp(sep->arg[0], "stay") == 0) {
  7525. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7526. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7527. client->GetPlayer()->SetCharSheetChanged(true);
  7528. if (client->GetPlayer()->GetPet())
  7529. client->GetPlayer()->GetPet()->following = false;
  7530. if (client->GetPlayer()->GetCharmedPet())
  7531. client->GetPlayer()->GetCharmedPet()->following = false;
  7532. }
  7533. else if (strcmp(sep->arg[0], "follow") == 0) {
  7534. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7535. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7536. client->GetPlayer()->SetCharSheetChanged(true);
  7537. }
  7538. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7539. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7540. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7541. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7542. }
  7543. else {
  7544. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7545. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7546. }
  7547. client->GetPlayer()->SetCharSheetChanged(true);
  7548. }
  7549. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7550. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7551. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7552. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7553. }
  7554. else {
  7555. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7556. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7557. }
  7558. client->GetPlayer()->SetCharSheetChanged(true);
  7559. }
  7560. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7561. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7562. if (client->GetPlayer()->GetPet())
  7563. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7564. if (client->GetPlayer()->GetCharmedPet())
  7565. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7566. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7567. client->GetPlayer()->SetCharSheetChanged(true);
  7568. }
  7569. else if (strcmp(sep->arg[0], "attack") == 0) {
  7570. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7571. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7572. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7573. if (client->GetPlayer()->GetPet())
  7574. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7575. if (client->GetPlayer()->GetCharmedPet())
  7576. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7577. }
  7578. else
  7579. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7580. }
  7581. else
  7582. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7583. }
  7584. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7585. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7586. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7587. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7588. }
  7589. else
  7590. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7591. }
  7592. /*
  7593. Function: Command_PetName()
  7594. Purpose : Pet your name (???)
  7595. Params :
  7596. Dev :
  7597. Example :
  7598. */
  7599. void Commands::Command_PetName(Client* client, Seperator* sep)
  7600. {
  7601. PrintSep(sep, "COMMAND_PETNAME");
  7602. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  7603. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7604. }
  7605. /*
  7606. Function: Command_NamePet()
  7607. Purpose : Name your pet
  7608. Params :
  7609. Dev :
  7610. Example :
  7611. */
  7612. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7613. {
  7614. PrintSep(sep, "COMMAND_NAME_PET");
  7615. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7616. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7617. }
  7618. /*
  7619. Function: Command_Rename()
  7620. Purpose : Renames existing pet
  7621. Params :
  7622. Dev :
  7623. Example :
  7624. */
  7625. void Commands::Command_Rename(Client* client, Seperator* sep)
  7626. {
  7627. PrintSep(sep, "COMMAND_RENAME");
  7628. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7629. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7630. }
  7631. /*
  7632. Function: Command_ConfirmRename()
  7633. Purpose : Confirms renaming your pet
  7634. Params :
  7635. Dev :
  7636. Example :
  7637. */
  7638. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7639. {
  7640. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7641. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7642. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7643. }
  7644. /*
  7645. Function: Command_PetOptions()
  7646. Purpose : Sets various pet options
  7647. Params :
  7648. Dev :
  7649. Example :
  7650. */
  7651. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7652. {
  7653. PrintSep(sep, "COMMAND_PETOPTIONS");
  7654. Player* player = client->GetPlayer();
  7655. Spawn* target = player->GetTarget();
  7656. if (!target)
  7657. return;
  7658. if (target == player->GetPet())
  7659. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7660. else if (target == player->GetCharmedPet())
  7661. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7662. else if (target == player->GetCosmeticPet())
  7663. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7664. else if (target == player->GetDeityPet())
  7665. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7666. }
  7667. /*
  7668. Function: Command_Random()
  7669. Purpose : Handles /random dice roll in-game
  7670. Params : 1-100
  7671. Dev : Scatman
  7672. Example : /randon 1 100
  7673. */
  7674. void Commands::Command_Random(Client* client, Seperator* sep)
  7675. {
  7676. char message[256] = {0};
  7677. if (sep)
  7678. {
  7679. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7680. 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])));
  7681. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7682. 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])));
  7683. else
  7684. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7685. }
  7686. else
  7687. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7688. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7689. }
  7690. /*
  7691. Function: Command_Randomize()
  7692. Purpose : Sets randomize (appearance) values for NPCs
  7693. Params : Attrib Name
  7694. Dev : Scatman
  7695. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7696. */
  7697. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7698. {
  7699. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7700. if (target)
  7701. {
  7702. if (target->IsNPC())
  7703. {
  7704. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7705. {
  7706. const char* value = sep->arg[0];
  7707. if (strncasecmp(value, "show", strlen(value)) == 0)
  7708. {
  7709. client->DisplayRandomizeFeatures(target->GetRandomize());
  7710. }
  7711. else
  7712. {
  7713. if (sep->arg[1] && sep->IsNumber(1))
  7714. {
  7715. int8 option = atoi(sep->arg[1]);
  7716. if (option == 0 || option == 1)
  7717. {
  7718. int32 feature = 0;
  7719. char feature_text[32] = {0};
  7720. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7721. feature = RANDOMIZE_GENDER;
  7722. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7723. }
  7724. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7725. feature = RANDOMIZE_RACE;
  7726. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7727. }
  7728. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7729. feature = RANDOMIZE_MODEL_TYPE;
  7730. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7731. }
  7732. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7733. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7734. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7735. }
  7736. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7737. feature = RANDOMIZE_HAIR_TYPE;
  7738. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7739. }
  7740. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7741. feature = RANDOMIZE_WING_TYPE;
  7742. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7743. }
  7744. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7745. feature = RANDOMIZE_CHEEK_TYPE;
  7746. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7747. }
  7748. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7749. feature = RANDOMIZE_CHIN_TYPE;
  7750. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7751. }
  7752. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7753. feature = RANDOMIZE_EAR_TYPE;
  7754. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7755. }
  7756. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7757. feature = RANDOMIZE_EYE_BROW_TYPE;
  7758. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7759. }
  7760. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7761. feature = RANDOMIZE_EYE_TYPE;
  7762. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7763. }
  7764. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7765. feature = RANDOMIZE_LIP_TYPE;
  7766. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7767. }
  7768. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7769. feature = RANDOMIZE_NOSE_TYPE;
  7770. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7771. }
  7772. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7773. feature = RANDOMIZE_EYE_COLOR;
  7774. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7775. }
  7776. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7777. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7778. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7779. }
  7780. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7781. feature = RANDOMIZE_HAIR_COLOR1;
  7782. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7783. }
  7784. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7785. feature = RANDOMIZE_HAIR_COLOR2;
  7786. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7787. }
  7788. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7789. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7790. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7791. }
  7792. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7793. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7794. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7795. }
  7796. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7797. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7798. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7799. }
  7800. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7801. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7802. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7803. }
  7804. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7805. feature = RANDOMIZE_SKIN_COLOR;
  7806. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7807. }
  7808. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7809. feature = RANDOMIZE_WING_COLOR1;
  7810. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7811. }
  7812. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7813. feature = RANDOMIZE_WING_COLOR2;
  7814. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7815. }
  7816. else {
  7817. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7818. 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'.");
  7819. }
  7820. if (feature > 0) {
  7821. if (option == 1) {
  7822. if (target->GetRandomize() & feature)
  7823. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7824. else {
  7825. target->AddRandomize(feature);
  7826. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7827. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7828. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7829. }
  7830. }
  7831. else {
  7832. if (target->GetRandomize() & feature) {
  7833. target->AddRandomize(-feature);
  7834. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7835. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7836. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7837. }
  7838. else
  7839. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7840. }
  7841. }
  7842. }
  7843. else
  7844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7845. }
  7846. else
  7847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7848. }
  7849. }
  7850. else {
  7851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7853. 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'.");
  7854. }
  7855. }
  7856. else
  7857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7858. }
  7859. else
  7860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7861. }
  7862. /*
  7863. Function: Command_ShowCloak()
  7864. Purpose : Character Settings combo box for Show Cloak
  7865. Params : true/false
  7866. Dev : John Adams
  7867. Example :
  7868. */
  7869. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7870. {
  7871. Player* player = client->GetPlayer();
  7872. if (sep && sep->arg[0])
  7873. {
  7874. const char* value = sep->arg[0];
  7875. if (strncasecmp(value, "true", strlen(value)) == 0)
  7876. {
  7877. player->set_character_flag(CF_SHOW_CLOAK);
  7878. player->reset_character_flag(CF2_SHOW_RANGED);
  7879. }
  7880. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7881. player->reset_character_flag(CF_SHOW_CLOAK);
  7882. else
  7883. {
  7884. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7885. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7886. }
  7887. }
  7888. }
  7889. /*
  7890. Function: Command_ShowHelm()
  7891. Purpose : Character Settings combo box for Show Helm
  7892. Params : true/false
  7893. Dev : John Adams
  7894. Example :
  7895. */
  7896. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7897. {
  7898. Player* player = client->GetPlayer();
  7899. if (sep && sep->arg[0])
  7900. {
  7901. const char* value = sep->arg[0];
  7902. if (strncasecmp(value, "true", strlen(value)) == 0)
  7903. {
  7904. player->reset_character_flag(CF_HIDE_HELM);
  7905. player->set_character_flag(CF_HIDE_HOOD);
  7906. }
  7907. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7908. player->set_character_flag(CF_HIDE_HELM);
  7909. else
  7910. {
  7911. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7912. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7913. }
  7914. }
  7915. }
  7916. /*
  7917. Function: Command_ShowHood()
  7918. Purpose : Character Settings combo box for Show Hood
  7919. Params : true/false
  7920. Dev : John Adams
  7921. Example :
  7922. */
  7923. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7924. {
  7925. Player* player = client->GetPlayer();
  7926. if (sep && sep->arg[0])
  7927. {
  7928. const char* value = sep->arg[0];
  7929. if (strncasecmp(value, "true", strlen(value)) == 0)
  7930. {
  7931. player->reset_character_flag(CF_HIDE_HOOD);
  7932. player->set_character_flag(CF_HIDE_HELM);
  7933. }
  7934. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7935. player->set_character_flag(CF_HIDE_HOOD);
  7936. else
  7937. {
  7938. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7939. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7940. }
  7941. }
  7942. }
  7943. /*
  7944. Function: Command_ShowHoodHelm()
  7945. Purpose : Character Settings combo box for Show Helm or Hood
  7946. Params : true/false
  7947. Dev : John Adams
  7948. Example :
  7949. */
  7950. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7951. {
  7952. Player* player = client->GetPlayer();
  7953. if (sep && sep->arg[0])
  7954. {
  7955. const char* value = sep->arg[0];
  7956. if (strncasecmp(value, "true", strlen(value)) == 0)
  7957. {
  7958. player->reset_character_flag(CF_HIDE_HOOD);
  7959. player->reset_character_flag(CF_HIDE_HELM);
  7960. }
  7961. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7962. {
  7963. // don't think we ever wind up in here...
  7964. player->set_character_flag(CF_HIDE_HOOD);
  7965. player->set_character_flag(CF_HIDE_HELM);
  7966. }
  7967. else
  7968. {
  7969. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7970. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7971. }
  7972. }
  7973. }
  7974. /*
  7975. Function: Command_ShowRanged()
  7976. Purpose : Character Settings combo box for Show Ranged weapon
  7977. Params : true/false
  7978. Dev : John Adams
  7979. Example :
  7980. */
  7981. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7982. {
  7983. Player* player = client->GetPlayer();
  7984. if (sep && sep->arg[0])
  7985. {
  7986. const char* value = sep->arg[0];
  7987. if (strncasecmp(value, "true", strlen(value)) == 0)
  7988. {
  7989. player->set_character_flag(CF2_SHOW_RANGED);
  7990. player->reset_character_flag(CF_SHOW_CLOAK);
  7991. }
  7992. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7993. player->reset_character_flag(CF2_SHOW_RANGED);
  7994. else
  7995. {
  7996. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7997. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7998. }
  7999. }
  8000. }
  8001. /*
  8002. Function:
  8003. Purpose :
  8004. Params :
  8005. Dev :
  8006. Example :
  8007. */
  8008. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8009. {
  8010. Player* player = 0;
  8011. Client* to_client = 0;
  8012. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8013. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  8014. switch(handler)
  8015. {
  8016. case COMMAND_SKILL:
  8017. {
  8018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8020. break;
  8021. }
  8022. case COMMAND_SKILL_ADD:
  8023. {
  8024. if (sep && sep->arg[0])
  8025. {
  8026. const char* skill_name = sep->argplus[0];
  8027. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8028. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8029. {
  8030. player = to_client->GetPlayer();
  8031. if (player)
  8032. {
  8033. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8034. {
  8035. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8036. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8037. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8038. }
  8039. else
  8040. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8041. }
  8042. }
  8043. else if (skill) // add skill to yourself
  8044. {
  8045. player = client->GetPlayer();
  8046. if (player)
  8047. {
  8048. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8049. {
  8050. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8051. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8052. }
  8053. else
  8054. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8055. }
  8056. }
  8057. else
  8058. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8059. }
  8060. else
  8061. {
  8062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8064. }
  8065. break;
  8066. }
  8067. case COMMAND_SKILL_REMOVE:
  8068. {
  8069. if (sep && sep->arg[0])
  8070. {
  8071. const char* skill_name = sep->argplus[0];
  8072. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8073. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8074. {
  8075. player = to_client->GetPlayer();
  8076. if (player)
  8077. {
  8078. if (player->GetSkills()->HasSkill(skill->skill_id))
  8079. {
  8080. player->RemoveSkillFromDB(skill, true);
  8081. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8082. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8083. }
  8084. else
  8085. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8086. }
  8087. }
  8088. else if(skill) // remove skill from yourself
  8089. {
  8090. Player* player = client->GetPlayer();
  8091. if (player)
  8092. {
  8093. if (player->GetSkills()->HasSkill(skill->skill_id))
  8094. {
  8095. player->RemoveSkillFromDB(skill, true);
  8096. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8097. }
  8098. else
  8099. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8100. }
  8101. }
  8102. else
  8103. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8104. }
  8105. else
  8106. {
  8107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8109. }
  8110. break;
  8111. }
  8112. case COMMAND_SKILL_LIST:
  8113. {
  8114. if (sep && sep->arg[0])
  8115. {
  8116. const char* skill_name = sep->argplus[0];
  8117. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8118. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8119. map<int32, Skill*>::iterator itr;
  8120. if (skills && skills->size() > 0)
  8121. {
  8122. for (itr = skills->begin(); itr != skills->end(); itr++)
  8123. {
  8124. Skill* skill = itr->second;
  8125. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8126. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8127. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8128. }
  8129. }
  8130. }
  8131. else
  8132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8133. break;
  8134. }
  8135. }
  8136. }
  8137. /*
  8138. Function: Command_SpawnTemplate()
  8139. Purpose : Create or Use defined Spawn Templates
  8140. Params : create, save, rempve, list
  8141. Dev : John Adams
  8142. Example : /spawn template create "Test"
  8143. */
  8144. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8145. {
  8146. if (sep == NULL || sep->arg[0] == NULL)
  8147. {
  8148. 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.");
  8149. return;
  8150. }
  8151. // got params, continue
  8152. const char * template_cmd = sep->arg[0];
  8153. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8154. {
  8155. if (!sep->IsSet(1))
  8156. {
  8157. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8158. 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.");
  8159. return;
  8160. }
  8161. map<int32, string>* template_names = 0;
  8162. if (sep->IsNumber(1))
  8163. {
  8164. int32 location_id = 0;
  8165. location_id = atoi(sep->arg[1]);
  8166. template_names = database.GetSpawnTemplateListByID(location_id);
  8167. }
  8168. else
  8169. {
  8170. const char* name = 0;
  8171. name = sep->argplus[1];
  8172. template_names = database.GetSpawnTemplateListByName(name);
  8173. }
  8174. if(!template_names)
  8175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8176. else
  8177. {
  8178. map<int32, string>::iterator itr;
  8179. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8180. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8181. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8182. safe_delete(template_names);
  8183. }
  8184. }
  8185. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8186. {
  8187. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8188. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8189. {
  8190. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8191. {
  8192. // first, lookup to see if template name already exists
  8193. const char* name = 0;
  8194. name = sep->argplus[1];
  8195. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8196. if(!template_names)
  8197. {
  8198. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8199. if( new_template_id > 0 )
  8200. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8201. else
  8202. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8203. }
  8204. else
  8205. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8206. }
  8207. else
  8208. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8209. }
  8210. else
  8211. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8212. }
  8213. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8214. {
  8215. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8216. {
  8217. int32 template_id = 0;
  8218. template_id = atoi(sep->arg[1]);
  8219. if (database.RemoveSpawnTemplate(template_id))
  8220. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8221. else
  8222. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8223. }
  8224. else
  8225. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8226. }
  8227. // Renamed create to spawn
  8228. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8229. {
  8230. if (sep && sep->arg[1][0])
  8231. {
  8232. int32 new_location = 0;
  8233. if (sep->IsNumber(1))
  8234. {
  8235. int32 template_id = 0;
  8236. template_id = atoi(sep->arg[1]);
  8237. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8238. if( new_location > 0 )
  8239. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8240. else
  8241. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8242. }
  8243. else
  8244. {
  8245. const char* name = 0;
  8246. name = sep->argplus[1];
  8247. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8248. if( new_location > 0 )
  8249. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8250. else
  8251. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8252. }
  8253. }
  8254. else
  8255. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8256. }
  8257. else
  8258. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8259. }
  8260. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8261. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8262. float new_speed = atof(sep->arg[0]);
  8263. if (new_speed > 0.0f)
  8264. {
  8265. client->GetPlayer()->SetSpeed(new_speed, true);
  8266. client->GetPlayer()->SetCharSheetChanged(true);
  8267. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8268. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8269. }
  8270. else
  8271. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8272. }
  8273. else{
  8274. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8275. }
  8276. }
  8277. /*
  8278. Function: Command_StationMarketPlace()
  8279. Purpose : just trying to eat the console spam for now
  8280. Params :
  8281. Dev : John
  8282. */
  8283. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8284. {
  8285. PrintSep(sep, "COMMAND_SMP");
  8286. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8287. // can't seem to reduce it any more get rid of it completely...
  8288. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8289. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8290. if (packet) {
  8291. packet->setDataByName("account_id", client->GetAccountID());
  8292. packet->setDataByName("character_id", client->GetCharacterID());
  8293. packet->setDataByName("unknown1", 1, 5);
  8294. packet->setDataByName("unknown1", 26, 6);
  8295. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8296. packet->setDataByName("unknown3", 248, 1);
  8297. client->QueuePacket(packet->serialize());
  8298. }
  8299. safe_delete(packet);
  8300. }
  8301. }
  8302. /*
  8303. Function: Command_StopDrinking()
  8304. Purpose : Stops player from auto-consuming drink
  8305. Params :
  8306. Dev : Zcoretri
  8307. Example : /stopdrinking
  8308. */
  8309. void Commands::Command_StopDrinking(Client* client)
  8310. {
  8311. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8312. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8313. }
  8314. /*
  8315. Function: Command_StopEating()
  8316. Purpose : Stops player from auto-consuming food
  8317. Params :
  8318. Dev : Zcoretri
  8319. Example : /stopeating
  8320. */
  8321. void Commands::Command_StopEating(Client* client)
  8322. {
  8323. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8324. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8325. }
  8326. /*
  8327. Function: Command_Title()
  8328. Purpose : Help for /title command
  8329. Params : n/a
  8330. Dev : Zcoretri
  8331. Example : /title
  8332. */
  8333. void Commands::Command_Title(Client* client)
  8334. {
  8335. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8336. }
  8337. /*
  8338. Function: Command_TitleList()
  8339. Purpose : List available titles for player
  8340. Params : n/a
  8341. Dev : Zcoretri
  8342. Example : /title list
  8343. */
  8344. void Commands::Command_TitleList(Client* client)
  8345. {
  8346. // must call release read lock before leaving function on GetPlayerTitles
  8347. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8348. vector<Title*>::iterator itr;
  8349. Title* title;
  8350. sint32 i = 0;
  8351. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8352. for(itr = titles->begin(); itr != titles->end(); itr++)
  8353. {
  8354. title = *itr;
  8355. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8356. i++;
  8357. }
  8358. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8359. }
  8360. /*
  8361. Function: Command_TitleSetPrefix()
  8362. Purpose : Set Prefix title for player
  8363. Params : Title ID
  8364. Dev : Zcoretri
  8365. Example : /title setprefix 1
  8366. */
  8367. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8368. {
  8369. if (sep && sep->arg[0] && sep->IsNumber(0))
  8370. {
  8371. sint32 index = atoul(sep->arg[0]);
  8372. if(index > -1)
  8373. {
  8374. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8375. if(!title)
  8376. {
  8377. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8378. return;
  8379. }
  8380. else if(!title->GetPrefix())
  8381. {
  8382. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8383. return;
  8384. }
  8385. }
  8386. else // make sure client doesn't pass some bogus negative index
  8387. index = -1;
  8388. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8389. client->SendTitleUpdate();
  8390. }
  8391. }
  8392. /*
  8393. Function: Command_TitleSetSuffix()
  8394. Purpose : Set Suffix title for player
  8395. Params : Title ID
  8396. Dev : Zcoretri
  8397. Example : /title setsuffix 1
  8398. */
  8399. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8400. {
  8401. if (sep && sep->arg[0] && sep->IsNumber(0))
  8402. {
  8403. sint32 index = atoul(sep->arg[0]);
  8404. if(index > -1)
  8405. {
  8406. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8407. if(!title)
  8408. {
  8409. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8410. return;
  8411. }
  8412. else if(title->GetPrefix())
  8413. {
  8414. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8415. return;
  8416. }
  8417. }
  8418. else // make sure client doesn't pass some bogus negative index
  8419. index = -1;
  8420. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8421. client->SendTitleUpdate();
  8422. }
  8423. }
  8424. /*
  8425. Function: Command_TitleFix()
  8426. Purpose : Fix title for player (???)
  8427. Params :
  8428. Dev : Zcoretri
  8429. Example :
  8430. */
  8431. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8432. {
  8433. PrintSep(sep, "COMMAND_TITLE_FIX");
  8434. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8435. }
  8436. /*
  8437. Function: Command_Toggle_Anonymous()
  8438. Purpose : Toggles player Anonymous
  8439. Params :
  8440. Dev : paulgh
  8441. Example : /anon
  8442. */
  8443. void Commands::Command_Toggle_Anonymous(Client* client)
  8444. {
  8445. Player* player = client->GetPlayer();
  8446. player->toggle_character_flag(CF_ANONYMOUS);
  8447. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8448. if (player->get_character_flag(CF_ANONYMOUS))
  8449. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8450. else
  8451. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8452. }
  8453. /*
  8454. Function: Command_Toggle_AutoConsume()
  8455. Purpose : Toggles player food/drink auto consume
  8456. Params : unknown
  8457. Dev : paulgh
  8458. Example : /set_auto_consume
  8459. */
  8460. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8461. {
  8462. Player* player = client->GetPlayer();
  8463. if (sep && sep->arg[0])
  8464. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8465. if (sep && sep->arg[0] && sep->IsNumber(0))
  8466. {
  8467. int8 slot = atoi(sep->arg[0]);
  8468. int8 flag = atoi(sep->arg[1]);
  8469. if (client->GetVersion() <= 283) {
  8470. slot += 4;
  8471. }
  8472. else if (client->GetVersion() <= 546) {
  8473. slot += 2;
  8474. }
  8475. if (slot == EQ2_FOOD_SLOT)
  8476. {
  8477. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8478. player->SetCharSheetChanged(true);
  8479. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8480. if (flag == 1)
  8481. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8482. else
  8483. {
  8484. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8485. return;
  8486. }
  8487. }
  8488. else
  8489. {
  8490. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8491. player->SetCharSheetChanged(true);
  8492. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8493. if (flag == 1)
  8494. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8495. else
  8496. {
  8497. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8498. return;
  8499. }
  8500. }
  8501. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  8502. return;
  8503. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  8504. return;
  8505. Item* item = player->GetEquipmentList()->GetItem(slot);
  8506. if(item)
  8507. client->ConsumeFoodDrink(item, slot);
  8508. }
  8509. }
  8510. /*
  8511. Function: Command_Toggle_BonusXP()
  8512. Purpose : Toggles player Bonus XP
  8513. Params :
  8514. Dev : John Adams
  8515. Example : /disable_char_bonus_exp
  8516. */
  8517. void Commands::Command_Toggle_BonusXP(Client* client)
  8518. {
  8519. Player* player = client->GetPlayer();
  8520. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8521. player->SetCharSheetChanged(true);
  8522. }
  8523. /*
  8524. Function: Command_Toggle_CombatXP()
  8525. Purpose : Toggles player Adventure XP
  8526. Params :
  8527. Dev : John Adams
  8528. Example : /disable_combat_exp
  8529. */
  8530. void Commands::Command_Toggle_CombatXP(Client* client)
  8531. {
  8532. Player* player = client->GetPlayer();
  8533. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8534. player->SetCharSheetChanged(true);
  8535. }
  8536. /*
  8537. Function: Command_Toggle_GMHide()
  8538. Purpose : Toggles hiding player GM status
  8539. Params :
  8540. Dev : Scatman
  8541. Example : /gm_hide
  8542. */
  8543. void Commands::Command_Toggle_GMHide(Client* client)
  8544. {
  8545. Player* player = client->GetPlayer();
  8546. player->toggle_character_flag(CF_HIDE_STATUS);
  8547. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8548. }
  8549. /*
  8550. Function: Command_Toggle_GMVanish()
  8551. Purpose : Toggles hiding GM players from /who searches
  8552. Params :
  8553. Dev : Scatman
  8554. Example : /gm_vanish
  8555. */
  8556. void Commands::Command_Toggle_GMVanish(Client* client)
  8557. {
  8558. Player* player = client->GetPlayer();
  8559. player->toggle_character_flag(CF_GM_HIDDEN);
  8560. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8561. }
  8562. /*
  8563. Function: Command_Toggle_Illusions()
  8564. Purpose : Toggles player illusion form
  8565. Params : not sure sep is needed, testing
  8566. Dev : paulgh
  8567. Example : /hide_illusions
  8568. */
  8569. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8570. {
  8571. if (sep && sep->arg[0])
  8572. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8573. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8574. }
  8575. /*
  8576. Function: Command_Toggle_LFG()
  8577. Purpose : Toggles player LFG Flag
  8578. Params :
  8579. Dev : paulgh
  8580. Example : /lfg
  8581. */
  8582. void Commands::Command_Toggle_LFG(Client* client)
  8583. {
  8584. Player* player = client->GetPlayer();
  8585. player->toggle_character_flag(CF_LFG);
  8586. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8587. if (player->get_character_flag(CF_LFG))
  8588. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8589. else
  8590. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8591. }
  8592. /*
  8593. Function: Command_Toggle_LFW()
  8594. Purpose : Toggles player LFW Flag
  8595. Params :
  8596. Dev : paulgh
  8597. Example : /lfw
  8598. */
  8599. void Commands::Command_Toggle_LFW(Client* client)
  8600. {
  8601. Player* player = client->GetPlayer();
  8602. player->toggle_character_flag(CF_LFW);
  8603. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8604. if (player->get_character_flag(CF_LFW))
  8605. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8606. else
  8607. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8608. }
  8609. /*
  8610. Function: Command_Toggle_QuestXP()
  8611. Purpose : Toggles player Quest XP
  8612. Params :
  8613. Dev : John Adams
  8614. Example : /disable_quest_exp
  8615. */
  8616. void Commands::Command_Toggle_QuestXP(Client* client)
  8617. {
  8618. Player* player = client->GetPlayer();
  8619. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8620. player->SetCharSheetChanged(true);
  8621. }
  8622. /*
  8623. Function: Command_Toggle_Roleplaying()
  8624. Purpose : Toggles player Roleplaying flag
  8625. Params :
  8626. Dev : paulgh
  8627. Example : /role
  8628. */
  8629. void Commands::Command_Toggle_Roleplaying(Client* client)
  8630. {
  8631. Player* player = client->GetPlayer();
  8632. player->toggle_character_flag(CF_ROLEPLAYING);
  8633. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8634. if (player->get_character_flag(CF_ROLEPLAYING))
  8635. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8636. else
  8637. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8638. }
  8639. void Commands::Command_Toggle_Duels(Client* client)
  8640. {
  8641. Player* player = client->GetPlayer();
  8642. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8643. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8644. }
  8645. void Commands::Command_Toggle_Trades(Client* client)
  8646. {
  8647. Player* player = client->GetPlayer();
  8648. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8649. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8650. }
  8651. void Commands::Command_Toggle_Guilds(Client* client)
  8652. {
  8653. Player* player = client->GetPlayer();
  8654. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8655. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8656. }
  8657. void Commands::Command_Toggle_Groups(Client* client)
  8658. {
  8659. Player* player = client->GetPlayer();
  8660. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8661. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8662. }
  8663. void Commands::Command_Toggle_Raids(Client* client)
  8664. {
  8665. Player* player = client->GetPlayer();
  8666. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8667. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8668. }
  8669. void Commands::Command_Toggle_LON(Client* client)
  8670. {
  8671. Player* player = client->GetPlayer();
  8672. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8673. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8674. }
  8675. void Commands::Command_Toggle_VoiceChat(Client* client)
  8676. {
  8677. Player* player = client->GetPlayer();
  8678. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8679. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8680. }
  8681. /*
  8682. Function: Command_TradeStart()
  8683. Purpose : Starts item/coin trade between players
  8684. Params :
  8685. Dev :
  8686. Example :
  8687. */
  8688. #include "../Trade.h"
  8689. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8690. {
  8691. PrintSep(sep, "COMMAND_START_TRADE");
  8692. Entity* trader = client->GetPlayer();
  8693. Entity* trader2 = 0;
  8694. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8695. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8696. if (spawn) {
  8697. if (spawn->IsEntity())
  8698. trader2 = (Entity*)spawn;
  8699. }
  8700. }
  8701. else if (client->GetPlayer()->GetTarget()) {
  8702. if (client->GetPlayer()->GetTarget()->IsEntity())
  8703. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8704. }
  8705. // can only trade with player or bots
  8706. if (trader && trader2) {
  8707. if (trader == trader2) {
  8708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8709. }
  8710. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8711. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8712. if (trader->trade)
  8713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8714. else if (trader2->trade)
  8715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8716. else {
  8717. Trade* trade = new Trade(trader, trader2);
  8718. trader->trade = trade;
  8719. trader2->trade = trade;
  8720. }
  8721. }
  8722. else {
  8723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8724. }
  8725. }
  8726. else
  8727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8728. }
  8729. /*
  8730. Function: Command_Track()
  8731. Purpose : Starts/Stops Tracking for a player
  8732. Params :
  8733. Dev : Scatman
  8734. Example : /track
  8735. */
  8736. void Commands::Command_Track(Client* client)
  8737. {
  8738. if (!client->GetPlayer()->GetIsTracking())
  8739. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8740. else
  8741. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8742. }
  8743. /*
  8744. Function: Command_TradeAccept()
  8745. Purpose : Accepts item/coin trade between players
  8746. Params :
  8747. Dev :
  8748. Example :
  8749. */
  8750. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8751. {
  8752. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8753. Trade* trade = client->GetPlayer()->trade;
  8754. if (trade) {
  8755. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8756. if (trade_complete)
  8757. safe_delete(trade);
  8758. }
  8759. else
  8760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8761. }
  8762. /*
  8763. Function: Command_TradeReject()
  8764. Purpose : Rejects item/coin trade between players
  8765. Params :
  8766. Dev :
  8767. Example :
  8768. */
  8769. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8770. {
  8771. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8772. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8773. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8774. }
  8775. /*
  8776. Function: Command_TradeCancel()
  8777. Purpose : Cancels item/coin trade between players
  8778. Params :
  8779. Dev :
  8780. Example :
  8781. */
  8782. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8783. {
  8784. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8785. Trade* trade = client->GetPlayer()->trade;
  8786. if (trade) {
  8787. trade->CancelTrade(client->GetPlayer());
  8788. safe_delete(trade);
  8789. }
  8790. else
  8791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8792. }
  8793. /*
  8794. Function: Command_TradeSetCoin()
  8795. Purpose : Sets coin trade between players
  8796. Params :
  8797. Dev :
  8798. Example :
  8799. */
  8800. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8801. {
  8802. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8803. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8804. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8805. }
  8806. /*
  8807. Function: Command_TradeAddCoin()
  8808. Purpose : Adds coin to trade between players
  8809. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8810. Dev :
  8811. Example :
  8812. */
  8813. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8814. {
  8815. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8816. Trade* trade = client->GetPlayer()->trade;
  8817. if (trade) {
  8818. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8819. int32 amount = atoi(sep->arg[0]);
  8820. int64 val = 0;
  8821. switch (handler) {
  8822. case COMMAND_ADD_TRADE_COPPER:
  8823. {
  8824. val = amount;
  8825. trade->AddCoinToTrade(client->GetPlayer(), val);
  8826. break;
  8827. }
  8828. case COMMAND_ADD_TRADE_SILVER:
  8829. {
  8830. val = amount * 100;
  8831. trade->AddCoinToTrade(client->GetPlayer(), val);
  8832. break;
  8833. }
  8834. case COMMAND_ADD_TRADE_GOLD:
  8835. {
  8836. val = amount * 10000;
  8837. trade->AddCoinToTrade(client->GetPlayer(), val);
  8838. break;
  8839. }
  8840. case COMMAND_ADD_TRADE_PLAT:
  8841. {
  8842. val = amount * 1000000;
  8843. trade->AddCoinToTrade(client->GetPlayer(), val);
  8844. break;
  8845. }
  8846. default:
  8847. {
  8848. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8849. break;
  8850. }
  8851. }
  8852. }
  8853. else
  8854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8855. }
  8856. else
  8857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8858. }
  8859. /*
  8860. Function: Command_TradeRemoveCoin()
  8861. Purpose : Removes coin from trade between players
  8862. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8863. Dev :
  8864. Example :
  8865. */
  8866. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8867. {
  8868. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8869. Trade* trade = client->GetPlayer()->trade;
  8870. if (trade) {
  8871. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8872. int32 amount = atoi(sep->arg[0]);
  8873. int64 val = 0;
  8874. switch (handler) {
  8875. case COMMAND_REMOVE_TRADE_COPPER:
  8876. {
  8877. val = amount;
  8878. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8879. break;
  8880. }
  8881. case COMMAND_REMOVE_TRADE_SILVER:
  8882. {
  8883. val = amount * 100;
  8884. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8885. break;
  8886. }
  8887. case COMMAND_REMOVE_TRADE_GOLD:
  8888. {
  8889. val = amount * 10000;
  8890. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8891. break;
  8892. }
  8893. case COMMAND_REMOVE_TRADE_PLAT:
  8894. {
  8895. val = amount * 1000000;
  8896. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8897. break;
  8898. }
  8899. default:
  8900. {
  8901. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8902. break;
  8903. }
  8904. }
  8905. }
  8906. else
  8907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8908. }
  8909. else
  8910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8911. }
  8912. /*
  8913. Function: Command_TradeAddItem()
  8914. Purpose : Adds item to trade between players
  8915. Params :
  8916. Dev :
  8917. Example :
  8918. */
  8919. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8920. {
  8921. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8922. /*
  8923. arg[0] = item index
  8924. arg[1] = slot
  8925. arg[2] = quantity
  8926. */
  8927. if (!client->GetPlayer()->trade) {
  8928. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8930. return;
  8931. }
  8932. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8933. Item* item = 0;
  8934. int32 index = atoi(sep->arg[0]);
  8935. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8936. if (item) {
  8937. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8938. if (result == 1)
  8939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8940. else if (result == 2)
  8941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8942. else if (result == 3)
  8943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8944. else if (result == 255)
  8945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8946. }
  8947. else {
  8948. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8949. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8950. }
  8951. }
  8952. else
  8953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8954. }
  8955. /*
  8956. Function: Command_TradeRemoveItem()
  8957. Purpose : Removes item from trade between players
  8958. Params :
  8959. Dev :
  8960. Example :
  8961. */
  8962. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8963. {
  8964. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8965. /*
  8966. arg[0] = trade window slot
  8967. */
  8968. Trade* trade = client->GetPlayer()->trade;
  8969. if (trade) {
  8970. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8971. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8972. }
  8973. else
  8974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8975. }
  8976. else
  8977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8978. }
  8979. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8980. {
  8981. Item *item = 0;
  8982. sint32 crc;
  8983. if (sep) {
  8984. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8985. if (client->GetVersion() < 1096) {
  8986. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8987. {
  8988. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8989. crc = atol(sep->arg[2]);
  8990. }
  8991. }
  8992. else {
  8993. // From the broker and links in chat
  8994. if (strcmp(sep->arg[0], "crc") == 0) {
  8995. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8996. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8997. crc = atol(sep->arg[3]);
  8998. }
  8999. }
  9000. // From inventory
  9001. if (strcmp(sep->arg[0], "dbid") == 0) {
  9002. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9003. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9004. crc = atol(sep->arg[4]);
  9005. }
  9006. }
  9007. }
  9008. if (item)
  9009. client->ShowDressingRoom(item, crc);
  9010. }
  9011. }
  9012. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9013. const char *channel_name, *password = NULL;
  9014. if (sep == NULL || !sep->IsSet(0)) {
  9015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9016. return;
  9017. }
  9018. channel_name = sep->arg[0];
  9019. if (sep->IsSet(1))
  9020. password = sep->arg[1];
  9021. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9022. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9023. return;
  9024. }
  9025. if (chat.IsInChannel(client, channel_name)) {
  9026. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9027. return;
  9028. }
  9029. if (chat.HasPassword(channel_name)) {
  9030. if (password == NULL) {
  9031. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9032. return;
  9033. }
  9034. if (!chat.PasswordMatches(channel_name, password)) {
  9035. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9036. return;
  9037. }
  9038. }
  9039. if (!chat.JoinChannel(client, channel_name))
  9040. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9041. }
  9042. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9043. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9044. Command_JoinChannel(client, sep);
  9045. }
  9046. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9047. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9049. PrintSep(sep, "tellchannel");
  9050. return;
  9051. }
  9052. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9053. }
  9054. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9055. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9056. if (sep->IsSet(0)) {
  9057. if (atoi(sep->arg[0]) == 1) {
  9058. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9059. if (packet2) {
  9060. packet2->setDataByName("spell_type", 2);
  9061. packet2->setDataByName("spell_id", 8308);
  9062. packet2->setDataByName("spell_name", "Sprint");
  9063. packet2->setDataByName("add_silently", 0);
  9064. packet2->setDataByName("tier", 1);
  9065. packet2->setDataByName("blah1", 1);
  9066. packet2->setDataByName("blah2", 1);
  9067. EQ2Packet* outapp = packet2->serialize();
  9068. DumpPacket(outapp);
  9069. client->QueuePacket(outapp);
  9070. safe_delete(packet2);
  9071. }
  9072. }
  9073. else if (atoi(sep->arg[0]) == 2) {
  9074. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9075. if (packet2) {
  9076. packet2->setDataByName("guild_name", "Test");
  9077. packet2->setDataByName("guild_motd", "Test MOTD");
  9078. packet2->setDataByName("guild_id", 1234);
  9079. packet2->setDataByName("guild_level", 1);
  9080. packet2->setDataByName("unknown", 2);
  9081. packet2->setDataByName("unknown2", 3);
  9082. packet2->setDataByName("exp_current", 1);
  9083. packet2->setDataByName("exp_to_next_level", 4);
  9084. EQ2Packet* outapp = packet2->serialize();
  9085. DumpPacket(outapp);
  9086. client->QueuePacket(outapp);
  9087. safe_delete(packet2);
  9088. }
  9089. }
  9090. else if (atoi(sep->arg[0]) == 3) {
  9091. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9092. if (packet2) {
  9093. packet2->setDataByName("guild_id", 1234);
  9094. packet2->setDataByName("character_id", 1);
  9095. packet2->setDataByName("account_id", 2);
  9096. packet2->setDataByName("guild_level", 1);
  9097. packet2->setDataByName("name", "Test");
  9098. packet2->setDataByName("unknown2", 0);
  9099. packet2->setDataByName("unknown3", 1);
  9100. packet2->setDataByName("adventure_class", 6);
  9101. packet2->setDataByName("adventure_level", 7);
  9102. packet2->setDataByName("tradeskill_class", 4);
  9103. packet2->setDataByName("tradeskill_level", 5);
  9104. packet2->setDataByName("rank", 0);
  9105. packet2->setDataByName("member_flags", 2);
  9106. packet2->setDataByName("join_date", 1591112273);
  9107. packet2->setDataByName("guild_status", 2);
  9108. packet2->setDataByName("last_login", 1591132273);
  9109. packet2->setDataByName("recruiter_id", 1);
  9110. packet2->setDataByName("points", 2345);
  9111. packet2->setDataByName("note", "note");
  9112. packet2->setMediumStringByName("officer_note", "O note");
  9113. packet2->setMediumStringByName("zone", "Blah");
  9114. EQ2Packet* outapp = packet2->serialize();
  9115. DumpPacket(outapp);
  9116. client->QueuePacket(outapp);
  9117. safe_delete(packet2);
  9118. }
  9119. }
  9120. else if (atoi(sep->arg[0]) == 5) {
  9121. int16 offset = atoi(sep->arg[1]);
  9122. int32 value1 = atol(sep->arg[2]);
  9123. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9124. client->QueuePacket(outapp);
  9125. }
  9126. else if (atoi(sep->arg[0]) == 6) {
  9127. Spawn* spawn = client->GetPlayer()->GetTarget();
  9128. if (!spawn)
  9129. spawn = client->GetPlayer();
  9130. else if (spawn->IsEntity())
  9131. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9132. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9133. }
  9134. else if (atoi(sep->arg[0]) == 7) {
  9135. int32 id = 0;
  9136. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9137. if (spawn) {
  9138. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9139. spawn->SetY(client->GetPlayer()->GetY(), false);
  9140. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9141. float heading = client->GetPlayer()->GetHeading() + 180;
  9142. if (heading > 360)
  9143. heading -= 360;
  9144. spawn->SetLevel(5);
  9145. spawn->SetAdventureClass(4);
  9146. spawn->SetHeading(heading, false);
  9147. spawn->SetSpawnOrigX(spawn->GetX());
  9148. spawn->SetSpawnOrigY(spawn->GetY());
  9149. spawn->SetSpawnOrigZ(spawn->GetZ());
  9150. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9151. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9152. spawn->appearance.targetable = 1;
  9153. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9154. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9155. spawn->SetHP(spawn->GetTotalHP());
  9156. }
  9157. if (spawn->GetTotalPower() == 0) {
  9158. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9159. spawn->SetPower(spawn->GetTotalPower());
  9160. }
  9161. int16 offset = atoi(sep->arg[1]);
  9162. int32 value1 = atol(sep->arg[2]);
  9163. sprintf(spawn->appearance.name, "Offset %i", offset);
  9164. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9165. DumpPacket(ret);
  9166. client->QueuePacket(ret);
  9167. }
  9168. }
  9169. else if (atoi(sep->arg[0]) == 8) {
  9170. int32 id = atoi(sep->arg[1]);
  9171. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9172. if (spawn) {
  9173. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9174. spawn->SetY(client->GetPlayer()->GetY(), false);
  9175. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9176. float heading = client->GetPlayer()->GetHeading() + 180;
  9177. if (heading > 360)
  9178. heading -= 360;
  9179. spawn->SetLevel(5);
  9180. spawn->SetAdventureClass(4);
  9181. spawn->SetHeading(heading, false);
  9182. spawn->SetSpawnOrigX(spawn->GetX());
  9183. spawn->SetSpawnOrigY(spawn->GetY());
  9184. spawn->SetSpawnOrigZ(spawn->GetZ());
  9185. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9186. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9187. spawn->appearance.targetable = 1;
  9188. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9189. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9190. spawn->SetHP(spawn->GetTotalHP());
  9191. }
  9192. if (spawn->GetTotalPower() == 0) {
  9193. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9194. spawn->SetPower(spawn->GetTotalPower());
  9195. }
  9196. int16 offset = atoi(sep->arg[2]);
  9197. int16 offset2 = atoi(sep->arg[3]);
  9198. int32 value1 = atol(sep->arg[4]);
  9199. int16 offset3 = 0;
  9200. int16 offset4 = 0;
  9201. int32 value2 = 0;
  9202. if (sep->IsSet(7)) {
  9203. offset3 = atoi(sep->arg[5]);
  9204. offset4 = atoi(sep->arg[6]);
  9205. value2 = atol(sep->arg[7]);
  9206. }
  9207. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9208. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9209. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9210. DumpPacket(ret);
  9211. client->QueuePacket(ret);
  9212. }
  9213. }
  9214. else if (atoi(sep->arg[0]) == 9) {
  9215. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9216. if (packet2) {
  9217. packet2->setArrayLengthByName("location_count", 1);
  9218. packet2->setArrayDataByName("location_ida", 1234);
  9219. packet2->setArrayDataByName("unknown2a", 3);
  9220. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9221. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9222. packet2->setArrayDataByName("distance", 134);
  9223. EQ2Packet* app = packet2->serialize();
  9224. if (sep->IsSet(2)) {
  9225. int8 offset = atoi(sep->arg[1]);
  9226. uchar* ptr2 = app->pBuffer;
  9227. ptr2 += offset;
  9228. if (sep->IsNumber(2)) {
  9229. int32 value1 = atol(sep->arg[2]);
  9230. if (value1 > 0xFFFF)
  9231. memcpy(ptr2, (uchar*)&value1, 4);
  9232. else if (value1 > 0xFF)
  9233. memcpy(ptr2, (uchar*)&value1, 2);
  9234. else
  9235. memcpy(ptr2, (uchar*)&value1, 1);
  9236. }
  9237. else {
  9238. int8 len = strlen(sep->arg[2]);
  9239. memcpy(ptr2, (uchar*)&len, 1);
  9240. ptr2 += 1;
  9241. memcpy(ptr2, sep->arg[2], len);
  9242. }
  9243. }
  9244. DumpPacket(app);
  9245. client->QueuePacket(app);
  9246. safe_delete(packet2);
  9247. }
  9248. }
  9249. else if (atoi(sep->arg[0]) == 10) {
  9250. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9251. if (packet2) {
  9252. packet2->setArrayLengthByName("num_quests", 1);
  9253. packet2->setArrayDataByName("active", 1);
  9254. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9255. packet2->setArrayDataByName("quest_type", "Hallmark");
  9256. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9257. packet2->setArrayDataByName("journal_updated", 1);
  9258. packet2->setArrayDataByName("quest_id", 524);
  9259. packet2->setArrayDataByName("day", 19);
  9260. packet2->setArrayDataByName("month", 6);
  9261. packet2->setArrayDataByName("year", 20);
  9262. packet2->setArrayDataByName("level", 2);
  9263. packet2->setArrayDataByName("encounter_level", 4);
  9264. packet2->setArrayDataByName("difficulty", 3);
  9265. packet2->setArrayDataByName("visible", 1);
  9266. packet2->setDataByName("visible_quest_id", 524);
  9267. packet2->setDataByName("player_crc", 2900677088);
  9268. packet2->setDataByName("player_name", "LethalEncounter");
  9269. EQ2Packet* app = packet2->serialize();
  9270. if (sep->IsSet(2)) {
  9271. int8 offset = atoi(sep->arg[1]);
  9272. uchar* ptr2 = app->pBuffer;
  9273. ptr2 += offset;
  9274. if (sep->IsNumber(2)) {
  9275. int32 value1 = atol(sep->arg[2]);
  9276. if (value1 > 0xFFFF)
  9277. memcpy(ptr2, (uchar*)&value1, 4);
  9278. else if (value1 > 0xFF)
  9279. memcpy(ptr2, (uchar*)&value1, 2);
  9280. else
  9281. memcpy(ptr2, (uchar*)&value1, 1);
  9282. }
  9283. else {
  9284. int8 len = strlen(sep->arg[2]);
  9285. memcpy(ptr2, (uchar*)&len, 1);
  9286. ptr2 += 1;
  9287. memcpy(ptr2, sep->arg[2], len);
  9288. }
  9289. }
  9290. DumpPacket(app);
  9291. client->QueuePacket(app);
  9292. safe_delete(packet2);
  9293. }
  9294. }
  9295. else if (atoi(sep->arg[0]) == 11) {
  9296. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9297. if (packet2) {
  9298. packet2->setDataByName("quest_id", 524);
  9299. packet2->setDataByName("player_crc", 2900677088);
  9300. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9301. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9302. packet2->setDataByName("type", "Hallmark");
  9303. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9304. packet2->setDataByName("day", 19);
  9305. packet2->setDataByName("month", 6);
  9306. packet2->setDataByName("year", 20);
  9307. packet2->setDataByName("level", 1);
  9308. packet2->setDataByName("encounter_level", 1);
  9309. packet2->setDataByName("difficulty", 1);
  9310. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9311. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9312. //packet2->setDataByName("timer_duration", 300);
  9313. //packet2->setDataByName("timer_running", 1);
  9314. packet2->setArrayLengthByName("task_groups_completed", 9);
  9315. packet2->setArrayLengthByName("num_task_groups", 10);
  9316. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9317. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9318. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9319. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9320. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9321. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9322. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9323. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9324. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9325. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9326. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9327. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9328. packet2->setSubArrayLengthByName("num_updates", 1);
  9329. packet2->setSubArrayDataByName("update_currentval", 0);
  9330. packet2->setSubArrayDataByName("update_maxval", 1);
  9331. packet2->setSubArrayDataByName("icon", 11);
  9332. */
  9333. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9334. packet2->setDataByName("journal_updated", 1);
  9335. packet2->setDataByName("bullets", 1);
  9336. EQ2Packet* app = packet2->serialize();
  9337. if (sep->IsSet(2)) {
  9338. int16 offset = atoi(sep->arg[1]);
  9339. uchar* ptr2 = app->pBuffer;
  9340. ptr2 += offset;
  9341. if (sep->IsNumber(2)) {
  9342. int32 value1 = atol(sep->arg[2]);
  9343. if (value1 > 0xFFFF)
  9344. memcpy(ptr2, (uchar*)&value1, 4);
  9345. else if (value1 > 0xFF)
  9346. memcpy(ptr2, (uchar*)&value1, 2);
  9347. else
  9348. memcpy(ptr2, (uchar*)&value1, 1);
  9349. }
  9350. else {
  9351. int16 len = strlen(sep->arg[2]);
  9352. memcpy(ptr2, (uchar*)&len, 2);
  9353. ptr2 += 2;
  9354. memcpy(ptr2, sep->arg[2], len);
  9355. }
  9356. }
  9357. DumpPacket(app);
  9358. client->QueuePacket(app);
  9359. safe_delete(packet2);
  9360. }
  9361. }
  9362. else if (atoi(sep->arg[0]) == 12) {
  9363. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9364. if (packet2) {
  9365. packet2->setDataByName("quest_id", 524);
  9366. packet2->setDataByName("player_crc", 2900677088);
  9367. packet2->setDataByName("name", "Archetype Selection");
  9368. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9369. packet2->setDataByName("type", "Hallmark");
  9370. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9371. packet2->setDataByName("day", 19);
  9372. packet2->setDataByName("month", 6);
  9373. packet2->setDataByName("year", 20);
  9374. packet2->setDataByName("level", 2);
  9375. packet2->setDataByName("encounter_level", 4);
  9376. packet2->setDataByName("difficulty", 3);
  9377. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9378. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9379. packet2->setDataByName("timer_duration", 300);
  9380. packet2->setDataByName("timer_running", 1);
  9381. packet2->setArrayLengthByName("task_groups_completed", 0);
  9382. packet2->setArrayLengthByName("num_task_groups", 1);
  9383. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9384. packet2->setSubArrayLengthByName("num_tasks", 1);
  9385. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9386. packet2->setSubArrayLengthByName("num_updates", 1);
  9387. packet2->setSubArrayDataByName("update_currentval", 0);
  9388. packet2->setSubArrayDataByName("update_maxval", 1);
  9389. packet2->setSubArrayDataByName("icon", 11);
  9390. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9391. packet2->setDataByName("journal_updated", 1);
  9392. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9393. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9394. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9395. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9396. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9397. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9398. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9399. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9400. Item* item = master_item_list.GetItem(152755);
  9401. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9402. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9403. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9404. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9405. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9406. packet2->setSubstructDataByName("item", "tier", 4);
  9407. packet2->setSubstructDataByName("item", "flags", 0x60);
  9408. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9409. packet2->setSubstructDataByName("item", "stat_type", 1);
  9410. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9411. packet2->setSubstructDataByName("item", "value", 3);
  9412. packet2->setSubstructDataByName("item", "condition", 100);
  9413. packet2->setSubstructDataByName("item", "weight", 1);
  9414. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9415. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9416. packet2->setSubstructDataByName("item", "skill_min", 1);
  9417. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9418. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9419. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9420. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9421. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9422. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9423. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9424. packet2->setSubstructDataByName("item", "level", 0x1e);
  9425. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9426. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9427. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9428. //packet2->PrintPacket();
  9429. EQ2Packet* app = packet2->serialize();
  9430. if (sep->IsSet(2)) {
  9431. int16 offset = atoi(sep->arg[1]);
  9432. uchar* ptr2 = app->pBuffer;
  9433. ptr2 += offset;
  9434. if (sep->IsNumber(2)) {
  9435. int32 value1 = atol(sep->arg[2]);
  9436. if (value1 > 0xFFFF)
  9437. memcpy(ptr2, (uchar*)&value1, 4);
  9438. else if (value1 > 0xFF)
  9439. memcpy(ptr2, (uchar*)&value1, 2);
  9440. else
  9441. memcpy(ptr2, (uchar*)&value1, 1);
  9442. }
  9443. else {
  9444. int16 len = strlen(sep->arg[2]);
  9445. memcpy(ptr2, (uchar*)&len, 2);
  9446. ptr2 += 2;
  9447. memcpy(ptr2, sep->arg[2], len);
  9448. }
  9449. }
  9450. DumpPacket(app);
  9451. client->QueuePacket(app);
  9452. safe_delete(packet2);
  9453. }
  9454. }
  9455. else if (atoi(sep->arg[0]) == 13) {
  9456. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9457. if (packet2 && sep->IsSet(7)) {
  9458. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9459. char blah[128];
  9460. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9461. packet2->setDataByName("text", blah);
  9462. packet2->setDataByName("message_type", sep->arg[3]);
  9463. packet2->setDataByName("size", atof(sep->arg[4]));
  9464. packet2->setDataByName("red", atoi(sep->arg[5]));
  9465. packet2->setDataByName("green", atoi(sep->arg[6]));
  9466. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9467. EQ2Packet* app = packet2->serialize();
  9468. DumpPacket(app);
  9469. client->QueuePacket(app);
  9470. safe_delete(packet2);
  9471. }
  9472. }
  9473. else if (atoi(sep->arg[0]) == 14) {
  9474. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9475. if (packet2 && sep->IsSet(3)) {
  9476. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9477. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9478. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9479. 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.");
  9480. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9481. packet2->setArrayLengthByName("num_goals", 1);
  9482. //packet2->setArrayDataByName("goal_text", )
  9483. packet2->setSubArrayLengthByName("num_tasks", 1);
  9484. packet2->setSubArrayDataByName("task_text", "continue");
  9485. packet2->setDataByName("complete_sound", "click");
  9486. packet2->setDataByName("signal", "introduction");
  9487. packet2->setDataByName("voice_key1", 0xcda65173);
  9488. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9489. EQ2Packet* app = packet2->serialize();
  9490. DumpPacket(app);
  9491. client->QueuePacket(app);
  9492. safe_delete(packet2);
  9493. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9494. packet2->setDataByName("window", "MainHUD.StartMenu");
  9495. packet2->setDataByName("show", 1);
  9496. app = packet2->serialize();
  9497. DumpPacket(app);
  9498. client->QueuePacket(app);
  9499. safe_delete(packet2);
  9500. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9501. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9502. packet2->setDataByName("flash_seconds", 10);
  9503. app = packet2->serialize();
  9504. DumpPacket(app);
  9505. client->QueuePacket(app);
  9506. safe_delete(packet2);
  9507. }
  9508. }
  9509. else if (atoi(sep->arg[0]) == 15) {
  9510. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9511. if (packet2) {
  9512. packet2->setArrayLengthByName("loot_count", 1);
  9513. packet2->setArrayDataByName("name", "Test");
  9514. packet2->setArrayDataByName("item_id", 1234);
  9515. packet2->setArrayDataByName("count", 1);
  9516. packet2->setArrayDataByName("icon", 258);
  9517. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9518. Spawn* spawn = client->GetPlayer()->GetTarget();
  9519. if (spawn)
  9520. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9521. packet2->setDataByName("unknown3", 1);
  9522. packet2->setDataByName("unknown4", 1);
  9523. packet2->setDataByName("unknown5", 60);
  9524. EQ2Packet* app = packet2->serialize();
  9525. DumpPacket(app);
  9526. client->QueuePacket(app);
  9527. safe_delete(packet2);
  9528. }
  9529. }
  9530. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9531. char blah[32];
  9532. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9533. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9534. }
  9535. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9536. if (sep->IsSet(2)) {
  9537. int16 offset = atoi(sep->arg[1]);
  9538. if (sep->IsNumber(2)) {
  9539. int32 value1 = atol(sep->arg[2]);
  9540. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9541. cout << "Sent" << endl;
  9542. }
  9543. }
  9544. }
  9545. else if (atoi(sep->arg[0]) == 18) {
  9546. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9547. if (packet2) {
  9548. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9549. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9550. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9551. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9552. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9553. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  9554. Item* item = new Item(master_item_list.GetItem(36212));
  9555. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9556. item->stack_count = 20;
  9557. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9558. safe_delete(item);
  9559. item = new Item(master_item_list.GetItem(36685));
  9560. item->stack_count = 20;
  9561. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9562. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9563. safe_delete(item);
  9564. item = master_item_list.GetItem(1414);
  9565. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9566. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9567. item = master_item_list.GetItem(75057);
  9568. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9569. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  9570. EQ2Packet* app = packet2->serialize();
  9571. if (sep->IsSet(2)) {
  9572. int16 offset = atoi(sep->arg[1]);
  9573. uchar* ptr2 = app->pBuffer;
  9574. ptr2 += offset;
  9575. if (sep->IsNumber(2)) {
  9576. int32 value1 = atol(sep->arg[2]);
  9577. if (value1 > 0xFFFF)
  9578. memcpy(ptr2, (uchar*)&value1, 4);
  9579. else if (value1 > 0xFF)
  9580. memcpy(ptr2, (uchar*)&value1, 2);
  9581. else
  9582. memcpy(ptr2, (uchar*)&value1, 1);
  9583. }
  9584. else {
  9585. int16 len = strlen(sep->arg[2]);
  9586. memcpy(ptr2, (uchar*)&len, 2);
  9587. ptr2 += 2;
  9588. memcpy(ptr2, sep->arg[2], len);
  9589. }
  9590. }
  9591. DumpPacket(app);
  9592. client->QueuePacket(app);
  9593. safe_delete(packet2);
  9594. }
  9595. }
  9596. else if (atoi(sep->arg[0]) == 19) {
  9597. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9598. Spawn* spawn = client->GetPlayer()->GetTarget();
  9599. if (packet2 && spawn) {
  9600. Item* item = master_item_list.GetItem(130053);
  9601. packet2->setArrayLengthByName("loot_count", 1);
  9602. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9603. packet2->setArrayDataByName("unknown2", 1);
  9604. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9605. packet2->setDataByName("display", 1);
  9606. packet2->setDataByName("unknown2b", 1);
  9607. packet2->setDataByName("unknown3", 0x3c);
  9608. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9609. packet2->PrintPacket();
  9610. EQ2Packet* app = packet2->serialize();
  9611. if (sep->IsSet(2)) {
  9612. int16 offset = atoi(sep->arg[1]);
  9613. int16 offset2 = 0;
  9614. int32 value1 = 0;
  9615. if (sep->IsSet(3)) {
  9616. offset2 = atoi(sep->arg[2]);
  9617. value1 = atol(sep->arg[3]);
  9618. }
  9619. else
  9620. value1 = atol(sep->arg[2]);
  9621. int16 offset3 = 0;
  9622. int16 offset4 = 0;
  9623. int32 value2 = 0;
  9624. if (sep->IsSet(6)) {
  9625. offset3 = atoi(sep->arg[4]);
  9626. offset4 = atoi(sep->arg[5]);
  9627. value2 = atol(sep->arg[6]);
  9628. }
  9629. offset--;
  9630. if (offset2 > 0 && offset2 >= offset) {
  9631. offset2--;
  9632. uchar* ptr2 = app->pBuffer;
  9633. ptr2 += offset;
  9634. for (int i = offset; i <= offset2; i++) {
  9635. if (value1 > 0xFFFF) {
  9636. memcpy(ptr2, (uchar*)&value1, 4);
  9637. i += 3;
  9638. ptr2 += 3;
  9639. }
  9640. else if (value1 > 0xFF) {
  9641. memcpy(ptr2, (uchar*)&value1, 2);
  9642. i++;
  9643. ptr2++;
  9644. }
  9645. else
  9646. memcpy(ptr2, (uchar*)&value1, 1);
  9647. ptr2++;
  9648. }
  9649. }
  9650. if (offset4 > 0 && offset4 >= offset3) {
  9651. offset3--;
  9652. offset4--;
  9653. uchar* ptr2 = app->pBuffer;
  9654. ptr2 += offset3;
  9655. for (int i = offset3; i <= offset4; i++) {
  9656. if (value2 > 0xFFFF) {
  9657. memcpy(ptr2, (uchar*)&value2, 4);
  9658. i += 3;
  9659. ptr2 += 3;
  9660. }
  9661. else if (value2 > 0xFF) {
  9662. memcpy(ptr2, (uchar*)&value2, 2);
  9663. i++;
  9664. ptr2++;
  9665. }
  9666. else
  9667. memcpy(ptr2, (uchar*)&value2, 1);
  9668. ptr2++;
  9669. }
  9670. }
  9671. }
  9672. DumpPacket(app);
  9673. client->QueuePacket(app);
  9674. safe_delete(packet2);
  9675. }
  9676. }
  9677. else if (atoi(sep->arg[0]) == 21) {
  9678. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9679. if (packet2) {
  9680. packet2->setDataByName("unknown0", 255);
  9681. packet2->setDataByName("reward", "New Quest");
  9682. packet2->setDataByName("title", "Title");
  9683. packet2->setDataByName("description", "description");
  9684. packet2->setDataByName("quest_difficulty", 3);
  9685. packet2->setDataByName("unknown1", 5);
  9686. packet2->setDataByName("level", 3);
  9687. packet2->setDataByName("coin", 150);
  9688. packet2->setDataByName("status_points", 5);
  9689. packet2->setDataByName("exp_bonus", 10);
  9690. packet2->setArrayLengthByName("num_rewards", 1);
  9691. Item* item = new Item(master_item_list.GetItem(36212));
  9692. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9693. item->stack_count = 20;
  9694. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9695. safe_delete(item);
  9696. char accept[35] = { 0 };
  9697. char decline[35] = { 0 };
  9698. sprintf(accept, "q_accept_pending_quest %u", 0);
  9699. sprintf(decline, "q_deny_pending_quest %u", 0);
  9700. packet2->setDataByName("accept_command", accept);
  9701. packet2->setDataByName("decline_command", decline);
  9702. EQ2Packet* app = packet2->serialize();
  9703. if (sep->IsSet(2)) {
  9704. int16 offset = atoi(sep->arg[1]);
  9705. uchar* ptr2 = app->pBuffer;
  9706. ptr2 += offset;
  9707. if (sep->IsNumber(2)) {
  9708. int32 value1 = atol(sep->arg[2]);
  9709. if (value1 > 0xFFFF)
  9710. memcpy(ptr2, (uchar*)&value1, 4);
  9711. else if (value1 > 0xFF)
  9712. memcpy(ptr2, (uchar*)&value1, 2);
  9713. else
  9714. memcpy(ptr2, (uchar*)&value1, 1);
  9715. }
  9716. DumpPacket(app);
  9717. client->QueuePacket(app);
  9718. safe_delete(packet2);
  9719. }
  9720. }
  9721. }
  9722. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9723. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9724. if (packet2) {
  9725. packet2->setDataByName("unknown0", 255);
  9726. packet2->setDataByName("reward", "New Quest");
  9727. packet2->setDataByName("title", "Title");
  9728. packet2->setDataByName("description", "description");
  9729. packet2->setDataByName("quest_difficulty", 3);
  9730. packet2->setDataByName("unknown1", 5);
  9731. packet2->setDataByName("level", 3);
  9732. packet2->setDataByName("coin", 150);
  9733. packet2->setDataByName("status_points", 5);
  9734. packet2->setDataByName("exp_bonus", 10);
  9735. packet2->setArrayLengthByName("num_rewards", 1);
  9736. Item* item = new Item(master_item_list.GetItem(36212));
  9737. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9738. item->stack_count = 20;
  9739. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9740. safe_delete(item);
  9741. char accept[35] = { 0 };
  9742. char decline[35] = { 0 };
  9743. sprintf(accept, "q_accept_pending_quest %u", 0);
  9744. sprintf(decline, "q_deny_pending_quest %u", 0);
  9745. packet2->setDataByName("accept_command", accept);
  9746. packet2->setDataByName("decline_command", decline);
  9747. EQ2Packet* app = packet2->serialize();
  9748. if (sep->IsSet(2)) {
  9749. int16 offset = atoi(sep->arg[1]);
  9750. uchar* ptr2 = app->pBuffer;
  9751. ptr2 += offset;
  9752. if (sep->IsNumber(2)) {
  9753. int32 value1 = atol(sep->arg[2]);
  9754. if (value1 > 0xFFFF)
  9755. memcpy(ptr2, (uchar*)&value1, 4);
  9756. else if (value1 > 0xFF)
  9757. memcpy(ptr2, (uchar*)&value1, 2);
  9758. else
  9759. memcpy(ptr2, (uchar*)&value1, 1);
  9760. }
  9761. else {
  9762. int8 len = strlen(sep->arg[2]);
  9763. memcpy(ptr2, (uchar*)&len, 1);
  9764. ptr2 += 1;
  9765. memcpy(ptr2, sep->arg[2], len);
  9766. }
  9767. }
  9768. DumpPacket(app);
  9769. client->QueuePacket(app);
  9770. safe_delete(packet2);
  9771. }
  9772. }
  9773. else if (atoi(sep->arg[0]) == 23) {
  9774. if (client->GetPlayer()->GetTarget()) {
  9775. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9776. if (packet2) {
  9777. Spawn* target = client->GetPlayer()->GetTarget();
  9778. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9779. Item* item = new Item(master_item_list.GetItem(12565));
  9780. int8 i = 0;
  9781. packet2->setArrayLengthByName("num_items", 1);
  9782. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9783. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9784. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9785. packet2->setArrayDataByName("icon", item->details.icon, i);
  9786. int8 tmp_level = 0;
  9787. if (item->generic_info.adventure_default_level > 0)
  9788. tmp_level = item->generic_info.adventure_default_level;
  9789. else
  9790. tmp_level = item->generic_info.tradeskill_default_level;
  9791. packet2->setArrayDataByName("level", tmp_level, i);
  9792. packet2->setArrayDataByName("tier", item->details.tier, i);
  9793. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9794. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9795. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9796. item_difficulty = ARROW_COLOR_WHITE;
  9797. item_difficulty -= 6;
  9798. if (item_difficulty < 0)
  9799. item_difficulty *= -1;
  9800. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9801. packet2->setArrayDataByName("quantity", 2, i);
  9802. packet2->setArrayDataByName("unknown5", 255, i);
  9803. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9804. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9805. packet2->setDataByName("type", 2);
  9806. EQ2Packet* app = packet2->serialize();
  9807. if (sep->IsSet(2)) {
  9808. int16 offset = atoi(sep->arg[1]);
  9809. uchar* ptr2 = app->pBuffer;
  9810. ptr2 += offset;
  9811. if (sep->IsNumber(2)) {
  9812. int32 value1 = atol(sep->arg[2]);
  9813. if (value1 > 0xFFFF)
  9814. memcpy(ptr2, (uchar*)&value1, 4);
  9815. else if (value1 > 0xFF)
  9816. memcpy(ptr2, (uchar*)&value1, 2);
  9817. else
  9818. memcpy(ptr2, (uchar*)&value1, 1);
  9819. }
  9820. else {
  9821. int8 len = strlen(sep->arg[2]);
  9822. memcpy(ptr2, (uchar*)&len, 1);
  9823. ptr2 += 1;
  9824. memcpy(ptr2, sep->arg[2], len);
  9825. }
  9826. }
  9827. DumpPacket(app);
  9828. client->QueuePacket(app);
  9829. safe_delete(packet2);
  9830. }
  9831. }
  9832. }
  9833. else if (atoi(sep->arg[0]) == 24) {
  9834. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9835. if (packet2) {
  9836. if (sep->IsSet(2)) {
  9837. packet2->setDataByName("event_name", sep->arg[1]);
  9838. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9839. EQ2Packet* app = packet2->serialize();
  9840. DumpPacket(app);
  9841. client->QueuePacket(app);
  9842. safe_delete(packet2);
  9843. }
  9844. }
  9845. }
  9846. else if (atoi(sep->arg[0]) == 25) {
  9847. if (sep->IsSet(1)) {
  9848. Widget* new_spawn = new Widget();
  9849. int32 id = atoul(sep->arg[1]);
  9850. new_spawn->SetWidgetID(id);
  9851. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9852. client->QueuePacket(ret);
  9853. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9854. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9855. if (packet2) {
  9856. packet2->setDataByName("spawn_index", index);
  9857. packet2->setDataByName("delete", 1);
  9858. EQ2Packet* app = packet2->serialize();
  9859. client->QueuePacket(app);
  9860. safe_delete(packet2);
  9861. }
  9862. }
  9863. }
  9864. else if (atoi(sep->arg[0]) == 26) {
  9865. if (sep->IsSet(4)) {
  9866. Widget* new_spawn = new Widget();
  9867. int32 id = atoul(sep->arg[1]);
  9868. new_spawn->SetWidgetID(id);
  9869. float x = atof(sep->arg[2]);
  9870. float y = atof(sep->arg[3]);
  9871. float z = atof(sep->arg[4]);
  9872. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9873. new_spawn->SetWidgetX(x);
  9874. new_spawn->SetWidgetY(y);
  9875. new_spawn->SetWidgetZ(z);
  9876. new_spawn->SetX(x);
  9877. new_spawn->SetY(y);
  9878. new_spawn->SetZ(z);
  9879. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9880. client->QueuePacket(ret);
  9881. }
  9882. }
  9883. else if (atoi(sep->arg[0]) == 27) {
  9884. Spawn* target = client->GetPlayer()->GetTarget();
  9885. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9886. if (packet2 && target && sep->IsSet(2)) {
  9887. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9888. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9889. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9890. packet2->setArrayLengthByName("num_dmg", 1);
  9891. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9892. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9893. packet2->setDataByName("spell", 1);
  9894. packet2->setDataByName("spell_name", "Testing");
  9895. EQ2Packet* app = packet2->serialize();
  9896. if (sep->IsSet(4)) {
  9897. int16 offset = atoi(sep->arg[3]);
  9898. uchar* ptr2 = app->pBuffer;
  9899. ptr2 += offset;
  9900. if (sep->IsNumber(4)) {
  9901. int32 value1 = atol(sep->arg[4]);
  9902. if (value1 > 0xFFFF)
  9903. memcpy(ptr2, (uchar*)&value1, 4);
  9904. else if (value1 > 0xFF)
  9905. memcpy(ptr2, (uchar*)&value1, 2);
  9906. else
  9907. memcpy(ptr2, (uchar*)&value1, 1);
  9908. }
  9909. else {
  9910. int8 len = strlen(sep->arg[4]);
  9911. memcpy(ptr2, (uchar*)&len, 1);
  9912. ptr2 += 1;
  9913. memcpy(ptr2, sep->arg[4], len);
  9914. }
  9915. }
  9916. if (sep->IsSet(6)) {
  9917. int16 offset = atoi(sep->arg[5]);
  9918. uchar* ptr2 = app->pBuffer;
  9919. ptr2 += offset;
  9920. if (sep->IsNumber(6)) {
  9921. int32 value1 = atol(sep->arg[6]);
  9922. if (value1 > 0xFFFF)
  9923. memcpy(ptr2, (uchar*)&value1, 4);
  9924. else if (value1 > 0xFF)
  9925. memcpy(ptr2, (uchar*)&value1, 2);
  9926. else
  9927. memcpy(ptr2, (uchar*)&value1, 1);
  9928. }
  9929. else {
  9930. int8 len = strlen(sep->arg[6]);
  9931. memcpy(ptr2, (uchar*)&len, 1);
  9932. ptr2 += 1;
  9933. memcpy(ptr2, sep->arg[6], len);
  9934. }
  9935. }
  9936. DumpPacket(app);
  9937. client->QueuePacket(app);
  9938. safe_delete(packet2);
  9939. }
  9940. }
  9941. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9942. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9943. }
  9944. }
  9945. else {
  9946. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9947. if (packet2) {
  9948. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9949. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9950. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9951. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9952. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9953. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9954. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9955. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9956. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9957. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9958. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9959. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9960. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9961. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9962. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9963. packet2->setSubstructDataByName("spell_info", "level", 19);
  9964. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9965. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9966. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9967. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9968. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9969. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9970. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9971. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9972. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9973. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9974. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9975. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9976. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9977. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9978. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9979. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9980. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9981. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9982. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9983. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9984. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9985. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9986. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9987. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9988. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9989. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9990. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9991. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9992. packet2->setArrayDataByName("reagent", "Alcohol");
  9993. packet2->setArrayDataByName("consumed", "123");
  9994. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9995. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9996. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9997. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9998. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9999. packet2->setSubstructDataByName("spell_info", "type", 2);
  10000. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10001. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10002. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10003. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10004. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10005. EQ2Packet* outapp = packet2->serialize();
  10006. DumpPacket(outapp);
  10007. client->QueuePacket(outapp);
  10008. safe_delete(packet2);
  10009. }
  10010. }
  10011. return;
  10012. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10013. if (!p) return;
  10014. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10015. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10016. //}
  10017. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10018. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10019. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10020. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10021. if (packet) {
  10022. client->QueuePacket(packet->serialize());
  10023. safe_delete(packet);
  10024. }
  10025. }*/
  10026. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10027. int32 numFaces = 0;
  10028. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10029. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10030. map<int32, vector<Face*> >::iterator itr;
  10031. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10032. numFaces += (*itr).second.size();
  10033. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10034. }*/
  10035. //uchar blah[] = {
  10036. // 1208 - OP_EQUpdateStoreCmd
  10037. // /*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
  10038. // /*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
  10039. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10040. // /*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
  10041. /*};
  10042. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10043. int8 val = 0;
  10044. int16 pos = 0;
  10045. int idx = 0;
  10046. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10047. pos = atoi(sep2->arg[idx]);
  10048. val = atoi(sep2->arg[idx+1]);
  10049. memset(blah+pos, val, 1);
  10050. idx+=2;
  10051. }
  10052. DumpPacket(blah, sizeof(blah));
  10053. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10054. if (client->GetPlayer()->GetTarget()) {
  10055. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10056. if (packet) {
  10057. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10058. packet->setDataByName("size", 0);
  10059. packet->setDataByName("unknown2", 0);
  10060. EQ2Packet* app = packet->serialize();
  10061. client->QueuePacket(app);
  10062. safe_delete(packet);
  10063. }
  10064. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10065. if (set_pov) {
  10066. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10067. EQ2Packet* app_pov = set_pov->serialize();
  10068. client->QueuePacket(app_pov);
  10069. safe_delete(set_pov);
  10070. }
  10071. }
  10072. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10073. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10074. if (packet) {
  10075. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10076. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10077. else
  10078. packet->setDataByName("Type", 2);
  10079. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10080. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10081. else
  10082. packet->setDataByName("race_id", 0);
  10083. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10084. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10085. else
  10086. packet->setDataByName("gender", 2);
  10087. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10088. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10089. else
  10090. packet->setDataByName("unknown", 0, 0);
  10091. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10092. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10093. else
  10094. packet->setDataByName("unknown", 0, 1);
  10095. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10096. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10097. else
  10098. packet->setDataByName("unknown", 0, 2);
  10099. client->QueuePacket(packet->serialize());
  10100. }
  10101. safe_delete(packet);
  10102. safe_delete(sep2);
  10103. }
  10104. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10105. const char *channel_name;
  10106. if (sep == NULL || !sep->IsSet(0)) {
  10107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10108. PrintSep(sep);
  10109. return;
  10110. }
  10111. channel_name = sep->arg[0];
  10112. if (!chat.IsInChannel(client, channel_name))
  10113. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10114. else if (!chat.LeaveChannel(client, channel_name))
  10115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10116. }
  10117. /*
  10118. Function:
  10119. Purpose :
  10120. Params :
  10121. Dev :
  10122. Example :
  10123. */
  10124. void Commands::Command_WeaponStats(Client* client)
  10125. {
  10126. Player* player = client->GetPlayer();
  10127. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10128. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10129. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10130. client->SimpleMessage(0, "Primary:");
  10131. if (primary) {
  10132. client->Message(0, "Name: %s", primary->name.c_str());
  10133. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10134. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10135. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  10136. client->Message(0, "Proc Percent: %d%%", 0);
  10137. client->Message(0, "Procs Per Minute: %d", 0);
  10138. }
  10139. else {
  10140. client->SimpleMessage(0, "Name: fist");
  10141. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10142. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10143. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  10144. client->Message(0, "Proc Percent: %d%%", 0);
  10145. client->Message(0, "Procs Per Minute: %d", 0);
  10146. }
  10147. client->SimpleMessage(0, " ");
  10148. client->SimpleMessage(0, " ");
  10149. if (secondary) {
  10150. client->SimpleMessage(0, "Secondary:");
  10151. client->Message(0, "Name: %s", secondary->name.c_str());
  10152. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10153. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  10154. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  10155. client->Message(0, "Proc Percent: %d%%", 0);
  10156. client->Message(0, "Procs Per Minute: %d", 0);
  10157. client->SimpleMessage(0, " ");
  10158. client->SimpleMessage(0, " ");
  10159. }
  10160. client->SimpleMessage(0, "Ranged:");
  10161. if (ranged) {
  10162. client->Message(0, "Name: %s", ranged->name.c_str());
  10163. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10164. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  10165. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  10166. client->Message(0, "Proc Percent: %d%%", 0);
  10167. client->Message(0, "Procs Per Minute: %d", 0);
  10168. }
  10169. else
  10170. client->SimpleMessage(0, "None");
  10171. }
  10172. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10173. const char *channel_name;
  10174. if (sep == NULL || !sep->IsSet(0)) {
  10175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10176. return;
  10177. }
  10178. channel_name = sep->arg[0];
  10179. if (!chat.ChannelExists(channel_name))
  10180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10181. else
  10182. chat.SendChannelUserList(client, channel_name);
  10183. }
  10184. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10185. {
  10186. ZoneServer* zone = 0;
  10187. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10188. if (zone_id > 0)
  10189. {
  10190. zone = zone_list.Get(zone_id, false);
  10191. if (zone)
  10192. {
  10193. zone->SetSafeX(client->GetPlayer()->GetX());
  10194. zone->SetSafeY(client->GetPlayer()->GetY());
  10195. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10196. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10197. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10199. else
  10200. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10201. }
  10202. }
  10203. }
  10204. /*
  10205. Function:
  10206. Purpose :
  10207. Params :
  10208. Dev :
  10209. Example :
  10210. */
  10211. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10212. {
  10213. ZoneInfo* zone_info = new ZoneInfo;
  10214. if (sep && sep->arg[0])
  10215. {
  10216. if (sep->IsNumber(0))
  10217. zone_info->id = atoi(sep->arg[0]);
  10218. else
  10219. zone_info->id = database.GetZoneID(sep->arg[0]);
  10220. if (zone_info->id > 0)
  10221. {
  10222. database.LoadZoneInfo(zone_info);
  10223. 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);
  10224. 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);
  10225. 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);
  10226. 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);
  10227. 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);
  10228. 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);
  10229. 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);
  10230. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10231. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10232. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10233. }
  10234. else
  10235. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10236. }
  10237. else
  10238. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10239. safe_delete(zone_info);
  10240. }
  10241. /*
  10242. Function:
  10243. Purpose :
  10244. Params :
  10245. Dev :
  10246. Example :
  10247. */
  10248. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10249. {
  10250. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10251. {
  10252. ZoneServer* zone = 0;
  10253. int32 zone_id = 0;
  10254. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10255. {
  10256. zone_id = atoi(sep->arg[0]);
  10257. zone = zone_list.Get(atoi(sep->arg[0]), false);
  10258. }
  10259. else
  10260. {
  10261. zone_id = database.GetZoneID(sep->arg[0]);
  10262. if (zone_id > 0)
  10263. zone = zone_list.Get(sep->arg[0], false);
  10264. }
  10265. if (zone_id > 0)
  10266. {
  10267. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10268. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10269. else
  10270. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10271. }
  10272. else
  10273. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10274. }
  10275. else
  10276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10277. }
  10278. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10279. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10280. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10281. return;
  10282. }
  10283. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10284. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10285. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10286. }
  10287. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10288. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10290. return;
  10291. }
  10292. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10293. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10294. }
  10295. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10296. Spawn* spawn = client->GetPlayer()->GetTarget();
  10297. if(spawn) {
  10298. client->SetMerchantTransaction(spawn);
  10299. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10300. client->SendHailCommand(spawn);
  10301. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10302. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10303. client->SendBuyMerchantList(sell);
  10304. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10305. client->SendSellMerchantList(sell);
  10306. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10307. client->SendBuyBackList(sell);
  10308. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10309. if (packet) {
  10310. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10311. packet->setDataByName("type", 16);
  10312. EQ2Packet* outapp = packet->serialize();
  10313. if (outapp)
  10314. client->QueuePacket(outapp);
  10315. safe_delete(packet);
  10316. }
  10317. }
  10318. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10319. client->SendRepairList();
  10320. }
  10321. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10322. }
  10323. void Commands::Command_Weather(Client* client, Seperator* sep)
  10324. {
  10325. //PrintSep(sep, "Weather");
  10326. if( sep && sep->arg[0] )
  10327. {
  10328. ZoneServer* zsZone = client->GetCurrentZone();
  10329. const char* value = sep->arg[0];
  10330. // process single-param commands first
  10331. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10332. {
  10333. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10334. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10335. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10336. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10337. }
  10338. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10339. {
  10340. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10341. zsZone->ProcessWeather();
  10342. }
  10343. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10344. {
  10345. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10346. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10347. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10348. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10349. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10350. zsZone->SetWeatherPattern(1);
  10351. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10352. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10353. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10354. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10355. zsZone->ProcessWeather();
  10356. }
  10357. // process commands with params
  10358. if( sep->arg[1] )
  10359. {
  10360. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10361. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10362. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10363. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10364. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10365. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10366. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10367. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10368. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10369. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10370. }
  10371. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10372. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10373. zsZone->SetRain(zsZone->GetCurrentWeather());
  10374. }
  10375. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10376. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10377. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10378. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10379. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10380. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10381. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10382. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10383. }
  10384. }
  10385. else
  10386. {
  10387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10390. return;
  10391. }
  10392. }
  10393. void Commands::Command_Select(Client* client, Seperator* sep) {
  10394. if (sep && sep->arg[1]) {
  10395. Spawn* spawn = client->GetPlayer()->GetTarget();
  10396. if (spawn && strlen(sep->arg[1]) > 0)
  10397. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10398. }
  10399. }
  10400. /*
  10401. Function: Command_ConsumeFood()
  10402. Purpose : Consume Food/Drink and apply mods
  10403. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10404. Dev : Zcoretri
  10405. Example : /consume_food 22
  10406. */
  10407. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10408. if (sep && sep->arg[0] && sep->IsNumber(0))
  10409. {
  10410. Player* player = client->GetPlayer();
  10411. int8 slot = atoi(sep->arg[0]);
  10412. Item* item = player->GetEquipmentList()->GetItem(slot);
  10413. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  10414. {
  10415. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  10416. return;
  10417. }
  10418. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  10419. {
  10420. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  10421. return;
  10422. }
  10423. client->ConsumeFoodDrink(item, slot);
  10424. }
  10425. }
  10426. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10427. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10428. if (atoi(sep->arg[0]) == 1) {
  10429. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10430. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10431. client->GetPlayer()->SetCharSheetChanged(true);
  10432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10433. }
  10434. else {
  10435. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10436. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10437. client->GetPlayer()->SetCharSheetChanged(true);
  10438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10439. }
  10440. }
  10441. else
  10442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10443. }
  10444. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10445. {
  10446. if(sep)
  10447. {
  10448. string data;
  10449. if(sep->arg[0]){
  10450. data = string(sep->arg[0]);
  10451. }
  10452. for(int i=1;i<sep->GetMaxArgNum();i++){
  10453. if(sep->arg[i])
  10454. data.append(" ").append(sep->arg[i]);
  10455. }
  10456. const char* target_name = 0;
  10457. int32 spawn_id = 0;
  10458. if(client->GetPlayer()->GetTarget())
  10459. {
  10460. target_name = client->GetPlayer()->GetTarget()->GetName();
  10461. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10462. }
  10463. else
  10464. target_name = "N/A";
  10465. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10466. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10468. else
  10469. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10470. }
  10471. }
  10472. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10473. PrintSep(sep, "Command_Attune_Inv");
  10474. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10475. // Get the item index from the first parameter
  10476. int16 index = atoi(sep->arg[0]);
  10477. // Check to see if this is a valid item index for the player, if not exit out of the function
  10478. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10479. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10480. return;
  10481. }
  10482. // Get the item
  10483. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10484. if(item) {
  10485. // Valid item lets check to make sure this item is attunable, if not return out
  10486. if (!item->CheckFlag(ATTUNEABLE)) {
  10487. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10488. return;
  10489. }
  10490. // Remove the attunable flag
  10491. item->generic_info.item_flags -= ATTUNEABLE;
  10492. // Set the attuned flag
  10493. item->generic_info.item_flags += ATTUNED;
  10494. // Flag this item for saving
  10495. item->save_needed = true;
  10496. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10497. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10498. EQ2Packet* outapp = 0;
  10499. for (int32 i=0;i<packets.size();i++) {
  10500. outapp = packets[i];
  10501. if(outapp)
  10502. client->QueuePacket(outapp);
  10503. }
  10504. }
  10505. }
  10506. }
  10507. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10508. PrintSep(sep, "Command_Reset_Zone_Timer");
  10509. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10510. int32 db_id = atoul(sep->arg[0]);
  10511. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10512. if (data) {
  10513. // TODO: add a check to timers to ensure it can be reset
  10514. // Delete the character from the instance
  10515. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10516. data->instance_id = 0;
  10517. // Update the success time and set to 0 so the player can enter it again
  10518. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10519. data->last_success_timestamp = 0;
  10520. }
  10521. }*/
  10522. }
  10523. void Commands::Command_Player(Client* client, Seperator* sep) {
  10524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10526. }
  10527. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10528. // /player coins add 10
  10529. // /player coins add plat 10
  10530. Player* player = client->GetPlayer();
  10531. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10532. player = (Player*)player->GetTarget();
  10533. if (sep && sep->arg[0] && sep->arg[1]) {
  10534. const char* action = sep->arg[0];
  10535. int64 value = 0;
  10536. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10537. if (sep->IsNumber(1)) {
  10538. value = atoi64(sep->arg[1]);
  10539. player->AddCoins(value);
  10540. if (client->GetPlayer() == player)
  10541. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10542. else {
  10543. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10544. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10545. }
  10546. return;
  10547. }
  10548. else if (sep->arg[2] && sep->IsNumber(2)) {
  10549. const char* type = sep->arg[1];
  10550. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10551. value = atoi64(sep->arg[2]);
  10552. }
  10553. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10554. value = atoi64(sep->arg[2]) * 100;
  10555. }
  10556. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10557. value = atoi64(sep->arg[2]) * 10000;
  10558. }
  10559. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10560. value = atoi64(sep->arg[2]) * 1000000;
  10561. }
  10562. player->AddCoins(value);
  10563. if (client->GetPlayer() == player)
  10564. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10565. else {
  10566. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10567. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10568. }
  10569. return;
  10570. }
  10571. }
  10572. }
  10573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10579. }
  10580. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10581. PrintSep(sep, "ACHIEVEMENT_ADD");
  10582. if (sep && sep->IsSet(0)) {
  10583. int32 spell_id = atoul(sep->arg[1]);
  10584. int8 spell_tier = 0;
  10585. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10586. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10587. // addspellbookentry here
  10588. if (spell_tier >= data->maxRank) {
  10589. return;
  10590. }
  10591. if (!spell_tier) {
  10592. spell_tier = 1;
  10593. }
  10594. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10595. {
  10596. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10597. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10598. client->GetPlayer()->UnlockSpell(spell);
  10599. client->SendSpellUpdate(spell);
  10600. }
  10601. else
  10602. {
  10603. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10604. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10605. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10606. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10607. client->GetPlayer()->UnlockSpell(spell);
  10608. client->SendSpellUpdate(spell);
  10609. }
  10610. // cast spell here
  10611. if (!spell_tier)
  10612. spell_tier = 1;
  10613. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10614. if (spell) {
  10615. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10616. }
  10617. }
  10618. else {
  10619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10620. }
  10621. master_aa_list.DisplayAA(client, 0, 0);
  10622. }
  10623. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10624. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10625. if (packet) {
  10626. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10627. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10628. char command[255];
  10629. url = "browser " + url;
  10630. int32 spawn_id = 0;
  10631. int32 zone_id = 0;
  10632. string type;
  10633. if (client->GetCurrentZone())
  10634. zone_id = client->GetCurrentZone()->GetZoneID();
  10635. if (client->GetPlayer()->GetTarget()) {
  10636. Spawn* target = client->GetPlayer()->GetTarget();
  10637. if (target->IsWidget())
  10638. type = "widgets";
  10639. else if (target->IsSign())
  10640. type = "signs";
  10641. else if (target->IsObject())
  10642. type = "objects";
  10643. else if (target->IsNPC())
  10644. type = "npcs";
  10645. else if (target->IsGroundSpawn())
  10646. type = "ground";
  10647. else
  10648. type = "spawn";
  10649. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10650. }
  10651. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10652. packet->setDataByName("accept_command", command);
  10653. }
  10654. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10655. char command[255];
  10656. url = "browser " + url;
  10657. if (client->GetPlayer()->GetTarget())
  10658. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10659. packet->setDataByName("accept_command", command);
  10660. }
  10661. else {
  10662. string command = "browser " + url;
  10663. packet->setDataByName("accept_command", command.c_str());
  10664. }
  10665. packet->setDataByName("text", "Open the web editor?");
  10666. packet->setDataByName("accept_text", "Open");
  10667. packet->setDataByName("cancel_text", "Cancel");
  10668. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10669. packet->setDataByName("unknown2", 50);
  10670. packet->setDataByName("unknown4", 1);
  10671. client->QueuePacket(packet->serialize());
  10672. safe_delete(packet);
  10673. }
  10674. }
  10675. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10676. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10677. return;
  10678. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10679. if(client->GetCurrentRez()->active)
  10680. client->AcceptResurrection();
  10681. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10682. }
  10683. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10684. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10685. return;
  10686. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10687. if(client->GetCurrentRez()->active)
  10688. client->GetCurrentRez()->should_delete = true;
  10689. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10690. }
  10691. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10692. PrintSep(sep, "Switch_AA_Profile");
  10693. if (sep && sep->IsSet(0)) {
  10694. string type = sep->arg[0];
  10695. int8 newtemplate = atoul(sep->arg[1]);
  10696. master_aa_list.DisplayAA(client, newtemplate, 1);
  10697. }
  10698. }
  10699. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10700. PrintSep(sep, "Get_AA_Xml");
  10701. if (sep && sep->IsSet(0)) {
  10702. string tabnum = sep->arg[0];
  10703. string spellid = sep->arg[1];
  10704. }
  10705. }
  10706. void Commands::Add_AA(Client* client, Seperator* sep) {
  10707. PrintSep(sep, "Add_AA");
  10708. if (sep && sep->IsSet(0)) {
  10709. int32 spell_id = atoul(sep->arg[1]);
  10710. int8 spell_tier = 0;
  10711. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10712. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10713. // addspellbookentry here
  10714. if(!data) {
  10715. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10716. return;
  10717. }
  10718. if (spell_tier >= data->maxRank) {
  10719. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10720. return;
  10721. }
  10722. if (!spell_tier) {
  10723. spell_tier = 1;
  10724. }
  10725. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10726. {
  10727. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10728. if(spell)
  10729. {
  10730. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10731. client->GetPlayer()->UnlockSpell(spell);
  10732. client->SendSpellUpdate(spell);
  10733. }
  10734. }
  10735. else
  10736. {
  10737. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10738. if(spell)
  10739. {
  10740. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10741. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10742. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10743. client->GetPlayer()->UnlockSpell(spell);
  10744. client->SendSpellUpdate(spell);
  10745. }
  10746. }
  10747. // cast spell here
  10748. if (!spell_tier)
  10749. spell_tier = 1;
  10750. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10751. if (spell) {
  10752. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10753. }
  10754. }
  10755. else {
  10756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10757. }
  10758. master_aa_list.DisplayAA(client, 0, 0);
  10759. }
  10760. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10761. PrintSep(sep, "Commit_AA_Profile");
  10762. if (sep && sep->IsSet(0)) {
  10763. }
  10764. }
  10765. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10766. PrintSep(sep, "Begin_AA_Profile");
  10767. if (sep && sep->IsSet(0)) {
  10768. master_aa_list.DisplayAA(client, 100, 2);
  10769. }
  10770. }
  10771. void Commands::Back_AA(Client* client, Seperator* sep) {
  10772. if (sep && sep->IsSet(0)) {
  10773. PrintSep(sep, "Back_AA");
  10774. }
  10775. }
  10776. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10777. if (sep && sep->IsSet(0)) {
  10778. PrintSep(sep, "Remove_AA");
  10779. }
  10780. }
  10781. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10782. MasterAAList master_aa_list;
  10783. PrintSep(sep, "Cancel_AA_Profile");
  10784. master_aa_list.DisplayAA(client, 0, 0);
  10785. }
  10786. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10787. if (sep && sep->IsSet(0)) {
  10788. PrintSep(sep, "Save_AA_Profile");
  10789. }
  10790. }
  10791. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10792. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10793. if (!sep->IsNumber(0)) return;
  10794. int32 request_id = atoul(sep->arg[0]);
  10795. if (!sep->IsNumber(1)) return;
  10796. sint32 item_id = atoi(sep->arg[1]);
  10797. if (client->IsCurrentTransmuteID(request_id)) {
  10798. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10799. }
  10800. else if (client->IsCurrentTransmuteID(item_id)) {
  10801. if (!sep->IsSet(2)) return;
  10802. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10803. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10804. }
  10805. }
  10806. }
  10807. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10808. if(sep)
  10809. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10810. }
  10811. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10812. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10813. {
  10814. char* name = sep->arg[0];
  10815. char* zoneName = sep->arg[1];
  10816. char query[256];
  10817. 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);
  10818. if (database.RunQuery(query, strnlen(query, 256)))
  10819. {
  10820. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10821. }
  10822. else
  10823. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10824. }
  10825. }
  10826. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10827. Player* player = client->GetPlayer();
  10828. if( sep && sep->arg[0] )
  10829. {
  10830. const char* value = sep->arg[0];
  10831. InfoStruct* info = player->GetInfoStruct();
  10832. int32 cid = client->GetCharacterID();
  10833. char* characterName = database.GetCharacterName(cid);
  10834. char tmp[1024]; // our emote string "xyz appears zyx"
  10835. //char properties vals
  10836. char* pname = "mood";
  10837. char* pval; // mood value
  10838. bool pt; //used to verify return from DB.
  10839. //This should never be seen.
  10840. sprintf(tmp, " ");
  10841. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10842. {
  10843. sprintf(tmp, "%s appears angry", characterName);
  10844. pval = "11852";
  10845. player->SetMoodState(11852, 1);
  10846. info->set_mood(11852);
  10847. pt = database.insertCharacterProperty(client, pname, pval);
  10848. }
  10849. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10850. {
  10851. sprintf(tmp, "%s appears afraid", characterName);
  10852. pval = "11851";
  10853. player->SetMoodState(11851, 1);
  10854. info->set_mood(11851);
  10855. pt = database.insertCharacterProperty(client, pname, pval);
  10856. }
  10857. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10858. {
  10859. sprintf(tmp, "%s appears happy", characterName);
  10860. pval = "11854";
  10861. player->SetMoodState(11854, 1);
  10862. info->set_mood(11854);
  10863. pt = database.insertCharacterProperty(client, pname, pval);
  10864. }
  10865. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10866. sprintf(tmp, "%s appears sad", characterName);
  10867. pval = "11856";
  10868. player->SetMoodState(11856, 1);
  10869. info->set_mood(11856);
  10870. pt = database.insertCharacterProperty(client, pname, pval);
  10871. }
  10872. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10873. {
  10874. sprintf(tmp, "%s appears tired", characterName);
  10875. pval = "11857";
  10876. player->SetMoodState(11857, 1);
  10877. info->set_mood(11857);
  10878. pt = database.insertCharacterProperty(client, pname, pval);
  10879. }
  10880. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10881. {
  10882. //using 11855 mood_idle for none, I assume thats what its for?
  10883. pval = "11855";
  10884. player->SetMoodState(11855, 1);
  10885. info->set_mood(11855);
  10886. pt = database.insertCharacterProperty(client, pname, pval);
  10887. //return since we have nothing left to do. No emote for none.
  10888. return;
  10889. }else{
  10890. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10891. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10892. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10893. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10894. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10895. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10896. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10897. return;
  10898. }
  10899. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  10900. return;
  10901. }
  10902. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10903. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10904. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10905. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10906. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10907. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10908. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10909. return;
  10910. }
  10911. /*
  10912. Function: Command_CancelEffect()
  10913. Purpose : Cancels (good) effect spells
  10914. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  10915. */
  10916. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  10917. {
  10918. if (sep && sep->arg[0] && sep->IsNumber(0))
  10919. {
  10920. int32 spell_id = atoul(sep->arg[0]);
  10921. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  10922. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  10923. return;
  10924. }
  10925. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  10926. if (!meffect || !meffect->spell || !meffect->spell->caster ||
  10927. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, true, client->GetPlayer()))
  10928. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  10929. }
  10930. }
  10931. /*
  10932. Function: Command_CurePlayer()
  10933. Purpose : Identifies spell to cast for cure based on type
  10934. Example : /cureplayer ??
  10935. https://eq2.fandom.com/wiki/Update:58
  10936. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  10937. Example: /cureplayer g0 noxious spell
  10938. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  10939. Example: /cureplayer r4 noxious
  10940. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  10941. */
  10942. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  10943. {
  10944. Entity* target = nullptr;
  10945. bool use_spells = true;
  10946. bool use_potions = true;
  10947. if (sep && sep->arg[0] && sep->arg[1]) {
  10948. if(sep->arg[2]) {
  10949. std::string type(sep->arg[2]);
  10950. boost::algorithm::to_lower(type);
  10951. if(type == "potion")
  10952. use_spells = false;
  10953. else if(type == "spell")
  10954. use_potions = false;
  10955. }
  10956. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  10957. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  10958. // TODO: RAID Support ('r' argument)
  10959. if(sep->arg[0][0] == 'g' && !mapped_position) {
  10960. target = (Entity*)client->GetPlayer();
  10961. }
  10962. else {
  10963. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  10964. if (gmi && gmi->group_id) {
  10965. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  10966. if(group) {
  10967. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  10968. }
  10969. }
  10970. }
  10971. }
  10972. else {
  10973. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  10974. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  10975. target = (Entity*)target_client->GetPlayer();
  10976. }
  10977. }
  10978. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  10979. bool successful_spell = false;
  10980. bool successful_potion = false;
  10981. if(target) {
  10982. SpellBookEntry* entry = nullptr;
  10983. std::string str(sep->arg[1]);
  10984. boost::algorithm::to_lower(str);
  10985. if(str == "arcane") {
  10986. type = EFFECT_CURE_TYPE_ARCANE;
  10987. // cure arcane spell missing in DB?
  10988. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  10989. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  10990. }
  10991. }
  10992. else if(str == "trauma") {
  10993. type = EFFECT_CURE_TYPE_TRAUMA;
  10994. // cure trauma spell missing in DB?
  10995. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  10996. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  10997. }
  10998. }
  10999. else if(str == "noxious") {
  11000. type = EFFECT_CURE_TYPE_NOXIOUS;
  11001. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11002. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11003. }
  11004. }
  11005. else if(str == "curse") {
  11006. type = EFFECT_CURE_TYPE_CURSE;
  11007. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11008. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11009. }
  11010. }
  11011. else if(str == "magic") {
  11012. type = EFFECT_CURE_TYPE_MAGIC;
  11013. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11014. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11015. }
  11016. }
  11017. if(use_spells) {
  11018. // check if any of the specific cure types are available, if not then check the base cures
  11019. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11020. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11021. }
  11022. if(entry) {
  11023. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11024. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11025. successful_spell = true;
  11026. }
  11027. }
  11028. }
  11029. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11030. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11031. if (potential_items && potential_items->size() > 0) {
  11032. vector<Item*>::iterator itr;
  11033. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11034. {
  11035. Item* item = *itr;
  11036. if(client->UseItem(item, target)) {
  11037. successful_potion = true;
  11038. break;
  11039. }
  11040. }
  11041. }
  11042. safe_delete(potential_items);
  11043. }
  11044. }
  11045. }