Commands.cpp 365 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. 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) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. 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());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1062. break;
  1063. }
  1064. case COMMAND_RELOADSTRUCTS: {
  1065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1066. configReader.ReloadStructs();
  1067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1068. break;
  1069. }
  1070. case COMMAND_RELOAD_QUESTS: {
  1071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1072. master_quest_list.Reload();
  1073. client_list.ReloadQuests();
  1074. zone_list.ReloadClientQuests();
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1076. break;
  1077. }
  1078. case COMMAND_RELOAD_SPAWNS: {
  1079. client->GetCurrentZone()->ReloadSpawns();
  1080. break;
  1081. }
  1082. case COMMAND_RELOAD_SPELLS: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1084. zone_list.DeleteSpellProcess();
  1085. master_spell_list.Reload();
  1086. if (lua_interface)
  1087. lua_interface->ReloadSpells();
  1088. zone_list.LoadSpellProcess();
  1089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1090. break;
  1091. }
  1092. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1094. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1095. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1097. break;
  1098. }
  1099. case COMMAND_RELOAD_ZONESCRIPTS: {
  1100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1101. world.ResetZoneScripts();
  1102. database.LoadZoneScriptData();
  1103. if (lua_interface)
  1104. lua_interface->DestroyZoneScripts();
  1105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1106. break;
  1107. }
  1108. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1110. client->GetCurrentZone()->ClearEntityCommands();
  1111. database.LoadEntityCommands(client->GetCurrentZone());
  1112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1113. break;
  1114. }
  1115. case COMMAND_RELOAD_FACTIONS: {
  1116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1117. master_faction_list.Clear();
  1118. database.LoadFactionList();
  1119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1120. break;
  1121. }
  1122. case COMMAND_RELOAD_MAIL: {
  1123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1124. zone_list.ReloadMail();
  1125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1126. break;
  1127. }
  1128. case COMMAND_RELOAD_GUILDS: {
  1129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1130. world.ReloadGuilds();
  1131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1132. break;
  1133. }
  1134. case COMMAND_RELOAD_LOCATIONS: {
  1135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1136. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1137. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1139. break;
  1140. }
  1141. case COMMAND_RELOAD_RULES: {
  1142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1143. database.LoadRuleSets(true);
  1144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1145. break;
  1146. }
  1147. case COMMAND_RELOAD_TRANSPORTERS: {
  1148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1149. database.LoadTransporters(client->GetCurrentZone());
  1150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1151. break;
  1152. }
  1153. case COMMAND_RELOAD_STARTABILITIES: {
  1154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1155. world.PurgeStartingLists();
  1156. world.LoadStartingLists();
  1157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1158. break;
  1159. }
  1160. case COMMAND_READ: {
  1161. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1162. if (strcmp(sep->arg[0], "read") == 0) {
  1163. int32 item_index = atol(sep->arg[1]);
  1164. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1165. if (item) {
  1166. Spawn* spawn = cmdTarget;
  1167. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1168. break;
  1169. }
  1170. }
  1171. }
  1172. break;
  1173. }
  1174. case COMMAND_USEABILITY:{
  1175. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1176. if (client->GetPlayer()->GetHP() == 0) {
  1177. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1178. }
  1179. else {
  1180. int32 spell_id = atoul(sep->arg[0]);
  1181. int8 spell_tier = 0;
  1182. if (sep->arg[1][0] && sep->IsNumber(1))
  1183. spell_tier = atoi(sep->arg[1]);
  1184. else
  1185. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1186. if (!spell_tier)
  1187. spell_tier = 1;
  1188. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1189. if (spell) {
  1190. 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)
  1191. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1192. else
  1193. {
  1194. if (cmdTarget)
  1195. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1196. else
  1197. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1198. }
  1199. }
  1200. }
  1201. }
  1202. else if (cmdTarget && cmdTarget->IsWidget())
  1203. {
  1204. Widget* widget = (Widget*)cmdTarget;
  1205. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1206. }
  1207. else
  1208. {
  1209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1210. }
  1211. break;
  1212. }
  1213. case COMMAND_INFO:{
  1214. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1215. if(strcmp(sep->arg[0], "inventory") == 0){
  1216. int32 item_index = atol(sep->arg[1]);
  1217. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1218. if(item){
  1219. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1220. break;
  1221. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1222. //DumpPacket(app);
  1223. client->QueuePacket(app);
  1224. if(item->GetItemScript() && lua_interface)
  1225. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1226. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1227. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1228. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1229. client->AddPendingQuest(quest);
  1230. }
  1231. }
  1232. else
  1233. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1234. }
  1235. else if(strcmp(sep->arg[0], "equipment") == 0){
  1236. int32 item_index = atol(sep->arg[1]);
  1237. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1238. if(item){
  1239. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1240. client->QueuePacket(app);
  1241. if(item->GetItemScript() && lua_interface)
  1242. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1243. }
  1244. else
  1245. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1246. }
  1247. 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){
  1248. int32 item_id = atoul(sep->arg[1]);
  1249. Item* item = master_item_list.GetItem(item_id);
  1250. if(item){
  1251. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1252. client->QueuePacket(app);
  1253. }
  1254. else
  1255. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1256. }
  1257. else if (strcmp(sep->arg[0], "spell") == 0) {
  1258. sint32 spell_id = atol(sep->arg[1]);
  1259. int8 tier = atoi(sep->arg[3]);
  1260. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1261. if (outapp)
  1262. client->QueuePacket(outapp);
  1263. else
  1264. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1265. }
  1266. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1267. sint32 spell_id = atol(sep->arg[2]);
  1268. int8 group = atoi(sep->arg[1]);
  1269. AltAdvanceData* data = 0;
  1270. SpellBookEntry* spellentry = 0;
  1271. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1273. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1274. if (outapp)
  1275. client->QueuePacket(outapp);
  1276. else
  1277. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1278. }
  1279. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1280. sint32 spell_id = atol(sep->arg[1]);
  1281. int8 tier = atoi(sep->arg[2]);
  1282. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1283. if (outapp)
  1284. client->QueuePacket(outapp);
  1285. else
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1287. }
  1288. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1289. sint32 recipe_id = atol(sep->arg[1]);
  1290. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1291. if(outapp)
  1292. client->QueuePacket(outapp);
  1293. else
  1294. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1295. }
  1296. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1297. int32 slot = atol(sep->arg[1]);
  1298. int32 spell_id = atol(sep->arg[2]);
  1299. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1300. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1301. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1302. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1303. if(outapp)
  1304. client->QueuePacket(outapp);
  1305. else
  1306. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1307. }
  1308. else if (strcmp(sep->arg[0], "effect") == 0) {
  1309. int32 spell_id = atol(sep->arg[1]);
  1310. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1311. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1312. int8 type = 0;
  1313. if (client->GetVersion() <= 283)
  1314. type = 1;
  1315. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1316. if (outapp){
  1317. client->QueuePacket(outapp);
  1318. }
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. }
  1323. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1324. Item* item = player->item_list.GetOverflowItem();
  1325. if(item) {
  1326. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1327. client->QueuePacket(app);
  1328. }
  1329. else
  1330. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1331. }
  1332. else
  1333. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1334. break;
  1335. }
  1336. case COMMAND_USE_EQUIPPED_ITEM:{
  1337. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1338. int32 slot_id = atoul(sep->arg[0]);
  1339. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1340. if (item && item->generic_info.usable && item->GetItemScript())
  1341. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1342. }
  1343. break;
  1344. }
  1345. case COMMAND_USE_ITEM: {
  1346. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1347. int32 item_index = atoul(sep->arg[0]);
  1348. Item* item = player->item_list.GetItemFromIndex(item_index);
  1349. if (item && item->GetItemScript()) {
  1350. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1351. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1352. else {
  1353. if (item->generic_info.display_charges > 0) {
  1354. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1355. item->generic_info.display_charges -= 1;
  1356. item->save_needed = true;
  1357. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1358. }
  1359. }
  1360. }
  1361. }
  1362. break;
  1363. }
  1364. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1365. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1366. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1367. if (item) {
  1368. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1369. if(item->generic_info.item_type == 6) {
  1370. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1371. int8 old_slot = 0;
  1372. if (spell) {
  1373. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1374. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1375. player->RemoveSpellBookEntry(spell->GetSpellID());
  1376. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1377. player->UnlockSpell(spell);
  1378. client->SendSpellUpdate(spell);
  1379. database.DeleteItem(client->GetCharacterID(), item, 0);
  1380. player->item_list.RemoveItem(item, true);
  1381. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1382. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1383. }
  1384. }
  1385. else
  1386. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1387. }
  1388. else if(item->generic_info.item_type == 7){
  1389. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1390. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1391. // if valid recipe book and the player doesn't have it
  1392. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1393. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1394. safe_delete(recipe_book);
  1395. }
  1396. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1397. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1398. // Add recipe book to the players list
  1399. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1400. // Get a list of all recipes this book contains
  1401. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1402. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1403. // Create the packet to send to update the players recipe list
  1404. PacketStruct* packet = 0;
  1405. if (client->GetRecipeListSent()) {
  1406. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1407. if (packet)
  1408. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1409. }
  1410. // loop through the list
  1411. vector<Recipe*>::iterator itr;
  1412. int16 i = 0;
  1413. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1414. // check to see if the player already has this recipe some how
  1415. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1416. // Player doesn't already have this recipe so lets add it
  1417. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1418. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1419. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1420. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1421. if (packet && client->GetRecipeListSent()) {
  1422. packet->setArrayDataByName("id", recipe->GetID(), i);
  1423. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1424. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1425. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1426. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1427. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1428. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1429. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1430. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1431. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1432. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1433. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1434. i++;
  1435. }
  1436. }
  1437. }
  1438. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1439. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1440. database.DeleteItem(client->GetCharacterID(), item, 0);
  1441. client->GetPlayer()->item_list.RemoveItem(item, true);
  1442. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1443. if (packet && client->GetRecipeListSent())
  1444. client->QueuePacket(packet->serialize());
  1445. safe_delete(packet);
  1446. }
  1447. else {
  1448. if (recipe_book)
  1449. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1450. safe_delete(recipe_book);
  1451. }
  1452. }
  1453. }
  1454. else
  1455. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1456. }
  1457. break;
  1458. }
  1459. case COMMAND_SUMMONITEM: {
  1460. if (sep && sep->IsNumber(0)) {
  1461. int32 item_id = atol(sep->arg[0]);
  1462. int32 quantity = 1;
  1463. if (sep->arg[1] && sep->IsNumber(1))
  1464. quantity = atoi(sep->arg[1]);
  1465. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1466. client->AddItemToBank(item_id,quantity);
  1467. }
  1468. else {
  1469. client->AddItem(item_id, quantity);
  1470. }
  1471. }
  1472. else {
  1473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1475. }
  1476. break;
  1477. }
  1478. case COMMAND_COLLECTION_ADDITEM: {
  1479. // takes 2 params: collection_id, slot
  1480. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1481. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1482. if (item)
  1483. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1484. else
  1485. 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]));
  1486. }
  1487. else
  1488. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1489. break;
  1490. }
  1491. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1492. // takes 1 param: slot
  1493. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1494. int i = 0;
  1495. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1496. printf("\t%u: %s\n", i, sep->arg[i]);
  1497. i++;
  1498. }
  1499. break;
  1500. }
  1501. case COMMAND_WHO:{
  1502. const char* who = 0;
  1503. if(sep && sep->arg[0]){
  1504. //cout << "Who query: \n";
  1505. who = sep->argplus[0];
  1506. //cout << who << endl;
  1507. }
  1508. zone_list.ProcessWhoQuery(who, client);
  1509. break;
  1510. }
  1511. case COMMAND_SELECT_JUNCTION:{
  1512. 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__);
  1513. int32 choice = 0;
  1514. if(sep && sep->arg[0] && sep->IsNumber(0))
  1515. choice = atoul(sep->arg[0]);
  1516. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1517. client->HandlePlayerRevive(choice);
  1518. }
  1519. break;
  1520. }
  1521. case COMMAND_SPAWN_MOVE: {
  1522. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1523. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1524. if (packet) {
  1525. float unknown2_3 = 0;
  1526. int8 placement_mode = 0;
  1527. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1528. if (sep && sep->arg[0][0]) {
  1529. if (strcmp(sep->arg[0], "wall") == 0) {
  1530. placement_mode = 2;
  1531. unknown2_3 = 150;
  1532. }
  1533. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1534. placement_mode = 1;
  1535. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1539. }
  1540. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1541. {
  1542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1543. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1544. }
  1545. else if (strcmp(sep->arg[0], "myloc") == 0)
  1546. {
  1547. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1548. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1549. safe_delete(packet);
  1550. break;
  1551. }
  1552. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1553. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1554. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1555. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1556. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1557. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1558. safe_delete(packet);
  1559. break;
  1560. }
  1561. }
  1562. packet->setDataByName("placement_mode", placement_mode);
  1563. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1564. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1565. packet->setDataByName("unknown", 1); //size
  1566. packet->setDataByName("unknown2", 1); //size 2
  1567. packet->setDataByName("unknown2", .5, 1); //size 3
  1568. packet->setDataByName("unknown2", 3, 2);
  1569. packet->setDataByName("unknown2", unknown2_3, 3);
  1570. packet->setDataByName("max_distance", 500);
  1571. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1572. client->QueuePacket(packet->serialize());
  1573. safe_delete(packet);
  1574. }
  1575. }
  1576. else {
  1577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1579. }
  1580. break;
  1581. }
  1582. case COMMAND_HAIL:{
  1583. Spawn* spawn = cmdTarget;
  1584. if(spawn && spawn->GetTargetable())
  1585. {
  1586. char tmp[75] = {0};
  1587. sprintf(tmp, "Hail, %s", spawn->GetName());
  1588. bool show_bubble = true;
  1589. if (spawn->IsNPC())
  1590. show_bubble = false;
  1591. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1592. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1593. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1594. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1595. else
  1596. spawn->ProcessMovement();
  1597. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1598. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1599. }
  1600. }
  1601. else {
  1602. string tmp = "Hail";
  1603. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1604. }
  1605. break;
  1606. }
  1607. case COMMAND_SAY:{
  1608. if (sep && sep->arg[0][0]) {
  1609. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1610. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1611. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1612. }
  1613. else
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1615. break;
  1616. }
  1617. case COMMAND_TELL:{
  1618. if(sep && sep->arg[0] && sep->argplus[1]){
  1619. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1620. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1621. }else
  1622. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1623. break;
  1624. }
  1625. case COMMAND_SHOUT:{
  1626. if(sep && sep->arg[0][0])
  1627. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1628. else
  1629. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1630. break;
  1631. }
  1632. case COMMAND_AUCTION:{
  1633. if(sep && sep->arg[0][0])
  1634. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1635. else
  1636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1637. break;
  1638. }
  1639. case COMMAND_OOC:{
  1640. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1641. if(sep && sep->arg[0][0])
  1642. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1643. else
  1644. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1645. break;
  1646. }
  1647. case COMMAND_EMOTE:{
  1648. if(sep && sep->arg[0][0])
  1649. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1650. else
  1651. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1652. break;
  1653. }
  1654. case COMMAND_RACE:{
  1655. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1656. if(sep->arg[1][0] && sep->IsNumber(1)){
  1657. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1658. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1659. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1660. client->GetPlayer()->SetCharSheetChanged(true);
  1661. }
  1662. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1663. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1664. //client->QueuePacket(outapp);
  1665. }
  1666. else{
  1667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1669. }
  1670. break;
  1671. }
  1672. case COMMAND_BANK_DEPOSIT:{
  1673. if(client->GetBanker() && sep && sep->arg[0]){
  1674. int64 amount = 0;
  1675. string deposit = string(sep->arg[0]);
  1676. amount = atoi64(deposit.c_str());
  1677. client->BankDeposit(amount);
  1678. }
  1679. break;
  1680. }
  1681. case COMMAND_BANK_WITHDRAWAL:{
  1682. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1683. int64 amount = 0;
  1684. string deposit = string(sep->arg[0]);
  1685. amount = atoi64(deposit.c_str());
  1686. client->BankWithdrawal(amount);
  1687. }
  1688. break;
  1689. }
  1690. case COMMAND_BANK_CANCEL:{
  1691. Spawn* banker = cmdTarget;
  1692. client->Bank(banker, true);
  1693. break;
  1694. }
  1695. case COMMAND_BANK:{
  1696. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1697. Spawn* banker = cmdTarget;
  1698. client->Bank(banker);
  1699. break;
  1700. }
  1701. case COMMAND_GUILD_BANK:{
  1702. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1703. //Spawn* banker = client->GetPlayer()->GetTarget();
  1704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1705. break;
  1706. }
  1707. case COMMAND_START_MAIL: {
  1708. client->SetMailTransaction(cmdTarget);
  1709. client->SendMailList();
  1710. break;
  1711. }
  1712. case COMMAND_CANCEL_MAIL: {
  1713. client->SetMailTransaction(0);
  1714. break;
  1715. }
  1716. case COMMAND_GET_MAIL_MESSAGE: {
  1717. if (sep && sep->arg[0] && sep->IsNumber(0))
  1718. client->DisplayMailMessage(atoul(sep->arg[0]));
  1719. break;
  1720. }
  1721. case COMMAND_ADD_MAIL_PLAT: {
  1722. if (sep && sep->arg[0] && sep->IsNumber(0))
  1723. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1724. break;
  1725. }
  1726. case COMMAND_ADD_MAIL_GOLD: {
  1727. if (sep && sep->arg[0] && sep->IsNumber(0))
  1728. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1729. break;
  1730. }
  1731. case COMMAND_ADD_MAIL_SILVER: {
  1732. if (sep && sep->arg[0] && sep->IsNumber(0))
  1733. client->AddMailCoin(0, atoul(sep->arg[0]));
  1734. break;
  1735. }
  1736. case COMMAND_ADD_MAIL_COPPER: {
  1737. if (sep && sep->arg[0] && sep->IsNumber(0))
  1738. client->AddMailCoin(atoul(sep->arg[0]));
  1739. break;
  1740. }
  1741. case COMMAND_SET_MAIL_ITEM: {
  1742. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1743. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1744. break;
  1745. }
  1746. case COMMAND_REMOVE_MAIL_PLAT: {
  1747. if (sep && sep->arg[0] && sep->IsNumber(0))
  1748. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1749. break;
  1750. }
  1751. case COMMAND_REMOVE_MAIL_GOLD: {
  1752. if (sep && sep->arg[0] && sep->IsNumber(0))
  1753. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1754. break;
  1755. }
  1756. case COMMAND_REMOVE_MAIL_SILVER: {
  1757. if (sep && sep->arg[0] && sep->IsNumber(0))
  1758. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1759. break;
  1760. }
  1761. case COMMAND_REMOVE_MAIL_COPPER: {
  1762. if (sep && sep->arg[0] && sep->IsNumber(0))
  1763. client->RemoveMailCoin(atoul(sep->arg[0]));
  1764. break;
  1765. }
  1766. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1767. if (sep && sep->arg[0] && sep->IsNumber(0))
  1768. client->TakeMailAttachments(atoul(sep->arg[0]));
  1769. break;
  1770. }
  1771. case COMMAND_CANCEL_SEND_MAIL: {
  1772. client->CancelSendMail();
  1773. break;
  1774. }
  1775. case COMMAND_DELETE_MAIL_MESSAGE: {
  1776. if (sep && sep->arg[0] && sep->IsNumber(0))
  1777. client->DeleteMail(atoul(sep->arg[0]), true);
  1778. break;
  1779. }
  1780. case COMMAND_REPORT_SPAM: {
  1781. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1782. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1783. break;
  1784. }
  1785. case COMMAND_KILL:{
  1786. Spawn* dead = 0;
  1787. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1788. dead=client->GetPlayer();
  1789. client->GetPlayer()->SetHP(0);
  1790. client->GetPlayer()->KillSpawn(dead);
  1791. }else{
  1792. dead= cmdTarget;
  1793. if(dead && dead->IsPlayer() == false){
  1794. dead->SetHP(0);
  1795. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1796. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1797. else
  1798. client->GetPlayer()->KillSpawn(dead);
  1799. }else{
  1800. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1801. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1802. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1803. }
  1804. }
  1805. break;
  1806. }
  1807. case COMMAND_LEVEL:{
  1808. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1809. int16 new_level = atoi(sep->arg[ndx]);
  1810. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1811. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1812. else {
  1813. if (new_level < 1)
  1814. new_level = 1;
  1815. if (new_level > 255)
  1816. new_level = 255;
  1817. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1818. client->GetPlayer()->SetXP(1);
  1819. client->GetPlayer()->SetNeededXP();
  1820. }
  1821. }else
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1823. break;
  1824. }
  1825. case COMMAND_SIT: {
  1826. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1827. if(client->GetPlayer()->GetHP() > 0){
  1828. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1829. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1830. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1831. }
  1832. break;
  1833. }
  1834. case COMMAND_STAND: {
  1835. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1836. if(client->GetPlayer()->GetHP() > 0){
  1837. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1838. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1839. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1840. }
  1841. break;
  1842. }
  1843. case COMMAND_CLASS:{
  1844. if(sep && sep->arg[ndx][0]){
  1845. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1846. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1847. }else
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1849. break;
  1850. }
  1851. case COMMAND_GENDER:{
  1852. if(sep && sep->arg[ndx][0]){
  1853. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1854. client->GetPlayer()->SetCharSheetChanged(true);
  1855. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1856. }else{
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1860. }
  1861. break;
  1862. }
  1863. case COMMAND_FLYMODE:{
  1864. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1865. PrintSep(sep, "COMMAND_FLYMODE");
  1866. int8 val = atoi(sep->arg[0]);
  1867. ClientPacketFunctions::SendFlyMode(client, val);
  1868. }
  1869. else{
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1872. }
  1873. break;
  1874. }
  1875. case COMMAND_LOOT_LIST:{
  1876. Spawn* spawn = cmdTarget;
  1877. if(spawn && spawn->IsEntity()){
  1878. if (sep && sep->arg[0]) {
  1879. if (!spawn->GetDatabaseID())
  1880. {
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1882. break;
  1883. }
  1884. else if (!spawn->IsNPC())
  1885. {
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1887. break;
  1888. }
  1889. bool reloadLoot = false;
  1890. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1891. {
  1892. int32 loottable_id = atoul(sep->arg[1]);
  1893. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1894. {
  1895. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1896. reloadLoot = true;
  1897. }
  1898. else
  1899. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1900. }
  1901. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0)
  1905. {
  1906. database.AddLootTableToSpawn(spawn, loottable_id);
  1907. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1908. reloadLoot = true;
  1909. }
  1910. else
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1912. }
  1913. else if (!stricmp(sep->arg[0], "clearall"))
  1914. {
  1915. if (database.RemoveSpawnLootTable(spawn, 0))
  1916. {
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1918. reloadLoot = true;
  1919. }
  1920. else
  1921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1922. }
  1923. else
  1924. {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1929. break;
  1930. }
  1931. if (reloadLoot)
  1932. {
  1933. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1934. if (spawn->IsNPC())
  1935. {
  1936. Entity* ent = (Entity*)spawn;
  1937. ent->SetLootCoins(0);
  1938. ent->ClearLootList();
  1939. spawn->GetZone()->AddLoot((NPC*)spawn);
  1940. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1941. }
  1942. }
  1943. break; // nothing further this is the end of these sub commands
  1944. }
  1945. else
  1946. {
  1947. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1948. if (loot_list.size() > 0) {
  1949. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1950. vector<int32>::iterator list_itr;
  1951. LootTable* table = 0;
  1952. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1953. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1954. if (table)
  1955. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1956. }
  1957. }
  1958. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  1959. vector<Item*>* items = spawn->GetLootItems();
  1960. if (items) {
  1961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1962. vector<Item*>::iterator itr;
  1963. Item* item = 0;
  1964. for (itr = items->begin(); itr != items->end(); itr++) {
  1965. item = *itr;
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1967. }
  1968. }
  1969. else
  1970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1971. }
  1972. }
  1973. break;
  1974. }
  1975. case COMMAND_LOOT_SETCOIN:{
  1976. Spawn* spawn = cmdTarget;
  1977. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1978. spawn->SetLootCoins(atoul(sep->arg[0]));
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1980. }
  1981. else
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1983. break;
  1984. }
  1985. case COMMAND_LOOT_ADDITEM:{
  1986. Spawn* spawn = cmdTarget;
  1987. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1988. int16 charges = 1;
  1989. if(sep->arg[1] && sep->IsNumber(1))
  1990. charges = atoi(sep->arg[1]);
  1991. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1993. }
  1994. else
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1996. break;
  1997. }
  1998. case COMMAND_LOOT_REMOVEITEM:{
  1999. Spawn* spawn = cmdTarget;
  2000. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2001. spawn->LootItem(atoul(sep->arg[0]));
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2003. }
  2004. else
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2006. break;
  2007. }
  2008. case COMMAND_LOOT_CORPSE:
  2009. case COMMAND_DISARM:
  2010. case COMMAND_LOOT:{
  2011. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2012. {
  2013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2014. break;
  2015. }
  2016. if(cmdTarget && cmdTarget->IsEntity()){
  2017. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2018. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2019. client->OpenChest(cmdTarget, true);
  2020. else
  2021. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2022. if (!(cmdTarget)->HasLoot()){
  2023. if (((Entity*)cmdTarget)->IsNPC())
  2024. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2025. }
  2026. }
  2027. else
  2028. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2029. }
  2030. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2032. break;
  2033. }
  2034. case COMMAND_RELOADSPAWNSCRIPTS:{
  2035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2036. if (lua_interface)
  2037. lua_interface->SetSpawnScriptsReloading(true);
  2038. world.ResetSpawnScripts();
  2039. database.LoadSpawnScriptData();
  2040. if(lua_interface) {
  2041. lua_interface->DestroySpawnScripts();
  2042. lua_interface->SetSpawnScriptsReloading(false);
  2043. }
  2044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2045. break;
  2046. }
  2047. case COMMAND_RELOADLUASYSTEM:{
  2048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2049. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2050. safe_delete(lua_interface);
  2051. lua_interface = new LuaInterface();
  2052. if(lua_interface)
  2053. lua_interface->SetSpawnScriptsReloading(true);
  2054. if(lua_interface && debug_clients.size() > 0){
  2055. map<Client*, int32>::iterator itr;
  2056. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2057. if(lua_interface)
  2058. lua_interface->UpdateDebugClients(itr->first);
  2059. }
  2060. }
  2061. world.ResetSpawnScripts();
  2062. database.LoadSpawnScriptData();
  2063. world.ResetZoneScripts();
  2064. database.LoadZoneScriptData();
  2065. int32 quest_count = database.LoadQuests();
  2066. zone_list.DeleteSpellProcess();
  2067. master_spell_list.Reload();
  2068. int32 spell_count = 0;
  2069. if(lua_interface) {
  2070. lua_interface->DestroySpawnScripts();
  2071. lua_interface->DestroySpells();
  2072. spell_count = database.LoadSpellScriptData();
  2073. lua_interface->SetSpawnScriptsReloading(false);
  2074. }
  2075. zone_list.LoadSpellProcess();
  2076. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2077. break;
  2078. }
  2079. case COMMAND_DECLINE_QUEST:{
  2080. int32 quest_id = 0;
  2081. if(sep && sep->arg[0] && sep->IsNumber(0))
  2082. quest_id = atoul(sep->arg[0]);
  2083. if(quest_id > 0){
  2084. Quest* quest = client->GetPendingQuest(quest_id);
  2085. if(quest){
  2086. client->RemovePendingQuest(quest);
  2087. if(lua_interface)
  2088. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2089. safe_delete(quest);
  2090. client->GetCurrentZone()->SendQuestUpdates(client);
  2091. }
  2092. }
  2093. break;
  2094. }
  2095. case COMMAND_DELETE_QUEST:{
  2096. int32 quest_id = 0;
  2097. if(sep && sep->arg[0] && sep->IsNumber(0))
  2098. quest_id = atoul(sep->arg[0]);
  2099. if(quest_id > 0){
  2100. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2101. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2102. if (quest)
  2103. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2104. }
  2105. client->RemovePlayerQuest(quest_id);
  2106. client->GetCurrentZone()->SendQuestUpdates(client);
  2107. }
  2108. break;
  2109. }
  2110. case COMMAND_ACCEPT_QUEST:{
  2111. int32 quest_id = 0;
  2112. if(sep && sep->arg[0] && sep->IsNumber(0))
  2113. quest_id = atoul(sep->arg[0]);
  2114. if(quest_id > 0){
  2115. client->AcceptQuest(quest_id);
  2116. }
  2117. break;
  2118. }
  2119. case COMMAND_NAME:{
  2120. if(sep && sep->arg[ndx][0]){
  2121. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2122. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2123. client->GetPlayer()->SetCharSheetChanged(true);
  2124. }else
  2125. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2126. break;
  2127. }
  2128. case COMMAND_GROUPSAY:{
  2129. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2130. if(sep && sep->arg[0] && gmi)
  2131. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2132. break;
  2133. }
  2134. case COMMAND_GROUPINVITE: {
  2135. Entity* target = 0;
  2136. Client* target_client = 0;
  2137. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2138. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2139. return;
  2140. }
  2141. // name provided with command so it has to be a player, npc not supported here
  2142. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2143. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2144. if (target_client) {
  2145. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2146. target = 0;
  2147. else
  2148. target = target_client->GetPlayer();
  2149. }
  2150. }
  2151. // if name was not provided use the players target, npc or player supported here
  2152. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2153. target = (Entity*)client->GetPlayer()->GetTarget();
  2154. if (target->IsPlayer()) {
  2155. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2156. }
  2157. }
  2158. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2159. if (result == 0) {
  2160. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2161. if (target_client) {
  2162. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2163. if (packet) {
  2164. packet->setDataByName("type", 1);
  2165. packet->setDataByName("name", client->GetPlayer()->GetName());
  2166. packet->setDataByName("unknown2", 1);
  2167. target_client->QueuePacket(packet->serialize());
  2168. safe_delete(packet);
  2169. }
  2170. }
  2171. }
  2172. else if (result == 1)
  2173. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2174. else if (result == 2)
  2175. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2176. else if (result == 3)
  2177. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2178. else if (result == 4)
  2179. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2180. else if (result == 5)
  2181. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2182. else if (result == 6)
  2183. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2184. else
  2185. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2186. break;
  2187. }
  2188. case COMMAND_GROUPDISBAND: {
  2189. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2190. if (gmi) { // TODO: Leader check
  2191. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2192. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2193. }
  2194. break;
  2195. }
  2196. case COMMAND_GROUP_LEAVE: {
  2197. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2198. if (gmi) {
  2199. int32 group_id = gmi->group_id;
  2200. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2201. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2202. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2203. }
  2204. else {
  2205. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2206. }
  2207. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2208. }
  2209. break;
  2210. }
  2211. case COMMAND_FRIEND_ADD:{
  2212. string name = "";
  2213. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2214. name = database.GetPlayerName(sep->arg[0]);
  2215. else if(cmdTarget && cmdTarget->IsPlayer())
  2216. name = string(cmdTarget->GetName());
  2217. if(name.length() > 0){
  2218. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2219. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2220. client->GetPlayer()->RemoveIgnore(name.c_str());
  2221. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2222. client->SendChatRelationship(3, name.c_str());
  2223. }
  2224. client->GetPlayer()->AddFriend(name.c_str(), true);
  2225. client->SendChatRelationship(0, name.c_str());
  2226. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2227. if(zone_list.GetClientByCharName(name))
  2228. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2229. }
  2230. else
  2231. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2232. }
  2233. else
  2234. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2235. break;
  2236. }
  2237. case COMMAND_FRIEND_REMOVE:{
  2238. string name = "";
  2239. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2240. name = database.GetPlayerName(sep->arg[0]);
  2241. else if(cmdTarget && cmdTarget->IsPlayer())
  2242. name = string(cmdTarget->GetName());
  2243. if(name.length() > 0){
  2244. client->GetPlayer()->RemoveFriend(name.c_str());
  2245. client->SendChatRelationship(1, name.c_str());
  2246. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2247. }
  2248. else
  2249. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2250. break;
  2251. }
  2252. case COMMAND_FRIENDS:{
  2253. break;
  2254. }
  2255. case COMMAND_IGNORE_ADD:{
  2256. string name = "";
  2257. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2258. name = database.GetPlayerName(sep->arg[0]);
  2259. else if(cmdTarget && cmdTarget->IsPlayer())
  2260. name = string(cmdTarget->GetName());
  2261. if(name.length() > 0){
  2262. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2263. if(client->GetPlayer()->IsFriend(name.c_str())){
  2264. client->GetPlayer()->RemoveFriend(name.c_str());
  2265. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2266. client->SendChatRelationship(1, name.c_str());
  2267. }
  2268. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2269. client->SendChatRelationship(2, name.c_str());
  2270. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2271. }
  2272. else
  2273. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2274. }
  2275. else
  2276. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2277. break;
  2278. }
  2279. case COMMAND_IGNORE_REMOVE:{
  2280. string name = "";
  2281. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2282. name = database.GetPlayerName(sep->arg[0]);
  2283. else if(cmdTarget && cmdTarget->IsPlayer())
  2284. name = string(cmdTarget->GetName());
  2285. if(name.length() > 0){
  2286. client->GetPlayer()->RemoveIgnore(name.c_str());
  2287. client->SendChatRelationship(3, name.c_str());
  2288. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2289. }
  2290. break;
  2291. }
  2292. case COMMAND_IGNORES:{
  2293. break;
  2294. }
  2295. case COMMAND_GROUP_KICK:{
  2296. Entity* kicked = 0;
  2297. Client* kicked_client = 0;
  2298. int32 group_id = 0;
  2299. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2300. return;
  2301. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2302. if (sep && sep->arg[0]) {
  2303. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2304. if (kicked_client)
  2305. kicked = kicked_client->GetPlayer();
  2306. }
  2307. else if (cmdTarget && cmdTarget->IsEntity()) {
  2308. kicked = (Entity*)cmdTarget;
  2309. }
  2310. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2311. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2312. if (kicked)
  2313. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2314. if(send_kicked_message)
  2315. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2316. else
  2317. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2318. if (kicked_client)
  2319. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2320. break;
  2321. }
  2322. case COMMAND_GROUP_MAKE_LEADER:{
  2323. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2324. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2325. return;
  2326. }
  2327. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2328. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2329. if (new_leader) {
  2330. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2331. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2332. }
  2333. }
  2334. else
  2335. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2336. }
  2337. else if (cmdTarget && cmdTarget->IsPlayer())
  2338. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2339. else
  2340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2341. break;
  2342. }
  2343. case COMMAND_GROUP_ACCEPT_INVITE: {
  2344. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2345. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2346. if (result == 0)
  2347. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2348. else if (result == 1)
  2349. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2350. else if (result == 2)
  2351. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2352. else
  2353. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2354. }
  2355. break;
  2356. }
  2357. case COMMAND_GROUP_DECLINE_INVITE: {
  2358. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2359. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2360. }
  2361. break;
  2362. }
  2363. case COMMAND_SUMMON:{
  2364. char* search_name = 0;
  2365. if(sep && sep->arg[0][0])
  2366. search_name = sep->arg[0];
  2367. if(!search_name && !cmdTarget){
  2368. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2369. 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.");
  2370. }
  2371. else{
  2372. if(!client->Summon(search_name))
  2373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2374. }
  2375. break;
  2376. }
  2377. case COMMAND_GOTO:{
  2378. const char* search_name = 0;
  2379. if(sep && sep->arg[0][0])
  2380. search_name = sep->argplus[0];
  2381. if(!search_name && !cmdTarget){
  2382. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2383. 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.");
  2384. }
  2385. else{
  2386. if(!client->GotoSpawn(search_name))
  2387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2388. }
  2389. break;
  2390. }
  2391. case COMMAND_MOVE:{
  2392. bool success = false;
  2393. try{
  2394. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2395. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2396. if(app){
  2397. client->QueuePacket(app);
  2398. success = true;
  2399. }
  2400. }
  2401. }
  2402. catch(...){}
  2403. if(!success){
  2404. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2405. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2406. }
  2407. break;
  2408. }
  2409. case COMMAND_SETTIME:{
  2410. if(sep && sep->arg[0]){
  2411. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2412. if(sep->arg[1] && sep->IsNumber(1))
  2413. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2414. if(sep->arg[2] && sep->IsNumber(2))
  2415. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2416. if(sep->arg[3] && sep->IsNumber(3))
  2417. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2418. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2419. }
  2420. else{
  2421. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2422. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2423. }
  2424. break;
  2425. }
  2426. case COMMAND_VERSION:{
  2427. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2428. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2429. break;
  2430. }
  2431. case COMMAND_ZONE:{
  2432. string* zonename = 0;
  2433. int32 instanceID = 0;
  2434. const char* zone = 0;
  2435. int32 zone_id = 0;
  2436. bool listSearch = false;
  2437. bool isInstance = false;
  2438. ZoneServer* zsZone = 0;
  2439. if(sep && sep->arg[0][0])
  2440. {
  2441. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2442. listSearch = true;
  2443. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2444. {
  2445. zone_list.SendZoneList(client);
  2446. break;
  2447. }
  2448. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2449. {
  2450. if(sep->IsNumber(1))
  2451. instanceID = atol(sep->arg[1]);
  2452. }
  2453. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2454. {
  2455. PrintSep(sep, "ZONE LOCK");
  2456. if(sep->IsNumber(1))
  2457. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2458. else
  2459. zsZone = zone_list.Get(sep->arg[1], false);
  2460. if( zsZone )
  2461. {
  2462. zsZone->SetZoneLockState(true);
  2463. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2464. }
  2465. else
  2466. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2467. break;
  2468. }
  2469. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2470. {
  2471. PrintSep(sep, "ZONE UNLOCK");
  2472. if(sep->IsNumber(1))
  2473. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2474. else
  2475. zsZone = zone_list.Get(sep->arg[1], false);
  2476. if( zsZone )
  2477. {
  2478. zsZone->SetZoneLockState(false);
  2479. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2480. }
  2481. else
  2482. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2483. break;
  2484. }
  2485. else
  2486. {
  2487. if(sep->IsNumber(0))
  2488. {
  2489. zone_id = atoul(sep->arg[0]);
  2490. zonename = database.GetZoneName(zone_id);
  2491. if(zonename)
  2492. zone = zonename->c_str();
  2493. }
  2494. else
  2495. zone = sep->arg[0];
  2496. }
  2497. if(instanceID > 0)
  2498. {
  2499. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2500. if(zsInstance != NULL)
  2501. {
  2502. instanceID = zsInstance->GetInstanceID();
  2503. zone = zsInstance->GetZoneName();
  2504. zone_id = zsInstance->GetZoneID();
  2505. isInstance = true;
  2506. }
  2507. }
  2508. }
  2509. if(!listSearch)
  2510. {
  2511. if(!zone)
  2512. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2513. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2514. zone_id != client->GetCurrentZone()->GetZoneID())
  2515. {
  2516. if(database.VerifyZone(zone))
  2517. {
  2518. if(client->CheckZoneAccess(zone))
  2519. {
  2520. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2521. if(isInstance)
  2522. client->Zone(instanceID,true,true);
  2523. else
  2524. client->Zone(zone);
  2525. }
  2526. }
  2527. else
  2528. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2529. }
  2530. else
  2531. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2532. }
  2533. else
  2534. {
  2535. const char* name = 0;
  2536. if(sep && sep->arg[1][0])
  2537. {
  2538. map<int32, string>* zone_names;
  2539. name = sep->argplus[1];
  2540. sint16 status = client->GetAdminStatus();
  2541. if( status > 0 )
  2542. {
  2543. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2544. zone_names = database.GetZoneList(name, true);
  2545. }
  2546. else
  2547. zone_names = database.GetZoneList(name);
  2548. if(!zone_names)
  2549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2550. else
  2551. {
  2552. map<int32, string>::iterator itr;
  2553. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2554. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2555. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2556. safe_delete(zone_names);
  2557. }
  2558. }
  2559. else
  2560. {
  2561. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2562. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2563. }
  2564. }
  2565. safe_delete(zonename);
  2566. break;
  2567. }
  2568. case COMMAND_USE: {
  2569. Spawn* target = cmdTarget;
  2570. if (target->IsWidget())
  2571. ((Widget*)target)->HandleUse(client, "use");
  2572. break;
  2573. }
  2574. case COMMAND_OPEN: {
  2575. Spawn* target = cmdTarget;
  2576. if (target->IsWidget())
  2577. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2578. break;
  2579. }
  2580. case COMMAND_CASTSPELL: {
  2581. if (sep && sep->arg[0] && sep->IsNumber(0))
  2582. {
  2583. int8 tier = 1;
  2584. if (sep->arg[1] && sep->IsNumber(1))
  2585. tier = atoul(sep->arg[1]);
  2586. int32 spellid = atoul(sep->arg[0]);
  2587. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2588. if (spell)
  2589. {
  2590. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2591. SpellProcess* spellProcess = 0;
  2592. // Get the current zones spell process
  2593. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2594. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2595. }
  2596. else
  2597. {
  2598. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2599. }
  2600. }
  2601. else if (sep && sep->arg[0])
  2602. {
  2603. database.FindSpell(client, (char*)sep->argplus[0]);
  2604. }
  2605. else
  2606. {
  2607. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2608. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2609. }
  2610. break;
  2611. }
  2612. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2613. if (client->GetVersion() <= 546)
  2614. break;
  2615. if (sep && sep->GetArgNumber() == 4)
  2616. {
  2617. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2618. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2619. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2620. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2621. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2622. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2623. ClientPacketFunctions::SendSkillSlotMappings(client);
  2624. }
  2625. else
  2626. {
  2627. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2628. }
  2629. break;
  2630. }
  2631. case COMMAND_MOVE_ITEM:
  2632. {
  2633. int32 id = 0;
  2634. if (sep->IsNumber(0))
  2635. id = atoul(sep->arg[0]);
  2636. Spawn* spawn = 0;
  2637. if (id == 0)
  2638. {
  2639. spawn = cmdTarget;
  2640. }
  2641. else
  2642. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2643. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2644. break;
  2645. client->SendMoveObjectMode(spawn, 0);
  2646. break;
  2647. }
  2648. case COMMAND_PICKUP:
  2649. {
  2650. int32 id = 0;
  2651. if (sep->IsNumber(0))
  2652. id = atoul(sep->arg[0]);
  2653. Spawn* spawn = 0;
  2654. if (id == 0)
  2655. {
  2656. spawn = cmdTarget;
  2657. }
  2658. else
  2659. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2660. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2661. break;
  2662. client->AddItem(spawn->GetPickupItemID(), 1);
  2663. Query query;
  2664. 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());
  2665. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2666. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2667. }
  2668. // we had a UI Window displayed, update the house items
  2669. if ( id > 0 )
  2670. client->GetCurrentZone()->SendHouseItems(client);
  2671. break;
  2672. }
  2673. case COMMAND_HOUSE_DEPOSIT:
  2674. {
  2675. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2676. // arg0 = ??? (set to 3)
  2677. // arg1 = coin (in copper)
  2678. // arg2 = status? (not implemented yet)
  2679. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2680. if (ph && sep && sep->IsNumber(1))
  2681. {
  2682. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2683. if (client->GetPlayer()->RemoveCoins(outVal))
  2684. {
  2685. char query[256];
  2686. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2687. if (itr != ph->depositsMap.end())
  2688. {
  2689. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2690. }
  2691. else
  2692. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2693. if (database.RunQuery(query, strnlen(query, 256)))
  2694. {
  2695. ph->escrow_coins += outVal;
  2696. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2697. database.LoadDeposits(ph);
  2698. client->PlaySound("coin_cha_ching");
  2699. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2700. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2701. }
  2702. else
  2703. {
  2704. client->GetPlayer()->AddCoins(outVal);
  2705. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2706. }
  2707. }
  2708. }
  2709. break;
  2710. }
  2711. case COMMAND_HOUSE:
  2712. {
  2713. if (sep && sep->IsNumber(0))
  2714. {
  2715. int32 unique_id = atoi(sep->arg[0]);
  2716. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2717. HouseZone* hz = 0;
  2718. if (ph)
  2719. hz = world.GetHouseZone(ph->house_id);
  2720. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2721. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2722. }
  2723. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2724. {
  2725. // inside a house or something? Send the access window
  2726. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2727. HouseZone* hz = 0;
  2728. if ( ph )
  2729. hz = world.GetHouseZone(ph->house_id);
  2730. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2731. client->GetCurrentZone()->SendHouseItems(client);
  2732. }
  2733. break;
  2734. }
  2735. case COMMAND_HOUSE_UI:
  2736. {
  2737. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2738. {
  2739. int32 unique_id = atoi(sep->arg[0]);
  2740. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2741. HouseZone* hz = 0;
  2742. if ( ph )
  2743. hz = world.GetHouseZone(ph->house_id);
  2744. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2745. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2746. }
  2747. break;
  2748. }
  2749. case COMMAND_PLACE_HOUSE_ITEM: {
  2750. if (sep && sep->IsNumber(0))
  2751. {
  2752. int32 uniqueid = atoi(sep->arg[0]);
  2753. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2754. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2755. if (item && item->IsHouseItem())
  2756. {
  2757. if (!client->HasOwnerOrEditAccess())
  2758. {
  2759. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2760. break;
  2761. }
  2762. else if (!item->generic_info.appearance_id)
  2763. {
  2764. 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);
  2765. break;
  2766. }
  2767. if (client->GetTempPlacementSpawn())
  2768. {
  2769. Spawn* tmp = client->GetTempPlacementSpawn();
  2770. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2771. delete tmp;
  2772. client->SetTempPlacementSpawn(nullptr);
  2773. }
  2774. Spawn* spawn = new Object();
  2775. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2776. spawn->SetID(Spawn::NextID());
  2777. spawn->SetX(client->GetPlayer()->GetX());
  2778. spawn->SetY(client->GetPlayer()->GetY());
  2779. spawn->SetZ(client->GetPlayer()->GetZ());
  2780. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2781. spawn->SetSpawnOrigX(spawn->GetX());
  2782. spawn->SetSpawnOrigY(spawn->GetY());
  2783. spawn->SetSpawnOrigZ(spawn->GetZ());
  2784. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2785. spawn->appearance.targetable = 1;
  2786. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2787. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2788. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2789. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2790. spawn->SetZone(client->GetCurrentZone());
  2791. client->GetCurrentZone()->SendSpawn(spawn, client);
  2792. client->SetTempPlacementSpawn(spawn);
  2793. client->SetPlacementUniqueItemID(uniqueid);
  2794. client->SendMoveObjectMode(spawn, 0);
  2795. }
  2796. }
  2797. break;
  2798. }
  2799. case COMMAND_GM:
  2800. {
  2801. if (sep->arg[0] && sep->arg[1])
  2802. {
  2803. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2804. if (strcmp(sep->arg[0], "vision") == 0)
  2805. {
  2806. client->GetPlayer()->SetGMVision(onOff);
  2807. #if defined(__GNUC__)
  2808. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2809. #else
  2810. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2811. #endif
  2812. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2813. if (onOff)
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2815. else
  2816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2817. }
  2818. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2819. {
  2820. client->SetLuaDebugClient(onOff);
  2821. #if defined(__GNUC__)
  2822. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2823. #else
  2824. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2825. #endif
  2826. if (onOff)
  2827. {
  2828. if (lua_interface)
  2829. lua_interface->UpdateDebugClients(client);
  2830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2831. }
  2832. else
  2833. {
  2834. if (lua_interface)
  2835. lua_interface->RemoveDebugClients(client);
  2836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2837. }
  2838. }
  2839. }
  2840. break;
  2841. }
  2842. case COMMAND_ATTACK:
  2843. case COMMAND_AUTO_ATTACK:{
  2844. int8 type = 1;
  2845. Player* player = client->GetPlayer();
  2846. if(!player)
  2847. break;
  2848. bool incombat = player->EngagedInCombat();
  2849. if(sep && sep->arg[0] && sep->IsNumber(0))
  2850. type = atoi(sep->arg[0]);
  2851. if(client->GetPlayer()->GetHP() == 0){
  2852. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2853. break;
  2854. }
  2855. if(type == 0){
  2856. if(incombat)
  2857. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2858. player->InCombat(false);
  2859. player->InCombat(false, true);
  2860. player->SetRangeAttack(false);
  2861. }
  2862. else {
  2863. if(type == 2){
  2864. player->InCombat(false);
  2865. if(incombat && player->GetRangeAttack()){
  2866. player->SetRangeAttack(false);
  2867. player->InCombat(false, true);
  2868. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2869. }
  2870. else{
  2871. player->SetRangeAttack(true);
  2872. player->InCombat(true, true);
  2873. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2874. }
  2875. }
  2876. else {
  2877. player->InCombat(false, true);
  2878. player->SetRangeAttack(false);
  2879. player->InCombat(true);
  2880. if(!incombat)
  2881. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2882. }
  2883. /*else
  2884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2885. }
  2886. player->SetCharSheetChanged(true);
  2887. break;
  2888. }
  2889. case COMMAND_DEPOP:{
  2890. bool allow_respawns = false;
  2891. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2892. if(atoi(sep->arg[0]) == 1)
  2893. allow_respawns = true;
  2894. }
  2895. client->GetCurrentZone()->Depop(allow_respawns);
  2896. break;
  2897. }
  2898. case COMMAND_REPOP:{
  2899. client->GetCurrentZone()->Depop(false, true);
  2900. break;
  2901. }
  2902. case COMMAND_BUYBACK:{
  2903. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2904. // 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
  2905. int64 id = atoi64(sep->arg[0]);
  2906. // get the first int32, the item id
  2907. //int32 item_id = (int32)id;
  2908. // get the second int32, the unique id
  2909. int32 unique_id = (int32)(id>>32);
  2910. int8 quantity = atoi(sep->arg[1]);
  2911. if(quantity == 255)
  2912. quantity = 1;
  2913. client->BuyBack(unique_id, quantity);
  2914. }
  2915. break;
  2916. }
  2917. case COMMAND_MERCHANT_BUY:{
  2918. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2919. int32 item_id = atoul(sep->arg[0]);
  2920. int8 quantity = atoi(sep->arg[1]);
  2921. client->BuyItem(item_id, quantity);
  2922. }
  2923. break;
  2924. }
  2925. case COMMAND_MERCHANT_SELL:{
  2926. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2927. // 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
  2928. int64 id = atoi64(sep->arg[0]);
  2929. // get the first int32, the item id
  2930. int32 item_id = (int32)id;
  2931. // get the second int32, the unique id
  2932. int32 unique_id = (int32)(id>>32);
  2933. int8 quantity = atoi(sep->arg[1]);
  2934. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2935. client->SellItem(item_id, quantity, unique_id);
  2936. }
  2937. break;
  2938. }
  2939. case COMMAND_MENDER_REPAIR: {
  2940. if (sep && sep->arg[0] && sep->IsNumber(0))
  2941. client->RepairItem(atoul(sep->arg[0]));
  2942. break;
  2943. }
  2944. case COMMAND_MENDER_REPAIR_ALL: {
  2945. client->RepairAllItems();
  2946. break;
  2947. }
  2948. case COMMAND_CANCEL_MERCHANT:{
  2949. client->SetMerchantTransaction(0);
  2950. break;
  2951. }
  2952. case COMMAND_START_MERCHANT:{
  2953. break;
  2954. }
  2955. case COMMAND_INVULNERABLE:{
  2956. sint8 val = -1;
  2957. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2958. val = atoi(sep->arg[0]);
  2959. //devn00b: Fix for linux builds
  2960. #if defined(__GNUC__)
  2961. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2962. #else
  2963. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2964. #endif
  2965. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2966. client->GetPlayer()->SetInvulnerable(val==1);
  2967. if(client->GetPlayer()->GetInvulnerable())
  2968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2969. else
  2970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2971. }
  2972. if(val == -1)
  2973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2974. break;
  2975. }
  2976. case COMMAND_REPAIR: {
  2977. Spawn* spawn = cmdTarget;
  2978. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2979. client->SendHailCommand(spawn);
  2980. client->SetMerchantTransaction(spawn);
  2981. client->SendRepairList();
  2982. }
  2983. break;
  2984. }
  2985. case COMMAND_LOTTO: {
  2986. Spawn* spawn = cmdTarget;
  2987. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2988. client->SetMerchantTransaction(spawn);
  2989. client->ShowLottoWindow();
  2990. }
  2991. break;
  2992. }
  2993. case COMMAND_ACCEPT_REWARD:{
  2994. int32 unknown = 0;
  2995. int32 selectable_item_id = 0;
  2996. //Quest *quest = 0;
  2997. Collection *collection = 0;
  2998. /* no idea what the first argument is for (faction maybe?)
  2999. if the reward has a selectable item reward, it's sent as the second argument
  3000. if neither of these are included in the reward, there is no sep
  3001. 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
  3002. only 1 quest or collection reward may be displayed at a time */
  3003. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3004. unknown = atoul(sep->arg[0]);
  3005. selectable_item_id = atoul(sep->arg[1]);
  3006. }
  3007. //if ((quest = player->GetPendingQuestReward()))
  3008. // client->AcceptQuestRewards(quest, selectable_item_id);
  3009. /* the below needs to go away eventually and be redone */
  3010. int32 item_id = 0;
  3011. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3012. item_id = atoul(sep->arg[0]);
  3013. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3014. if(quest){
  3015. client->AcceptQuestReward(quest, item_id);
  3016. break;
  3017. }
  3018. if (collection = player->GetPendingCollectionReward())
  3019. client->AcceptCollectionRewards(collection, selectable_item_id);
  3020. else
  3021. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3022. break;
  3023. }
  3024. case COMMAND_BUY_FROM_BROKER:{
  3025. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3026. int32 item_id = atoul(sep->arg[0]);
  3027. int16 quantity = atoul(sep->arg[1]);
  3028. client->AddItem(item_id, quantity);
  3029. }
  3030. break;
  3031. }
  3032. case COMMAND_SEARCH_STORES_PAGE:{
  3033. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3034. int32 page = atoul(sep->arg[0]);
  3035. client->SearchStore(page);
  3036. }
  3037. break;
  3038. }
  3039. case COMMAND_SEARCH_STORES:{
  3040. if(sep && sep->arg[0][0]){
  3041. const char* values = sep->argplus[0];
  3042. if(values){
  3043. map<string, string> str_values = TranslateBrokerRequest(values);
  3044. vector<Item*>* items = master_item_list.GetItems(str_values);
  3045. if(items){
  3046. client->SetItemSearch(items);
  3047. client->SearchStore(0);
  3048. }
  3049. }
  3050. }
  3051. break;
  3052. }
  3053. case COMMAND_LUADEBUG:{
  3054. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3055. client->SetLuaDebugClient(true);
  3056. if(lua_interface)
  3057. lua_interface->UpdateDebugClients(client);
  3058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3059. }
  3060. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3061. client->SetLuaDebugClient(false);
  3062. if(lua_interface)
  3063. lua_interface->RemoveDebugClients(client);
  3064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3065. }
  3066. else{
  3067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3069. }
  3070. break;
  3071. }
  3072. case COMMAND_SPAWN_GROUP:
  3073. {
  3074. Spawn* target = cmdTarget;
  3075. if(target && target->IsPlayer() == false)
  3076. {
  3077. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3078. {
  3079. if(target->GetSpawnLocationPlacementID() > 0)
  3080. {
  3081. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3082. {
  3083. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3084. if(id > 0)
  3085. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3086. else
  3087. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3088. target->SetSpawnGroupID(id);
  3089. target->AddSpawnToGroup(target);
  3090. }
  3091. else
  3092. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3093. }
  3094. else
  3095. 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.");
  3096. }
  3097. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3098. {
  3099. if(sep->arg[1] && sep->IsNumber(1))
  3100. {
  3101. int32 group_id = atoul(sep->arg[1]);
  3102. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3103. if(leader)
  3104. {
  3105. leader->AddSpawnToGroup(target);
  3106. target->SetSpawnGroupID(group_id);
  3107. if(database.SpawnGroupAddSpawn(target, group_id))
  3108. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3109. else
  3110. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3111. }
  3112. else
  3113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3114. }
  3115. else
  3116. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3117. }
  3118. else if(target->GetSpawnGroupID() == 0)
  3119. {
  3120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3121. }
  3122. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3123. {
  3124. int32 group_id = target->GetSpawnGroupID();
  3125. target->RemoveSpawnFromGroup();
  3126. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3127. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3128. else
  3129. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3130. }
  3131. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3132. {
  3133. int32 group_id = target->GetSpawnGroupID();
  3134. if(sep->arg[1] && sep->IsNumber(1))
  3135. {
  3136. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3137. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3138. else
  3139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3140. }
  3141. else
  3142. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3143. }
  3144. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3145. {
  3146. int32 group_id = target->GetSpawnGroupID();
  3147. if(sep->arg[1] && sep->IsNumber(1))
  3148. {
  3149. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3150. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3151. else
  3152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3153. }
  3154. else
  3155. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3156. }
  3157. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3158. {
  3159. if(sep->arg[1] && sep->IsNumber(1))
  3160. {
  3161. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3162. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3163. else
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3165. }
  3166. else
  3167. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3168. }
  3169. else
  3170. {
  3171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3172. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3173. }
  3174. }
  3175. else
  3176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3177. break;
  3178. }
  3179. case COMMAND_SPAWN_COMBINE:{
  3180. Spawn* spawn = cmdTarget;
  3181. float radius = 0;
  3182. bool failed = true;
  3183. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3184. failed = false;
  3185. if(spawn->GetSpawnGroupID() > 0){
  3186. 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.");
  3187. }
  3188. else if(sep->IsNumber(0)){
  3189. radius = atof(sep->arg[0]);
  3190. client->CombineSpawns(radius, spawn);
  3191. }
  3192. else{
  3193. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3194. client->AddCombineSpawn(spawn);
  3195. }
  3196. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3197. client->RemoveCombineSpawn(spawn);
  3198. }
  3199. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3200. const char* name = 0;
  3201. if(sep->arg[1] && sep->arg[1][0])
  3202. name = sep->argplus[1];
  3203. client->SaveCombineSpawns(name);
  3204. }
  3205. else
  3206. failed = true;
  3207. }
  3208. }
  3209. if(failed){
  3210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3211. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3212. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3213. }
  3214. break;
  3215. }
  3216. case COMMAND_SPAWN_CREATE:{
  3217. Spawn* spawn = 0;
  3218. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3219. spawn = new Object();
  3220. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3221. }
  3222. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3223. spawn = new GroundSpawn();
  3224. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3225. }
  3226. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3227. spawn = new Sign();
  3228. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3229. }
  3230. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3231. spawn = new NPC();
  3232. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3233. spawn->appearance.pos.collision_radius = 32;
  3234. spawn->secondary_command_list_id = 0;
  3235. spawn->primary_command_list_id = 0;
  3236. spawn->appearance.display_name = 1;
  3237. spawn->appearance.show_level = 1;
  3238. spawn->appearance.attackable = 1;
  3239. }
  3240. else{
  3241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3242. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3243. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3244. break;
  3245. }
  3246. spawn->SetID(Spawn::NextID());
  3247. spawn->SetX(client->GetPlayer()->GetX());
  3248. spawn->SetY(client->GetPlayer()->GetY());
  3249. spawn->SetZ(client->GetPlayer()->GetZ());
  3250. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3251. spawn->SetSpawnOrigX(spawn->GetX());
  3252. spawn->SetSpawnOrigY(spawn->GetY());
  3253. spawn->SetSpawnOrigZ(spawn->GetZ());
  3254. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3255. spawn->appearance.targetable = 1;
  3256. spawn->appearance.race = 255;
  3257. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3258. spawn->SetModelType(atoi(sep->arg[1]));
  3259. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3260. spawn->SetLevel(atoi(sep->arg[3]));
  3261. spawn->SetName(sep->arg[4]);
  3262. if(sep->arg[5][0] && sep->IsNumber(5))
  3263. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3264. if(sep->arg[6][0] && sep->IsNumber(6))
  3265. spawn->size = atoi(sep->arg[6]);
  3266. if(spawn->GetTotalHP() == 0){
  3267. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3268. spawn->SetHP(25*spawn->GetLevel() + 1);
  3269. }
  3270. if(spawn->GetTotalPower() == 0){
  3271. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3272. spawn->SetPower(25*spawn->GetLevel() + 1);
  3273. }
  3274. client->GetCurrentZone()->AddSpawn(spawn);
  3275. break;
  3276. }
  3277. case COMMAND_SPAWN_EQUIPMENT:{
  3278. Spawn* spawn = cmdTarget;
  3279. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3280. int8 slot = atoi(sep->arg[0]);
  3281. int16 type = atoi(sep->arg[1]);
  3282. int8 red = 0;
  3283. int8 green = 0;
  3284. int8 blue = 0;
  3285. int8 h_red = 0;
  3286. int8 h_green = 0;
  3287. int8 h_blue = 0;
  3288. if(sep->arg[2])
  3289. red = atoi(sep->arg[2]);
  3290. if(sep->arg[3])
  3291. green = atoi(sep->arg[3]);
  3292. if(sep->arg[4])
  3293. blue = atoi(sep->arg[4]);
  3294. if(sep->arg[5])
  3295. h_red = atoi(sep->arg[5]);
  3296. if(sep->arg[6])
  3297. h_green = atoi(sep->arg[6]);
  3298. if(sep->arg[7])
  3299. h_blue = atoi(sep->arg[7]);
  3300. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3301. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3302. }
  3303. else{
  3304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3306. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3307. }
  3308. break;
  3309. }
  3310. case COMMAND_SPAWN_DETAILS: {
  3311. Spawn* spawn = cmdTarget;
  3312. if (sep && sep->arg[0][0]) {
  3313. if (cmdTarget)
  3314. {
  3315. if (ToLower(string(sep->arg[0])) == "los")
  3316. {
  3317. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3318. if (hasLOS)
  3319. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3320. else
  3321. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3322. break;
  3323. }
  3324. else if (ToLower(string(sep->arg[0])) == "bestz")
  3325. {
  3326. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3327. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3328. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3329. break;
  3330. }
  3331. else if (ToLower(string(sep->arg[0])) == "pathto")
  3332. {
  3333. break;
  3334. }
  3335. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3336. {
  3337. break;
  3338. }
  3339. }
  3340. if (sep->IsNumber(0))
  3341. {
  3342. float radius = atof(sep->arg[0]);
  3343. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3344. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3345. break;
  3346. }
  3347. }
  3348. if (spawn) {
  3349. const char* type = "NPC";
  3350. if (spawn->IsObject())
  3351. type = "Object";
  3352. else if (spawn->IsSign())
  3353. type = "Sign";
  3354. else if (spawn->IsWidget())
  3355. type = "Widget";
  3356. else if (spawn->IsGroundSpawn())
  3357. type = "GroundSpawn";
  3358. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3359. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3360. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3361. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3362. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3363. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3364. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3365. 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());
  3366. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3367. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3368. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3369. if (spawn->IsEntity()) {
  3370. 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());
  3371. 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());
  3372. }
  3373. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3375. 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());
  3376. 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);
  3377. if (spawn->IsNPC())
  3378. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3379. string details;
  3380. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3381. details += "Type: " + string(type) + "\n";
  3382. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3383. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3384. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3385. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3386. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3387. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3388. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3389. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3390. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3391. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3392. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3393. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3394. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3395. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3396. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3397. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3398. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3399. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3400. char x[16];
  3401. sprintf(x, "%.2f", spawn->GetX());
  3402. char y[16];
  3403. sprintf(y, "%.2f", spawn->GetY());
  3404. char z[16];
  3405. sprintf(z, "%.2f", spawn->GetZ());
  3406. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3407. string details2;
  3408. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3409. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3410. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3411. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3412. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3413. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3414. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3415. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3416. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3417. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3418. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3419. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3420. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3421. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3422. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3423. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3424. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3425. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3426. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3427. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3428. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3429. string details3;
  3430. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3431. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3432. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3433. string details4;
  3434. if (spawn->IsEntity()) {
  3435. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3436. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3437. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3438. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3439. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3440. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3441. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3442. if (spawn->IsNPC()) {
  3443. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3444. }
  3445. }
  3446. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3447. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3448. }
  3449. else {
  3450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3451. 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.");
  3452. }
  3453. break;
  3454. }
  3455. case COMMAND_SPAWN_TARGET:{
  3456. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3457. int32 spawn_id = atoul(sep->arg[0]);
  3458. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3459. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3460. }
  3461. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3462. float distance = atof(sep->arg[1]);
  3463. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3464. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3465. }
  3466. else{
  3467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3469. }
  3470. break;
  3471. }
  3472. case COMMAND_SPAWN_SET:
  3473. {
  3474. Spawn* spawn = cmdTarget;
  3475. sint16 set_type = -1;
  3476. string type_str;
  3477. if (spawn)
  3478. {
  3479. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3480. 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)
  3481. {
  3482. // set the type, which will be 0 if location or list or invalid
  3483. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3484. }
  3485. if(set_type > 0)
  3486. {
  3487. // check if spawn set is NOT a char update, or not location, or isn't a number
  3488. 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)
  3489. {
  3490. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3491. }
  3492. else
  3493. {
  3494. string name = string(spawn->GetName());
  3495. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3496. {
  3497. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3498. {
  3499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3500. }
  3501. else if(set_type == SPAWN_SET_VALUE_NAME)
  3502. {
  3503. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3504. }
  3505. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3506. {
  3507. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3508. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3509. }
  3510. else
  3511. {
  3512. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3513. }
  3514. switch (set_type)
  3515. {
  3516. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3517. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3518. case SPAWN_SET_VALUE_FACTION:
  3519. {
  3520. // not applicable
  3521. break;
  3522. }
  3523. default:
  3524. {
  3525. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3526. break;
  3527. }
  3528. }
  3529. 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))
  3530. {
  3531. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3532. {
  3533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3534. }
  3535. else if(spawn->GetSpawnLocationID() > 0)
  3536. {
  3537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3538. }
  3539. }
  3540. else
  3541. {
  3542. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3543. {
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3545. }
  3546. else if(spawn->GetDatabaseID() > 0)
  3547. {
  3548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3549. }
  3550. }
  3551. }
  3552. }
  3553. }
  3554. else if(set_type == 0)
  3555. {
  3556. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3557. map<string, int8>::iterator itr;
  3558. int i=0;
  3559. string list;
  3560. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3561. {
  3562. if(i==10)
  3563. {
  3564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3565. i = 0;
  3566. }
  3567. if(i>0)
  3568. {
  3569. list.append(", ").append(itr->first);
  3570. }
  3571. else
  3572. {
  3573. list = itr->first;
  3574. }
  3575. }
  3576. if(list.length() > 0)
  3577. {
  3578. // if 1 or more, display in client.
  3579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3580. }
  3581. }
  3582. else
  3583. {
  3584. // syntax fail
  3585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3589. }
  3590. }
  3591. break;
  3592. }
  3593. case COMMAND_SPAWN_REMOVE:{
  3594. Spawn* spawn = cmdTarget;
  3595. if(spawn && !spawn->IsPlayer()){
  3596. if(spawn->GetSpawnLocationID() > 0){
  3597. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3598. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3599. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3600. }
  3601. else
  3602. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3603. }
  3604. else
  3605. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3606. }
  3607. else{
  3608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3610. }
  3611. break;
  3612. }
  3613. case COMMAND_SPAWN_LIST:{
  3614. if(sep && sep->arg[0][0]){
  3615. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3616. vector<string>::iterator itr;
  3617. if(results){
  3618. for(itr=results->begin();itr!=results->end();itr++){
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3620. }
  3621. safe_delete(results);
  3622. }
  3623. else
  3624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3625. }
  3626. else{
  3627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3630. }
  3631. break;
  3632. }
  3633. case COMMAND_SPAWN_ADD:{
  3634. Spawn* spawn = cmdTarget;
  3635. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3636. if(spawn->GetSpawnLocationID() > 0){
  3637. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3638. break;
  3639. }
  3640. if(spawn->GetDatabaseID() == 0){
  3641. if(database.SaveSpawnInfo(spawn)) {
  3642. char spawn_type[32];
  3643. memset(spawn_type, 0, sizeof(spawn_type));
  3644. if (spawn->IsNPC())
  3645. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3646. else if (spawn->IsObject())
  3647. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3648. else if (spawn->IsSign())
  3649. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3650. else if (spawn->IsGroundSpawn())
  3651. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3652. else
  3653. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3654. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3655. }
  3656. else
  3657. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3658. }
  3659. int32 spawn_group_id = 0;
  3660. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3661. spawn_group_id = database.GetNextSpawnLocation();
  3662. else
  3663. spawn_group_id = atol(sep->arg[0]);
  3664. int8 percent = 100;
  3665. if(sep->arg[2] && sep->IsNumber(2))
  3666. percent = atoi(sep->arg[2]);
  3667. spawn->SetSpawnLocationID(spawn_group_id);
  3668. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3669. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3670. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3671. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3672. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3673. else
  3674. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3675. }
  3676. else{
  3677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3680. }
  3681. break;
  3682. }
  3683. case COMMAND_SPAWN:{
  3684. int32 id = 0;
  3685. Spawn* spawn = 0;
  3686. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3687. id = atol(sep->arg[0]);
  3688. spawn = client->GetCurrentZone()->GetSpawn(id);
  3689. }
  3690. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3691. id = 0;
  3692. if(!id || !spawn){
  3693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3696. safe_delete(sep);
  3697. return;
  3698. }
  3699. if(sep && sep->arg[1][0]){
  3700. float x = atof(sep->arg[1]);
  3701. spawn->appearance.pos.X = x;
  3702. }
  3703. else
  3704. spawn->SetX(client->GetPlayer()->GetX(), false);
  3705. if(sep && sep->arg[2][0]){
  3706. float y = atof(sep->arg[2]);
  3707. spawn->appearance.pos.Y = y;
  3708. }
  3709. else
  3710. spawn->SetY(client->GetPlayer()->GetY(), false);
  3711. if(sep && sep->arg[3][0]){
  3712. float z = atof(sep->arg[3]);
  3713. spawn->appearance.pos.Z = z;
  3714. }
  3715. else
  3716. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3717. if(sep && sep->arg[4][0]){
  3718. float heading = atof(sep->arg[4]);
  3719. spawn->SetHeading(heading);
  3720. }
  3721. else
  3722. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3723. spawn->SetSpawnOrigX(spawn->GetX());
  3724. spawn->SetSpawnOrigY(spawn->GetY());
  3725. spawn->SetSpawnOrigZ(spawn->GetZ());
  3726. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3727. if(sep && sep->arg[5][0])
  3728. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3729. else
  3730. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3731. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3732. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3733. spawn->SetHP(spawn->GetTotalHP());
  3734. }
  3735. if(spawn->GetTotalPower() == 0){
  3736. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3737. spawn->SetPower(spawn->GetTotalPower());
  3738. }
  3739. const char* script = world.GetSpawnScript(id);
  3740. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3741. spawn->SetSpawnScript(string(script));
  3742. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3743. client->GetCurrentZone()->AddSpawn(spawn);
  3744. if(spawn->IsNPC())
  3745. spawn->GetZone()->AddLoot((NPC*)spawn);
  3746. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3747. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3748. break;
  3749. }
  3750. case COMMAND_ADMINFLAG:
  3751. {
  3752. if(sep && sep->arg[0]){
  3753. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3754. sint16 new_status = atoi(sep->arg[1]);
  3755. if(tmp_status == -10)
  3756. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3757. else if(tmp_status >= client->GetAdminStatus())
  3758. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3759. else if (new_status > client->GetAdminStatus())
  3760. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3761. else{
  3762. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3763. if (!client2)
  3764. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3765. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3766. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3767. if (client2) {
  3768. client2->SetAdminStatus(new_status);
  3769. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3770. }
  3771. }
  3772. else
  3773. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3774. }
  3775. }else{
  3776. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3777. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3778. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3779. }
  3780. break;
  3781. }
  3782. case COMMAND_CANNEDEMOTE:{
  3783. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3784. break;
  3785. }
  3786. case COMMAND_BROADCAST: {
  3787. if (sep && sep->arg[0])
  3788. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3789. else
  3790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3791. break;
  3792. }
  3793. case COMMAND_ANNOUNCE: {
  3794. if (sep && sep->arg[0])
  3795. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3796. else
  3797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3798. break;
  3799. }
  3800. case COMMAND_RELOAD_ITEMS:{
  3801. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3803. database.ReloadItemList();
  3804. database.LoadMerchantInformation();
  3805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3806. break;
  3807. }
  3808. case COMMAND_ENABLE_ABILITY_QUE:{
  3809. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3810. if(app)
  3811. client->QueuePacket(app);
  3812. break;
  3813. }
  3814. case COMMAND_ITEMSEARCH:{
  3815. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3816. if (packet) {
  3817. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3818. //packet->setDataByName("unknown", 1);
  3819. packet->setDataByName("unknown2", 5, 0);
  3820. packet->setDataByName("unknown2", 20, 1);
  3821. packet->setDataByName("unknown2", 58, 3);
  3822. packet->setDataByName("unknown2", 40, 4);
  3823. client->QueuePacket(packet->serialize());
  3824. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3825. if (packet2) {
  3826. packet2->setDataByName("char_id", client->GetCharacterID());
  3827. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3828. safe_delete(packet2);
  3829. }
  3830. safe_delete(packet);
  3831. }
  3832. break;
  3833. }
  3834. case COMMAND_ANIMTEST:{
  3835. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3836. if(command_packet){
  3837. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3838. if (cmdTarget)
  3839. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3840. command_packet->setDataByName ( "spawn_id" , id);
  3841. int animID = 1;
  3842. if(sep && sep->arg[0] && sep->IsNumber(0))
  3843. animID = atoi(sep->arg[0]);
  3844. VisualState* vs = NULL;
  3845. if(animID == 0)
  3846. {
  3847. vs = visual_states.FindVisualState(sep->arg[0]);
  3848. }
  3849. char msg[128];
  3850. sprintf(msg,"Animation Test ID: %i",animID);
  3851. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3852. if(vs != NULL)
  3853. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3854. else
  3855. command_packet->setDataByName ( "anim_type", animID );
  3856. command_packet->setDataByName ( "unknown0", 0 );
  3857. EQ2Packet* outapp = command_packet->serialize();
  3858. client->QueuePacket(outapp);
  3859. safe_delete(command_packet);
  3860. }
  3861. break;
  3862. }
  3863. case COMMAND_KICK:
  3864. {
  3865. if( sep == 0 || sep->arg[0] == 0)
  3866. {
  3867. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3868. }
  3869. else
  3870. {
  3871. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3872. if ( kickClient == client )
  3873. {
  3874. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3875. break;
  3876. }
  3877. else if(kickClient != NULL)
  3878. {
  3879. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3880. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3881. {
  3882. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3883. break;
  3884. }
  3885. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3886. kickClient->Disconnect();
  3887. }
  3888. else
  3889. {
  3890. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3891. }
  3892. }
  3893. break;
  3894. }
  3895. case COMMAND_LOCK:
  3896. {
  3897. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3898. int worldLocked = atoi(sep->arg[0]);
  3899. net.world_locked = worldLocked;
  3900. if ( worldLocked )
  3901. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3902. else
  3903. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3904. }
  3905. else
  3906. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3907. break;
  3908. }
  3909. case COMMAND_BAN:{
  3910. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3911. {
  3912. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3913. }
  3914. else
  3915. {
  3916. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3917. if ( kickClient == client )
  3918. {
  3919. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3920. break;
  3921. }
  3922. else if(kickClient != NULL)
  3923. {
  3924. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3925. if ( maxStatus > client->GetAdminStatus( ) ||
  3926. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3927. {
  3928. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3929. break;
  3930. }
  3931. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3932. int perm = atol(sep->arg[1]);
  3933. if ( perm == 1 )
  3934. database.UpdateAdminStatus(sep->arg[0],-2);
  3935. else
  3936. database.UpdateAdminStatus(sep->arg[0],-1);
  3937. kickClient->Disconnect();
  3938. }
  3939. else
  3940. {
  3941. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3942. }
  3943. }
  3944. break;
  3945. }
  3946. case COMMAND_SET_COMBAT_VOICE:{
  3947. int32 value = 0;
  3948. if(sep && sep->arg[0] && sep->IsNumber(0))
  3949. value = atoi(sep->arg[0]);
  3950. client->GetPlayer()->SetCombatVoice(value);
  3951. break;
  3952. }
  3953. case COMMAND_SET_EMOTE_VOICE:{
  3954. int32 value = 0;
  3955. if(sep && sep->arg[0] && sep->IsNumber(0))
  3956. value = atoi(sep->arg[0]);
  3957. client->GetPlayer()->SetEmoteVoice(value);
  3958. break;
  3959. }
  3960. case COMMAND_GIVEITEM:{
  3961. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3962. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3963. if ( itemToClient == NULL )
  3964. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3965. else
  3966. {
  3967. int32 item_id = atol(sep->arg[1]);
  3968. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3969. itemToClient->AddItem(item_id);
  3970. }
  3971. }
  3972. else
  3973. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3974. break;
  3975. }
  3976. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3977. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3978. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3979. case COMMAND_SKILL :
  3980. case COMMAND_SKILL_ADD :
  3981. case COMMAND_SKILL_REMOVE :
  3982. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3983. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3984. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3985. case COMMAND_ENTITYCOMMAND :
  3986. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3987. case COMMAND_MERCHANT :
  3988. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3989. case COMMAND_APPEARANCE :
  3990. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3991. case COMMAND_TRACK : { Command_Track(client); break; }
  3992. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3993. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3994. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3995. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3996. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3997. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3998. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3999. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4000. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4001. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4002. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4003. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4004. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4005. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4006. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4007. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4008. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4009. case COMMAND_LOCATION : { Command_Location(client); break; }
  4010. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4011. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4012. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4013. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4014. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4015. case COMMAND_GRID : { Command_Grid(client); break; }
  4016. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4017. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4018. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4019. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4020. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4021. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4022. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4023. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4024. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4025. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4026. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4027. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4028. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4029. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4030. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4031. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4032. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4033. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4034. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4035. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4036. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4037. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4038. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4039. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4040. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4041. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4042. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4043. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4044. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4045. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4046. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4047. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4048. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4049. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4050. case COMMAND_TITLE : { Command_Title(client); break; }
  4051. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4052. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4053. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4054. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4055. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4056. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4057. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4058. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4059. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4060. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4061. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4062. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4063. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4064. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4065. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4066. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4067. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4068. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4069. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4070. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4071. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4072. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4073. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4074. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4075. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4076. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4077. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4078. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4079. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4080. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4081. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4082. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4083. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4084. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4085. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4086. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4087. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4088. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4089. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4090. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4091. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4092. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4093. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4094. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4095. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4096. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4097. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4098. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4099. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4100. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4101. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4102. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4103. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4104. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4105. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4106. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4107. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4108. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4109. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4110. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4111. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4112. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4113. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4114. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4115. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4116. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4117. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4118. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4119. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4120. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4121. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4122. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4123. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4124. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4125. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4126. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4127. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4128. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4129. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4130. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4131. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4132. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4133. case ADD_AA : { Add_AA(client, sep); break; }
  4134. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4135. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4136. case BACK_AA : { Back_AA(client, sep); break; }
  4137. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4138. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4139. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4140. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4141. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4142. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4143. default:
  4144. {
  4145. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4146. break;
  4147. }
  4148. }
  4149. safe_delete(sep);
  4150. }
  4151. /******************** New COMMAND Handler Functions ********************/
  4152. /*
  4153. Started breaking apart the huge switch() for commands into sepErate
  4154. functions so it is easier to locate the blocks of code by command
  4155. -- JA 2012.03.03
  4156. */
  4157. // sample function header
  4158. /*
  4159. Function:
  4160. Purpose :
  4161. Params :
  4162. Dev :
  4163. Example :
  4164. */
  4165. //void Commands::Command()
  4166. //{
  4167. //}
  4168. /*
  4169. Function: Command_AcceptAdvancement()
  4170. Purpose : Player accepts a new advancement option
  4171. Params : Spell ID
  4172. Dev : Jabantiz
  4173. */
  4174. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4175. {
  4176. Player *player = client->GetPlayer();
  4177. if (sep && sep->IsSet(0)) {
  4178. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4179. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4180. if (!player->HasSpell(trait->spellID, 0, true))
  4181. {
  4182. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4183. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4184. }
  4185. else
  4186. {
  4187. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4188. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4189. player->RemoveSpellBookEntry(spell->GetSpellID());
  4190. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4191. player->UnlockSpell(spell);
  4192. client->SendSpellUpdate(spell);
  4193. }
  4194. // Spell book update
  4195. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4196. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4197. }
  4198. }
  4199. /*
  4200. Function:
  4201. Purpose :
  4202. Params :
  4203. Dev :
  4204. Example :
  4205. */
  4206. void Commands::Command_AFK(Client* client, Seperator* sep)
  4207. {
  4208. Player* player = client->GetPlayer();
  4209. player->toggle_character_flag(CF_AFK);
  4210. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4211. if (player->get_character_flag(CF_AFK))
  4212. {
  4213. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4214. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4215. if (sep && sep->argplus[0])
  4216. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4217. else
  4218. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4219. string message = string(player->GetName()) + " is going afk.";
  4220. Spawn* target = player->GetTarget();
  4221. if (target && target != player)
  4222. {
  4223. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4224. player->GetGender() == 1 ? message += "he" : message += "she";
  4225. message += " is going afk.";
  4226. }
  4227. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4228. }
  4229. /*else
  4230. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4231. }
  4232. /*
  4233. Function: Command_Appearance()
  4234. Purpose : Handles /appearance commands
  4235. Params : list
  4236. Dev : Scatman
  4237. Example : /appearance list
  4238. */
  4239. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4240. {
  4241. if( handler == COMMAND_APPEARANCE )
  4242. {
  4243. // /appearance command by itself shows help (to be extended)
  4244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4245. return;
  4246. }
  4247. else if( handler == COMMAND_APPEARANCE_LIST )
  4248. {
  4249. // /appearance list command expects "name" param
  4250. if (sep && sep->arg[0])
  4251. {
  4252. const char* appearance_name = sep->argplus[0];
  4253. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4254. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4255. if (appearances)
  4256. {
  4257. vector<int16>::iterator itr;
  4258. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4259. {
  4260. int16 id = *itr;
  4261. string name = database.GetAppearanceName(id);
  4262. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4263. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4264. }
  4265. safe_delete(appearances);
  4266. }
  4267. }
  4268. else // no param
  4269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4270. }
  4271. }
  4272. /*
  4273. Function: Command_Claim()
  4274. Purpose :
  4275. Params :
  4276. Dev :
  4277. Example :
  4278. */
  4279. void Commands::Command_Claim(Client* client, Seperator* sep)
  4280. {
  4281. if (sep && sep->arg[0] && sep->IsNumber(0))
  4282. {
  4283. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4285. }
  4286. else
  4287. client->ShowClaimWindow();
  4288. }
  4289. /*
  4290. Function: Command_ClearAllQueued()
  4291. Purpose :
  4292. Params :
  4293. Dev :
  4294. Example :
  4295. */
  4296. void Commands::Command_ClearAllQueued(Client* client)
  4297. {
  4298. ZoneServer* zone = client->GetPlayer()->GetZone();
  4299. if (zone && zone->GetSpellProcess())
  4300. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4301. }
  4302. /*
  4303. Function: Command_CancelMaintained()
  4304. Purpose : Cancels maintained spells
  4305. Params : Maintained Spell Index
  4306. Dev : Zcoretri
  4307. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4308. */
  4309. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4310. {
  4311. if (sep && sep->arg[0] && sep->IsNumber(0))
  4312. {
  4313. int32 spell_index = atoul(sep->arg[0]);
  4314. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4315. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4316. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4317. // just not spelleffects/dets - Foof
  4318. //{
  4319. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4320. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4321. // }
  4322. //else
  4323. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4324. }
  4325. }
  4326. /*
  4327. Function: Command_Create()
  4328. Purpose : Handler for starting Tradeskilling table
  4329. Params :
  4330. Dev : Zcoretri
  4331. Example :
  4332. */
  4333. void Commands::Command_Create(Client* client, Seperator* sep)
  4334. {
  4335. PrintSep(sep, "COMMAND_CREATE");
  4336. client->SendRecipeList();
  4337. client->ShowRecipeBook();
  4338. }
  4339. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4340. {
  4341. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4342. if (sep && sep->arg[0] && sep->IsNumber(0))
  4343. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4344. }
  4345. /*
  4346. Function: Command_Distance()
  4347. Purpose : Displays distance from targeted spawn
  4348. Params :
  4349. Dev : Scatman
  4350. Example : /distance
  4351. */
  4352. void Commands::Command_Distance(Client* client)
  4353. {
  4354. Spawn* target = client->GetPlayer()->GetTarget();
  4355. if (target)
  4356. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4357. else
  4358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4359. }
  4360. /*
  4361. Function: Command_Duel()
  4362. Purpose : Handle the /duel commands - not yet implemented
  4363. Params : unknown
  4364. Dev :
  4365. Example :
  4366. */
  4367. void Commands::Command_Duel(Client* client, Seperator* sep)
  4368. {
  4369. PrintSep(sep, "COMMAND_DUEL");
  4370. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4371. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4372. }
  4373. /*
  4374. Function: Command_DuelBet()
  4375. Purpose : Handle the /duel commands - not yet implemented
  4376. Params : unknown
  4377. Dev :
  4378. Example :
  4379. */
  4380. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4381. {
  4382. PrintSep(sep, "COMMAND_DUELBET");
  4383. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4384. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4385. }
  4386. /*
  4387. Function: Command_DuelAccept()
  4388. Purpose : Handle the /duel commands - not yet implemented
  4389. Params : unknown
  4390. Dev :
  4391. Example :
  4392. */
  4393. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4394. {
  4395. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4396. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4397. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4398. }
  4399. /*
  4400. Function: Command_DuelDecline()
  4401. Purpose : Handle the /duel commands - not yet implemented
  4402. Params : unknown
  4403. Dev :
  4404. Example :
  4405. */
  4406. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4407. {
  4408. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4409. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4410. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4411. }
  4412. /*
  4413. Function: Command_DuelSurrender()
  4414. Purpose : Handle the /duel commands - not yet implemented
  4415. Params : unknown
  4416. Dev :
  4417. Example :
  4418. */
  4419. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4420. {
  4421. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4422. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4423. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4424. // JA, just messin around ;)
  4425. char surrender[64];
  4426. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4427. zone_list.HandleGlobalAnnouncement(surrender);
  4428. }
  4429. /*
  4430. Function: Command_DuelToggle()
  4431. Purpose : Handle the /duel commands - not yet implemented
  4432. Params : unknown
  4433. Dev :
  4434. Example :
  4435. */
  4436. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4437. {
  4438. PrintSep(sep, "COMMAND_DUEL");
  4439. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4440. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4441. }
  4442. /*
  4443. Function:
  4444. Purpose :
  4445. Params :
  4446. Dev :
  4447. Example :
  4448. */
  4449. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4450. {
  4451. if( handler == COMMAND_ENTITYCOMMAND )
  4452. {
  4453. // /entitycommand command by itself shows help (to be extended)
  4454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4455. return;
  4456. }
  4457. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4458. {
  4459. // /entitycommand list command expects "name" param
  4460. if (sep && sep->arg[0])
  4461. {
  4462. const char* entity_command_name = sep->argplus[0];
  4463. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4464. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4465. map<int32, vector<EntityCommand*>*>::iterator itr;
  4466. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4467. {
  4468. vector<EntityCommand*>* entity_command_list = itr->second;
  4469. vector<EntityCommand*>::iterator itr2;
  4470. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4471. {
  4472. EntityCommand* entity_command = *itr2;
  4473. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4474. 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);
  4475. }
  4476. }
  4477. }
  4478. else // no command name
  4479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4480. }
  4481. }
  4482. /*
  4483. Function: Command_Follow()
  4484. Purpose : Handle the /follow command - not yet implemented
  4485. Params :
  4486. Dev :
  4487. Example :
  4488. */
  4489. void Commands::Command_Follow(Client* client, Seperator* sep)
  4490. {
  4491. PrintSep(sep, "COMMAND_FOLLOW");
  4492. // flag to toggle if the players target is in the players group
  4493. bool targetInGroup = false;
  4494. // get a pointer to the players group
  4495. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4496. // If the player has a group and has a target
  4497. if (gmi && client->GetPlayer()->GetTarget()) {
  4498. deque<GroupMemberInfo*>::iterator itr;
  4499. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4500. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4501. // Loop through the group members
  4502. for (itr = members->begin(); itr != members->end(); itr++) {
  4503. // If a group member matches a target
  4504. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4505. // toggle the flag and break the loop
  4506. targetInGroup = true;
  4507. break;
  4508. }
  4509. }
  4510. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4511. }
  4512. if (targetInGroup) {
  4513. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4514. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4515. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4516. client->GetPlayer()->info_changed = true;
  4517. client->GetPlayer()->changed = true;
  4518. }
  4519. else
  4520. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4521. }
  4522. /*
  4523. Function: Command_StopFollow()
  4524. Purpose : Handle the /stop_follow command - not yet implemented
  4525. Params :
  4526. Dev :
  4527. Example :
  4528. */
  4529. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4530. {
  4531. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4532. if (client->GetPlayer()->GetFollowTarget()) {
  4533. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4534. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4535. client->GetPlayer()->SetFollowTarget(0);
  4536. client->GetPlayer()->info_changed = true;
  4537. client->GetPlayer()->changed = true;
  4538. }
  4539. }
  4540. #include "../Zone/SPGrid.h"
  4541. /*
  4542. Function: Command_Grid()
  4543. Purpose : Show player's current Grid ID
  4544. Params :
  4545. Dev : Scatman
  4546. Example : /grid
  4547. */
  4548. void Commands::Command_Grid(Client* client)
  4549. {
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4551. if (client->GetCurrentZone()->Grid != nullptr) {
  4552. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4553. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4554. }
  4555. }
  4556. /*
  4557. Function: Command_Guild()
  4558. Purpose : Handler for all UI-related guild commands
  4559. Dev : Scatman
  4560. */
  4561. void Commands::Command_Guild(Client* client, Seperator* sep)
  4562. {
  4563. Guild* guild = client->GetPlayer()->GetGuild();
  4564. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4565. {
  4566. const char* command = sep->arg[0];
  4567. int32 length = strlen(command);
  4568. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4569. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4570. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4571. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4572. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4573. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4574. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4575. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4576. guild->KickGuildMember(client, sep->arg[1]);
  4577. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4578. guild->DemoteGuildMember(client, sep->arg[1]);
  4579. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4580. guild->PromoteGuildMember(client, sep->arg[1]);
  4581. else if (strncmp(command, "points", length) == 0 && guild)
  4582. {
  4583. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4584. {
  4585. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4586. {
  4587. float points = atof(sep->arg[2]);
  4588. const char* option = sep->arg[3];
  4589. const char* comment = sep->argplus[4];
  4590. if (strncmp(option, "all", strlen(option)) == 0)
  4591. guild->AddPointsToAll(client, points, comment);
  4592. else if (strncmp(option, "online", strlen(option)) == 0)
  4593. guild->AddPointsToAllOnline(client, points, comment);
  4594. else if (strncmp(option, "group", strlen(option)) == 0)
  4595. guild->AddPointsToGroup(client, points, comment);
  4596. else if (strncmp(option, "raid", strlen(option)) == 0)
  4597. guild->AddPointsToRaid(client, points, comment);
  4598. else
  4599. guild->AddPointsToGuildMember(client, points, option, comment);
  4600. }
  4601. }
  4602. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4603. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4604. else
  4605. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4606. }
  4607. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4608. guild->SetMOTD(sep->argplus[1]);
  4609. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4610. {
  4611. if (sep->arg[1])
  4612. {
  4613. const char* option = sep->arg[1];
  4614. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4615. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4616. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4617. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4618. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4619. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4620. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4621. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4622. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4623. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4624. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4625. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4626. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4627. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4628. else
  4629. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4630. }
  4631. else
  4632. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4633. }
  4634. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4635. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4636. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4637. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4638. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4639. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4640. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4641. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4642. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4643. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4644. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4645. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4646. else if (strncmp(command, "invite", length) == 0 && guild)
  4647. {
  4648. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4649. guild->InvitePlayer(client, sep->arg[1]);
  4650. else
  4651. {
  4652. Spawn* target = client->GetPlayer()->GetTarget();
  4653. if (target)
  4654. {
  4655. if (target->IsPlayer())
  4656. guild->InvitePlayer(client, target->GetName());
  4657. else
  4658. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4659. }
  4660. }
  4661. }
  4662. else if (strncmp(command, "accept", length) == 0)
  4663. {
  4664. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4665. if (pgi && pgi->guild && pgi->invited_by)
  4666. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4667. client->SetPendingGuildInvite(0);
  4668. }
  4669. else if (strncmp(command, "decline", length) == 0)
  4670. {
  4671. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4672. if (pgi && pgi->guild && pgi->invited_by)
  4673. {
  4674. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4675. if (client_inviter)
  4676. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4677. }
  4678. client->SetPendingGuildInvite(0);
  4679. }
  4680. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4681. {
  4682. const char* guild_name = sep->argplus[1];
  4683. if (!guild_list.GetGuild(guild_name))
  4684. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4685. else
  4686. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4687. }
  4688. else if (strncmp(command, "search", length) == 0)
  4689. client->ShowGuildSearchWindow();
  4690. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4691. {
  4692. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4693. if (to_guild)
  4694. to_guild->SendGuildRecruitingDetails(client);
  4695. }
  4696. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4697. {
  4698. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4699. if (to_guild)
  4700. to_guild->SendGuildRecruitingImages(client);
  4701. }
  4702. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4703. {
  4704. if (sep->arg[1])
  4705. {
  4706. const char* option = sep->arg[1];
  4707. if (strncmp(option, "toggle", strlen(option)) == 0)
  4708. guild->ToggleGuildRecruiterAdventureClass(client);
  4709. }
  4710. else
  4711. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4712. }
  4713. else if (strncmp(command, "display_heraldry", length) == 0)
  4714. {
  4715. // JA: not sure this is right...
  4716. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4717. client->GetPlayer()->SetCharSheetChanged(true);
  4718. }
  4719. else
  4720. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4721. }
  4722. }
  4723. /*
  4724. Function: Command_GuildCreate()
  4725. Purpose : Display's in-game Guild Creation window
  4726. Dev : Scatman
  4727. */
  4728. void Commands::Command_CreateGuild(Client* client)
  4729. {
  4730. client->SendGuildCreateWindow();
  4731. }
  4732. /*
  4733. Function: Command_SetGuildOfficerNote()
  4734. Purpose :
  4735. Dev : Scatman
  4736. */
  4737. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4738. {
  4739. if (sep && sep->arg[0] && sep->arg[1])
  4740. {
  4741. Guild* guild = client->GetPlayer()->GetGuild();
  4742. if (guild)
  4743. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4744. }
  4745. }
  4746. /*
  4747. Function: Command_SetGuildMemberNote()
  4748. Purpose :
  4749. Dev : Scatman
  4750. */
  4751. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4752. {
  4753. if (sep && sep->arg[0] && sep->arg[1])
  4754. {
  4755. Guild* guild = client->GetPlayer()->GetGuild();
  4756. if (guild)
  4757. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4758. }
  4759. }
  4760. /*
  4761. Function: Command_GuildSay()
  4762. Purpose :
  4763. Dev : Scatman
  4764. */
  4765. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4766. {
  4767. Guild* guild = client->GetPlayer()->GetGuild();
  4768. if (guild)
  4769. {
  4770. if (sep && sep->arg[0])
  4771. guild->HandleGuildSay(client, sep->argplus[0]);
  4772. }
  4773. else
  4774. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4775. }
  4776. /*
  4777. Function: Command_OfficerSay()
  4778. Purpose :
  4779. Dev : Scatman
  4780. */
  4781. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4782. {
  4783. Guild* guild = client->GetPlayer()->GetGuild();
  4784. if (guild)
  4785. {
  4786. if (sep && sep->arg[0])
  4787. guild->HandleOfficerSay(client, sep->argplus[0]);
  4788. }
  4789. else
  4790. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4791. }
  4792. /*
  4793. Function: Command_Guilds()
  4794. Purpose : Shows help for /guild command
  4795. Params :
  4796. Dev : Scatman
  4797. Example :
  4798. */
  4799. void Commands::Command_Guilds(Client* client)
  4800. {
  4801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4802. }
  4803. /*
  4804. Function: Command_GuildsAdd()
  4805. Purpose : Add's players to a guild
  4806. Params : guild_name|guild_id, player name
  4807. Dev : Scatman
  4808. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4809. */
  4810. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4811. {
  4812. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4813. {
  4814. Guild* guild = 0;
  4815. bool found = true;
  4816. if (sep->IsNumber(0))
  4817. {
  4818. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4819. if (!guild)
  4820. {
  4821. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4822. found = false;
  4823. }
  4824. }
  4825. else
  4826. {
  4827. guild = guild_list.GetGuild(sep->arg[0]);
  4828. if (!guild)
  4829. {
  4830. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4831. found = false;
  4832. }
  4833. }
  4834. if (found)
  4835. {
  4836. Client* to_client = 0;
  4837. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4838. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4839. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4840. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4841. if (to_client)
  4842. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4843. else
  4844. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4845. }
  4846. }
  4847. else
  4848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4849. }
  4850. /*
  4851. Function: Command_GuildsCreate()
  4852. Purpose : Creates a guild
  4853. Params : guild_name, player_name (optional)
  4854. Dev : Scatman
  4855. Example : /guilds create [guild name] (player name)
  4856. */
  4857. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4858. {
  4859. if (sep && sep->arg[0])
  4860. {
  4861. const char* guild_name = sep->arg[0];
  4862. if (!guild_list.GetGuild(guild_name))
  4863. {
  4864. bool ret = false;
  4865. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4866. {
  4867. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4868. if (to_client)
  4869. {
  4870. world.CreateGuild(guild_name, to_client);
  4871. ret = true;
  4872. }
  4873. else
  4874. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4875. }
  4876. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4877. {
  4878. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4879. if (to_client)
  4880. {
  4881. world.CreateGuild(guild_name, to_client);
  4882. ret = true;
  4883. }
  4884. }
  4885. else
  4886. {
  4887. world.CreateGuild(guild_name);
  4888. ret = true;
  4889. }
  4890. if (ret)
  4891. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4892. else
  4893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4894. }
  4895. else
  4896. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4897. }
  4898. else
  4899. 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.");
  4900. }
  4901. /*
  4902. Function: Command_GuildsDelete()
  4903. Purpose : Delete's a guild
  4904. Params : guild name
  4905. Dev : Scatman
  4906. Example : /guilds delete Test
  4907. */
  4908. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4909. {
  4910. if (sep && sep->arg[0])
  4911. {
  4912. Guild* guild = 0;
  4913. bool found = true;
  4914. if (sep->IsNumber(0))
  4915. {
  4916. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4917. if (!guild)
  4918. {
  4919. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4920. found = false;
  4921. }
  4922. }
  4923. else
  4924. {
  4925. guild = guild_list.GetGuild(sep->arg[0]);
  4926. if (!guild)
  4927. {
  4928. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4929. found = false;
  4930. }
  4931. }
  4932. if (found)
  4933. {
  4934. guild->RemoveAllGuildMembers();
  4935. database.DeleteGuild(guild);
  4936. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4937. guild_list.RemoveGuild(guild, true);
  4938. }
  4939. }
  4940. else
  4941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4942. }
  4943. /*
  4944. Function: Command_GuildsList()
  4945. Purpose : Lists current guilds on server
  4946. Params :
  4947. Dev : Scatman
  4948. Example : /guilds list
  4949. */
  4950. void Commands::Command_GuildsList(Client* client)
  4951. {
  4952. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4953. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4955. if (guilds->size() == 0)
  4956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4957. else {
  4958. while (itr.Next()) {
  4959. Guild* guild = itr.second;
  4960. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4961. }
  4962. }
  4963. }
  4964. /*
  4965. Function: Command_GuildsRemove()
  4966. Purpose : Removes a player from a guild
  4967. Params : guild name|guild id, player name
  4968. Dev : Scatman
  4969. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4970. */
  4971. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4972. {
  4973. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4974. {
  4975. Guild* guild = 0;
  4976. bool found = true;
  4977. if (sep->IsNumber(0))
  4978. {
  4979. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4980. if (!guild)
  4981. {
  4982. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4983. found = false;
  4984. }
  4985. }
  4986. else
  4987. {
  4988. guild = guild_list.GetGuild(sep->arg[0]);
  4989. if (!guild)
  4990. {
  4991. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4992. found = false;
  4993. }
  4994. }
  4995. if (found)
  4996. {
  4997. Client* to_client = 0;
  4998. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4999. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5000. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5001. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5002. if (to_client)
  5003. {
  5004. Player* to_player = to_client->GetPlayer();
  5005. if (to_player->GetGuild())
  5006. {
  5007. if (to_player->GetGuild() == guild)
  5008. {
  5009. guild->KickGuildMember(client, to_player->GetName());
  5010. }
  5011. else
  5012. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5013. }
  5014. else
  5015. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5016. }
  5017. else
  5018. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5019. }
  5020. }
  5021. else
  5022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5023. }
  5024. /*
  5025. Function: Command_InspectPlayer()
  5026. Purpose : Handle the Inspect functions
  5027. Params : Client to inspect
  5028. Dev : Scatman
  5029. Example : /inspect Scatman
  5030. */
  5031. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5032. {
  5033. if (sep && sep->arg[0])
  5034. {
  5035. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5036. if (inspect_client)
  5037. client->InspectPlayer(inspect_client->GetPlayer());
  5038. }
  5039. else
  5040. {
  5041. Spawn* target = client->GetPlayer()->GetTarget();
  5042. if (target && target->IsPlayer())
  5043. client->InspectPlayer((Player*)target);
  5044. }
  5045. }
  5046. /*
  5047. Function: Command_Inventory()
  5048. Purpose : Handle changes in player inventory
  5049. Params : <TBD>
  5050. Dev : All
  5051. Example : /inventory delete item_id
  5052. */
  5053. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5054. {
  5055. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5056. Player* player = client->GetPlayer();
  5057. if(sep && sep->arg[0][0])
  5058. {
  5059. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5060. if(client->GetPlayer()->GetHP() == 0)
  5061. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5062. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5063. {
  5064. int16 index = atoi(sep->arg[1]);
  5065. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5066. if(item)
  5067. {
  5068. if(item->GetItemScript() && lua_interface)
  5069. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5070. int32 bag_id = item->details.inv_slot_id;
  5071. database.DeleteItem(client->GetCharacterID(), item, 0);
  5072. client->GetPlayer()->item_list.DestroyItem(index);
  5073. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5074. client->QueuePacket(outapp);
  5075. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5076. if (outapp)
  5077. client->QueuePacket(outapp);
  5078. }
  5079. }
  5080. 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))
  5081. {
  5082. int16 from_index = atoi(sep->arg[1]);
  5083. sint16 to_slot = atoi(sep->arg[2]);
  5084. sint32 bag_id = atol(sep->arg[3]);
  5085. int8 charges = atoi(sep->arg[4]);
  5086. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5087. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5088. {
  5089. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5090. return;
  5091. }
  5092. sint32 old_inventory_id = 0;
  5093. if(item)
  5094. old_inventory_id = item->details.inv_slot_id;
  5095. //autobank
  5096. if (bag_id == -3 && to_slot == -1)
  5097. {
  5098. if (player->HasFreeBankSlot())
  5099. to_slot = player->FindFreeBankSlot();
  5100. else
  5101. {
  5102. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5103. return;
  5104. }
  5105. }
  5106. //auto inventory
  5107. if (bag_id == 0 && to_slot == -1)
  5108. {
  5109. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5110. {
  5111. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5112. return;
  5113. }
  5114. }
  5115. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5116. client->QueuePacket(outapp);
  5117. //removed from bag send update
  5118. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5119. {
  5120. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5121. if(outapp)
  5122. client->QueuePacket(outapp);
  5123. }
  5124. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5125. {
  5126. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5127. if(outapp)
  5128. client->QueuePacket(outapp);
  5129. }
  5130. }
  5131. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5132. {
  5133. if(client->GetPlayer()->EngagedInCombat())
  5134. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5135. else
  5136. {
  5137. int16 index = atoi(sep->arg[1]);
  5138. int8 slot_id = 255;
  5139. if(sep->arg[2][0] && sep->IsNumber(2))
  5140. slot_id = atoi(sep->arg[2]);
  5141. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5142. EQ2Packet* outapp = 0;
  5143. for(int32 i=0;i<packets.size();i++)
  5144. {
  5145. outapp = packets[i];
  5146. if(outapp)
  5147. client->QueuePacket(outapp);
  5148. }
  5149. client->GetPlayer()->ChangePrimaryWeapon();
  5150. client->GetPlayer()->ChangeSecondaryWeapon();
  5151. client->GetPlayer()->ChangeRangedWeapon();
  5152. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5153. client->QueuePacket(characterSheetPackets);
  5154. }
  5155. }
  5156. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5157. {
  5158. if (client->GetPlayer()->EngagedInCombat())
  5159. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5160. else {
  5161. int16 index = atoi(sep->arg[1]);
  5162. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5163. if (item) {
  5164. // client->GetPlayer()->item_list.DestroyItem(index);
  5165. if (item->item_sets.size() > 0) {
  5166. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5167. ItemSet* set = item->item_sets[i];
  5168. if (set->item_stack_size == 0)
  5169. set->item_stack_size += 1;
  5170. client->AddItem(set->item_id, set->item_stack_size);
  5171. }
  5172. }
  5173. }
  5174. client->RemoveItem(item, 1);
  5175. }
  5176. }
  5177. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5178. {
  5179. if(client->GetPlayer()->EngagedInCombat())
  5180. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5181. else
  5182. {
  5183. int16 index = atoi(sep->arg[1]);
  5184. sint32 bag_id = -999;
  5185. int8 to_slot = 255;
  5186. if(sep->arg[3][0])
  5187. {
  5188. if(sep->IsNumber(2))
  5189. bag_id = atol(sep->arg[2]);
  5190. if(sep->IsNumber(3))
  5191. to_slot = atoi(sep->arg[3]);
  5192. }
  5193. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5194. EQ2Packet* outapp = 0;
  5195. for(int32 i=0;i<packets.size();i++)
  5196. {
  5197. outapp = packets[i];
  5198. if(outapp)
  5199. client->QueuePacket(outapp);
  5200. }
  5201. client->GetPlayer()->ChangePrimaryWeapon();
  5202. client->GetPlayer()->ChangeSecondaryWeapon();
  5203. client->GetPlayer()->ChangeRangedWeapon();
  5204. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5205. client->QueuePacket(characterSheetPackets);
  5206. }
  5207. }
  5208. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5209. {
  5210. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5211. int16 index1 = atoi(sep->arg[1]);
  5212. int16 index2 = atoi(sep->arg[2]);
  5213. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5214. if(outapp)
  5215. client->QueuePacket(outapp);
  5216. else
  5217. {
  5218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5219. return;
  5220. }
  5221. }
  5222. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5223. {
  5224. sint16 to_slot = atoi(sep->arg[1]);
  5225. sint32 bag_id = atoi(sep->arg[2]);
  5226. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5227. if (item) {
  5228. //auto inventory
  5229. if (bag_id == 0 && to_slot == -1)
  5230. {
  5231. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5232. {
  5233. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5234. return;
  5235. }
  5236. // Set the slot for the item
  5237. item->details.inv_slot_id = bag_id;
  5238. item->details.slot_id = to_slot;
  5239. // Flag the item so it gets saved in its new location
  5240. item->save_needed = true;
  5241. // Add the item to its new location
  5242. player->item_list.AddItem(item);
  5243. // Remove the item from the overflow list
  5244. player->item_list.RemoveOverflowItem(item);
  5245. // Send the inventory update packet
  5246. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5247. return;
  5248. }
  5249. else if (bag_id == -3 && to_slot == -1) {
  5250. // Auto Bank
  5251. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5252. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5253. return;
  5254. }
  5255. item->details.inv_slot_id = bag_id;
  5256. item->details.slot_id = to_slot;
  5257. item->save_needed = true;
  5258. player->item_list.AddItem(item);
  5259. player->item_list.RemoveOverflowItem(item);
  5260. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5261. }
  5262. else if (bag_id == -4) {
  5263. // Shared Bank
  5264. if (!player->item_list.SharedBankAddAllowed(item)) {
  5265. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5266. return;
  5267. }
  5268. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5269. if (tmp_item) {
  5270. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5271. return;
  5272. }
  5273. else {
  5274. item->details.inv_slot_id = bag_id;
  5275. item->details.slot_id = to_slot;
  5276. item->save_needed = true;
  5277. player->item_list.AddItem(item);
  5278. player->item_list.RemoveOverflowItem(item);
  5279. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5280. return;
  5281. }
  5282. }
  5283. else {
  5284. // Try to get an item from the given bag id and slot id
  5285. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5286. // Check to see if we got an item, if we do send an error,
  5287. // if we don't put the overflow item into this slot
  5288. if (tmp_item) {
  5289. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5290. }
  5291. else {
  5292. item->details.inv_slot_id = bag_id;
  5293. item->details.slot_id = to_slot;
  5294. item->save_needed = true;
  5295. player->item_list.AddItem(item);
  5296. player->item_list.RemoveOverflowItem(item);
  5297. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5298. return;
  5299. }
  5300. }
  5301. }
  5302. }
  5303. }
  5304. else
  5305. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5306. }
  5307. /*
  5308. Function: Command_IRC()
  5309. Purpose : Handle the IRC functions
  5310. Params : IRC Commands
  5311. Dev : Scatman
  5312. Example : /irc say #Channel Hello World!
  5313. */
  5314. void Commands::Command_IRC(Client* client, Seperator* sep)
  5315. {
  5316. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5317. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5318. return;
  5319. }
  5320. if (sep && sep->arg[0][0]) {
  5321. if (strcasecmp(sep->arg[0], "say") == 0) {
  5322. if (sep->arg[1][0] && sep->arg[2][0]) {
  5323. if (sep->IsNumber(sep->arg[1]))
  5324. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5325. else
  5326. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5327. }
  5328. else
  5329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5330. }
  5331. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5332. if (sep->arg[1][0])
  5333. irc.JoinChannel(client, sep->arg[1]);
  5334. else
  5335. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5336. }
  5337. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5338. if (sep->arg[1][0])
  5339. irc.LeaveChannel(client, sep->arg[1]);
  5340. else
  5341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5342. }
  5343. else if (strcasecmp(sep->arg[0], "list") == 0)
  5344. irc.ListChannels(client);
  5345. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5346. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5347. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5348. else
  5349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5350. }
  5351. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5352. irc.DisconnectFromServer(client);
  5353. else
  5354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5355. }
  5356. else
  5357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5358. }
  5359. /*
  5360. Function: Command_Languages()
  5361. Purpose : Show's languages the player knows
  5362. Params :
  5363. Dev : Zcoretri
  5364. Example :
  5365. */
  5366. void Commands::Command_Languages(Client* client, Seperator* sep)
  5367. {
  5368. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5369. list<Language*>::iterator itr;
  5370. Language* language;
  5371. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5372. for(itr = languages->begin(); itr != languages->end(); itr++)
  5373. {
  5374. language = *itr;
  5375. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5376. }
  5377. }
  5378. /*
  5379. Function: Command_SetLanguage()
  5380. Purpose : Handles language commands
  5381. Params : Language ID
  5382. Dev : Zcoretri
  5383. Example :
  5384. */
  5385. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5386. {
  5387. Player* player = client->GetPlayer();
  5388. if (sep && sep->arg[0])
  5389. {
  5390. if(!sep->IsNumber(0))
  5391. {
  5392. //String passed in
  5393. const char* value = sep->arg[0];
  5394. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5395. {
  5396. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5397. client->SendLanguagesUpdate(0);
  5398. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5399. }
  5400. else
  5401. {
  5402. if(player->HasLanguage(value))
  5403. {
  5404. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5405. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5406. client->SendLanguagesUpdate(language->GetID());
  5407. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5408. }
  5409. else
  5410. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5411. }
  5412. }
  5413. else
  5414. {
  5415. //Number passed in
  5416. int32 id = atoul(sep->arg[0]);
  5417. if(player->HasLanguage(id))
  5418. {
  5419. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5420. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5421. client->SendLanguagesUpdate(id);
  5422. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5423. }
  5424. else
  5425. {
  5426. Language* language = master_languages_list.GetLanguage(id);
  5427. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5428. }
  5429. }
  5430. }
  5431. else
  5432. {
  5433. //No value was passed in
  5434. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5435. if(id > 0)
  5436. {
  5437. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5438. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5439. }
  5440. else
  5441. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5442. }
  5443. }
  5444. /*
  5445. Function: Command_LastName()
  5446. Purpose : Sets player surname
  5447. Params : Name text
  5448. Dev : theFoof
  5449. Example :
  5450. */
  5451. void Commands::Command_LastName(Client* client, Seperator* sep)
  5452. {
  5453. if (!client)
  5454. return;
  5455. if (sep && sep->arg[0])
  5456. {
  5457. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5458. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5459. return;
  5460. }
  5461. client->RemovePendingLastName();
  5462. uchar* checkname = (uchar*)sep->arg[0];
  5463. bool valid_name = true;
  5464. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5465. if (!alpha_check(checkname[i])) {
  5466. valid_name = false;
  5467. break;
  5468. }
  5469. }
  5470. if (!valid_name) {
  5471. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5472. return;
  5473. }
  5474. string last_name = (string)sep->arg[0];
  5475. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5476. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5477. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5478. client->SetPendingLastName(last_name);
  5479. client->SendLastNameConfirmation();
  5480. }
  5481. else
  5482. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5483. }
  5484. }
  5485. /*
  5486. Function: Command_ConfirmLastName()
  5487. Purpose : Confirms setting of player surname
  5488. Params : Name text
  5489. Dev : theFoof
  5490. Example :
  5491. */
  5492. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5493. {
  5494. if (!client)
  5495. return;
  5496. string* name = client->GetPendingLastName();
  5497. if (name){
  5498. Player* player = client->GetPlayer();
  5499. player->SetLastName(name->c_str(), false);
  5500. client->SendTitleUpdate();
  5501. player->SetCharSheetChanged(true);
  5502. client->RemovePendingLastName();
  5503. }
  5504. }
  5505. /*
  5506. Function: Command_Location()
  5507. Purpose : Display's Help for /location commands
  5508. Params :
  5509. Dev : Scatman
  5510. Example : /location = show's help for command
  5511. */
  5512. void Commands::Command_Location(Client* client)
  5513. {
  5514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5516. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5519. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5520. }
  5521. /*
  5522. Function: Command_LocationAdd()
  5523. Purpose : Add's a location to an existing location config
  5524. Params : location_id
  5525. Dev : Scatman
  5526. Example : /location add {location_id}
  5527. */
  5528. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5529. {
  5530. if (sep && sep->arg[0] && sep->IsNumber(0))
  5531. {
  5532. int32 location_id = atoul(sep->arg[0]);
  5533. float x = client->GetPlayer()->GetX();
  5534. float y = client->GetPlayer()->GetY();
  5535. float z = client->GetPlayer()->GetZ();
  5536. if (database.AddLocationPoint(location_id, x, y, z))
  5537. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5538. else
  5539. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5540. }
  5541. else
  5542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5543. }
  5544. /*
  5545. Function: Command_LocationCreate()
  5546. Purpose : Creates a new location config
  5547. Params : location name, 0/1 for include_y (optional)
  5548. Dev : Scatman
  5549. Example : /location create Test 1 = creates a new location named Test with include_y True
  5550. */
  5551. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5552. {
  5553. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5554. {
  5555. const char* name = sep->arg[0];
  5556. bool include_y = false;
  5557. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5558. include_y = true;
  5559. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5560. if (location_id > 0)
  5561. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5562. else
  5563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5564. }
  5565. else
  5566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5567. }
  5568. /*
  5569. Function: Command_LocationDelete()
  5570. Purpose : Delete's a location config and all it's location points
  5571. Params : location_id
  5572. Dev : Scatman
  5573. Example : /location delete {location_id}
  5574. */
  5575. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5576. {
  5577. if (sep && sep->arg[0] && sep->IsNumber(0))
  5578. {
  5579. int32 location_id = atoul(sep->arg[0]);
  5580. if (database.DeleteLocation(location_id))
  5581. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5582. else
  5583. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5584. }
  5585. else
  5586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5587. }
  5588. /*
  5589. Function: Command_LocationList()
  5590. Purpose : Display's a list of location points
  5591. Params : location_id
  5592. Dev : Scatman
  5593. Example : /location list {location_id}
  5594. */
  5595. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5596. {
  5597. if (sep && sep->arg[0])
  5598. {
  5599. const char* option = sep->arg[0];
  5600. if (strncmp(option, "locations", strlen(option)) == 0)
  5601. database.ListLocations(client);
  5602. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5603. {
  5604. int32 location_id = atoul(sep->arg[1]);
  5605. database.ListLocationPoints(client, location_id);
  5606. }
  5607. else
  5608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5609. }
  5610. else
  5611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5612. }
  5613. /*
  5614. Function: Command_LocationRemove()
  5615. Purpose : Removes a single location point from a location config
  5616. Params : location_point_id (gotten from /location list {id})
  5617. Dev : Scatman
  5618. Example : /location remove 1 = will remove location_point_id 1
  5619. */
  5620. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5621. {
  5622. if (sep && sep->arg[0] && sep->IsNumber(0))
  5623. {
  5624. int32 location_point_id = atoul(sep->arg[0]);
  5625. if (database.DeleteLocationPoint(location_point_id))
  5626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5627. else
  5628. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5629. }
  5630. else
  5631. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5632. }
  5633. /*
  5634. Function: Command_Merchant()
  5635. Purpose : Handles Merchant commands
  5636. Params : list
  5637. Dev : Scatman
  5638. Example : /merchant list
  5639. */
  5640. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5641. {
  5642. if( handler == COMMAND_MERCHANT )
  5643. {
  5644. // /merchant command by itself shows help (to be extended)
  5645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5646. return;
  5647. }
  5648. else if( handler == COMMAND_MERCHANT_LIST )
  5649. {
  5650. // /merchant list command expects "description" param
  5651. if (sep && sep->arg[0])
  5652. {
  5653. const char* merchant_description = sep->argplus[0];
  5654. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5655. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5656. map<int32, MerchantInfo*>::iterator itr;
  5657. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5658. {
  5659. string description = database.GetMerchantDescription(itr->first);
  5660. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5661. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5662. }
  5663. }
  5664. else // no description
  5665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5666. }
  5667. }
  5668. /*
  5669. Function: Command_Modify()
  5670. Purpose : to replace our other "set" commands
  5671. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5672. Dev : John Adams
  5673. Example : /modify spell set name "Aegolism III"
  5674. */
  5675. void Commands::Command_Modify(Client* client)
  5676. {
  5677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5682. }
  5683. /*
  5684. Function: Command_ModifySpawn()
  5685. Purpose : replace "spawn set" commands
  5686. Params : Action : the action to perform (or special handler)
  5687. : Field : the DB field to change
  5688. : Value : what to set the value to
  5689. : Target : what object to change (my target, or spawn_id)
  5690. Dev : John Adams
  5691. Example : /modify spawn set name "Lady Vox"
  5692. :
  5693. Note : Special Handlers, like "zoneto" for Signs
  5694. : /modify spawn zoneto
  5695. : Will set a sign's zone x/y/z to my current coords
  5696. */
  5697. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5698. {
  5699. PrintSep(sep, "COMMAND_MODIFY");
  5700. // need at least 2 args for a valid command
  5701. if( sep && sep->arg[1] )
  5702. {
  5703. // JA: just a quick implementation because I need it :)
  5704. if (strcmp(sep->arg[0], "zoneto") == 0)
  5705. {
  5706. if( sep->IsNumber(1) )
  5707. {
  5708. int32 spawn_id = atoul(sep->arg[1]);
  5709. float x_coord = client->GetPlayer()->GetX();
  5710. float y_coord = client->GetPlayer()->GetY();
  5711. float z_coord = client->GetPlayer()->GetZ();
  5712. float h_coord = client->GetPlayer()->GetHeading();
  5713. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5714. }
  5715. else
  5716. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5717. }
  5718. }
  5719. else
  5720. Command_Modify(client);
  5721. }
  5722. /*
  5723. Function: Command_ModifyCharacter()
  5724. Purpose : to replace our other "set" commands
  5725. Params : Action : Add, Remove
  5726. : Field : copper, silver, gold, plat
  5727. : Value : min 1, max unlimited
  5728. : Target : Self, Player
  5729. Dev : Cynnar
  5730. Example : /modify character add gold 50
  5731. : /modify character remove silver 25
  5732. */
  5733. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5734. {
  5735. PrintSep(sep, "COMMAND_MODIFY");
  5736. int64 value = 0;
  5737. Player* player = client->GetPlayer();
  5738. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5739. player = (Player*)player->GetTarget();
  5740. // need at least 2 args for a valid command
  5741. if( sep && sep->arg[1] )
  5742. {
  5743. if (strcmp(sep->arg[0], "add") == 0)
  5744. {
  5745. if (strcmp(sep->arg[1], "copper") == 0)
  5746. {
  5747. value = atoi64(sep->arg[2]);
  5748. player->AddCoins(value);
  5749. if (client->GetPlayer() == player)
  5750. {
  5751. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5752. }
  5753. else {
  5754. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5755. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5756. }
  5757. }
  5758. else if (strcmp(sep->arg[1], "silver") == 0)
  5759. {
  5760. value = atoi64(sep->arg[2]) * 100;
  5761. player->AddCoins(value);
  5762. if (client->GetPlayer() == player)
  5763. {
  5764. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5765. }
  5766. else {
  5767. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5768. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5769. }
  5770. }
  5771. else if (strcmp(sep->arg[1], "gold") == 0)
  5772. {
  5773. value = atoi64(sep->arg[2]) * 10000;
  5774. player->AddCoins(value);
  5775. if (client->GetPlayer() == player)
  5776. {
  5777. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5778. }
  5779. else {
  5780. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5781. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5782. }
  5783. }
  5784. else if (strcmp(sep->arg[1], "plat") == 0)
  5785. {
  5786. value = atoi64(sep->arg[2]) * 1000000;
  5787. player->AddCoins(value);
  5788. if (client->GetPlayer() == player)
  5789. {
  5790. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5791. }
  5792. else {
  5793. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5794. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5795. }
  5796. }
  5797. else
  5798. {
  5799. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5800. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5801. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5802. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5803. }
  5804. }
  5805. else if (strcmp(sep->arg[0], "remove") == 0)
  5806. {
  5807. if (strcmp(sep->arg[1], "copper") == 0)
  5808. {
  5809. value = atoi64(sep->arg[2]);
  5810. player->RemoveCoins(value);
  5811. if (client->GetPlayer() == player)
  5812. {
  5813. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5814. }
  5815. else {
  5816. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5817. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5818. }
  5819. }
  5820. else if (strcmp(sep->arg[1], "silver") == 0)
  5821. {
  5822. value = atoi64(sep->arg[2]) * 100;
  5823. player->RemoveCoins(value);
  5824. if (client->GetPlayer() == player)
  5825. {
  5826. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5827. }
  5828. else {
  5829. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5830. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5831. }
  5832. }
  5833. else if (strcmp(sep->arg[1], "gold") == 0)
  5834. {
  5835. value = atoi64(sep->arg[2]) * 10000;
  5836. player->RemoveCoins(value);
  5837. if (client->GetPlayer() == player)
  5838. {
  5839. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5840. }
  5841. else {
  5842. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5843. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5844. }
  5845. }
  5846. else if (strcmp(sep->arg[1], "plat") == 0)
  5847. {
  5848. value = atoi64(sep->arg[2]) * 1000000;
  5849. player->RemoveCoins(value);
  5850. if (client->GetPlayer() == player)
  5851. {
  5852. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5853. }
  5854. else {
  5855. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5856. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5857. }
  5858. }
  5859. else
  5860. {
  5861. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5862. }
  5863. }
  5864. else if (strcmp(sep->arg[0], "set") == 0) {
  5865. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5866. int8 level = atoi(sep->arg[2]);
  5867. if (level > 0 && level < 256) {
  5868. if (player) {
  5869. if (client->GetPlayer() == player)
  5870. client->ChangeTSLevel(player->GetTSLevel(), level);
  5871. else
  5872. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5873. }
  5874. }
  5875. else
  5876. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5877. }
  5878. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5879. int8 tsclass = atoi(sep->arg[2]);
  5880. player->SetTradeskillClass(tsclass);
  5881. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5882. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5883. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5884. player->SetCharSheetChanged(true);
  5885. }
  5886. }
  5887. }
  5888. else
  5889. {
  5890. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5891. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5892. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5893. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5894. }
  5895. }
  5896. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5897. {
  5898. PrintSep(sep, "COMMAND_MODIFY");
  5899. // need at least 2 args for a valid command
  5900. if( sep && sep->arg[1] )
  5901. {
  5902. }
  5903. else
  5904. Command_Modify(client);
  5905. }
  5906. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5907. {
  5908. PrintSep(sep, "COMMAND_MODIFY");
  5909. // need at least 2 args for a valid command
  5910. if( sep && sep->arg[1] )
  5911. {
  5912. }
  5913. else
  5914. Command_Modify(client);
  5915. }
  5916. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5917. {
  5918. PrintSep(sep, "COMMAND_MODIFY");
  5919. // need at least 2 args for a valid command
  5920. if( sep && sep->arg[1] )
  5921. {
  5922. }
  5923. else
  5924. Command_Modify(client);
  5925. }
  5926. /*
  5927. Function: Command_ModifyQuest()
  5928. Purpose : to list players quest and completed quests
  5929. Params : Action : list, completed
  5930. : Target : Self, Player
  5931. Dev : Cynnar
  5932. Example : /modify quest list
  5933. : /modify quest completed
  5934. */
  5935. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5936. {
  5937. PrintSep(sep, "COMMAND_MODIFY");
  5938. int64 value = 0;
  5939. Player* player = client->GetPlayer();
  5940. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5941. player = (Player*)player->GetTarget();
  5942. // need at least 2 args for a valid command
  5943. if (sep && sep->arg[1])
  5944. {
  5945. if (strcmp(sep->arg[0], "list") == 0)
  5946. {
  5947. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5948. map<int32, Quest*>::iterator itr;
  5949. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5950. if (quests->size() == 0)
  5951. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5952. else
  5953. {
  5954. for (itr = quests->begin(); itr != quests->end(); itr++)
  5955. {
  5956. Quest* quest = itr->second;
  5957. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5958. }
  5959. }
  5960. }
  5961. else if (strcmp(sep->arg[0], "completed") == 0)
  5962. {
  5963. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5964. map<int32, Quest*>::iterator itr;
  5965. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5966. if (quests->size() == 0)
  5967. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5968. else
  5969. {
  5970. for (itr = quests->begin(); itr != quests->end(); itr++)
  5971. {
  5972. Quest* quest = itr->second;
  5973. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5974. }
  5975. }
  5976. }
  5977. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5978. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5979. else if (strcmp(sep->arg[0], "remove") == 0)
  5980. {
  5981. int32 quest_id = 0;
  5982. if (sep && sep->arg[1] && sep->IsNumber(1))
  5983. quest_id = atoul(sep->arg[1]);
  5984. if (quest_id > 0)
  5985. {
  5986. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5987. {
  5988. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5989. if (quest)
  5990. if (client->GetPlayer() == player)
  5991. {
  5992. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5993. }
  5994. else
  5995. {
  5996. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5997. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5998. }
  5999. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6000. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6001. }
  6002. client->RemovePlayerQuest(quest_id);
  6003. client->GetCurrentZone()->SendQuestUpdates(client);
  6004. }
  6005. }
  6006. else if (strcmp(sep->arg[0], "advance") == 0)
  6007. {
  6008. int32 quest_id = 0;
  6009. int32 step = 0;
  6010. if (sep && sep->arg[1] && sep->IsNumber(1))
  6011. {
  6012. quest_id = atoul(sep->arg[1]);
  6013. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6014. if (sep && sep->arg[2] && sep->IsNumber(1))
  6015. {
  6016. step = atoul(sep->arg[2]);
  6017. if (quest_id > 0 && step > 0)
  6018. {
  6019. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6020. {
  6021. if (client)
  6022. {
  6023. client->AddPendingQuestUpdate(quest_id, step);
  6024. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6025. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6026. }
  6027. }
  6028. }
  6029. else
  6030. {
  6031. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6032. }
  6033. }
  6034. else
  6035. {
  6036. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6037. }
  6038. }
  6039. else
  6040. {
  6041. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6042. }
  6043. }
  6044. else
  6045. {
  6046. Command_Modify(client);
  6047. }
  6048. }
  6049. else
  6050. {
  6051. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6052. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6053. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6054. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6055. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6056. }
  6057. }
  6058. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6059. {
  6060. PrintSep(sep, "COMMAND_MODIFY");
  6061. // need at least 2 args for a valid command
  6062. if( sep && sep->arg[1] )
  6063. {
  6064. if (strcmp(sep->arg[0], "add") == 0) {
  6065. const char* skill_name = sep->argplus[1];
  6066. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6067. if (skill) {
  6068. Player* player = 0;
  6069. Client* to_client = 0;
  6070. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6071. player = (Player*)client->GetPlayer()->GetTarget();
  6072. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6073. }
  6074. else {
  6075. player = client->GetPlayer();
  6076. to_client = client;
  6077. }
  6078. if (player)
  6079. {
  6080. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6081. {
  6082. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6083. if (to_client == client) {
  6084. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6085. }
  6086. else {
  6087. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6088. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6089. }
  6090. }
  6091. else
  6092. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6093. }
  6094. }
  6095. else
  6096. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6097. }
  6098. else if (strcmp(sep->arg[0], "remove") == 0) {
  6099. const char* skill_name = sep->argplus[1];
  6100. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6101. if (skill) {
  6102. Player* player = 0;
  6103. Client* to_client = 0;
  6104. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6105. player = (Player*)client->GetPlayer()->GetTarget();
  6106. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6107. }
  6108. else {
  6109. player = client->GetPlayer();
  6110. to_client = client;
  6111. }
  6112. if (player)
  6113. {
  6114. if (player->GetSkills()->HasSkill(skill->skill_id))
  6115. {
  6116. player->RemoveSkillFromDB(skill, true);
  6117. if (client == to_client) {
  6118. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6119. }
  6120. else {
  6121. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6122. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6123. }
  6124. }
  6125. else {
  6126. if (client == to_client)
  6127. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6128. else
  6129. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6130. }
  6131. }
  6132. }
  6133. else
  6134. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6135. }
  6136. else if (strcmp(sep->arg[0], "set") == 0) {
  6137. if (!sep->IsNumber(2)) {
  6138. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6139. return;
  6140. }
  6141. const char* skill_name = sep->arg[1];
  6142. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6143. if (skill) {
  6144. int16 val = atoi(sep->arg[2]);
  6145. Player* player = 0;
  6146. Client* to_client = 0;
  6147. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6148. player = (Player*)client->GetPlayer()->GetTarget();
  6149. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6150. }
  6151. else {
  6152. player = client->GetPlayer();
  6153. to_client = client;
  6154. }
  6155. if (player)
  6156. {
  6157. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6158. player->GetSkills()->SetSkill(skill->skill_id, val);
  6159. if (client != to_client)
  6160. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6161. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6162. }
  6163. else {
  6164. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6165. }
  6166. }
  6167. }
  6168. else {
  6169. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6170. }
  6171. }
  6172. else {
  6173. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6174. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6175. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6176. }
  6177. }
  6178. else {
  6179. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6180. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6181. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6182. }
  6183. }
  6184. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6185. {
  6186. PrintSep(sep, "COMMAND_MODIFY");
  6187. // need at least 2 args for a valid command
  6188. if( sep && sep->arg[1] )
  6189. {
  6190. }
  6191. else
  6192. Command_Modify(client);
  6193. }
  6194. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6195. {
  6196. PrintSep(sep, "COMMAND_MODIFY");
  6197. // need at least 2 args for a valid command
  6198. if( sep && sep->arg[1] )
  6199. {
  6200. }
  6201. else
  6202. Command_Modify(client);
  6203. }
  6204. /*
  6205. Function: Command_MOTD()
  6206. Purpose : Displays server MOTD
  6207. Params :
  6208. Dev : LethalEncounter
  6209. Example : /motd
  6210. */
  6211. void Commands::Command_MOTD(Client* client)
  6212. {
  6213. if (client)
  6214. ClientPacketFunctions::SendMOTD(client);
  6215. }
  6216. /*
  6217. Function: Command_Pet()
  6218. Purpose : Handle Pet {Command} commands
  6219. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6220. Dev :
  6221. Example : /pet preserve_master
  6222. */
  6223. void Commands::Command_Pet(Client* client, Seperator* sep)
  6224. {
  6225. PrintSep(sep, "COMMAND_PET");
  6226. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6227. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6228. if (strcmp(sep->arg[0], "hide") == 0) {
  6229. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6230. Entity* pet = client->GetPlayer()->GetDeityPet();
  6231. if (pet) {
  6232. if (pet->IsPrivateSpawn())
  6233. client->GetPlayer()->HideDeityPet(false);
  6234. else
  6235. client->GetPlayer()->HideDeityPet(true);
  6236. }
  6237. pet = client->GetPlayer()->GetCosmeticPet();
  6238. if (pet) {
  6239. if (pet->IsPrivateSpawn())
  6240. client->GetPlayer()->HideCosmeticPet(false);
  6241. else
  6242. client->GetPlayer()->HideCosmeticPet(true);
  6243. }
  6244. return;
  6245. }
  6246. // below is for all combat pets
  6247. if (!client->GetPlayer()->HasPet()) {
  6248. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6249. return;
  6250. }
  6251. if (strcmp(sep->arg[0], "stay") == 0) {
  6252. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6253. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6254. client->GetPlayer()->SetCharSheetChanged(true);
  6255. if (client->GetPlayer()->GetPet())
  6256. client->GetPlayer()->GetPet()->following = false;
  6257. if (client->GetPlayer()->GetCharmedPet())
  6258. client->GetPlayer()->GetCharmedPet()->following = false;
  6259. }
  6260. else if (strcmp(sep->arg[0], "follow") == 0) {
  6261. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6262. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6263. client->GetPlayer()->SetCharSheetChanged(true);
  6264. }
  6265. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6266. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6267. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6268. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6269. }
  6270. else {
  6271. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6272. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6273. }
  6274. client->GetPlayer()->SetCharSheetChanged(true);
  6275. }
  6276. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6277. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6278. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6279. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6280. }
  6281. else {
  6282. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6283. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6284. }
  6285. client->GetPlayer()->SetCharSheetChanged(true);
  6286. }
  6287. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6288. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6289. if (client->GetPlayer()->GetPet())
  6290. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6291. if (client->GetPlayer()->GetCharmedPet())
  6292. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6293. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6294. client->GetPlayer()->SetCharSheetChanged(true);
  6295. }
  6296. else if (strcmp(sep->arg[0], "attack") == 0) {
  6297. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6298. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6299. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6300. if (client->GetPlayer()->GetPet())
  6301. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6302. if (client->GetPlayer()->GetCharmedPet())
  6303. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6304. }
  6305. else
  6306. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6307. }
  6308. else
  6309. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6310. }
  6311. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6312. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6313. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6314. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6315. }
  6316. else
  6317. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6318. }
  6319. /*
  6320. Function: Command_PetName()
  6321. Purpose : Pet your name (???)
  6322. Params :
  6323. Dev :
  6324. Example :
  6325. */
  6326. void Commands::Command_PetName(Client* client, Seperator* sep)
  6327. {
  6328. PrintSep(sep, "COMMAND_PETNAME");
  6329. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6330. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6331. }
  6332. /*
  6333. Function: Command_NamePet()
  6334. Purpose : Name your pet
  6335. Params :
  6336. Dev :
  6337. Example :
  6338. */
  6339. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6340. {
  6341. PrintSep(sep, "COMMAND_NAME_PET");
  6342. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6343. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6344. }
  6345. /*
  6346. Function: Command_Rename()
  6347. Purpose : Renames existing pet
  6348. Params :
  6349. Dev :
  6350. Example :
  6351. */
  6352. void Commands::Command_Rename(Client* client, Seperator* sep)
  6353. {
  6354. PrintSep(sep, "COMMAND_RENAME");
  6355. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6356. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6357. }
  6358. /*
  6359. Function: Command_ConfirmRename()
  6360. Purpose : Confirms renaming your pet
  6361. Params :
  6362. Dev :
  6363. Example :
  6364. */
  6365. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6366. {
  6367. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6368. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6369. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6370. }
  6371. /*
  6372. Function: Command_PetOptions()
  6373. Purpose : Sets various pet options
  6374. Params :
  6375. Dev :
  6376. Example :
  6377. */
  6378. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6379. {
  6380. PrintSep(sep, "COMMAND_PETOPTIONS");
  6381. Player* player = client->GetPlayer();
  6382. Spawn* target = player->GetTarget();
  6383. if (!target)
  6384. return;
  6385. if (target == player->GetPet())
  6386. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6387. else if (target == player->GetCharmedPet())
  6388. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6389. else if (target == player->GetCosmeticPet())
  6390. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6391. else if (target == player->GetDeityPet())
  6392. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6393. }
  6394. /*
  6395. Function: Command_Random()
  6396. Purpose : Handles /random dice roll in-game
  6397. Params : 1-100
  6398. Dev : Scatman
  6399. Example : /randon 1 100
  6400. */
  6401. void Commands::Command_Random(Client* client, Seperator* sep)
  6402. {
  6403. char message[256] = {0};
  6404. if (sep)
  6405. {
  6406. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6407. 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])));
  6408. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6409. 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])));
  6410. else
  6411. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6412. }
  6413. else
  6414. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6415. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6416. }
  6417. /*
  6418. Function: Command_Randomize()
  6419. Purpose : Sets randomize (appearance) values for NPCs
  6420. Params : Attrib Name
  6421. Dev : Scatman
  6422. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6423. */
  6424. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6425. {
  6426. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6427. if (target)
  6428. {
  6429. if (target->IsNPC())
  6430. {
  6431. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6432. {
  6433. const char* value = sep->arg[0];
  6434. if (strncasecmp(value, "show", strlen(value)) == 0)
  6435. {
  6436. client->DisplayRandomizeFeatures(target->GetRandomize());
  6437. }
  6438. else
  6439. {
  6440. if (sep->arg[1] && sep->IsNumber(1))
  6441. {
  6442. int8 option = atoi(sep->arg[1]);
  6443. if (option == 0 || option == 1)
  6444. {
  6445. int32 feature = 0;
  6446. char feature_text[32] = {0};
  6447. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6448. feature = RANDOMIZE_GENDER;
  6449. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6450. }
  6451. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6452. feature = RANDOMIZE_RACE;
  6453. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6454. }
  6455. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6456. feature = RANDOMIZE_MODEL_TYPE;
  6457. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6458. }
  6459. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6460. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6461. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6462. }
  6463. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6464. feature = RANDOMIZE_HAIR_TYPE;
  6465. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6466. }
  6467. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6468. feature = RANDOMIZE_WING_TYPE;
  6469. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6470. }
  6471. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6472. feature = RANDOMIZE_CHEEK_TYPE;
  6473. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6474. }
  6475. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6476. feature = RANDOMIZE_CHIN_TYPE;
  6477. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6478. }
  6479. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6480. feature = RANDOMIZE_EAR_TYPE;
  6481. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6482. }
  6483. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6484. feature = RANDOMIZE_EYE_BROW_TYPE;
  6485. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6486. }
  6487. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6488. feature = RANDOMIZE_EYE_TYPE;
  6489. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6490. }
  6491. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6492. feature = RANDOMIZE_LIP_TYPE;
  6493. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6494. }
  6495. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6496. feature = RANDOMIZE_NOSE_TYPE;
  6497. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6498. }
  6499. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6500. feature = RANDOMIZE_EYE_COLOR;
  6501. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6502. }
  6503. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6504. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6505. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6506. }
  6507. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6508. feature = RANDOMIZE_HAIR_COLOR1;
  6509. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6510. }
  6511. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6512. feature = RANDOMIZE_HAIR_COLOR2;
  6513. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6514. }
  6515. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6516. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6517. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6518. }
  6519. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6520. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6521. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6522. }
  6523. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6524. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6525. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6526. }
  6527. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6528. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6529. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6530. }
  6531. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6532. feature = RANDOMIZE_SKIN_COLOR;
  6533. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6534. }
  6535. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6536. feature = RANDOMIZE_WING_COLOR1;
  6537. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6538. }
  6539. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6540. feature = RANDOMIZE_WING_COLOR2;
  6541. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6542. }
  6543. else {
  6544. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6545. 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'.");
  6546. }
  6547. if (feature > 0) {
  6548. if (option == 1) {
  6549. if (target->GetRandomize() & feature)
  6550. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6551. else {
  6552. target->AddRandomize(feature);
  6553. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6554. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6555. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6556. }
  6557. }
  6558. else {
  6559. if (target->GetRandomize() & feature) {
  6560. target->AddRandomize(-feature);
  6561. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6562. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6563. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6564. }
  6565. else
  6566. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6567. }
  6568. }
  6569. }
  6570. else
  6571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6572. }
  6573. else
  6574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6575. }
  6576. }
  6577. else {
  6578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6580. 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'.");
  6581. }
  6582. }
  6583. else
  6584. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6585. }
  6586. else
  6587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6588. }
  6589. /*
  6590. Function: Command_ShowCloak()
  6591. Purpose : Character Settings combo box for Show Cloak
  6592. Params : true/false
  6593. Dev : John Adams
  6594. Example :
  6595. */
  6596. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6597. {
  6598. Player* player = client->GetPlayer();
  6599. if (sep && sep->arg[0])
  6600. {
  6601. const char* value = sep->arg[0];
  6602. if (strncasecmp(value, "true", strlen(value)) == 0)
  6603. {
  6604. player->set_character_flag(CF_SHOW_CLOAK);
  6605. player->reset_character_flag(CF2_SHOW_RANGED);
  6606. }
  6607. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6608. player->reset_character_flag(CF_SHOW_CLOAK);
  6609. else
  6610. {
  6611. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6612. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6613. }
  6614. }
  6615. }
  6616. /*
  6617. Function: Command_ShowHelm()
  6618. Purpose : Character Settings combo box for Show Helm
  6619. Params : true/false
  6620. Dev : John Adams
  6621. Example :
  6622. */
  6623. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6624. {
  6625. Player* player = client->GetPlayer();
  6626. if (sep && sep->arg[0])
  6627. {
  6628. const char* value = sep->arg[0];
  6629. if (strncasecmp(value, "true", strlen(value)) == 0)
  6630. {
  6631. player->reset_character_flag(CF_HIDE_HELM);
  6632. player->set_character_flag(CF_HIDE_HOOD);
  6633. }
  6634. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6635. player->set_character_flag(CF_HIDE_HELM);
  6636. else
  6637. {
  6638. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6639. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6640. }
  6641. }
  6642. }
  6643. /*
  6644. Function: Command_ShowHood()
  6645. Purpose : Character Settings combo box for Show Hood
  6646. Params : true/false
  6647. Dev : John Adams
  6648. Example :
  6649. */
  6650. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6651. {
  6652. Player* player = client->GetPlayer();
  6653. if (sep && sep->arg[0])
  6654. {
  6655. const char* value = sep->arg[0];
  6656. if (strncasecmp(value, "true", strlen(value)) == 0)
  6657. {
  6658. player->reset_character_flag(CF_HIDE_HOOD);
  6659. player->set_character_flag(CF_HIDE_HELM);
  6660. }
  6661. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6662. player->set_character_flag(CF_HIDE_HOOD);
  6663. else
  6664. {
  6665. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6666. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6667. }
  6668. }
  6669. }
  6670. /*
  6671. Function: Command_ShowHoodHelm()
  6672. Purpose : Character Settings combo box for Show Helm or Hood
  6673. Params : true/false
  6674. Dev : John Adams
  6675. Example :
  6676. */
  6677. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6678. {
  6679. Player* player = client->GetPlayer();
  6680. if (sep && sep->arg[0])
  6681. {
  6682. const char* value = sep->arg[0];
  6683. if (strncasecmp(value, "true", strlen(value)) == 0)
  6684. {
  6685. player->reset_character_flag(CF_HIDE_HOOD);
  6686. player->reset_character_flag(CF_HIDE_HELM);
  6687. }
  6688. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6689. {
  6690. // don't think we ever wind up in here...
  6691. player->set_character_flag(CF_HIDE_HOOD);
  6692. player->set_character_flag(CF_HIDE_HELM);
  6693. }
  6694. else
  6695. {
  6696. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6697. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6698. }
  6699. }
  6700. }
  6701. /*
  6702. Function: Command_ShowRanged()
  6703. Purpose : Character Settings combo box for Show Ranged weapon
  6704. Params : true/false
  6705. Dev : John Adams
  6706. Example :
  6707. */
  6708. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6709. {
  6710. Player* player = client->GetPlayer();
  6711. if (sep && sep->arg[0])
  6712. {
  6713. const char* value = sep->arg[0];
  6714. if (strncasecmp(value, "true", strlen(value)) == 0)
  6715. {
  6716. player->set_character_flag(CF2_SHOW_RANGED);
  6717. player->reset_character_flag(CF_SHOW_CLOAK);
  6718. }
  6719. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6720. player->reset_character_flag(CF2_SHOW_RANGED);
  6721. else
  6722. {
  6723. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6724. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6725. }
  6726. }
  6727. }
  6728. /*
  6729. Function:
  6730. Purpose :
  6731. Params :
  6732. Dev :
  6733. Example :
  6734. */
  6735. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6736. {
  6737. Player* player = 0;
  6738. Client* to_client = 0;
  6739. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6740. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6741. switch(handler)
  6742. {
  6743. case COMMAND_SKILL:
  6744. {
  6745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6746. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6747. break;
  6748. }
  6749. case COMMAND_SKILL_ADD:
  6750. {
  6751. if (sep && sep->arg[0])
  6752. {
  6753. const char* skill_name = sep->argplus[0];
  6754. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6755. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6756. {
  6757. player = to_client->GetPlayer();
  6758. if (player)
  6759. {
  6760. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6761. {
  6762. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6763. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6764. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6765. }
  6766. else
  6767. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6768. }
  6769. }
  6770. else if (skill) // add skill to yourself
  6771. {
  6772. player = client->GetPlayer();
  6773. if (player)
  6774. {
  6775. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6776. {
  6777. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6778. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6779. }
  6780. else
  6781. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6782. }
  6783. }
  6784. else
  6785. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6786. }
  6787. else
  6788. {
  6789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6791. }
  6792. break;
  6793. }
  6794. case COMMAND_SKILL_REMOVE:
  6795. {
  6796. if (sep && sep->arg[0])
  6797. {
  6798. const char* skill_name = sep->argplus[0];
  6799. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6800. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6801. {
  6802. player = to_client->GetPlayer();
  6803. if (player)
  6804. {
  6805. if (player->GetSkills()->HasSkill(skill->skill_id))
  6806. {
  6807. player->RemoveSkillFromDB(skill, true);
  6808. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6809. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6810. }
  6811. else
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6813. }
  6814. }
  6815. else if(skill) // remove skill from yourself
  6816. {
  6817. Player* player = client->GetPlayer();
  6818. if (player)
  6819. {
  6820. if (player->GetSkills()->HasSkill(skill->skill_id))
  6821. {
  6822. player->RemoveSkillFromDB(skill, true);
  6823. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6824. }
  6825. else
  6826. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6827. }
  6828. }
  6829. else
  6830. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6831. }
  6832. else
  6833. {
  6834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6836. }
  6837. break;
  6838. }
  6839. case COMMAND_SKILL_LIST:
  6840. {
  6841. if (sep && sep->arg[0])
  6842. {
  6843. const char* skill_name = sep->argplus[0];
  6844. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6845. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6846. map<int32, Skill*>::iterator itr;
  6847. if (skills && skills->size() > 0)
  6848. {
  6849. for (itr = skills->begin(); itr != skills->end(); itr++)
  6850. {
  6851. Skill* skill = itr->second;
  6852. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6853. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6854. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6855. }
  6856. }
  6857. }
  6858. else
  6859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6860. break;
  6861. }
  6862. }
  6863. }
  6864. /*
  6865. Function: Command_SpawnTemplate()
  6866. Purpose : Create or Use defined Spawn Templates
  6867. Params : create, save, rempve, list
  6868. Dev : John Adams
  6869. Example : /spawn template create "Test"
  6870. */
  6871. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6872. {
  6873. if (sep == NULL || sep->arg[0] == NULL)
  6874. {
  6875. 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.");
  6876. return;
  6877. }
  6878. // got params, continue
  6879. const char * template_cmd = sep->arg[0];
  6880. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6881. {
  6882. if (!sep->IsSet(1))
  6883. {
  6884. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6885. 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.");
  6886. return;
  6887. }
  6888. map<int32, string>* template_names = 0;
  6889. if (sep->IsNumber(1))
  6890. {
  6891. int32 location_id = 0;
  6892. location_id = atoi(sep->arg[1]);
  6893. template_names = database.GetSpawnTemplateListByID(location_id);
  6894. }
  6895. else
  6896. {
  6897. const char* name = 0;
  6898. name = sep->argplus[1];
  6899. template_names = database.GetSpawnTemplateListByName(name);
  6900. }
  6901. if(!template_names)
  6902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6903. else
  6904. {
  6905. map<int32, string>::iterator itr;
  6906. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6907. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6908. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6909. safe_delete(template_names);
  6910. }
  6911. }
  6912. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6913. {
  6914. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6915. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6916. {
  6917. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6918. {
  6919. // first, lookup to see if template name already exists
  6920. const char* name = 0;
  6921. name = sep->argplus[1];
  6922. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6923. if(!template_names)
  6924. {
  6925. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6926. if( new_template_id > 0 )
  6927. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6928. else
  6929. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6930. }
  6931. else
  6932. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6933. }
  6934. else
  6935. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6936. }
  6937. else
  6938. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6939. }
  6940. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6941. {
  6942. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6943. {
  6944. int32 template_id = 0;
  6945. template_id = atoi(sep->arg[1]);
  6946. if (database.RemoveSpawnTemplate(template_id))
  6947. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6948. else
  6949. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6950. }
  6951. else
  6952. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6953. }
  6954. // Renamed create to spawn
  6955. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6956. {
  6957. if (sep && sep->arg[1][0])
  6958. {
  6959. int32 new_location = 0;
  6960. if (sep->IsNumber(1))
  6961. {
  6962. int32 template_id = 0;
  6963. template_id = atoi(sep->arg[1]);
  6964. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6965. if( new_location > 0 )
  6966. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6967. else
  6968. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6969. }
  6970. else
  6971. {
  6972. const char* name = 0;
  6973. name = sep->argplus[1];
  6974. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6975. if( new_location > 0 )
  6976. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6977. else
  6978. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6979. }
  6980. }
  6981. else
  6982. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6983. }
  6984. else
  6985. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6986. }
  6987. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6988. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6989. float new_speed = atof(sep->arg[0]);
  6990. if (new_speed > 0.0f)
  6991. {
  6992. client->GetPlayer()->SetSpeed(new_speed, true);
  6993. client->GetPlayer()->SetCharSheetChanged(true);
  6994. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6995. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6996. }
  6997. else
  6998. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6999. }
  7000. else{
  7001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7002. }
  7003. }
  7004. /*
  7005. Function: Command_StationMarketPlace()
  7006. Purpose : just trying to eat the console spam for now
  7007. Params :
  7008. Dev : John
  7009. */
  7010. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7011. {
  7012. PrintSep(sep, "COMMAND_SMP");
  7013. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7014. // can't seem to reduce it any more get rid of it completely...
  7015. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7016. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7017. if (packet) {
  7018. packet->setDataByName("account_id", client->GetAccountID());
  7019. packet->setDataByName("character_id", client->GetCharacterID());
  7020. packet->setDataByName("unknown1", 1, 5);
  7021. packet->setDataByName("unknown1", 26, 6);
  7022. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7023. packet->setDataByName("unknown3", 248, 1);
  7024. client->QueuePacket(packet->serialize());
  7025. }
  7026. safe_delete(packet);
  7027. }
  7028. }
  7029. /*
  7030. Function: Command_StopDrinking()
  7031. Purpose : Stops player from auto-consuming drink
  7032. Params :
  7033. Dev : Zcoretri
  7034. Example : /stopdrinking
  7035. */
  7036. void Commands::Command_StopDrinking(Client* client)
  7037. {
  7038. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7039. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7040. }
  7041. /*
  7042. Function: Command_StopEating()
  7043. Purpose : Stops player from auto-consuming food
  7044. Params :
  7045. Dev : Zcoretri
  7046. Example : /stopeating
  7047. */
  7048. void Commands::Command_StopEating(Client* client)
  7049. {
  7050. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7051. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7052. }
  7053. /*
  7054. Function: Command_Title()
  7055. Purpose : Help for /title command
  7056. Params : n/a
  7057. Dev : Zcoretri
  7058. Example : /title
  7059. */
  7060. void Commands::Command_Title(Client* client)
  7061. {
  7062. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7063. }
  7064. /*
  7065. Function: Command_TitleList()
  7066. Purpose : List available titles for player
  7067. Params : n/a
  7068. Dev : Zcoretri
  7069. Example : /title list
  7070. */
  7071. void Commands::Command_TitleList(Client* client)
  7072. {
  7073. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7074. list<Title*>::iterator itr;
  7075. Title* title;
  7076. int16 i = 0;
  7077. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7078. for(itr = titles->begin(); itr != titles->end(); itr++)
  7079. {
  7080. title = *itr;
  7081. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7082. i++;
  7083. }
  7084. }
  7085. /*
  7086. Function: Command_TitleSetPrefix()
  7087. Purpose : Set Prefix title for player
  7088. Params : Title ID
  7089. Dev : Zcoretri
  7090. Example : /title setprefix 1
  7091. */
  7092. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7093. {
  7094. if (sep && sep->arg[0] && sep->IsNumber(0))
  7095. {
  7096. int32 index = atoul(sep->arg[0]);
  7097. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7098. client->SendTitleUpdate();
  7099. }
  7100. }
  7101. /*
  7102. Function: Command_TitleSetSuffix()
  7103. Purpose : Set Suffix title for player
  7104. Params : Title ID
  7105. Dev : Zcoretri
  7106. Example : /title setsuffix 1
  7107. */
  7108. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7109. {
  7110. if (sep && sep->arg[0] && sep->IsNumber(0))
  7111. {
  7112. int32 index = atoul(sep->arg[0]);
  7113. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7114. client->SendTitleUpdate();
  7115. }
  7116. }
  7117. /*
  7118. Function: Command_TitleFix()
  7119. Purpose : Fix title for player (???)
  7120. Params :
  7121. Dev : Zcoretri
  7122. Example :
  7123. */
  7124. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7125. {
  7126. PrintSep(sep, "COMMAND_TITLE_FIX");
  7127. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7128. }
  7129. /*
  7130. Function: Command_Toggle_Anonymous()
  7131. Purpose : Toggles player Anonymous
  7132. Params :
  7133. Dev : paulgh
  7134. Example : /anon
  7135. */
  7136. void Commands::Command_Toggle_Anonymous(Client* client)
  7137. {
  7138. Player* player = client->GetPlayer();
  7139. player->toggle_character_flag(CF_ANONYMOUS);
  7140. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7141. if (player->get_character_flag(CF_ANONYMOUS))
  7142. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7143. else
  7144. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7145. }
  7146. /*
  7147. Function: Command_Toggle_AutoConsume()
  7148. Purpose : Toggles player food/drink auto consume
  7149. Params : unknown
  7150. Dev : paulgh
  7151. Example : /set_auto_consume
  7152. */
  7153. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7154. {
  7155. Player* player = client->GetPlayer();
  7156. if (sep && sep->arg[0])
  7157. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7158. if (sep && sep->arg[0] && sep->IsNumber(0))
  7159. {
  7160. int8 slot = atoi(sep->arg[0]);
  7161. int8 flag = atoi(sep->arg[1]);
  7162. if (slot == EQ2_FOOD_SLOT)
  7163. {
  7164. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7165. player->SetCharSheetChanged(true);
  7166. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7167. if (flag == 1)
  7168. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7169. else
  7170. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7171. }
  7172. else
  7173. {
  7174. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7175. player->SetCharSheetChanged(true);
  7176. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7177. if (flag == 1)
  7178. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7179. else
  7180. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7181. }
  7182. }
  7183. }
  7184. /*
  7185. Function: Command_Toggle_BonusXP()
  7186. Purpose : Toggles player Bonus XP
  7187. Params :
  7188. Dev : John Adams
  7189. Example : /disable_char_bonus_exp
  7190. */
  7191. void Commands::Command_Toggle_BonusXP(Client* client)
  7192. {
  7193. Player* player = client->GetPlayer();
  7194. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7195. player->SetCharSheetChanged(true);
  7196. }
  7197. /*
  7198. Function: Command_Toggle_CombatXP()
  7199. Purpose : Toggles player Adventure XP
  7200. Params :
  7201. Dev : John Adams
  7202. Example : /disable_combat_exp
  7203. */
  7204. void Commands::Command_Toggle_CombatXP(Client* client)
  7205. {
  7206. Player* player = client->GetPlayer();
  7207. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7208. player->SetCharSheetChanged(true);
  7209. }
  7210. /*
  7211. Function: Command_Toggle_GMHide()
  7212. Purpose : Toggles hiding player GM status
  7213. Params :
  7214. Dev : Scatman
  7215. Example : /gm_hide
  7216. */
  7217. void Commands::Command_Toggle_GMHide(Client* client)
  7218. {
  7219. Player* player = client->GetPlayer();
  7220. player->toggle_character_flag(CF_HIDE_STATUS);
  7221. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7222. }
  7223. /*
  7224. Function: Command_Toggle_GMVanish()
  7225. Purpose : Toggles hiding GM players from /who searches
  7226. Params :
  7227. Dev : Scatman
  7228. Example : /gm_vanish
  7229. */
  7230. void Commands::Command_Toggle_GMVanish(Client* client)
  7231. {
  7232. Player* player = client->GetPlayer();
  7233. player->toggle_character_flag(CF_GM_HIDDEN);
  7234. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7235. }
  7236. /*
  7237. Function: Command_Toggle_Illusions()
  7238. Purpose : Toggles player illusion form
  7239. Params : not sure sep is needed, testing
  7240. Dev : paulgh
  7241. Example : /hide_illusions
  7242. */
  7243. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7244. {
  7245. if (sep && sep->arg[0])
  7246. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7247. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7248. }
  7249. /*
  7250. Function: Command_Toggle_LFG()
  7251. Purpose : Toggles player LFG Flag
  7252. Params :
  7253. Dev : paulgh
  7254. Example : /lfg
  7255. */
  7256. void Commands::Command_Toggle_LFG(Client* client)
  7257. {
  7258. Player* player = client->GetPlayer();
  7259. player->toggle_character_flag(CF_LFG);
  7260. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7261. if (player->get_character_flag(CF_LFG))
  7262. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7263. else
  7264. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7265. }
  7266. /*
  7267. Function: Command_Toggle_LFW()
  7268. Purpose : Toggles player LFW Flag
  7269. Params :
  7270. Dev : paulgh
  7271. Example : /lfw
  7272. */
  7273. void Commands::Command_Toggle_LFW(Client* client)
  7274. {
  7275. Player* player = client->GetPlayer();
  7276. player->toggle_character_flag(CF_LFW);
  7277. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7278. if (player->get_character_flag(CF_LFW))
  7279. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7280. else
  7281. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7282. }
  7283. /*
  7284. Function: Command_Toggle_QuestXP()
  7285. Purpose : Toggles player Quest XP
  7286. Params :
  7287. Dev : John Adams
  7288. Example : /disable_quest_exp
  7289. */
  7290. void Commands::Command_Toggle_QuestXP(Client* client)
  7291. {
  7292. Player* player = client->GetPlayer();
  7293. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7294. player->SetCharSheetChanged(true);
  7295. }
  7296. /*
  7297. Function: Command_Toggle_Roleplaying()
  7298. Purpose : Toggles player Roleplaying flag
  7299. Params :
  7300. Dev : paulgh
  7301. Example : /role
  7302. */
  7303. void Commands::Command_Toggle_Roleplaying(Client* client)
  7304. {
  7305. Player* player = client->GetPlayer();
  7306. player->toggle_character_flag(CF_ROLEPLAYING);
  7307. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7308. if (player->get_character_flag(CF_ROLEPLAYING))
  7309. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7310. else
  7311. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7312. }
  7313. void Commands::Command_Toggle_Duels(Client* client)
  7314. {
  7315. Player* player = client->GetPlayer();
  7316. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7317. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7318. }
  7319. void Commands::Command_Toggle_Trades(Client* client)
  7320. {
  7321. Player* player = client->GetPlayer();
  7322. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7323. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7324. }
  7325. void Commands::Command_Toggle_Guilds(Client* client)
  7326. {
  7327. Player* player = client->GetPlayer();
  7328. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7329. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7330. }
  7331. void Commands::Command_Toggle_Groups(Client* client)
  7332. {
  7333. Player* player = client->GetPlayer();
  7334. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7335. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7336. }
  7337. void Commands::Command_Toggle_Raids(Client* client)
  7338. {
  7339. Player* player = client->GetPlayer();
  7340. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7341. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7342. }
  7343. void Commands::Command_Toggle_LON(Client* client)
  7344. {
  7345. Player* player = client->GetPlayer();
  7346. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7347. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7348. }
  7349. void Commands::Command_Toggle_VoiceChat(Client* client)
  7350. {
  7351. Player* player = client->GetPlayer();
  7352. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7353. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7354. }
  7355. /*
  7356. Function: Command_TradeStart()
  7357. Purpose : Starts item/coin trade between players
  7358. Params :
  7359. Dev :
  7360. Example :
  7361. */
  7362. #include "../Trade.h"
  7363. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7364. {
  7365. PrintSep(sep, "COMMAND_START_TRADE");
  7366. Entity* trader = client->GetPlayer();
  7367. Entity* trader2 = 0;
  7368. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7369. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7370. if (spawn) {
  7371. if (spawn->IsEntity())
  7372. trader2 = (Entity*)spawn;
  7373. }
  7374. }
  7375. else if (client->GetPlayer()->GetTarget()) {
  7376. if (client->GetPlayer()->GetTarget()->IsEntity())
  7377. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7378. }
  7379. // can only trade with player or bots
  7380. if (trader && trader2) {
  7381. if (trader == trader2) {
  7382. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7383. }
  7384. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7385. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7386. if (trader->trade)
  7387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7388. else if (trader2->trade)
  7389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7390. else {
  7391. Trade* trade = new Trade(trader, trader2);
  7392. trader->trade = trade;
  7393. trader2->trade = trade;
  7394. }
  7395. }
  7396. else {
  7397. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7398. }
  7399. }
  7400. else
  7401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7402. }
  7403. /*
  7404. Function: Command_Track()
  7405. Purpose : Starts/Stops Tracking for a player
  7406. Params :
  7407. Dev : Scatman
  7408. Example : /track
  7409. */
  7410. void Commands::Command_Track(Client* client)
  7411. {
  7412. if (!client->GetPlayer()->GetIsTracking())
  7413. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7414. else
  7415. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7416. }
  7417. /*
  7418. Function: Command_TradeAccept()
  7419. Purpose : Accepts item/coin trade between players
  7420. Params :
  7421. Dev :
  7422. Example :
  7423. */
  7424. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7425. {
  7426. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7427. Trade* trade = client->GetPlayer()->trade;
  7428. if (trade) {
  7429. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7430. if (trade_complete)
  7431. safe_delete(trade);
  7432. }
  7433. else
  7434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7435. }
  7436. /*
  7437. Function: Command_TradeReject()
  7438. Purpose : Rejects item/coin trade between players
  7439. Params :
  7440. Dev :
  7441. Example :
  7442. */
  7443. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7444. {
  7445. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7446. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7447. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7448. }
  7449. /*
  7450. Function: Command_TradeCancel()
  7451. Purpose : Cancels item/coin trade between players
  7452. Params :
  7453. Dev :
  7454. Example :
  7455. */
  7456. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7457. {
  7458. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7459. Trade* trade = client->GetPlayer()->trade;
  7460. if (trade) {
  7461. trade->CancelTrade(client->GetPlayer());
  7462. safe_delete(trade);
  7463. }
  7464. else
  7465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7466. }
  7467. /*
  7468. Function: Command_TradeSetCoin()
  7469. Purpose : Sets coin trade between players
  7470. Params :
  7471. Dev :
  7472. Example :
  7473. */
  7474. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7475. {
  7476. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7477. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7478. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7479. }
  7480. /*
  7481. Function: Command_TradeAddCoin()
  7482. Purpose : Adds coin to trade between players
  7483. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7484. Dev :
  7485. Example :
  7486. */
  7487. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7488. {
  7489. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7490. Trade* trade = client->GetPlayer()->trade;
  7491. if (trade) {
  7492. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7493. int32 amount = atoi(sep->arg[0]);
  7494. int64 val = 0;
  7495. switch (handler) {
  7496. case COMMAND_ADD_TRADE_COPPER:
  7497. {
  7498. val = amount;
  7499. trade->AddCoinToTrade(client->GetPlayer(), val);
  7500. break;
  7501. }
  7502. case COMMAND_ADD_TRADE_SILVER:
  7503. {
  7504. val = amount * 100;
  7505. trade->AddCoinToTrade(client->GetPlayer(), val);
  7506. break;
  7507. }
  7508. case COMMAND_ADD_TRADE_GOLD:
  7509. {
  7510. val = amount * 10000;
  7511. trade->AddCoinToTrade(client->GetPlayer(), val);
  7512. break;
  7513. }
  7514. case COMMAND_ADD_TRADE_PLAT:
  7515. {
  7516. val = amount * 1000000;
  7517. trade->AddCoinToTrade(client->GetPlayer(), val);
  7518. break;
  7519. }
  7520. default:
  7521. {
  7522. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7523. break;
  7524. }
  7525. }
  7526. }
  7527. else
  7528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7529. }
  7530. else
  7531. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7532. }
  7533. /*
  7534. Function: Command_TradeRemoveCoin()
  7535. Purpose : Removes coin from trade between players
  7536. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7537. Dev :
  7538. Example :
  7539. */
  7540. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7541. {
  7542. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7543. Trade* trade = client->GetPlayer()->trade;
  7544. if (trade) {
  7545. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7546. int32 amount = atoi(sep->arg[0]);
  7547. int64 val = 0;
  7548. switch (handler) {
  7549. case COMMAND_REMOVE_TRADE_COPPER:
  7550. {
  7551. val = amount;
  7552. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7553. break;
  7554. }
  7555. case COMMAND_REMOVE_TRADE_SILVER:
  7556. {
  7557. val = amount * 100;
  7558. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7559. break;
  7560. }
  7561. case COMMAND_REMOVE_TRADE_GOLD:
  7562. {
  7563. val = amount * 10000;
  7564. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7565. break;
  7566. }
  7567. case COMMAND_REMOVE_TRADE_PLAT:
  7568. {
  7569. val = amount * 1000000;
  7570. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7571. break;
  7572. }
  7573. default:
  7574. {
  7575. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7576. break;
  7577. }
  7578. }
  7579. }
  7580. else
  7581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7582. }
  7583. else
  7584. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7585. }
  7586. /*
  7587. Function: Command_TradeAddItem()
  7588. Purpose : Adds item to trade between players
  7589. Params :
  7590. Dev :
  7591. Example :
  7592. */
  7593. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7594. {
  7595. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7596. /*
  7597. arg[0] = item index
  7598. arg[1] = slot
  7599. arg[2] = quantity
  7600. */
  7601. if (!client->GetPlayer()->trade) {
  7602. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7603. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7604. return;
  7605. }
  7606. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7607. Item* item = 0;
  7608. int32 index = atoi(sep->arg[0]);
  7609. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7610. if (item) {
  7611. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7612. if (result == 1)
  7613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7614. else if (result == 2)
  7615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7616. else if (result == 3)
  7617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7618. else if (result == 255)
  7619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7620. }
  7621. else {
  7622. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7623. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7624. }
  7625. }
  7626. else
  7627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7628. }
  7629. /*
  7630. Function: Command_TradeRemoveItem()
  7631. Purpose : Removes item from trade between players
  7632. Params :
  7633. Dev :
  7634. Example :
  7635. */
  7636. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7637. {
  7638. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7639. /*
  7640. arg[0] = trade window slot
  7641. */
  7642. Trade* trade = client->GetPlayer()->trade;
  7643. if (trade) {
  7644. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7645. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7646. }
  7647. else
  7648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7649. }
  7650. else
  7651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7652. }
  7653. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7654. {
  7655. Item *item = 0;
  7656. sint32 crc;
  7657. if (sep) {
  7658. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7659. if (client->GetVersion() < 1096) {
  7660. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7661. {
  7662. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7663. crc = atol(sep->arg[2]);
  7664. }
  7665. }
  7666. else {
  7667. // From the broker and links in chat
  7668. if (strcmp(sep->arg[0], "crc") == 0) {
  7669. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7670. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7671. crc = atol(sep->arg[3]);
  7672. }
  7673. }
  7674. // From inventory
  7675. if (strcmp(sep->arg[0], "dbid") == 0) {
  7676. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7677. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7678. crc = atol(sep->arg[4]);
  7679. }
  7680. }
  7681. }
  7682. if (item)
  7683. client->ShowDressingRoom(item, crc);
  7684. }
  7685. }
  7686. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7687. const char *channel_name, *password = NULL;
  7688. if (sep == NULL || !sep->IsSet(0)) {
  7689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7690. return;
  7691. }
  7692. channel_name = sep->arg[0];
  7693. if (sep->IsSet(1))
  7694. password = sep->arg[1];
  7695. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7696. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7697. return;
  7698. }
  7699. if (chat.IsInChannel(client, channel_name)) {
  7700. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7701. return;
  7702. }
  7703. if (chat.HasPassword(channel_name)) {
  7704. if (password == NULL) {
  7705. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7706. return;
  7707. }
  7708. if (!chat.PasswordMatches(channel_name, password)) {
  7709. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7710. return;
  7711. }
  7712. }
  7713. if (!chat.JoinChannel(client, channel_name))
  7714. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7715. }
  7716. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7717. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7718. Command_JoinChannel(client, sep);
  7719. }
  7720. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7721. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7723. PrintSep(sep, "tellchannel");
  7724. return;
  7725. }
  7726. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7727. }
  7728. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7729. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7730. if (sep->IsSet(0)) {
  7731. if (atoi(sep->arg[0]) == 1) {
  7732. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7733. if (packet2) {
  7734. packet2->setDataByName("spell_type", 2);
  7735. packet2->setDataByName("spell_id", 8308);
  7736. packet2->setDataByName("spell_name", "Sprint");
  7737. packet2->setDataByName("add_silently", 0);
  7738. packet2->setDataByName("tier", 1);
  7739. packet2->setDataByName("blah1", 1);
  7740. packet2->setDataByName("blah2", 1);
  7741. EQ2Packet* outapp = packet2->serialize();
  7742. DumpPacket(outapp);
  7743. client->QueuePacket(outapp);
  7744. safe_delete(packet2);
  7745. }
  7746. }
  7747. else if (atoi(sep->arg[0]) == 2) {
  7748. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7749. if (packet2) {
  7750. packet2->setDataByName("guild_name", "Test");
  7751. packet2->setDataByName("guild_motd", "Test MOTD");
  7752. packet2->setDataByName("guild_id", 1234);
  7753. packet2->setDataByName("guild_level", 1);
  7754. packet2->setDataByName("unknown", 2);
  7755. packet2->setDataByName("unknown2", 3);
  7756. packet2->setDataByName("exp_current", 1);
  7757. packet2->setDataByName("exp_to_next_level", 4);
  7758. EQ2Packet* outapp = packet2->serialize();
  7759. DumpPacket(outapp);
  7760. client->QueuePacket(outapp);
  7761. safe_delete(packet2);
  7762. }
  7763. }
  7764. else if (atoi(sep->arg[0]) == 3) {
  7765. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7766. if (packet2) {
  7767. packet2->setDataByName("guild_id", 1234);
  7768. packet2->setDataByName("character_id", 1);
  7769. packet2->setDataByName("account_id", 2);
  7770. packet2->setDataByName("guild_level", 1);
  7771. packet2->setDataByName("name", "Test");
  7772. packet2->setDataByName("unknown2", 0);
  7773. packet2->setDataByName("unknown3", 1);
  7774. packet2->setDataByName("adventure_class", 6);
  7775. packet2->setDataByName("adventure_level", 7);
  7776. packet2->setDataByName("tradeskill_class", 4);
  7777. packet2->setDataByName("tradeskill_level", 5);
  7778. packet2->setDataByName("rank", 0);
  7779. packet2->setDataByName("member_flags", 2);
  7780. packet2->setDataByName("join_date", 1591112273);
  7781. packet2->setDataByName("guild_status", 2);
  7782. packet2->setDataByName("last_login", 1591132273);
  7783. packet2->setDataByName("recruiter_id", 1);
  7784. packet2->setDataByName("points", 2345);
  7785. packet2->setDataByName("note", "note");
  7786. packet2->setMediumStringByName("officer_note", "O note");
  7787. packet2->setMediumStringByName("zone", "Blah");
  7788. EQ2Packet* outapp = packet2->serialize();
  7789. DumpPacket(outapp);
  7790. client->QueuePacket(outapp);
  7791. safe_delete(packet2);
  7792. }
  7793. }
  7794. else if (atoi(sep->arg[0]) == 5) {
  7795. client->GetPlayer()->GetTarget();
  7796. int16 offset = atoi(sep->arg[2]);
  7797. int32 value1 = atol(sep->arg[4]);
  7798. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7799. client->QueuePacket(outapp);
  7800. }
  7801. else if (atoi(sep->arg[0]) == 6) {
  7802. Spawn* spawn = client->GetPlayer()->GetTarget();
  7803. if (!spawn)
  7804. spawn = client->GetPlayer();
  7805. else if (spawn->IsEntity())
  7806. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7807. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7808. }
  7809. else if (atoi(sep->arg[0]) == 7) {
  7810. int32 id = 0;
  7811. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7812. if (spawn) {
  7813. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7814. spawn->SetY(client->GetPlayer()->GetY(), false);
  7815. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7816. float heading = client->GetPlayer()->GetHeading() + 180;
  7817. if (heading > 360)
  7818. heading -= 360;
  7819. spawn->SetLevel(5);
  7820. spawn->SetAdventureClass(4);
  7821. spawn->SetHeading(heading, false);
  7822. spawn->SetSpawnOrigX(spawn->GetX());
  7823. spawn->SetSpawnOrigY(spawn->GetY());
  7824. spawn->SetSpawnOrigZ(spawn->GetZ());
  7825. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7826. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7827. spawn->appearance.targetable = 1;
  7828. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7829. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7830. spawn->SetHP(spawn->GetTotalHP());
  7831. }
  7832. if (spawn->GetTotalPower() == 0) {
  7833. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7834. spawn->SetPower(spawn->GetTotalPower());
  7835. }
  7836. int16 offset = atoi(sep->arg[1]);
  7837. int32 value1 = atol(sep->arg[2]);
  7838. sprintf(spawn->appearance.name, "Offset %i", offset);
  7839. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7840. DumpPacket(ret);
  7841. client->QueuePacket(ret);
  7842. }
  7843. }
  7844. else if (atoi(sep->arg[0]) == 8) {
  7845. int32 id = atoi(sep->arg[1]);
  7846. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7847. if (spawn) {
  7848. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7849. spawn->SetY(client->GetPlayer()->GetY(), false);
  7850. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7851. float heading = client->GetPlayer()->GetHeading() + 180;
  7852. if (heading > 360)
  7853. heading -= 360;
  7854. spawn->SetLevel(5);
  7855. spawn->SetAdventureClass(4);
  7856. spawn->SetHeading(heading, false);
  7857. spawn->SetSpawnOrigX(spawn->GetX());
  7858. spawn->SetSpawnOrigY(spawn->GetY());
  7859. spawn->SetSpawnOrigZ(spawn->GetZ());
  7860. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7861. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7862. spawn->appearance.targetable = 1;
  7863. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7864. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7865. spawn->SetHP(spawn->GetTotalHP());
  7866. }
  7867. if (spawn->GetTotalPower() == 0) {
  7868. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7869. spawn->SetPower(spawn->GetTotalPower());
  7870. }
  7871. int16 offset = atoi(sep->arg[2]);
  7872. int16 offset2 = atoi(sep->arg[3]);
  7873. int32 value1 = atol(sep->arg[4]);
  7874. int16 offset3 = 0;
  7875. int16 offset4 = 0;
  7876. int32 value2 = 0;
  7877. if (sep->IsSet(7)) {
  7878. offset3 = atoi(sep->arg[5]);
  7879. offset4 = atoi(sep->arg[6]);
  7880. value2 = atol(sep->arg[7]);
  7881. }
  7882. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7883. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7884. DumpPacket(ret);
  7885. client->QueuePacket(ret);
  7886. }
  7887. }
  7888. else if (atoi(sep->arg[0]) == 9) {
  7889. Item* item = master_item_list.GetItem(70007);
  7890. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7891. if (sep->IsSet(2)) {
  7892. int8 offset = atoi(sep->arg[1]);
  7893. uchar* ptr2 = app->pBuffer;
  7894. ptr2 += offset;
  7895. if (sep->IsNumber(2)) {
  7896. int32 value1 = atol(sep->arg[2]);
  7897. if (value1 > 0xFFFF)
  7898. memcpy(ptr2, (uchar*)&value1, 4);
  7899. else if (value1 > 0xFF)
  7900. memcpy(ptr2, (uchar*)&value1, 2);
  7901. else
  7902. memcpy(ptr2, (uchar*)&value1, 1);
  7903. }
  7904. else {
  7905. int8 len = strlen(sep->arg[2]);
  7906. memcpy(ptr2, (uchar*)&len, 1);
  7907. ptr2 += 1;
  7908. memcpy(ptr2, sep->arg[2], len);
  7909. }
  7910. }
  7911. if (sep->IsSet(4)) {
  7912. int8 offset = atoi(sep->arg[3]);
  7913. uchar* ptr2 = app->pBuffer;
  7914. ptr2 += offset;
  7915. if (sep->IsNumber(4)) {
  7916. int32 value1 = atol(sep->arg[4]);
  7917. if (value1 > 0xFFFF)
  7918. memcpy(ptr2, (uchar*)&value1, 4);
  7919. else if (value1 > 0xFF)
  7920. memcpy(ptr2, (uchar*)&value1, 2);
  7921. else
  7922. memcpy(ptr2, (uchar*)&value1, 1);
  7923. }
  7924. else {
  7925. int8 len = strlen(sep->arg[4]);
  7926. memcpy(ptr2, (uchar*)&len, 1);
  7927. ptr2 += 1;
  7928. memcpy(ptr2, sep->arg[4], len);
  7929. }
  7930. }
  7931. DumpPacket(app);
  7932. client->QueuePacket(app);
  7933. }
  7934. else if (atoi(sep->arg[0]) == 10) {
  7935. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7936. if (packet2) {
  7937. packet2->setArrayLengthByName("num_quests", 1);
  7938. packet2->setArrayDataByName("active", 1);
  7939. packet2->setArrayDataByName("name", "Archetype Selection");
  7940. packet2->setArrayDataByName("quest_type", "Hallmark");
  7941. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7942. packet2->setArrayDataByName("journal_updated", 1);
  7943. packet2->setArrayDataByName("quest_id", 5);
  7944. packet2->setArrayDataByName("day", 19);
  7945. packet2->setArrayDataByName("month", 6);
  7946. packet2->setArrayDataByName("year", 20);
  7947. packet2->setArrayDataByName("level", 2);
  7948. packet2->setArrayDataByName("encounter_level", 4);
  7949. packet2->setArrayDataByName("difficulty", 3);
  7950. packet2->setArrayDataByName("visible", 1);
  7951. packet2->setDataByName("visible_quest_id", 5);
  7952. packet2->setDataByName("player_crc", 2900677088);
  7953. packet2->setDataByName("player_name", "LethalEncounter");
  7954. EQ2Packet* app = packet2->serialize();
  7955. if (sep->IsSet(2)) {
  7956. int8 offset = atoi(sep->arg[1]);
  7957. uchar* ptr2 = app->pBuffer;
  7958. ptr2 += offset;
  7959. if (sep->IsNumber(2)) {
  7960. int32 value1 = atol(sep->arg[2]);
  7961. if (value1 > 0xFFFF)
  7962. memcpy(ptr2, (uchar*)&value1, 4);
  7963. else if (value1 > 0xFF)
  7964. memcpy(ptr2, (uchar*)&value1, 2);
  7965. else
  7966. memcpy(ptr2, (uchar*)&value1, 1);
  7967. }
  7968. else {
  7969. int8 len = strlen(sep->arg[2]);
  7970. memcpy(ptr2, (uchar*)&len, 1);
  7971. ptr2 += 1;
  7972. memcpy(ptr2, sep->arg[2], len);
  7973. }
  7974. }
  7975. DumpPacket(app);
  7976. client->QueuePacket(app);
  7977. safe_delete(packet2);
  7978. }
  7979. }
  7980. else if (atoi(sep->arg[0]) == 11) {
  7981. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  7982. if (packet2) {
  7983. packet2->setDataByName("quest_id", 5);
  7984. packet2->setDataByName("player_crc", 2900677088);
  7985. packet2->setDataByName("name", "Archetype Selection");
  7986. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  7987. packet2->setDataByName("type", "Hallmark");
  7988. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  7989. packet2->setDataByName("day", 19);
  7990. packet2->setDataByName("month", 6);
  7991. packet2->setDataByName("year", 20);
  7992. packet2->setDataByName("level", 2);
  7993. packet2->setDataByName("encounter_level", 4);
  7994. packet2->setDataByName("difficulty", 3);
  7995. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  7996. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  7997. packet2->setDataByName("timer_duration", 300);
  7998. packet2->setDataByName("timer_running", 1);
  7999. packet2->setArrayLengthByName("task_groups_completed", 0);
  8000. packet2->setArrayLengthByName("num_task_groups", 1);
  8001. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8002. packet2->setSubArrayLengthByName("num_tasks", 1);
  8003. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8004. packet2->setSubArrayLengthByName("num_updates", 1);
  8005. packet2->setSubArrayDataByName("update_currentval", 0);
  8006. packet2->setSubArrayDataByName("update_maxval", 1);
  8007. packet2->setSubArrayDataByName("icon", 11);
  8008. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8009. packet2->setDataByName("journal_updated", 1);
  8010. EQ2Packet* app = packet2->serialize();
  8011. if (sep->IsSet(2)) {
  8012. int16 offset = atoi(sep->arg[1]);
  8013. uchar* ptr2 = app->pBuffer;
  8014. ptr2 += offset;
  8015. if (sep->IsNumber(2)) {
  8016. int32 value1 = atol(sep->arg[2]);
  8017. if (value1 > 0xFFFF)
  8018. memcpy(ptr2, (uchar*)&value1, 4);
  8019. else if (value1 > 0xFF)
  8020. memcpy(ptr2, (uchar*)&value1, 2);
  8021. else
  8022. memcpy(ptr2, (uchar*)&value1, 1);
  8023. }
  8024. else {
  8025. int16 len = strlen(sep->arg[2]);
  8026. memcpy(ptr2, (uchar*)&len, 2);
  8027. ptr2 += 2;
  8028. memcpy(ptr2, sep->arg[2], len);
  8029. }
  8030. }
  8031. DumpPacket(app);
  8032. client->QueuePacket(app);
  8033. safe_delete(packet2);
  8034. }
  8035. }
  8036. else if (atoi(sep->arg[0]) == 12) {
  8037. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8038. if (packet2) {
  8039. packet2->setDataByName("quest_id", 5);
  8040. packet2->setDataByName("player_crc", 2900677088);
  8041. packet2->setDataByName("name", "Archetype Selection");
  8042. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8043. packet2->setDataByName("type", "Hallmark");
  8044. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8045. packet2->setDataByName("day", 19);
  8046. packet2->setDataByName("month", 6);
  8047. packet2->setDataByName("year", 20);
  8048. packet2->setDataByName("level", 2);
  8049. packet2->setDataByName("encounter_level", 4);
  8050. packet2->setDataByName("difficulty", 3);
  8051. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8052. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8053. packet2->setDataByName("timer_duration", 300);
  8054. packet2->setDataByName("timer_running", 1);
  8055. packet2->setArrayLengthByName("task_groups_completed", 0);
  8056. packet2->setArrayLengthByName("num_task_groups", 1);
  8057. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8058. packet2->setSubArrayLengthByName("num_tasks", 1);
  8059. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8060. packet2->setSubArrayLengthByName("num_updates", 1);
  8061. packet2->setSubArrayDataByName("update_currentval", 0);
  8062. packet2->setSubArrayDataByName("update_maxval", 1);
  8063. packet2->setSubArrayDataByName("icon", 11);
  8064. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8065. packet2->setDataByName("journal_updated", 1);
  8066. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8067. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8068. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8069. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8070. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8071. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8072. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8073. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8074. Item* item = master_item_list.GetItem(152755);
  8075. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8076. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8077. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8078. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8079. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8080. packet2->setSubstructDataByName("item", "tier", 4);
  8081. packet2->setSubstructDataByName("item", "flags", 0x60);
  8082. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8083. packet2->setSubstructDataByName("item", "stat_type", 1);
  8084. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8085. packet2->setSubstructDataByName("item", "value", 3);
  8086. packet2->setSubstructDataByName("item", "condition", 100);
  8087. packet2->setSubstructDataByName("item", "weight", 1);
  8088. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8089. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8090. packet2->setSubstructDataByName("item", "skill_min", 1);
  8091. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8092. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8093. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8094. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8095. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8096. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8097. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8098. packet2->setSubstructDataByName("item", "level", 0x1e);
  8099. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8100. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8101. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8102. //packet2->PrintPacket();
  8103. EQ2Packet* app = packet2->serialize();
  8104. if (sep->IsSet(2)) {
  8105. int16 offset = atoi(sep->arg[1]);
  8106. uchar* ptr2 = app->pBuffer;
  8107. ptr2 += offset;
  8108. if (sep->IsNumber(2)) {
  8109. int32 value1 = atol(sep->arg[2]);
  8110. if (value1 > 0xFFFF)
  8111. memcpy(ptr2, (uchar*)&value1, 4);
  8112. else if (value1 > 0xFF)
  8113. memcpy(ptr2, (uchar*)&value1, 2);
  8114. else
  8115. memcpy(ptr2, (uchar*)&value1, 1);
  8116. }
  8117. else {
  8118. int16 len = strlen(sep->arg[2]);
  8119. memcpy(ptr2, (uchar*)&len, 2);
  8120. ptr2 += 2;
  8121. memcpy(ptr2, sep->arg[2], len);
  8122. }
  8123. }
  8124. DumpPacket(app);
  8125. client->QueuePacket(app);
  8126. safe_delete(packet2);
  8127. }
  8128. }
  8129. else if (atoi(sep->arg[0]) == 13) {
  8130. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8131. if (packet2 && sep->IsSet(7)) {
  8132. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8133. char blah[128];
  8134. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8135. packet2->setDataByName("text", blah);
  8136. packet2->setDataByName("message_type", sep->arg[3]);
  8137. packet2->setDataByName("size", atof(sep->arg[4]));
  8138. packet2->setDataByName("red", atoi(sep->arg[5]));
  8139. packet2->setDataByName("green", atoi(sep->arg[6]));
  8140. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8141. EQ2Packet* app = packet2->serialize();
  8142. DumpPacket(app);
  8143. client->QueuePacket(app);
  8144. safe_delete(packet2);
  8145. }
  8146. }
  8147. else if (atoi(sep->arg[0]) == 14) {
  8148. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8149. if (packet2 && sep->IsSet(3)) {
  8150. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8151. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8152. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8153. 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.");
  8154. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8155. packet2->setArrayLengthByName("num_goals", 1);
  8156. //packet2->setArrayDataByName("goal_text", )
  8157. packet2->setSubArrayLengthByName("num_tasks", 1);
  8158. packet2->setSubArrayDataByName("task_text", "continue");
  8159. packet2->setDataByName("complete_sound", "click");
  8160. packet2->setDataByName("signal", "introduction");
  8161. packet2->setDataByName("voice_key1", 0xcda65173);
  8162. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8163. EQ2Packet* app = packet2->serialize();
  8164. DumpPacket(app);
  8165. client->QueuePacket(app);
  8166. safe_delete(packet2);
  8167. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8168. packet2->setDataByName("window", "MainHUD.StartMenu");
  8169. packet2->setDataByName("show", 1);
  8170. app = packet2->serialize();
  8171. DumpPacket(app);
  8172. client->QueuePacket(app);
  8173. safe_delete(packet2);
  8174. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8175. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8176. packet2->setDataByName("flash_seconds", 10);
  8177. app = packet2->serialize();
  8178. DumpPacket(app);
  8179. client->QueuePacket(app);
  8180. safe_delete(packet2);
  8181. }
  8182. }
  8183. else if (atoi(sep->arg[0]) == 15) {
  8184. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8185. if (packet2) {
  8186. packet2->setArrayLengthByName("loot_count", 1);
  8187. packet2->setArrayDataByName("name", "Test");
  8188. packet2->setArrayDataByName("item_id", 1234);
  8189. packet2->setArrayDataByName("count", 1);
  8190. packet2->setArrayDataByName("icon", 258);
  8191. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8192. Spawn* spawn = client->GetPlayer()->GetTarget();
  8193. if (spawn)
  8194. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8195. packet2->setDataByName("unknown3", 1);
  8196. packet2->setDataByName("unknown4", 1);
  8197. packet2->setDataByName("unknown5", 60);
  8198. EQ2Packet* app = packet2->serialize();
  8199. DumpPacket(app);
  8200. client->QueuePacket(app);
  8201. safe_delete(packet2);
  8202. }
  8203. }
  8204. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8205. char blah[32];
  8206. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8207. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8208. }
  8209. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8210. if (sep->IsSet(2)) {
  8211. int16 offset = atoi(sep->arg[1]);
  8212. if (sep->IsNumber(2)) {
  8213. int32 value1 = atol(sep->arg[2]);
  8214. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8215. cout << "Sent" << endl;
  8216. }
  8217. }
  8218. }
  8219. else if (atoi(sep->arg[0]) == 18) {
  8220. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8221. if (packet2) {
  8222. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8223. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8224. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8225. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8226. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8227. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8228. Item* item = new Item(master_item_list.GetItem(36212));
  8229. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8230. item->stack_count = 20;
  8231. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8232. safe_delete(item);
  8233. item = new Item(master_item_list.GetItem(36685));
  8234. item->stack_count = 20;
  8235. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8236. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8237. safe_delete(item);
  8238. item = master_item_list.GetItem(1414);
  8239. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8240. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8241. item = master_item_list.GetItem(75057);
  8242. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8243. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8244. EQ2Packet* app = packet2->serialize();
  8245. if (sep->IsSet(2)) {
  8246. int16 offset = atoi(sep->arg[1]);
  8247. uchar* ptr2 = app->pBuffer;
  8248. ptr2 += offset;
  8249. if (sep->IsNumber(2)) {
  8250. int32 value1 = atol(sep->arg[2]);
  8251. if (value1 > 0xFFFF)
  8252. memcpy(ptr2, (uchar*)&value1, 4);
  8253. else if (value1 > 0xFF)
  8254. memcpy(ptr2, (uchar*)&value1, 2);
  8255. else
  8256. memcpy(ptr2, (uchar*)&value1, 1);
  8257. }
  8258. else {
  8259. int16 len = strlen(sep->arg[2]);
  8260. memcpy(ptr2, (uchar*)&len, 2);
  8261. ptr2 += 2;
  8262. memcpy(ptr2, sep->arg[2], len);
  8263. }
  8264. }
  8265. DumpPacket(app);
  8266. client->QueuePacket(app);
  8267. safe_delete(packet2);
  8268. }
  8269. }
  8270. else if (atoi(sep->arg[0]) == 19) {
  8271. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8272. Spawn* spawn = client->GetPlayer()->GetTarget();
  8273. if (packet2 && spawn) {
  8274. Item* item = master_item_list.GetItem(130053);
  8275. packet2->setArrayLengthByName("loot_count", 1);
  8276. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8277. packet2->setArrayDataByName("unknown2", 1);
  8278. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8279. packet2->setDataByName("display", 1);
  8280. packet2->setDataByName("unknown2b", 1);
  8281. packet2->setDataByName("unknown3", 0x3c);
  8282. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8283. packet2->PrintPacket();
  8284. EQ2Packet* app = packet2->serialize();
  8285. if (sep->IsSet(2)) {
  8286. int16 offset = atoi(sep->arg[1]);
  8287. int16 offset2 = 0;
  8288. int32 value1 = 0;
  8289. if (sep->IsSet(3)) {
  8290. offset2 = atoi(sep->arg[2]);
  8291. value1 = atol(sep->arg[3]);
  8292. }
  8293. else
  8294. value1 = atol(sep->arg[2]);
  8295. int16 offset3 = 0;
  8296. int16 offset4 = 0;
  8297. int32 value2 = 0;
  8298. if (sep->IsSet(6)) {
  8299. offset3 = atoi(sep->arg[4]);
  8300. offset4 = atoi(sep->arg[5]);
  8301. value2 = atol(sep->arg[6]);
  8302. }
  8303. offset--;
  8304. if (offset2 > 0 && offset2 >= offset) {
  8305. offset2--;
  8306. uchar* ptr2 = app->pBuffer;
  8307. ptr2 += offset;
  8308. for (int i = offset; i <= offset2; i++) {
  8309. if (value1 > 0xFFFF) {
  8310. memcpy(ptr2, (uchar*)&value1, 4);
  8311. i += 3;
  8312. ptr2 += 3;
  8313. }
  8314. else if (value1 > 0xFF) {
  8315. memcpy(ptr2, (uchar*)&value1, 2);
  8316. i++;
  8317. ptr2++;
  8318. }
  8319. else
  8320. memcpy(ptr2, (uchar*)&value1, 1);
  8321. ptr2++;
  8322. }
  8323. }
  8324. if (offset4 > 0 && offset4 >= offset3) {
  8325. offset3--;
  8326. offset4--;
  8327. uchar* ptr2 = app->pBuffer;
  8328. ptr2 += offset3;
  8329. for (int i = offset3; i <= offset4; i++) {
  8330. if (value2 > 0xFFFF) {
  8331. memcpy(ptr2, (uchar*)&value2, 4);
  8332. i += 3;
  8333. ptr2 += 3;
  8334. }
  8335. else if (value2 > 0xFF) {
  8336. memcpy(ptr2, (uchar*)&value2, 2);
  8337. i++;
  8338. ptr2++;
  8339. }
  8340. else
  8341. memcpy(ptr2, (uchar*)&value2, 1);
  8342. ptr2++;
  8343. }
  8344. }
  8345. }
  8346. DumpPacket(app);
  8347. client->QueuePacket(app);
  8348. safe_delete(packet2);
  8349. }
  8350. }
  8351. else if (atoi(sep->arg[0]) == 21) {
  8352. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8353. if (packet2) {
  8354. packet2->setDataByName("unknown0", 255);
  8355. packet2->setDataByName("reward", "New Quest");
  8356. packet2->setDataByName("title", "Title");
  8357. packet2->setDataByName("description", "description");
  8358. packet2->setDataByName("quest_difficulty", 3);
  8359. packet2->setDataByName("unknown1", 5);
  8360. packet2->setDataByName("level", 3);
  8361. packet2->setDataByName("coin", 150);
  8362. packet2->setDataByName("status_points", 5);
  8363. packet2->setDataByName("exp_bonus", 10);
  8364. packet2->setArrayLengthByName("num_rewards", 1);
  8365. Item* item = new Item(master_item_list.GetItem(36212));
  8366. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8367. item->stack_count = 20;
  8368. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8369. safe_delete(item);
  8370. char accept[35] = { 0 };
  8371. char decline[35] = { 0 };
  8372. sprintf(accept, "q_accept_pending_quest %u", 0);
  8373. sprintf(decline, "q_deny_pending_quest %u", 0);
  8374. packet2->setDataByName("accept_command", accept);
  8375. packet2->setDataByName("decline_command", decline);
  8376. EQ2Packet* app = packet2->serialize();
  8377. if (sep->IsSet(2)) {
  8378. int16 offset = atoi(sep->arg[1]);
  8379. uchar* ptr2 = app->pBuffer;
  8380. ptr2 += offset;
  8381. if (sep->IsNumber(2)) {
  8382. int32 value1 = atol(sep->arg[2]);
  8383. if (value1 > 0xFFFF)
  8384. memcpy(ptr2, (uchar*)&value1, 4);
  8385. else if (value1 > 0xFF)
  8386. memcpy(ptr2, (uchar*)&value1, 2);
  8387. else
  8388. memcpy(ptr2, (uchar*)&value1, 1);
  8389. }
  8390. DumpPacket(app);
  8391. client->QueuePacket(app);
  8392. safe_delete(packet2);
  8393. }
  8394. }
  8395. }
  8396. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8397. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8398. if (packet2) {
  8399. packet2->setDataByName("unknown0", 255);
  8400. packet2->setDataByName("reward", "New Quest");
  8401. packet2->setDataByName("title", "Title");
  8402. packet2->setDataByName("description", "description");
  8403. packet2->setDataByName("quest_difficulty", 3);
  8404. packet2->setDataByName("unknown1", 5);
  8405. packet2->setDataByName("level", 3);
  8406. packet2->setDataByName("coin", 150);
  8407. packet2->setDataByName("status_points", 5);
  8408. packet2->setDataByName("exp_bonus", 10);
  8409. packet2->setArrayLengthByName("num_rewards", 1);
  8410. Item* item = new Item(master_item_list.GetItem(36212));
  8411. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8412. item->stack_count = 20;
  8413. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8414. safe_delete(item);
  8415. char accept[35] = { 0 };
  8416. char decline[35] = { 0 };
  8417. sprintf(accept, "q_accept_pending_quest %u", 0);
  8418. sprintf(decline, "q_deny_pending_quest %u", 0);
  8419. packet2->setDataByName("accept_command", accept);
  8420. packet2->setDataByName("decline_command", decline);
  8421. EQ2Packet* app = packet2->serialize();
  8422. if (sep->IsSet(2)) {
  8423. int16 offset = atoi(sep->arg[1]);
  8424. uchar* ptr2 = app->pBuffer;
  8425. ptr2 += offset;
  8426. if (sep->IsNumber(2)) {
  8427. int32 value1 = atol(sep->arg[2]);
  8428. if (value1 > 0xFFFF)
  8429. memcpy(ptr2, (uchar*)&value1, 4);
  8430. else if (value1 > 0xFF)
  8431. memcpy(ptr2, (uchar*)&value1, 2);
  8432. else
  8433. memcpy(ptr2, (uchar*)&value1, 1);
  8434. }
  8435. else {
  8436. int8 len = strlen(sep->arg[2]);
  8437. memcpy(ptr2, (uchar*)&len, 1);
  8438. ptr2 += 1;
  8439. memcpy(ptr2, sep->arg[2], len);
  8440. }
  8441. }
  8442. DumpPacket(app);
  8443. client->QueuePacket(app);
  8444. safe_delete(packet2);
  8445. }
  8446. }
  8447. else if (atoi(sep->arg[0]) == 23) {
  8448. if (client->GetPlayer()->GetTarget()) {
  8449. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8450. if (packet2) {
  8451. Spawn* target = client->GetPlayer()->GetTarget();
  8452. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8453. Item* item = new Item(master_item_list.GetItem(12565));
  8454. int8 i = 0;
  8455. packet2->setArrayLengthByName("num_items", 1);
  8456. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8457. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8458. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8459. packet2->setArrayDataByName("icon", item->details.icon, i);
  8460. int8 tmp_level = 0;
  8461. if (item->generic_info.adventure_default_level > 0)
  8462. tmp_level = item->generic_info.adventure_default_level;
  8463. else
  8464. tmp_level = item->generic_info.tradeskill_default_level;
  8465. packet2->setArrayDataByName("level", tmp_level, i);
  8466. packet2->setArrayDataByName("tier", item->details.tier, i);
  8467. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8468. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8469. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8470. item_difficulty = ARROW_COLOR_WHITE;
  8471. item_difficulty -= 6;
  8472. if (item_difficulty < 0)
  8473. item_difficulty *= -1;
  8474. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8475. packet2->setArrayDataByName("quantity", 2, i);
  8476. packet2->setArrayDataByName("unknown5", 255, i);
  8477. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8478. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8479. packet2->setDataByName("type", 2);
  8480. EQ2Packet* app = packet2->serialize();
  8481. if (sep->IsSet(2)) {
  8482. int16 offset = atoi(sep->arg[1]);
  8483. uchar* ptr2 = app->pBuffer;
  8484. ptr2 += offset;
  8485. if (sep->IsNumber(2)) {
  8486. int32 value1 = atol(sep->arg[2]);
  8487. if (value1 > 0xFFFF)
  8488. memcpy(ptr2, (uchar*)&value1, 4);
  8489. else if (value1 > 0xFF)
  8490. memcpy(ptr2, (uchar*)&value1, 2);
  8491. else
  8492. memcpy(ptr2, (uchar*)&value1, 1);
  8493. }
  8494. else {
  8495. int8 len = strlen(sep->arg[2]);
  8496. memcpy(ptr2, (uchar*)&len, 1);
  8497. ptr2 += 1;
  8498. memcpy(ptr2, sep->arg[2], len);
  8499. }
  8500. }
  8501. DumpPacket(app);
  8502. client->QueuePacket(app);
  8503. safe_delete(packet2);
  8504. }
  8505. }
  8506. }
  8507. else if (atoi(sep->arg[0]) == 24) {
  8508. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8509. if (packet2) {
  8510. if (sep->IsSet(2)) {
  8511. packet2->setDataByName("event_name", sep->arg[1]);
  8512. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8513. EQ2Packet* app = packet2->serialize();
  8514. DumpPacket(app);
  8515. client->QueuePacket(app);
  8516. safe_delete(packet2);
  8517. }
  8518. }
  8519. }
  8520. else if (atoi(sep->arg[0]) == 25) {
  8521. if (sep->IsSet(1)) {
  8522. Widget* new_spawn = new Widget();
  8523. int32 id = atoul(sep->arg[1]);
  8524. new_spawn->SetWidgetID(id);
  8525. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8526. client->QueuePacket(ret);
  8527. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8528. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8529. if (packet2) {
  8530. packet2->setDataByName("spawn_index", index);
  8531. packet2->setDataByName("delete", 1);
  8532. EQ2Packet* app = packet2->serialize();
  8533. client->QueuePacket(app);
  8534. safe_delete(packet2);
  8535. }
  8536. }
  8537. }
  8538. else if (atoi(sep->arg[0]) == 26) {
  8539. if (sep->IsSet(4)) {
  8540. Widget* new_spawn = new Widget();
  8541. int32 id = atoul(sep->arg[1]);
  8542. new_spawn->SetWidgetID(id);
  8543. float x = atof(sep->arg[2]);
  8544. float y = atof(sep->arg[3]);
  8545. float z = atof(sep->arg[4]);
  8546. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8547. new_spawn->SetWidgetX(x);
  8548. new_spawn->SetWidgetY(y);
  8549. new_spawn->SetWidgetZ(z);
  8550. new_spawn->SetX(x);
  8551. new_spawn->SetY(y);
  8552. new_spawn->SetZ(z);
  8553. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8554. client->QueuePacket(ret);
  8555. }
  8556. }
  8557. else if (atoi(sep->arg[0]) == 27) {
  8558. Spawn* target = client->GetPlayer()->GetTarget();
  8559. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8560. if (packet2 && target && sep->IsSet(2)) {
  8561. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8562. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8563. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8564. packet2->setArrayLengthByName("num_dmg", 1);
  8565. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8566. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8567. packet2->setDataByName("spell", 1);
  8568. packet2->setDataByName("spell_name", "Testing");
  8569. EQ2Packet* app = packet2->serialize();
  8570. if (sep->IsSet(4)) {
  8571. int16 offset = atoi(sep->arg[3]);
  8572. uchar* ptr2 = app->pBuffer;
  8573. ptr2 += offset;
  8574. if (sep->IsNumber(4)) {
  8575. int32 value1 = atol(sep->arg[4]);
  8576. if (value1 > 0xFFFF)
  8577. memcpy(ptr2, (uchar*)&value1, 4);
  8578. else if (value1 > 0xFF)
  8579. memcpy(ptr2, (uchar*)&value1, 2);
  8580. else
  8581. memcpy(ptr2, (uchar*)&value1, 1);
  8582. }
  8583. else {
  8584. int8 len = strlen(sep->arg[4]);
  8585. memcpy(ptr2, (uchar*)&len, 1);
  8586. ptr2 += 1;
  8587. memcpy(ptr2, sep->arg[4], len);
  8588. }
  8589. }
  8590. if (sep->IsSet(6)) {
  8591. int16 offset = atoi(sep->arg[5]);
  8592. uchar* ptr2 = app->pBuffer;
  8593. ptr2 += offset;
  8594. if (sep->IsNumber(6)) {
  8595. int32 value1 = atol(sep->arg[6]);
  8596. if (value1 > 0xFFFF)
  8597. memcpy(ptr2, (uchar*)&value1, 4);
  8598. else if (value1 > 0xFF)
  8599. memcpy(ptr2, (uchar*)&value1, 2);
  8600. else
  8601. memcpy(ptr2, (uchar*)&value1, 1);
  8602. }
  8603. else {
  8604. int8 len = strlen(sep->arg[6]);
  8605. memcpy(ptr2, (uchar*)&len, 1);
  8606. ptr2 += 1;
  8607. memcpy(ptr2, sep->arg[6], len);
  8608. }
  8609. }
  8610. DumpPacket(app);
  8611. client->QueuePacket(app);
  8612. safe_delete(packet2);
  8613. }
  8614. }
  8615. }
  8616. else {
  8617. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8618. if (packet2) {
  8619. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8620. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8621. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8622. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8623. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8624. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8625. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8626. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8627. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8628. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8629. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8630. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8631. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8632. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8633. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8634. packet2->setSubstructDataByName("spell_info", "level", 19);
  8635. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8636. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8637. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8638. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8639. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8640. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8641. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8642. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8643. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8644. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8645. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8646. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8647. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8648. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8649. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8650. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8651. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8652. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8653. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8654. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8655. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8656. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8657. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8658. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8659. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8660. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8661. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8662. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8663. packet2->setArrayDataByName("reagent", "Alcohol");
  8664. packet2->setArrayDataByName("consumed", "123");
  8665. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8666. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8667. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8668. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8669. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8670. packet2->setSubstructDataByName("spell_info", "type", 2);
  8671. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8672. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8673. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8674. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8675. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8676. EQ2Packet* outapp = packet2->serialize();
  8677. DumpPacket(outapp);
  8678. client->QueuePacket(outapp);
  8679. safe_delete(packet2);
  8680. }
  8681. }
  8682. return;
  8683. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8684. if (!p) return;
  8685. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8686. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8687. //}
  8688. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8689. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8690. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8691. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8692. if (packet) {
  8693. client->QueuePacket(packet->serialize());
  8694. safe_delete(packet);
  8695. }
  8696. }*/
  8697. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8698. int32 numFaces = 0;
  8699. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8700. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8701. map<int32, vector<Face*> >::iterator itr;
  8702. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8703. numFaces += (*itr).second.size();
  8704. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8705. }*/
  8706. //uchar blah[] = {
  8707. // 1208 - OP_EQUpdateStoreCmd
  8708. // /*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
  8709. // /*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
  8710. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8711. // /*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
  8712. /*};
  8713. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8714. int8 val = 0;
  8715. int16 pos = 0;
  8716. int idx = 0;
  8717. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8718. pos = atoi(sep2->arg[idx]);
  8719. val = atoi(sep2->arg[idx+1]);
  8720. memset(blah+pos, val, 1);
  8721. idx+=2;
  8722. }
  8723. DumpPacket(blah, sizeof(blah));
  8724. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8725. if (client->GetPlayer()->GetTarget()) {
  8726. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8727. if (packet) {
  8728. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8729. packet->setDataByName("size", 0);
  8730. packet->setDataByName("unknown2", 0);
  8731. EQ2Packet* app = packet->serialize();
  8732. client->QueuePacket(app);
  8733. safe_delete(packet);
  8734. }
  8735. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8736. if (set_pov) {
  8737. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8738. EQ2Packet* app_pov = set_pov->serialize();
  8739. client->QueuePacket(app_pov);
  8740. safe_delete(set_pov);
  8741. }
  8742. }
  8743. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8744. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8745. if (packet) {
  8746. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8747. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8748. else
  8749. packet->setDataByName("Type", 2);
  8750. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8751. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8752. else
  8753. packet->setDataByName("race_id", 0);
  8754. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8755. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8756. else
  8757. packet->setDataByName("gender", 2);
  8758. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8759. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8760. else
  8761. packet->setDataByName("unknown", 0, 0);
  8762. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8763. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8764. else
  8765. packet->setDataByName("unknown", 0, 1);
  8766. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8767. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8768. else
  8769. packet->setDataByName("unknown", 0, 2);
  8770. client->QueuePacket(packet->serialize());
  8771. }
  8772. safe_delete(packet);
  8773. safe_delete(sep2);
  8774. }
  8775. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8776. const char *channel_name;
  8777. if (sep == NULL || !sep->IsSet(0)) {
  8778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8779. PrintSep(sep);
  8780. return;
  8781. }
  8782. channel_name = sep->arg[0];
  8783. if (!chat.IsInChannel(client, channel_name))
  8784. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8785. else if (!chat.LeaveChannel(client, channel_name))
  8786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8787. }
  8788. /*
  8789. Function:
  8790. Purpose :
  8791. Params :
  8792. Dev :
  8793. Example :
  8794. */
  8795. void Commands::Command_WeaponStats(Client* client)
  8796. {
  8797. Player* player = client->GetPlayer();
  8798. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8799. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8800. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8801. client->SimpleMessage(0, "Primary:");
  8802. if (primary) {
  8803. client->Message(0, "Name: %s", primary->name.c_str());
  8804. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8805. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8806. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8807. client->Message(0, "Proc Percent: %d%%", 0);
  8808. client->Message(0, "Procs Per Minute: %d", 0);
  8809. }
  8810. else {
  8811. client->SimpleMessage(0, "Name: fist");
  8812. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8813. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8814. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8815. client->Message(0, "Proc Percent: %d%%", 0);
  8816. client->Message(0, "Procs Per Minute: %d", 0);
  8817. }
  8818. client->SimpleMessage(0, " ");
  8819. client->SimpleMessage(0, " ");
  8820. if (secondary) {
  8821. client->SimpleMessage(0, "Secondary:");
  8822. client->Message(0, "Name: %s", secondary->name.c_str());
  8823. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8824. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8825. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8826. client->Message(0, "Proc Percent: %d%%", 0);
  8827. client->Message(0, "Procs Per Minute: %d", 0);
  8828. client->SimpleMessage(0, " ");
  8829. client->SimpleMessage(0, " ");
  8830. }
  8831. client->SimpleMessage(0, "Ranged:");
  8832. if (ranged) {
  8833. client->Message(0, "Name: %s", ranged->name.c_str());
  8834. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8835. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8836. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8837. client->Message(0, "Proc Percent: %d%%", 0);
  8838. client->Message(0, "Procs Per Minute: %d", 0);
  8839. }
  8840. else
  8841. client->SimpleMessage(0, "None");
  8842. }
  8843. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8844. const char *channel_name;
  8845. if (sep == NULL || !sep->IsSet(0)) {
  8846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8847. return;
  8848. }
  8849. channel_name = sep->arg[0];
  8850. if (!chat.ChannelExists(channel_name))
  8851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8852. else
  8853. chat.SendChannelUserList(client, channel_name);
  8854. }
  8855. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8856. {
  8857. ZoneServer* zone = 0;
  8858. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8859. if (zone_id > 0)
  8860. {
  8861. zone = zone_list.Get(zone_id, false);
  8862. if (zone)
  8863. {
  8864. zone->SetSafeX(client->GetPlayer()->GetX());
  8865. zone->SetSafeY(client->GetPlayer()->GetY());
  8866. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8867. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8868. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8870. else
  8871. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8872. }
  8873. }
  8874. }
  8875. /*
  8876. Function:
  8877. Purpose :
  8878. Params :
  8879. Dev :
  8880. Example :
  8881. */
  8882. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8883. {
  8884. ZoneInfo* zone_info = new ZoneInfo;
  8885. if (sep && sep->arg[0])
  8886. {
  8887. if (sep->IsNumber(0))
  8888. zone_info->id = atoi(sep->arg[0]);
  8889. else
  8890. zone_info->id = database.GetZoneID(sep->arg[0]);
  8891. if (zone_info->id > 0)
  8892. {
  8893. database.LoadZoneInfo(zone_info);
  8894. 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);
  8895. 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);
  8896. 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);
  8897. 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);
  8898. 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);
  8899. 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);
  8900. 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);
  8901. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8902. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8903. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8904. }
  8905. else
  8906. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8907. }
  8908. else
  8909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8910. safe_delete(zone_info);
  8911. }
  8912. /*
  8913. Function:
  8914. Purpose :
  8915. Params :
  8916. Dev :
  8917. Example :
  8918. */
  8919. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8920. {
  8921. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8922. {
  8923. ZoneServer* zone = 0;
  8924. int32 zone_id = 0;
  8925. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8926. {
  8927. zone_id = atoi(sep->arg[0]);
  8928. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8929. }
  8930. else
  8931. {
  8932. zone_id = database.GetZoneID(sep->arg[0]);
  8933. if (zone_id > 0)
  8934. zone = zone_list.Get(sep->arg[0], false);
  8935. }
  8936. if (zone_id > 0)
  8937. {
  8938. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8939. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8940. else
  8941. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8942. }
  8943. else
  8944. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8945. }
  8946. else
  8947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8948. }
  8949. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8950. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8952. return;
  8953. }
  8954. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8955. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8956. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8957. }
  8958. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8959. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8961. return;
  8962. }
  8963. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8964. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8965. }
  8966. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8967. Spawn* spawn = client->GetPlayer()->GetTarget();
  8968. if(spawn) {
  8969. client->SetMerchantTransaction(spawn);
  8970. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8971. client->SendHailCommand(spawn);
  8972. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8973. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8974. client->SendBuyMerchantList(sell);
  8975. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8976. client->SendSellMerchantList(sell);
  8977. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8978. client->SendBuyBackList(sell);
  8979. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8980. if (packet) {
  8981. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8982. packet->setDataByName("type", 16);
  8983. EQ2Packet* outapp = packet->serialize();
  8984. if (outapp)
  8985. client->QueuePacket(outapp);
  8986. safe_delete(packet);
  8987. }
  8988. }
  8989. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8990. client->SendRepairList();
  8991. }
  8992. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8993. }
  8994. void Commands::Command_Weather(Client* client, Seperator* sep)
  8995. {
  8996. //PrintSep(sep, "Weather");
  8997. if( sep && sep->arg[0] )
  8998. {
  8999. ZoneServer* zsZone = client->GetCurrentZone();
  9000. const char* value = sep->arg[0];
  9001. // process single-param commands first
  9002. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9003. {
  9004. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9005. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9006. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9007. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9008. }
  9009. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9010. {
  9011. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9012. zsZone->ProcessWeather();
  9013. }
  9014. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9015. {
  9016. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9017. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9018. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9019. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9020. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9021. zsZone->SetWeatherPattern(1);
  9022. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9023. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9024. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9025. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9026. zsZone->ProcessWeather();
  9027. }
  9028. // process commands with params
  9029. if( sep->arg[1] )
  9030. {
  9031. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9032. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9033. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9034. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9035. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9036. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9037. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9038. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9039. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9040. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9041. }
  9042. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9043. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9044. zsZone->SetRain(zsZone->GetCurrentWeather());
  9045. }
  9046. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9047. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9048. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9049. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9050. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9051. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9052. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9053. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9054. }
  9055. }
  9056. else
  9057. {
  9058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9061. return;
  9062. }
  9063. }
  9064. void Commands::Command_Select(Client* client, Seperator* sep) {
  9065. if (sep && sep->arg[1]) {
  9066. Spawn* spawn = client->GetPlayer()->GetTarget();
  9067. if (spawn && strlen(sep->arg[1]) > 0)
  9068. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9069. }
  9070. }
  9071. /*
  9072. Function: Command_ConsumeFood()
  9073. Purpose : Consume Food/Drink and apply mods
  9074. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9075. Dev : Zcoretri
  9076. Example : /consume_food 22
  9077. */
  9078. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9079. if (sep && sep->arg[0] && sep->IsNumber(0))
  9080. {
  9081. Player* player = client->GetPlayer();
  9082. int8 slot = atoi(sep->arg[0]);
  9083. Item* item = player->GetEquipmentList()->GetItem(slot);
  9084. if(item) {
  9085. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9086. if(item->GetItemScript() && lua_interface){
  9087. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9088. if (slot == 22)
  9089. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9090. else
  9091. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9092. }
  9093. }
  9094. if (item->details.count > 1) {
  9095. item->details.count -= 1;
  9096. item->save_needed = true;
  9097. }
  9098. else {
  9099. player->GetEquipmentList()->RemoveItem(slot, true);
  9100. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9101. }
  9102. client->GetPlayer()->SetCharSheetChanged(true);
  9103. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9104. }
  9105. }
  9106. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9107. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9108. if (atoi(sep->arg[0]) == 1) {
  9109. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9110. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9111. client->GetPlayer()->SetCharSheetChanged(true);
  9112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9113. }
  9114. else {
  9115. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9116. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9117. client->GetPlayer()->SetCharSheetChanged(true);
  9118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9119. }
  9120. }
  9121. else
  9122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9123. }
  9124. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9125. {
  9126. if(sep)
  9127. {
  9128. string data;
  9129. if(sep->arg[0]){
  9130. data = string(sep->arg[0]);
  9131. }
  9132. for(int i=1;i<sep->GetMaxArgNum();i++){
  9133. if(sep->arg[i])
  9134. data.append(" ").append(sep->arg[i]);
  9135. }
  9136. const char* target_name = 0;
  9137. int32 spawn_id = 0;
  9138. if(client->GetPlayer()->GetTarget())
  9139. {
  9140. target_name = client->GetPlayer()->GetTarget()->GetName();
  9141. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9142. }
  9143. else
  9144. target_name = "N/A";
  9145. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9146. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9148. else
  9149. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9150. }
  9151. }
  9152. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9153. PrintSep(sep, "Command_Attune_Inv");
  9154. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9155. // Get the item index from the first parameter
  9156. int16 index = atoi(sep->arg[0]);
  9157. // Check to see if this is a valid item index for the player, if not exit out of the function
  9158. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9159. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9160. return;
  9161. }
  9162. // Get the item
  9163. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9164. if(item) {
  9165. // Valid item lets check to make sure this item is attunable, if not return out
  9166. if (!item->CheckFlag(ATTUNEABLE)) {
  9167. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9168. return;
  9169. }
  9170. // Remove the attunable flag
  9171. item->generic_info.item_flags -= ATTUNEABLE;
  9172. // Set the attuned flag
  9173. item->generic_info.item_flags += ATTUNED;
  9174. // Flag this item for saving
  9175. item->save_needed = true;
  9176. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9177. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9178. EQ2Packet* outapp = 0;
  9179. for (int32 i=0;i<packets.size();i++) {
  9180. outapp = packets[i];
  9181. if(outapp)
  9182. client->QueuePacket(outapp);
  9183. }
  9184. }
  9185. }
  9186. }
  9187. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9188. PrintSep(sep, "Command_Reset_Zone_Timer");
  9189. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9190. int32 db_id = atoul(sep->arg[0]);
  9191. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9192. if (data) {
  9193. // TODO: add a check to timers to ensure it can be reset
  9194. // Delete the character from the instance
  9195. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9196. data->instance_id = 0;
  9197. // Update the success time and set to 0 so the player can enter it again
  9198. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9199. data->last_success_timestamp = 0;
  9200. }
  9201. }*/
  9202. }
  9203. void Commands::Command_Player(Client* client, Seperator* sep) {
  9204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9206. }
  9207. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9208. // /player coins add 10
  9209. // /player coins add plat 10
  9210. Player* player = client->GetPlayer();
  9211. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9212. player = (Player*)player->GetTarget();
  9213. if (sep && sep->arg[0] && sep->arg[1]) {
  9214. const char* action = sep->arg[0];
  9215. int64 value = 0;
  9216. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9217. if (sep->IsNumber(1)) {
  9218. value = atoi64(sep->arg[1]);
  9219. player->AddCoins(value);
  9220. if (client->GetPlayer() == player)
  9221. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9222. else {
  9223. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9224. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9225. }
  9226. return;
  9227. }
  9228. else if (sep->arg[2] && sep->IsNumber(2)) {
  9229. const char* type = sep->arg[1];
  9230. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9231. value = atoi64(sep->arg[2]);
  9232. }
  9233. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9234. value = atoi64(sep->arg[2]) * 100;
  9235. }
  9236. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9237. value = atoi64(sep->arg[2]) * 10000;
  9238. }
  9239. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9240. value = atoi64(sep->arg[2]) * 1000000;
  9241. }
  9242. player->AddCoins(value);
  9243. if (client->GetPlayer() == player)
  9244. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9245. else {
  9246. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9247. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9248. }
  9249. return;
  9250. }
  9251. }
  9252. }
  9253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9259. }
  9260. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9261. PrintSep(sep, "ACHIEVEMENT_ADD");
  9262. if (sep && sep->IsSet(0)) {
  9263. int32 spell_id = atoul(sep->arg[1]);
  9264. int8 spell_tier = 0;
  9265. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9266. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9267. // addspellbookentry here
  9268. if (spell_tier >= data->maxRank) {
  9269. return;
  9270. }
  9271. if (!spell_tier) {
  9272. spell_tier = 1;
  9273. }
  9274. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9275. {
  9276. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9277. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9278. client->GetPlayer()->UnlockSpell(spell);
  9279. client->SendSpellUpdate(spell);
  9280. }
  9281. else
  9282. {
  9283. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9284. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9285. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9286. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9287. client->GetPlayer()->UnlockSpell(spell);
  9288. client->SendSpellUpdate(spell);
  9289. }
  9290. // cast spell here
  9291. if (!spell_tier)
  9292. spell_tier = 1;
  9293. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9294. if (spell) {
  9295. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9296. }
  9297. }
  9298. else {
  9299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9300. }
  9301. master_aa_list.DisplayAA(client, 0, 0);
  9302. }
  9303. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9304. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9305. if (packet) {
  9306. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9307. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9308. char command[255];
  9309. url = "browser " + url;
  9310. int32 spawn_id = 0;
  9311. int32 zone_id = 0;
  9312. string type;
  9313. if (client->GetCurrentZone())
  9314. zone_id = client->GetCurrentZone()->GetZoneID();
  9315. if (client->GetPlayer()->GetTarget()) {
  9316. Spawn* target = client->GetPlayer()->GetTarget();
  9317. if (target->IsWidget())
  9318. type = "widgets";
  9319. else if (target->IsSign())
  9320. type = "signs";
  9321. else if (target->IsObject())
  9322. type = "objects";
  9323. else if (target->IsNPC())
  9324. type = "npcs";
  9325. else if (target->IsGroundSpawn())
  9326. type = "ground";
  9327. else
  9328. type = "spawn";
  9329. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9330. }
  9331. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9332. packet->setDataByName("accept_command", command);
  9333. }
  9334. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9335. char command[255];
  9336. url = "browser " + url;
  9337. if (client->GetPlayer()->GetTarget())
  9338. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9339. packet->setDataByName("accept_command", command);
  9340. }
  9341. else {
  9342. string command = "browser " + url;
  9343. packet->setDataByName("accept_command", command.c_str());
  9344. }
  9345. packet->setDataByName("text", "Open the web editor?");
  9346. packet->setDataByName("accept_text", "Open");
  9347. packet->setDataByName("cancel_text", "Cancel");
  9348. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9349. packet->setDataByName("unknown2", 50);
  9350. packet->setDataByName("unknown4", 1);
  9351. client->QueuePacket(packet->serialize());
  9352. safe_delete(packet);
  9353. }
  9354. }
  9355. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9356. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9357. return;
  9358. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9359. if(client->GetCurrentRez()->active)
  9360. client->AcceptResurrection();
  9361. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9362. }
  9363. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9364. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9365. return;
  9366. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9367. if(client->GetCurrentRez()->active)
  9368. client->GetCurrentRez()->should_delete = true;
  9369. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9370. }
  9371. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9372. PrintSep(sep, "Switch_AA_Profile");
  9373. if (sep && sep->IsSet(0)) {
  9374. string type = sep->arg[0];
  9375. int8 newtemplate = atoul(sep->arg[1]);
  9376. master_aa_list.DisplayAA(client, newtemplate, 1);
  9377. }
  9378. }
  9379. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9380. PrintSep(sep, "Get_AA_Xml");
  9381. if (sep && sep->IsSet(0)) {
  9382. string tabnum = sep->arg[0];
  9383. string spellid = sep->arg[1];
  9384. }
  9385. }
  9386. void Commands::Add_AA(Client* client, Seperator* sep) {
  9387. PrintSep(sep, "Add_AA");
  9388. if (sep && sep->IsSet(0)) {
  9389. int32 spell_id = atoul(sep->arg[1]);
  9390. int8 spell_tier = 0;
  9391. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9392. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9393. // addspellbookentry here
  9394. if (spell_tier >= data->maxRank) {
  9395. return;
  9396. }
  9397. if (!spell_tier) {
  9398. spell_tier = 1;
  9399. }
  9400. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9401. {
  9402. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9403. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9404. client->GetPlayer()->UnlockSpell(spell);
  9405. client->SendSpellUpdate(spell);
  9406. }
  9407. else
  9408. {
  9409. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9410. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9411. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9412. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9413. client->GetPlayer()->UnlockSpell(spell);
  9414. client->SendSpellUpdate(spell);
  9415. }
  9416. // cast spell here
  9417. if (!spell_tier)
  9418. spell_tier = 1;
  9419. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9420. if (spell) {
  9421. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9422. }
  9423. }
  9424. else {
  9425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9426. }
  9427. master_aa_list.DisplayAA(client, 0, 0);
  9428. }
  9429. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9430. PrintSep(sep, "Commit_AA_Profile");
  9431. if (sep && sep->IsSet(0)) {
  9432. }
  9433. }
  9434. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9435. PrintSep(sep, "Begin_AA_Profile");
  9436. if (sep && sep->IsSet(0)) {
  9437. master_aa_list.DisplayAA(client, 100, 2);
  9438. }
  9439. }
  9440. void Commands::Back_AA(Client* client, Seperator* sep) {
  9441. if (sep && sep->IsSet(0)) {
  9442. PrintSep(sep, "Back_AA");
  9443. }
  9444. }
  9445. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9446. if (sep && sep->IsSet(0)) {
  9447. PrintSep(sep, "Remove_AA");
  9448. }
  9449. }
  9450. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9451. MasterAAList master_aa_list;
  9452. PrintSep(sep, "Cancel_AA_Profile");
  9453. master_aa_list.DisplayAA(client, 0, 0);
  9454. }
  9455. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9456. if (sep && sep->IsSet(0)) {
  9457. PrintSep(sep, "Save_AA_Profile");
  9458. }
  9459. }
  9460. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9461. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9462. if (!sep->IsNumber(0)) return;
  9463. int32 request_id = atoul(sep->arg[0]);
  9464. if (!sep->IsNumber(1)) return;
  9465. sint32 item_id = atoi(sep->arg[1]);
  9466. if (client->IsCurrentTransmuteID(request_id)) {
  9467. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9468. }
  9469. else if (client->IsCurrentTransmuteID(item_id)) {
  9470. if (!sep->IsSet(2)) return;
  9471. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9472. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9473. }
  9474. }
  9475. }
  9476. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9477. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9478. }