Commands.cpp 315 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896
  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. extern WorldDatabase database;
  46. extern MasterSpellList master_spell_list;
  47. extern MasterTraitList master_trait_list;
  48. extern MasterRecipeList master_recipe_list;
  49. extern MasterRecipeBookList master_recipebook_list;
  50. extern World world;
  51. extern ClientList client_list;
  52. extern ConfigReader configReader;
  53. extern VisualStates visual_states;
  54. extern ZoneList zone_list;
  55. extern LuaInterface* lua_interface;
  56. extern MasterQuestList master_quest_list;
  57. extern MasterCollectionList master_collection_list;
  58. extern MasterSkillList master_skill_list;
  59. extern MasterFactionList master_faction_list;
  60. extern GuildList guild_list;
  61. extern MasterLanguagesList master_languages_list;
  62. extern IRC irc;
  63. extern Chat chat;
  64. extern RuleManager rule_manager;
  65. extern MasterAAList master_aa_list;
  66. extern MasterRaceTypeList race_types_list;
  67. extern Classes classes;
  68. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  69. #if defined(__GNUC__)
  70. #define stricmp strcasecmp
  71. #define strnicmp strncasecmp
  72. #endif
  73. EQ2Packet* RemoteCommands::serialize(){
  74. buffer.clear();
  75. vector<EQ2_RemoteCommandString>::iterator command_list;
  76. buffer.append((char*)&num_commands, sizeof(int16));
  77. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  78. AddDataCommand(&(*command_list));
  79. }
  80. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  81. return app;
  82. }
  83. Commands::Commands(){
  84. remote_commands = new RemoteCommands();
  85. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  86. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  87. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  88. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  89. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  90. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  91. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  92. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  93. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  94. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  95. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  96. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  97. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  98. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  99. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  100. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  101. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  102. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  103. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  104. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  105. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  106. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  107. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  108. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  109. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  110. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  111. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  112. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  113. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  114. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  115. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  116. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  117. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  118. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  119. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  120. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  121. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  122. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  123. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  124. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  125. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  126. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  127. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  128. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  129. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  130. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  131. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  132. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  133. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  134. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  135. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  136. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  137. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  138. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  139. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  140. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  141. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  142. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  143. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  144. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  145. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  146. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  147. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  148. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  149. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  150. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  151. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  152. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  153. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  154. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  155. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  156. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  157. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  158. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  159. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  160. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  161. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  162. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  163. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  164. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  165. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  166. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  167. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  168. }
  169. Commands::~Commands() {
  170. safe_delete(remote_commands);
  171. }
  172. int32 Commands::GetSpawnSetType(string val){
  173. if(spawn_set_values.count(val) > 0)
  174. return spawn_set_values[val];
  175. return 0xFFFFFFFF;
  176. }
  177. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  178. if(!target)
  179. return false;
  180. int32 val = 0;
  181. try{
  182. 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_LASTNAME))
  183. val = atoul(value);
  184. }
  185. catch(...){
  186. if(client)
  187. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  188. return false;
  189. }
  190. if(temporary && temp_value){
  191. char tmp[128] = {0};
  192. switch(type){
  193. case SPAWN_SET_VALUE_NAME:{
  194. sprintf(tmp, "%s", target->GetName());
  195. target->SetName(value);
  196. client->GetCurrentZone()->SendUpdateTitles(target);
  197. break;
  198. }
  199. case SPAWN_SET_VALUE_X_OFFSET:
  200. {
  201. sprintf(tmp, "%f", target->GetXOffset());
  202. target->SetXOffset(float(val));
  203. break;
  204. }
  205. case SPAWN_SET_VALUE_Y_OFFSET:
  206. {
  207. sprintf(tmp, "%f", target->GetYOffset());
  208. target->SetYOffset(float(val));
  209. break;
  210. }
  211. case SPAWN_SET_VALUE_Z_OFFSET:
  212. {
  213. sprintf(tmp, "%f", target->GetZOffset());
  214. target->SetZOffset(float(val));
  215. break;
  216. }
  217. case SPAWN_SET_VALUE_EXPIRE: {
  218. sprintf(tmp, "%u", target->GetExpireTime());
  219. target->SetExpireTime(val);
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  223. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  224. target->SetExpireOffsetTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_SUB_TITLE: {
  228. sprintf(tmp, "%s", target->GetSubTitle());
  229. target->SetSubTitle(value);
  230. client->GetCurrentZone()->SendUpdateTitles(target);
  231. break;
  232. }
  233. case SPAWN_SET_VALUE_LEVEL:{
  234. sprintf(tmp, "%i", target->GetLevel());
  235. target->SetLevel(val, send_update);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_DIFFICULTY:{
  239. sprintf(tmp, "%i", target->GetEncounterLevel());
  240. target->SetEncounterLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_MODEL_TYPE:{
  244. sprintf(tmp, "%i", target->GetModelType());
  245. target->SetModelType(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_CLASS:{
  249. sprintf(tmp, "%i", target->GetAdventureClass());
  250. target->SetAdventureClass(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_GENDER:{
  254. sprintf(tmp, "%i", target->GetGender());
  255. target->SetGender(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_SHOW_NAME:{
  259. sprintf(tmp, "%i", target->GetShowName());
  260. target->SetShowName(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_ATTACKABLE:{
  264. sprintf(tmp, "%i", target->GetAttackable());
  265. target->SetAttackable(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  269. sprintf(tmp, "%i", target->GetShowLevel());
  270. target->SetShowLevel(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_TARGETABLE:{
  274. sprintf(tmp, "%i", target->GetTargetable());
  275. target->SetTargetable(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  279. sprintf(tmp, "%i", target->GetShowCommandIcon());
  280. target->SetShowCommandIcon(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_HAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowHandIcon());
  285. target->SetShowHandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAIR_TYPE:{
  289. if(target->IsEntity()){
  290. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  291. ((Entity*)target)->SetHairType(val, send_update);
  292. }
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  296. if(target->IsEntity()){
  297. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  298. ((Entity*)target)->SetHairType(val, send_update);
  299. }
  300. break;
  301. }
  302. case SPAWN_SET_VALUE_WING_TYPE:{
  303. if(target->IsEntity()){
  304. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  305. ((Entity*)target)->SetWingType(val, send_update);
  306. }
  307. break;
  308. }
  309. case SPAWN_SET_VALUE_CHEST_TYPE:{
  310. if(target->IsEntity()){
  311. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  312. ((Entity*)target)->SetChestType(val, send_update);
  313. }
  314. break;
  315. }
  316. case SPAWN_SET_VALUE_LEGS_TYPE:{
  317. if(target->IsEntity()){
  318. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  319. ((Entity*)target)->SetLegsType(val, send_update);
  320. }
  321. break;
  322. }
  323. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  324. if(target->IsEntity()){
  325. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  326. ((Entity*)target)->SetSogaHairType(val, send_update);
  327. }
  328. break;
  329. }
  330. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  331. if(target->IsEntity()){
  332. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  333. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  334. }
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  338. sprintf(tmp, "%i", target->GetSogaModelType());
  339. target->SetSogaModelType(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SIZE:{
  343. sprintf(tmp, "%i", target->GetSize());
  344. target->SetSize(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_HP:{
  348. sprintf(tmp, "%i", target->GetHP());
  349. target->SetHP(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_POWER:{
  353. sprintf(tmp, "%i", target->GetPower());
  354. target->SetPower(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_HEROIC:{
  358. sprintf(tmp, "%i", target->GetHeroic());
  359. target->SetHeroic(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_RESPAWN:{
  363. sprintf(tmp, "%u", target->GetRespawnTime());
  364. target->SetRespawnTime(val);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_X:{
  368. sprintf(tmp, "%f", target->GetX());
  369. target->SetX(atof(value), send_update);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_Y:{
  373. sprintf(tmp, "%f", target->GetY());
  374. target->SetY(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Z:{
  378. sprintf(tmp, "%f", target->GetZ());
  379. target->SetZ(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_HEADING:{
  383. sprintf(tmp, "%f", target->GetHeading());
  384. target->SetHeading(atof(value) + 360, send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_VISUAL_STATE:{
  388. sprintf(tmp, "%i", target->GetVisualState());
  389. target->SetVisualState(val, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_ACTION_STATE:{
  393. sprintf(tmp, "%i", target->GetActionState());
  394. target->SetActionState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_MOOD_STATE:{
  398. sprintf(tmp, "%i", target->GetMoodState());
  399. target->SetMoodState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_INITIAL_STATE:{
  403. sprintf(tmp, "%i", target->GetInitialState());
  404. target->SetInitialState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  408. sprintf(tmp, "%i", target->GetActivityStatus());
  409. target->SetActivityStatus(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  413. sprintf(tmp, "%i", target->GetCollisionRadius());
  414. target->SetCollisionRadius(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_DEVICE_ID: {
  418. if (target->IsObject()) {
  419. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  420. ((Object*)target)->SetDeviceID(val);
  421. }
  422. break;
  423. }
  424. case SPAWN_SET_VALUE_PITCH: {
  425. sprintf(tmp, "%f", target->GetPitch());
  426. target->SetPitch(atof(value), send_update);
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_ROLL: {
  430. sprintf(tmp, "%f", target->GetRoll());
  431. target->SetRoll(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_HIDE_HOOD: {
  435. sprintf(tmp, "%i", target->appearance.hide_hood);
  436. target->SetHideHood(val);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_EMOTE_STATE: {
  440. sprintf(tmp, "%i", target->appearance.emote_state);
  441. target->SetEmoteState(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_ICON: {
  445. sprintf(tmp, "%i", target->GetIconValue());
  446. target->SetIcon(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_PREFIX: {
  450. sprintf(tmp, "%s", target->GetPrefixTitle());
  451. target->SetPrefixTitle(value);
  452. client->GetCurrentZone()->SendUpdateTitles(target);
  453. break;
  454. }
  455. case SPAWN_SET_VALUE_SUFFIX: {
  456. sprintf(tmp, "%s", target->GetSuffixTitle());
  457. target->SetSuffixTitle(value);
  458. client->GetCurrentZone()->SendUpdateTitles(target);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_LASTNAME: {
  462. sprintf(tmp, "%s", target->GetLastName());
  463. target->SetLastName(value);
  464. client->GetCurrentZone()->SendUpdateTitles(target);
  465. break;
  466. }
  467. *temp_value = string(tmp);
  468. }
  469. }
  470. else{
  471. switch(type){
  472. case SPAWN_SET_VALUE_NAME:{
  473. target->SetName(value);
  474. client->GetCurrentZone()->SendUpdateTitles(target);
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_SUB_TITLE: {
  478. target->SetSubTitle(value);
  479. client->GetCurrentZone()->SendUpdateTitles(target);
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_X_OFFSET:
  483. {
  484. target->SetXOffset(atof(value));
  485. break;
  486. }
  487. case SPAWN_SET_VALUE_Y_OFFSET:
  488. {
  489. target->SetYOffset(atof(value));
  490. break;
  491. }
  492. case SPAWN_SET_VALUE_Z_OFFSET:
  493. {
  494. target->SetZOffset(atof(value));
  495. break;
  496. }
  497. case SPAWN_SET_VALUE_EXPIRE: {
  498. target->SetExpireTime(val);
  499. break;
  500. }
  501. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  502. target->SetExpireOffsetTime(val);
  503. break;
  504. }
  505. case SPAWN_SET_VALUE_LEVEL:{
  506. target->SetLevel(val, send_update);
  507. break;
  508. }
  509. case SPAWN_SET_VALUE_DIFFICULTY:{
  510. target->SetEncounterLevel(val, send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_MODEL_TYPE:{
  514. target->SetModelType(val, send_update);
  515. break;
  516. }
  517. case SPAWN_SET_VALUE_CLASS:{
  518. target->SetAdventureClass(val, send_update);
  519. break;
  520. }
  521. case SPAWN_SET_VALUE_GENDER:{
  522. target->SetGender(val, send_update);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_SHOW_NAME:{
  526. target->SetShowName(val, send_update);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_ATTACKABLE:{
  530. target->SetAttackable(val, send_update);
  531. break;
  532. }
  533. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  534. target->SetShowLevel(val, send_update);
  535. break;
  536. }
  537. case SPAWN_SET_VALUE_TARGETABLE:{
  538. target->SetTargetable(val, send_update);
  539. break;
  540. }
  541. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  542. target->SetShowCommandIcon(val, send_update);
  543. break;
  544. }
  545. case SPAWN_SET_VALUE_HAND_ICON:{
  546. target->SetShowHandIcon(val, send_update);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_HAIR_TYPE:{
  550. if(target->IsEntity())
  551. ((Entity*)target)->SetHairType(val, send_update);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  555. if(target->IsEntity())
  556. ((Entity*)target)->SetHairType(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_WING_TYPE:{
  560. if(target->IsEntity())
  561. ((Entity*)target)->SetWingType(val, send_update);
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_CHEST_TYPE:{
  565. if(target->IsEntity())
  566. ((Entity*)target)->SetChestType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_LEGS_TYPE:{
  570. if(target->IsEntity())
  571. ((Entity*)target)->SetLegsType(val, send_update);
  572. break;
  573. }
  574. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  575. if(target->IsEntity())
  576. ((Entity*)target)->SetSogaHairType(val, send_update);
  577. break;
  578. }
  579. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  580. if(target->IsEntity())
  581. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  582. break;
  583. }
  584. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  585. target->SetSogaModelType(val, send_update);
  586. break;
  587. }
  588. case SPAWN_SET_VALUE_SIZE:{
  589. target->SetSize(val, send_update);
  590. break;
  591. }
  592. case SPAWN_SET_VALUE_HP:{
  593. target->SetHP(val, send_update);
  594. break;
  595. }
  596. case SPAWN_SET_VALUE_POWER:{
  597. target->SetPower(val, send_update);
  598. break;
  599. }
  600. case SPAWN_SET_VALUE_HEROIC:{
  601. target->SetHeroic(val, send_update);
  602. break;
  603. }
  604. case SPAWN_SET_VALUE_RESPAWN:{
  605. target->SetRespawnTime(val);
  606. break;
  607. }
  608. case SPAWN_SET_VALUE_X:{
  609. target->SetX(atof(value), send_update);
  610. target->SetSpawnOrigX(target->GetX());
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_Y:{
  614. target->SetY(atof(value), send_update);
  615. target->SetSpawnOrigY(target->GetY());
  616. break;
  617. }
  618. case SPAWN_SET_VALUE_Z:{
  619. target->SetZ(atof(value), send_update);
  620. target->SetSpawnOrigZ(target->GetZ());
  621. break;
  622. }
  623. case SPAWN_SET_VALUE_HEADING:{
  624. target->SetHeading(atof(value), send_update);
  625. target->SetSpawnOrigHeading(target->GetHeading());
  626. break;
  627. }
  628. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  629. ZoneServer* zone = target->GetZone();
  630. if (!zone)
  631. zone = client->GetCurrentZone();
  632. if(zone->GetEntityCommandList(val))
  633. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  634. target->primary_command_list_id = val;
  635. break;
  636. }
  637. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  638. ZoneServer* zone = target->GetZone();
  639. if (!zone)
  640. zone = client->GetCurrentZone();
  641. if (zone->GetEntityCommandList(val))
  642. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  643. target->secondary_command_list_id = val;
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_VISUAL_STATE:{
  647. target->SetVisualState(val, send_update);
  648. break;
  649. }
  650. case SPAWN_SET_VALUE_ACTION_STATE:{
  651. target->SetActionState(val, send_update);
  652. break;
  653. }
  654. case SPAWN_SET_VALUE_MOOD_STATE:{
  655. target->SetMoodState(val, send_update);
  656. break;
  657. }
  658. case SPAWN_SET_VALUE_INITIAL_STATE:{
  659. target->SetInitialState(val, send_update);
  660. break;
  661. }
  662. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  663. target->SetActivityStatus(val, send_update);
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  667. target->SetCollisionRadius(val, send_update);
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_FACTION:{
  671. ZoneServer* zone = target->GetZone();
  672. if (!zone)
  673. zone = client->GetCurrentZone();
  674. target->faction_id = val;
  675. zone->RemoveDeadEnemyList(target);
  676. if(target->IsNPC())
  677. zone->AddEnemyList((NPC*)target);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_DEVICE_ID:{
  681. if (target->IsObject())
  682. ((Object*)target)->SetDeviceID(val);
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_PITCH: {
  686. target->SetPitch(atof(value), send_update);
  687. target->SetSpawnOrigPitch(atof(value));
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_ROLL: {
  691. target->SetRoll(atof(value), send_update);
  692. target->SetSpawnOrigRoll(atof(value));
  693. break;
  694. }
  695. case SPAWN_SET_VALUE_HIDE_HOOD: {
  696. target->SetHideHood(val);
  697. break;
  698. }
  699. case SPAWN_SET_VALUE_EMOTE_STATE: {
  700. target->SetEmoteState(val);
  701. break;
  702. }
  703. case SPAWN_SET_VALUE_ICON: {
  704. target->SetIcon(val);
  705. break;
  706. }
  707. case SPAWN_SET_VALUE_PREFIX: {
  708. target->SetPrefixTitle(value);
  709. client->GetCurrentZone()->SendUpdateTitles(target);
  710. break;
  711. }
  712. case SPAWN_SET_VALUE_SUFFIX: {
  713. target->SetSuffixTitle(value);
  714. client->GetCurrentZone()->SendUpdateTitles(target);
  715. break;
  716. }
  717. case SPAWN_SET_VALUE_LASTNAME: {
  718. target->SetLastName(value);
  719. client->GetCurrentZone()->SendUpdateTitles(target);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  723. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  724. if(client){
  725. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  726. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  727. }
  728. return false;
  729. }
  730. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  731. return false;
  732. else{
  733. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  734. target->SetSpawnScript(value);
  735. }
  736. break;
  737. }
  738. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  739. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  740. if(client){
  741. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  742. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  743. }
  744. return false;
  745. }
  746. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  747. return false;
  748. else{
  749. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  750. target->SetSpawnScript(value);
  751. }
  752. break;
  753. }
  754. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  755. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  756. if(client){
  757. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  758. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  759. }
  760. return false;
  761. }
  762. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  763. return false;
  764. else
  765. target->SetSpawnScript(value);
  766. break;
  767. }
  768. }
  769. }
  770. return true;
  771. }
  772. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  773. the database fields always and also update the zone in memory if it's running. */
  774. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  775. if (client && zone_id > 0 && type > 0 && value) {
  776. sint32 int_value = 0;
  777. float float_value = 0;
  778. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  779. try {
  780. float_value = atof(value);
  781. }
  782. catch (...) {
  783. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  784. return false;
  785. }
  786. }
  787. 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) {
  788. try {
  789. int_value = atoi(value);
  790. }
  791. catch (...) {
  792. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  793. return false;
  794. }
  795. }
  796. switch (type) {
  797. case ZONE_SET_VALUE_EXPANSION_ID: {
  798. break;
  799. }
  800. case ZONE_SET_VALUE_NAME: {
  801. if (zone)
  802. zone->SetZoneName(const_cast<char*>(value));
  803. database.SaveZoneInfo(zone_id, "name", value);
  804. break;
  805. }
  806. case ZONE_SET_VALUE_FILE: {
  807. if (zone)
  808. zone->SetZoneFile(const_cast<char*>(value));
  809. database.SaveZoneInfo(zone_id, "file", value);
  810. break;
  811. }
  812. case ZONE_SET_VALUE_DESCRIPTION: {
  813. if (zone)
  814. zone->SetZoneDescription(const_cast<char*>(value));
  815. database.SaveZoneInfo(zone_id, "description", value);
  816. break;
  817. }
  818. case ZONE_SET_VALUE_SAFE_X: {
  819. if (zone)
  820. zone->SetSafeX(float_value);
  821. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  822. break;
  823. }
  824. case ZONE_SET_VALUE_SAFE_Y: {
  825. if (zone)
  826. zone->SetSafeY(float_value);
  827. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  828. break;
  829. }
  830. case ZONE_SET_VALUE_SAFE_Z: {
  831. if (zone)
  832. zone->SetSafeZ(float_value);
  833. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  834. break;
  835. }
  836. case ZONE_SET_VALUE_UNDERWORLD: {
  837. if (zone)
  838. zone->SetUnderWorld(float_value);
  839. database.SaveZoneInfo(zone_id, "underworld", float_value);
  840. break;
  841. }
  842. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  843. break;
  844. }
  845. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  846. break;
  847. }
  848. case ZONE_SET_VALUE_ZONE_TYPE: {
  849. break;
  850. }
  851. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  852. if (zone)
  853. zone->SetAlwaysLoaded(int_value == 1);
  854. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  855. break;
  856. }
  857. case ZONE_SET_VALUE_CITY_ZONE: {
  858. if (zone)
  859. zone->SetCityZone(int_value == 1);
  860. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  861. break;
  862. }
  863. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  864. if (zone)
  865. zone->SetWeatherAllowed(int_value == 1);
  866. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  867. break;
  868. }
  869. case ZONE_SET_VALUE_MIN_STATUS: {
  870. if (zone)
  871. zone->SetMinimumStatus(int_value);
  872. database.SaveZoneInfo(zone_id, "min_status", int_value);
  873. break;
  874. }
  875. case ZONE_SET_VALUE_MIN_LEVEL: {
  876. if (zone)
  877. zone->SetMinimumLevel(int_value);
  878. database.SaveZoneInfo(zone_id, "min_level", int_value);
  879. break;
  880. }
  881. case ZONE_SET_VALUE_MAX_LEVEL: {
  882. if (zone)
  883. zone->SetMaximumLevel(int_value);
  884. database.SaveZoneInfo(zone_id, "max_level", int_value);
  885. break;
  886. }
  887. case ZONE_SET_VALUE_START_ZONE: {
  888. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  889. break;
  890. }
  891. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  892. if (zone)
  893. zone->SetInstanceType(int_value);
  894. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  895. break;
  896. }
  897. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  898. if (zone)
  899. zone->SetDefaultReenterTime(int_value);
  900. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  901. break;
  902. }
  903. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  904. if (zone)
  905. zone->SetDefaultResetTime(int_value);
  906. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  910. if (zone)
  911. zone->SetDefaultLockoutTime(int_value);
  912. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  916. if (zone)
  917. zone->SetForceGroupZoneOption(int_value);
  918. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_LUA_SCRIPT: {
  922. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  923. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  924. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  925. return false;
  926. }
  927. else {
  928. world.AddZoneScript(zone_id, const_cast<char*>(value));
  929. database.SaveZoneInfo(zone_id, "lua_script", value);
  930. }
  931. break;
  932. }
  933. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  934. if (zone)
  935. zone->SetShutdownTimer(int_value);
  936. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_ZONE_MOTD: {
  940. if (zone)
  941. zone->SetZoneMOTD(string(value));
  942. database.SaveZoneInfo(zone_id, "zone_motd", value);
  943. break;
  944. }
  945. default: {
  946. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  947. return false;
  948. }
  949. }
  950. }
  951. else {
  952. if (client)
  953. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  954. return false;
  955. }
  956. return true;
  957. }
  958. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  959. if (index >= remote_commands->commands.size()) {
  960. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  961. return;
  962. }
  963. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  964. EQ2_RemoteCommandString* parent_command = 0;
  965. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  966. Seperator* sep = 0;
  967. if (command_parms->size > 0) {
  968. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  969. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  970. parent_command = command;
  971. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  972. safe_delete(sep);
  973. if (command_parms->data.length() > (command->command.data.length() + 1))
  974. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  975. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  976. }
  977. else
  978. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  979. }
  980. int ndx = 0;
  981. if (command->required_status > client->GetAdminStatus())
  982. {
  983. 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());
  984. safe_delete(sep);
  985. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  986. return;
  987. }
  988. Player* player = client->GetPlayer();
  989. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  990. switch (command->handler) {
  991. case COMMAND_RELOAD: {
  992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1007. break;
  1008. }
  1009. case COMMAND_RELOADSTRUCTS: {
  1010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1011. configReader.ReloadStructs();
  1012. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1013. break;
  1014. }
  1015. case COMMAND_RELOAD_QUESTS: {
  1016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1017. master_quest_list.Reload();
  1018. client_list.ReloadQuests();
  1019. zone_list.ReloadClientQuests();
  1020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1021. break;
  1022. }
  1023. case COMMAND_RELOAD_SPAWNS: {
  1024. client->GetCurrentZone()->ReloadSpawns();
  1025. break;
  1026. }
  1027. case COMMAND_RELOAD_SPELLS: {
  1028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1029. zone_list.DeleteSpellProcess();
  1030. master_spell_list.Reload();
  1031. if (lua_interface)
  1032. lua_interface->ReloadSpells();
  1033. zone_list.LoadSpellProcess();
  1034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1035. break;
  1036. }
  1037. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1039. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1040. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1042. break;
  1043. }
  1044. case COMMAND_RELOAD_ZONESCRIPTS: {
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1046. world.ResetZoneScripts();
  1047. database.LoadZoneScriptData();
  1048. if (lua_interface)
  1049. lua_interface->DestroyZoneScripts();
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1051. break;
  1052. }
  1053. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1055. client->GetCurrentZone()->ClearEntityCommands();
  1056. database.LoadEntityCommands(client->GetCurrentZone());
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1058. break;
  1059. }
  1060. case COMMAND_RELOAD_FACTIONS: {
  1061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1062. master_faction_list.Clear();
  1063. database.LoadFactionList();
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1065. break;
  1066. }
  1067. case COMMAND_RELOAD_MAIL: {
  1068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1069. zone_list.ReloadMail();
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1071. break;
  1072. }
  1073. case COMMAND_RELOAD_GUILDS: {
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1075. world.ReloadGuilds();
  1076. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1077. break;
  1078. }
  1079. case COMMAND_RELOAD_LOCATIONS: {
  1080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1081. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1082. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1084. break;
  1085. }
  1086. case COMMAND_READ: {
  1087. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1088. if (strcmp(sep->arg[0], "read") == 0) {
  1089. int32 item_index = atol(sep->arg[1]);
  1090. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1091. if (item) {
  1092. Spawn* spawn = cmdTarget;
  1093. int8 numpages = item->book_pages.size();
  1094. string page1 = string(item->book_pages[0]->page_text.data);
  1095. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1096. string title = item->name;
  1097. if (packet) {
  1098. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1099. packet->setDataByName("book_title", title.c_str());
  1100. packet->setDataByName("book_type", "simple");
  1101. packet->setDataByName("unknown2", 1);
  1102. packet->setDataByName("unknown5", 1, 4);
  1103. packet->setArrayLengthByName("num_pages", numpages);
  1104. for (int8 pages = 1; pages <= numpages; pages++) {
  1105. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1106. string page = string(item->book_pages[pages-1]->page_text.data);
  1107. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1108. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1109. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1110. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1111. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1112. // Need to add support for images
  1113. }
  1114. client->QueuePacket(packet->serialize());
  1115. safe_delete(packet);
  1116. }
  1117. break;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. case COMMAND_USEABILITY:{
  1123. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1124. if (client->GetPlayer()->GetHP() == 0) {
  1125. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1126. }
  1127. else {
  1128. int32 spell_id = atoul(sep->arg[0]);
  1129. int8 spell_tier = 0;
  1130. if (sep->arg[1][0] && sep->IsNumber(1))
  1131. spell_tier = atoi(sep->arg[1]);
  1132. else
  1133. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1134. if (!spell_tier)
  1135. spell_tier = 1;
  1136. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1137. if (spell) {
  1138. 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)
  1139. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1140. else
  1141. {
  1142. if (cmdTarget)
  1143. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1144. else
  1145. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1146. }
  1147. }
  1148. }
  1149. }
  1150. else if (cmdTarget && cmdTarget->IsWidget())
  1151. {
  1152. Widget* widget = (Widget*)cmdTarget;
  1153. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1154. }
  1155. else
  1156. {
  1157. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1158. }
  1159. break;
  1160. }
  1161. case COMMAND_INFO:{
  1162. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1163. if(strcmp(sep->arg[0], "inventory") == 0){
  1164. int32 item_index = atol(sep->arg[1]);
  1165. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1166. if(item){
  1167. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1168. break;
  1169. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1170. //DumpPacket(app);
  1171. client->QueuePacket(app);
  1172. if(item->GetItemScript() && lua_interface)
  1173. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1174. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1175. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1176. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1177. client->AddPendingQuest(quest);
  1178. }
  1179. }
  1180. else
  1181. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1182. }
  1183. else if(strcmp(sep->arg[0], "equipment") == 0){
  1184. int32 item_index = atol(sep->arg[1]);
  1185. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1186. if(item){
  1187. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1188. client->QueuePacket(app);
  1189. if(item->GetItemScript() && lua_interface)
  1190. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1191. }
  1192. else
  1193. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1194. }
  1195. 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){
  1196. int32 item_id = atoul(sep->arg[1]);
  1197. Item* item = master_item_list.GetItem(item_id);
  1198. if(item){
  1199. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1200. client->QueuePacket(app);
  1201. }
  1202. else
  1203. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1204. }
  1205. else if (strcmp(sep->arg[0], "spell") == 0) {
  1206. sint32 spell_id = atol(sep->arg[1]);
  1207. int8 tier = atoi(sep->arg[3]);
  1208. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1209. if (outapp)
  1210. client->QueuePacket(outapp);
  1211. else
  1212. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1213. }
  1214. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1215. sint32 spell_id = atol(sep->arg[2]);
  1216. int8 group = atoi(sep->arg[1]);
  1217. AltAdvanceData* data = 0;
  1218. SpellBookEntry* spellentry = 0;
  1219. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1220. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1221. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1222. if (outapp)
  1223. client->QueuePacket(outapp);
  1224. else
  1225. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1226. }
  1227. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1228. sint32 spell_id = atol(sep->arg[1]);
  1229. int8 tier = atoi(sep->arg[2]);
  1230. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1231. if (outapp)
  1232. client->QueuePacket(outapp);
  1233. else
  1234. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1235. }
  1236. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1237. sint32 recipe_id = atol(sep->arg[1]);
  1238. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1239. if(outapp)
  1240. client->QueuePacket(outapp);
  1241. else
  1242. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1243. }
  1244. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1245. int32 slot = atol(sep->arg[1]);
  1246. int32 spell_id = atol(sep->arg[2]);
  1247. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1248. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1249. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1250. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1251. if(outapp)
  1252. client->QueuePacket(outapp);
  1253. else
  1254. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1255. }
  1256. else if (strcmp(sep->arg[0], "effect") == 0) {
  1257. int32 spell_id = atol(sep->arg[1]);
  1258. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1259. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1260. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1261. if (outapp){
  1262. client->QueuePacket(outapp);
  1263. }
  1264. else
  1265. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1266. }
  1267. }
  1268. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1269. Item* item = player->item_list.GetOverflowItem();
  1270. if(item) {
  1271. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1272. client->QueuePacket(app);
  1273. }
  1274. else
  1275. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1276. }
  1277. else
  1278. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1279. break;
  1280. }
  1281. case COMMAND_USE_EQUIPPED_ITEM:{
  1282. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1283. int32 slot_id = atoul(sep->arg[0]);
  1284. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1285. if (item && item->generic_info.usable && item->GetItemScript())
  1286. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1287. }
  1288. break;
  1289. }
  1290. case COMMAND_USE_ITEM: {
  1291. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1292. int32 item_index = atoul(sep->arg[0]);
  1293. Item* item = player->item_list.GetItemFromIndex(item_index);
  1294. if (item && item->GetItemScript()) {
  1295. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1296. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1297. else {
  1298. if (item->generic_info.display_charges > 0) {
  1299. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1300. item->generic_info.display_charges -= 1;
  1301. item->save_needed = true;
  1302. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1303. }
  1304. }
  1305. }
  1306. }
  1307. break;
  1308. }
  1309. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1310. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1311. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1312. if (item) {
  1313. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1314. if(item->generic_info.item_type == 6) {
  1315. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1316. int8 old_slot = 0;
  1317. if (spell) {
  1318. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1319. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1320. player->RemoveSpellBookEntry(spell->GetSpellID());
  1321. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1322. player->UnlockSpell(spell);
  1323. client->SendSpellUpdate(spell);
  1324. database.DeleteItem(client->GetCharacterID(), item, 0);
  1325. player->item_list.RemoveItem(item, true);
  1326. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1327. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1328. }
  1329. }
  1330. else
  1331. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1332. }
  1333. else if(item->generic_info.item_type == 7){
  1334. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1335. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1336. // if valid recipe book and the player doesn't have it
  1337. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1338. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1339. safe_delete(recipe_book);
  1340. }
  1341. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1342. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1343. // Add recipe book to the players list
  1344. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1345. // Get a list of all recipes this book contains
  1346. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1347. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1348. // Create the packet to send to update the players recipe list
  1349. PacketStruct* packet = 0;
  1350. if (client->GetRecipeListSent()) {
  1351. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1352. if (packet)
  1353. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1354. }
  1355. // loop through the list
  1356. vector<Recipe*>::iterator itr;
  1357. int16 i = 0;
  1358. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1359. // check to see if the player already has this recipe some how
  1360. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1361. // Player doesn't already have this recipe so lets add it
  1362. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1363. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1364. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1365. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1366. if (packet && client->GetRecipeListSent()) {
  1367. packet->setArrayDataByName("id", recipe->GetID(), i);
  1368. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1369. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1370. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1371. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1372. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1373. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1374. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1375. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1376. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1377. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1378. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1379. i++;
  1380. }
  1381. }
  1382. }
  1383. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1384. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1385. database.DeleteItem(client->GetCharacterID(), item, 0);
  1386. client->GetPlayer()->item_list.RemoveItem(item, true);
  1387. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1388. if (packet && client->GetRecipeListSent())
  1389. client->QueuePacket(packet->serialize());
  1390. safe_delete(packet);
  1391. }
  1392. else {
  1393. if (recipe_book)
  1394. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1395. safe_delete(recipe_book);
  1396. }
  1397. }
  1398. }
  1399. else
  1400. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1401. }
  1402. break;
  1403. }
  1404. case COMMAND_SUMMONITEM: {
  1405. if (sep && sep->IsNumber(0)) {
  1406. int32 item_id = atol(sep->arg[0]);
  1407. int32 quantity = 1;
  1408. if (sep->arg[1] && sep->IsNumber(1))
  1409. quantity = atoi(sep->arg[1]);
  1410. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1411. client->AddItemToBank(item_id,quantity);
  1412. }
  1413. else {
  1414. client->AddItem(item_id, quantity);
  1415. }
  1416. }
  1417. else {
  1418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1420. }
  1421. break;
  1422. }
  1423. case COMMAND_COLLECTION_ADDITEM: {
  1424. // takes 2 params: collection_id, slot
  1425. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1426. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1427. if (item)
  1428. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1429. else
  1430. 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]));
  1431. }
  1432. else
  1433. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1434. break;
  1435. }
  1436. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1437. // takes 1 param: slot
  1438. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1439. int i = 0;
  1440. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1441. printf("\t%u: %s\n", i, sep->arg[i]);
  1442. i++;
  1443. }
  1444. break;
  1445. }
  1446. case COMMAND_WHO:{
  1447. const char* who = 0;
  1448. if(sep && sep->arg[0]){
  1449. //cout << "Who query: \n";
  1450. who = sep->argplus[0];
  1451. //cout << who << endl;
  1452. }
  1453. zone_list.ProcessWhoQuery(who, client);
  1454. break;
  1455. }
  1456. case COMMAND_SELECT_JUNCTION:{
  1457. 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__);
  1458. int32 choice = 0;
  1459. if(sep && sep->arg[0] && sep->IsNumber(0))
  1460. choice = atoul(sep->arg[0]);
  1461. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1462. client->HandlePlayerRevive(choice);
  1463. }
  1464. break;
  1465. }
  1466. case COMMAND_SPAWN_MOVE:{
  1467. if(cmdTarget && cmdTarget->IsPlayer() == false){
  1468. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1469. if(packet){
  1470. float unknown2_3 = 0;
  1471. int8 placement_mode = 0;
  1472. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1473. if(sep && sep->arg[0][0]){
  1474. if(strcmp(sep->arg[0], "wall") == 0){
  1475. placement_mode = 2;
  1476. unknown2_3 = 150;
  1477. }
  1478. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1479. placement_mode = 1;
  1480. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1481. {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1483. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1484. }
  1485. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1486. {
  1487. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1488. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1489. }
  1490. }
  1491. packet->setDataByName("placement_mode", placement_mode);
  1492. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1493. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1494. packet->setDataByName("unknown", 1); //size
  1495. packet->setDataByName("unknown2", 1); //size 2
  1496. packet->setDataByName("unknown2", .5, 1); //size 3
  1497. packet->setDataByName("unknown2", 3, 2);
  1498. packet->setDataByName("unknown2", unknown2_3, 3);
  1499. packet->setDataByName("max_distance", 500);
  1500. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1501. client->QueuePacket(packet->serialize());
  1502. safe_delete(packet);
  1503. }
  1504. }
  1505. else{
  1506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1508. }
  1509. break;
  1510. }
  1511. case COMMAND_HAIL:{
  1512. Spawn* spawn = cmdTarget;
  1513. if(spawn && spawn->GetTargetable())
  1514. {
  1515. char tmp[75] = {0};
  1516. sprintf(tmp, "Hail, %s", spawn->GetName());
  1517. bool show_bubble = true;
  1518. if (spawn->IsNPC())
  1519. show_bubble = false;
  1520. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1521. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1522. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1523. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1524. else
  1525. spawn->ProcessMovement();
  1526. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1527. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1528. }
  1529. }
  1530. else {
  1531. string tmp = "Hail";
  1532. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1533. }
  1534. break;
  1535. }
  1536. case COMMAND_SAY:{
  1537. if (sep && sep->arg[0][0]) {
  1538. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1539. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1540. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1541. }
  1542. else
  1543. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1544. break;
  1545. }
  1546. case COMMAND_TELL:{
  1547. if(sep && sep->arg[0] && sep->argplus[1]){
  1548. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1549. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1550. }else
  1551. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1552. break;
  1553. }
  1554. case COMMAND_SHOUT:{
  1555. if(sep && sep->arg[0][0])
  1556. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1557. else
  1558. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1559. break;
  1560. }
  1561. case COMMAND_AUCTION:{
  1562. if(sep && sep->arg[0][0])
  1563. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1564. else
  1565. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1566. break;
  1567. }
  1568. case COMMAND_OOC:{
  1569. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1570. if(sep && sep->arg[0][0])
  1571. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1572. else
  1573. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1574. break;
  1575. }
  1576. case COMMAND_EMOTE:{
  1577. if(sep && sep->arg[0][0])
  1578. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1579. else
  1580. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1581. break;
  1582. }
  1583. case COMMAND_RACE:{
  1584. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1585. if(sep->arg[1][0] && sep->IsNumber(1)){
  1586. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1587. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1588. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1589. client->GetPlayer()->SetCharSheetChanged(true);
  1590. }
  1591. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1592. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1593. //client->QueuePacket(outapp);
  1594. }
  1595. else{
  1596. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1598. }
  1599. break;
  1600. }
  1601. case COMMAND_BANK_DEPOSIT:{
  1602. if(client->GetBanker() && sep && sep->arg[0]){
  1603. int64 amount = 0;
  1604. string deposit = string(sep->arg[0]);
  1605. amount = atoi64(deposit.c_str());
  1606. client->BankDeposit(amount);
  1607. }
  1608. break;
  1609. }
  1610. case COMMAND_BANK_WITHDRAWAL:{
  1611. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1612. int64 amount = 0;
  1613. string deposit = string(sep->arg[0]);
  1614. amount = atoi64(deposit.c_str());
  1615. client->BankWithdrawal(amount);
  1616. }
  1617. break;
  1618. }
  1619. case COMMAND_BANK_CANCEL:{
  1620. Spawn* banker = cmdTarget;
  1621. client->Bank(banker, true);
  1622. break;
  1623. }
  1624. case COMMAND_BANK:{
  1625. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1626. Spawn* banker = cmdTarget;
  1627. client->Bank(banker);
  1628. break;
  1629. }
  1630. case COMMAND_GUILD_BANK:{
  1631. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1632. //Spawn* banker = client->GetPlayer()->GetTarget();
  1633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1634. break;
  1635. }
  1636. case COMMAND_START_MAIL: {
  1637. client->SetMailTransaction(cmdTarget);
  1638. client->SendMailList();
  1639. break;
  1640. }
  1641. case COMMAND_CANCEL_MAIL: {
  1642. client->SetMailTransaction(0);
  1643. break;
  1644. }
  1645. case COMMAND_GET_MAIL_MESSAGE: {
  1646. if (sep && sep->arg[0] && sep->IsNumber(0))
  1647. client->DisplayMailMessage(atoul(sep->arg[0]));
  1648. break;
  1649. }
  1650. case COMMAND_ADD_MAIL_PLAT: {
  1651. if (sep && sep->arg[0] && sep->IsNumber(0))
  1652. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1653. break;
  1654. }
  1655. case COMMAND_ADD_MAIL_GOLD: {
  1656. if (sep && sep->arg[0] && sep->IsNumber(0))
  1657. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1658. break;
  1659. }
  1660. case COMMAND_ADD_MAIL_SILVER: {
  1661. if (sep && sep->arg[0] && sep->IsNumber(0))
  1662. client->AddMailCoin(0, atoul(sep->arg[0]));
  1663. break;
  1664. }
  1665. case COMMAND_ADD_MAIL_COPPER: {
  1666. if (sep && sep->arg[0] && sep->IsNumber(0))
  1667. client->AddMailCoin(atoul(sep->arg[0]));
  1668. break;
  1669. }
  1670. case COMMAND_SET_MAIL_ITEM: {
  1671. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1672. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1673. break;
  1674. }
  1675. case COMMAND_REMOVE_MAIL_PLAT: {
  1676. if (sep && sep->arg[0] && sep->IsNumber(0))
  1677. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1678. break;
  1679. }
  1680. case COMMAND_REMOVE_MAIL_GOLD: {
  1681. if (sep && sep->arg[0] && sep->IsNumber(0))
  1682. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1683. break;
  1684. }
  1685. case COMMAND_REMOVE_MAIL_SILVER: {
  1686. if (sep && sep->arg[0] && sep->IsNumber(0))
  1687. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1688. break;
  1689. }
  1690. case COMMAND_REMOVE_MAIL_COPPER: {
  1691. if (sep && sep->arg[0] && sep->IsNumber(0))
  1692. client->RemoveMailCoin(atoul(sep->arg[0]));
  1693. break;
  1694. }
  1695. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1696. if (sep && sep->arg[0] && sep->IsNumber(0))
  1697. client->TakeMailAttachments(atoul(sep->arg[0]));
  1698. break;
  1699. }
  1700. case COMMAND_CANCEL_SEND_MAIL: {
  1701. client->CancelSendMail();
  1702. break;
  1703. }
  1704. case COMMAND_DELETE_MAIL_MESSAGE: {
  1705. if (sep && sep->arg[0] && sep->IsNumber(0))
  1706. client->DeleteMail(atoul(sep->arg[0]), true);
  1707. break;
  1708. }
  1709. case COMMAND_REPORT_SPAM: {
  1710. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1711. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1712. break;
  1713. }
  1714. case COMMAND_KILL:{
  1715. Spawn* dead = 0;
  1716. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1717. dead=client->GetPlayer();
  1718. client->GetPlayer()->SetHP(0);
  1719. client->GetPlayer()->KillSpawn(dead);
  1720. }else{
  1721. dead= cmdTarget;
  1722. if(dead && dead->IsPlayer() == false){
  1723. dead->SetHP(0);
  1724. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1725. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1726. else
  1727. client->GetPlayer()->KillSpawn(dead);
  1728. }else{
  1729. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1730. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1731. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1732. }
  1733. }
  1734. break;
  1735. }
  1736. case COMMAND_LEVEL:{
  1737. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1738. int16 new_level = atoi(sep->arg[ndx]);
  1739. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1740. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1741. else {
  1742. if (new_level < 1)
  1743. new_level = 1;
  1744. if (new_level > 255)
  1745. new_level = 255;
  1746. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1747. client->GetPlayer()->SetXP(1);
  1748. client->GetPlayer()->SetNeededXP();
  1749. }
  1750. }else
  1751. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1752. break;
  1753. }
  1754. case COMMAND_SIT: {
  1755. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1756. if(client->GetPlayer()->GetHP() > 0){
  1757. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1758. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1759. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1760. }
  1761. break;
  1762. }
  1763. case COMMAND_STAND: {
  1764. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1765. if(client->GetPlayer()->GetHP() > 0){
  1766. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1767. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1768. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1769. }
  1770. break;
  1771. }
  1772. case COMMAND_CLASS:{
  1773. if(sep && sep->arg[ndx][0]){
  1774. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1775. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1776. }else
  1777. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1778. break;
  1779. }
  1780. case COMMAND_GENDER:{
  1781. if(sep && sep->arg[ndx][0]){
  1782. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1783. client->GetPlayer()->SetCharSheetChanged(true);
  1784. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1785. }else{
  1786. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1787. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1788. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1789. }
  1790. break;
  1791. }
  1792. case COMMAND_FLYMODE:{
  1793. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1794. PrintSep(sep, "COMMAND_FLYMODE");
  1795. int8 val = atoi(sep->arg[0]);
  1796. ClientPacketFunctions::SendFlyMode(client, val);
  1797. }
  1798. else{
  1799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1801. }
  1802. break;
  1803. }
  1804. case COMMAND_LOOT_LIST:{
  1805. Spawn* spawn = cmdTarget;
  1806. if(spawn && spawn->IsEntity()){
  1807. if (sep && sep->arg[0]) {
  1808. if (!spawn->GetDatabaseID())
  1809. {
  1810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1811. break;
  1812. }
  1813. else if (!spawn->IsNPC())
  1814. {
  1815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1816. break;
  1817. }
  1818. bool reloadLoot = false;
  1819. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1820. {
  1821. int32 loottable_id = atoul(sep->arg[1]);
  1822. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1823. {
  1824. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1825. reloadLoot = true;
  1826. }
  1827. else
  1828. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1829. }
  1830. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1831. {
  1832. int32 loottable_id = atoul(sep->arg[1]);
  1833. if (loottable_id > 0)
  1834. {
  1835. database.AddLootTableToSpawn(spawn, loottable_id);
  1836. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1837. reloadLoot = true;
  1838. }
  1839. else
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1841. }
  1842. else if (!stricmp(sep->arg[0], "clearall"))
  1843. {
  1844. if (database.RemoveSpawnLootTable(spawn, 0))
  1845. {
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1847. reloadLoot = true;
  1848. }
  1849. else
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1851. }
  1852. else
  1853. {
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1858. break;
  1859. }
  1860. if (reloadLoot)
  1861. {
  1862. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1863. if (spawn->IsNPC())
  1864. {
  1865. Entity* ent = (Entity*)spawn;
  1866. ent->SetLootCoins(0);
  1867. ent->ClearLootList();
  1868. spawn->GetZone()->AddLoot((NPC*)spawn);
  1869. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1870. }
  1871. }
  1872. break; // nothing further this is the end of these sub commands
  1873. }
  1874. else
  1875. {
  1876. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1877. if (loot_list.size() > 0) {
  1878. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1879. vector<int32>::iterator list_itr;
  1880. LootTable* table = 0;
  1881. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1882. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1883. if (table)
  1884. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1885. }
  1886. }
  1887. Entity* target = (Entity*)spawn;
  1888. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1889. vector<Item*>* items = target->GetLootItems();
  1890. if (items) {
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1892. vector<Item*>::iterator itr;
  1893. Item* item = 0;
  1894. for (itr = items->begin(); itr != items->end(); itr++) {
  1895. item = *itr;
  1896. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1897. }
  1898. }
  1899. else
  1900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1901. }
  1902. }
  1903. break;
  1904. }
  1905. case COMMAND_LOOT_SETCOIN:{
  1906. Spawn* spawn = cmdTarget;
  1907. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1908. Entity* target = (Entity*)spawn;
  1909. target->SetLootCoins(atoul(sep->arg[0]));
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1911. }
  1912. else
  1913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1914. break;
  1915. }
  1916. case COMMAND_LOOT_ADDITEM:{
  1917. Spawn* spawn = cmdTarget;
  1918. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1919. Entity* target = (Entity*)spawn;
  1920. int16 charges = 1;
  1921. if(sep->arg[1] && sep->IsNumber(1))
  1922. charges = atoi(sep->arg[1]);
  1923. target->AddLootItem(atoul(sep->arg[0]), charges);
  1924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1925. }
  1926. else
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1928. break;
  1929. }
  1930. case COMMAND_LOOT_REMOVEITEM:{
  1931. Spawn* spawn = cmdTarget;
  1932. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1933. Entity* target = (Entity*)spawn;
  1934. target->LootItem(atoul(sep->arg[0]));
  1935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1936. }
  1937. else
  1938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1939. break;
  1940. }
  1941. case COMMAND_LOOT_CORPSE:
  1942. case COMMAND_DISARM:
  1943. case COMMAND_LOOT:{
  1944. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1945. {
  1946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1947. break;
  1948. }
  1949. if(cmdTarget && cmdTarget->IsEntity()){
  1950. if (cmdTarget->GetDistance(client->GetPlayer()) <= 10){
  1951. client->Loot((Entity*)cmdTarget);
  1952. if (!((Entity*)cmdTarget)->HasLoot()){
  1953. if (((Entity*)cmdTarget)->IsNPC())
  1954. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1955. }
  1956. }
  1957. else
  1958. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1959. }
  1960. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1962. break;
  1963. }
  1964. case COMMAND_RELOADSPAWNSCRIPTS:{
  1965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  1966. if (lua_interface)
  1967. lua_interface->SetSpawnScriptsReloading(true);
  1968. world.ResetSpawnScripts();
  1969. database.LoadSpawnScriptData();
  1970. if(lua_interface) {
  1971. lua_interface->DestroySpawnScripts();
  1972. lua_interface->SetSpawnScriptsReloading(false);
  1973. }
  1974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  1975. break;
  1976. }
  1977. case COMMAND_RELOADLUASYSTEM:{
  1978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  1979. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  1980. safe_delete(lua_interface);
  1981. lua_interface = new LuaInterface();
  1982. if(lua_interface)
  1983. lua_interface->SetSpawnScriptsReloading(true);
  1984. if(lua_interface && debug_clients.size() > 0){
  1985. map<Client*, int32>::iterator itr;
  1986. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  1987. if(lua_interface)
  1988. lua_interface->UpdateDebugClients(itr->first);
  1989. }
  1990. }
  1991. world.ResetSpawnScripts();
  1992. database.LoadSpawnScriptData();
  1993. world.ResetZoneScripts();
  1994. database.LoadZoneScriptData();
  1995. int32 quest_count = database.LoadQuests();
  1996. zone_list.DeleteSpellProcess();
  1997. master_spell_list.Reload();
  1998. int32 spell_count = 0;
  1999. if(lua_interface) {
  2000. lua_interface->DestroySpawnScripts();
  2001. lua_interface->DestroySpells();
  2002. spell_count = database.LoadSpellScriptData();
  2003. lua_interface->SetSpawnScriptsReloading(false);
  2004. }
  2005. zone_list.LoadSpellProcess();
  2006. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2007. break;
  2008. }
  2009. case COMMAND_DECLINE_QUEST:{
  2010. int32 quest_id = 0;
  2011. if(sep && sep->arg[0] && sep->IsNumber(0))
  2012. quest_id = atoul(sep->arg[0]);
  2013. if(quest_id > 0){
  2014. Quest* quest = client->GetPendingQuest(quest_id);
  2015. if(quest){
  2016. client->RemovePendingQuest(quest);
  2017. if(lua_interface)
  2018. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2019. safe_delete(quest);
  2020. client->GetCurrentZone()->SendQuestUpdates(client);
  2021. }
  2022. }
  2023. break;
  2024. }
  2025. case COMMAND_DELETE_QUEST:{
  2026. int32 quest_id = 0;
  2027. if(sep && sep->arg[0] && sep->IsNumber(0))
  2028. quest_id = atoul(sep->arg[0]);
  2029. if(quest_id > 0){
  2030. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2031. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2032. if (quest)
  2033. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2034. }
  2035. client->RemovePlayerQuest(quest_id);
  2036. client->GetCurrentZone()->SendQuestUpdates(client);
  2037. }
  2038. break;
  2039. }
  2040. case COMMAND_ACCEPT_QUEST:{
  2041. int32 quest_id = 0;
  2042. if(sep && sep->arg[0] && sep->IsNumber(0))
  2043. quest_id = atoul(sep->arg[0]);
  2044. if(quest_id > 0){
  2045. Quest* quest = client->GetPendingQuest(quest_id);
  2046. if(quest){
  2047. client->RemovePendingQuest(quest);
  2048. client->AddPlayerQuest(quest);
  2049. client->GetCurrentZone()->SendQuestUpdates(client);
  2050. // If character has already completed this quest once update the given date in the database
  2051. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2052. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2053. if (quest2)
  2054. quest->SetCompleteCount(quest2->GetCompleteCount());
  2055. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2056. }
  2057. }
  2058. }
  2059. break;
  2060. }
  2061. case COMMAND_NAME:{
  2062. if(sep && sep->arg[ndx][0]){
  2063. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2064. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2065. client->GetPlayer()->SetCharSheetChanged(true);
  2066. }else
  2067. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2068. break;
  2069. }
  2070. case COMMAND_GROUPSAY:{
  2071. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2072. if(sep && sep->arg[0] && gmi)
  2073. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2074. break;
  2075. }
  2076. case COMMAND_GROUPINVITE: {
  2077. Entity* target = 0;
  2078. Client* target_client = 0;
  2079. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2080. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2081. return;
  2082. }
  2083. // name provided with command so it has to be a player, npc not supported here
  2084. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2085. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2086. if (target_client) {
  2087. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2088. target = 0;
  2089. else
  2090. target = target_client->GetPlayer();
  2091. }
  2092. }
  2093. // if name was not provided use the players target, npc or player supported here
  2094. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2095. target = (Entity*)client->GetPlayer()->GetTarget();
  2096. if (target->IsPlayer()) {
  2097. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2098. }
  2099. }
  2100. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2101. if (result == 0) {
  2102. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2103. if (target_client) {
  2104. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2105. if (packet) {
  2106. packet->setDataByName("type", 1);
  2107. packet->setDataByName("name", client->GetPlayer()->GetName());
  2108. packet->setDataByName("unknown2", 1);
  2109. target_client->QueuePacket(packet->serialize());
  2110. safe_delete(packet);
  2111. }
  2112. }
  2113. }
  2114. else if (result == 1)
  2115. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2116. else if (result == 2)
  2117. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2118. else if (result == 3)
  2119. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2120. else if (result == 4)
  2121. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2122. else if (result == 5)
  2123. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2124. else if (result == 6)
  2125. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2126. else
  2127. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2128. break;
  2129. }
  2130. case COMMAND_GROUPDISBAND: {
  2131. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2132. if (gmi) { // TODO: Leader check
  2133. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2134. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2135. }
  2136. break;
  2137. }
  2138. case COMMAND_GROUP_LEAVE: {
  2139. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2140. if (gmi) {
  2141. int32 group_id = gmi->group_id;
  2142. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2143. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2144. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2145. }
  2146. else {
  2147. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2148. }
  2149. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2150. }
  2151. break;
  2152. }
  2153. case COMMAND_FRIEND_ADD:{
  2154. string name = "";
  2155. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2156. name = database.GetPlayerName(sep->arg[0]);
  2157. else if(cmdTarget && cmdTarget->IsPlayer())
  2158. name = string(cmdTarget->GetName());
  2159. if(name.length() > 0){
  2160. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2161. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2162. client->GetPlayer()->RemoveIgnore(name.c_str());
  2163. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2164. client->SendChatRelationship(3, name.c_str());
  2165. }
  2166. client->GetPlayer()->AddFriend(name.c_str(), true);
  2167. client->SendChatRelationship(0, name.c_str());
  2168. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2169. if(zone_list.GetClientByCharName(name))
  2170. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2171. }
  2172. else
  2173. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2174. }
  2175. else
  2176. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2177. break;
  2178. }
  2179. case COMMAND_FRIEND_REMOVE:{
  2180. string name = "";
  2181. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2182. name = database.GetPlayerName(sep->arg[0]);
  2183. else if(cmdTarget && cmdTarget->IsPlayer())
  2184. name = string(cmdTarget->GetName());
  2185. if(name.length() > 0){
  2186. client->GetPlayer()->RemoveFriend(name.c_str());
  2187. client->SendChatRelationship(1, name.c_str());
  2188. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2189. }
  2190. else
  2191. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2192. break;
  2193. }
  2194. case COMMAND_FRIENDS:{
  2195. break;
  2196. }
  2197. case COMMAND_IGNORE_ADD:{
  2198. string name = "";
  2199. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2200. name = database.GetPlayerName(sep->arg[0]);
  2201. else if(cmdTarget && cmdTarget->IsPlayer())
  2202. name = string(cmdTarget->GetName());
  2203. if(name.length() > 0){
  2204. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2205. if(client->GetPlayer()->IsFriend(name.c_str())){
  2206. client->GetPlayer()->RemoveFriend(name.c_str());
  2207. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2208. client->SendChatRelationship(1, name.c_str());
  2209. }
  2210. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2211. client->SendChatRelationship(2, name.c_str());
  2212. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2213. }
  2214. else
  2215. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2216. }
  2217. else
  2218. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2219. break;
  2220. }
  2221. case COMMAND_IGNORE_REMOVE:{
  2222. string name = "";
  2223. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2224. name = database.GetPlayerName(sep->arg[0]);
  2225. else if(cmdTarget && cmdTarget->IsPlayer())
  2226. name = string(cmdTarget->GetName());
  2227. if(name.length() > 0){
  2228. client->GetPlayer()->RemoveIgnore(name.c_str());
  2229. client->SendChatRelationship(3, name.c_str());
  2230. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2231. }
  2232. break;
  2233. }
  2234. case COMMAND_IGNORES:{
  2235. break;
  2236. }
  2237. case COMMAND_GROUP_KICK:{
  2238. Entity* kicked = 0;
  2239. Client* kicked_client = 0;
  2240. int32 group_id = 0;
  2241. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2242. return;
  2243. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2244. if (sep && sep->arg[0]) {
  2245. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2246. if (kicked_client)
  2247. kicked = kicked_client->GetPlayer();
  2248. }
  2249. else if (cmdTarget && cmdTarget->IsEntity()) {
  2250. kicked = (Entity*)cmdTarget;
  2251. }
  2252. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2253. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2254. if (kicked)
  2255. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2256. if(send_kicked_message)
  2257. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2258. else
  2259. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2260. if (kicked_client)
  2261. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2262. break;
  2263. }
  2264. case COMMAND_GROUP_MAKE_LEADER:{
  2265. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2266. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2267. return;
  2268. }
  2269. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2270. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2271. if (new_leader) {
  2272. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2273. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2274. }
  2275. }
  2276. else
  2277. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2278. }
  2279. else if (cmdTarget && cmdTarget->IsPlayer())
  2280. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2281. else
  2282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2283. break;
  2284. }
  2285. case COMMAND_GROUP_ACCEPT_INVITE: {
  2286. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2287. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2288. if (result == 0)
  2289. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2290. else if (result == 1)
  2291. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2292. else if (result == 2)
  2293. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2294. else
  2295. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2296. }
  2297. break;
  2298. }
  2299. case COMMAND_GROUP_DECLINE_INVITE: {
  2300. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2301. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2302. }
  2303. break;
  2304. }
  2305. case COMMAND_SUMMON:{
  2306. char* search_name = 0;
  2307. if(sep && sep->arg[0][0])
  2308. search_name = sep->arg[0];
  2309. if(!search_name && !cmdTarget){
  2310. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2311. 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.");
  2312. }
  2313. else{
  2314. if(!client->Summon(search_name))
  2315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2316. }
  2317. break;
  2318. }
  2319. case COMMAND_GOTO:{
  2320. const char* search_name = 0;
  2321. if(sep && sep->arg[0][0])
  2322. search_name = sep->argplus[0];
  2323. if(!search_name && !cmdTarget){
  2324. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2325. 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.");
  2326. }
  2327. else{
  2328. if(!client->GotoSpawn(search_name))
  2329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2330. }
  2331. break;
  2332. }
  2333. case COMMAND_MOVE:{
  2334. bool success = false;
  2335. try{
  2336. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2337. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2338. if(app){
  2339. client->QueuePacket(app);
  2340. success = true;
  2341. }
  2342. }
  2343. }
  2344. catch(...){}
  2345. if(!success){
  2346. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2348. }
  2349. break;
  2350. }
  2351. case COMMAND_SETTIME:{
  2352. if(sep && sep->arg[0]){
  2353. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2354. if(sep->arg[1] && sep->IsNumber(1))
  2355. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2356. if(sep->arg[2] && sep->IsNumber(2))
  2357. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2358. if(sep->arg[3] && sep->IsNumber(3))
  2359. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2360. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2361. }
  2362. else{
  2363. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2364. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2365. }
  2366. break;
  2367. }
  2368. case COMMAND_VERSION:{
  2369. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2370. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2371. break;
  2372. }
  2373. case COMMAND_ZONE:{
  2374. string* zonename = 0;
  2375. int32 instanceID = 0;
  2376. const char* zone = 0;
  2377. int32 zone_id = 0;
  2378. bool listSearch = false;
  2379. bool isInstance = false;
  2380. ZoneServer* zsZone = 0;
  2381. if(sep && sep->arg[0][0])
  2382. {
  2383. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2384. listSearch = true;
  2385. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2386. {
  2387. zone_list.SendZoneList(client);
  2388. break;
  2389. }
  2390. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2391. {
  2392. if(sep->IsNumber(1))
  2393. instanceID = atol(sep->arg[1]);
  2394. }
  2395. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2396. {
  2397. PrintSep(sep, "ZONE LOCK");
  2398. if(sep->IsNumber(1))
  2399. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2400. else
  2401. zsZone = zone_list.Get(sep->arg[1], false);
  2402. if( zsZone )
  2403. {
  2404. zsZone->SetZoneLockState(true);
  2405. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2406. }
  2407. else
  2408. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2409. break;
  2410. }
  2411. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2412. {
  2413. PrintSep(sep, "ZONE UNLOCK");
  2414. if(sep->IsNumber(1))
  2415. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2416. else
  2417. zsZone = zone_list.Get(sep->arg[1], false);
  2418. if( zsZone )
  2419. {
  2420. zsZone->SetZoneLockState(false);
  2421. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2422. }
  2423. else
  2424. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2425. break;
  2426. }
  2427. else
  2428. {
  2429. if(sep->IsNumber(0))
  2430. {
  2431. zone_id = atoul(sep->arg[0]);
  2432. zonename = database.GetZoneName(zone_id);
  2433. if(zonename)
  2434. zone = zonename->c_str();
  2435. }
  2436. else
  2437. zone = sep->arg[0];
  2438. }
  2439. if(instanceID > 0)
  2440. {
  2441. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2442. if(zsInstance != NULL)
  2443. {
  2444. instanceID = zsInstance->GetInstanceID();
  2445. zone = zsInstance->GetZoneName();
  2446. zone_id = zsInstance->GetZoneID();
  2447. isInstance = true;
  2448. }
  2449. }
  2450. }
  2451. if(!listSearch)
  2452. {
  2453. if(!zone)
  2454. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2455. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2456. zone_id != client->GetCurrentZone()->GetZoneID())
  2457. {
  2458. if(database.VerifyZone(zone))
  2459. {
  2460. if(client->CheckZoneAccess(zone))
  2461. {
  2462. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2463. if(isInstance)
  2464. client->Zone(instanceID,true,true);
  2465. else
  2466. client->Zone(zone);
  2467. }
  2468. }
  2469. else
  2470. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2471. }
  2472. else
  2473. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2474. }
  2475. else
  2476. {
  2477. const char* name = 0;
  2478. if(sep && sep->arg[1][0])
  2479. {
  2480. map<int32, string>* zone_names;
  2481. name = sep->argplus[1];
  2482. sint16 status = client->GetAdminStatus();
  2483. if( status > 0 )
  2484. {
  2485. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2486. zone_names = database.GetZoneList(name, true);
  2487. }
  2488. else
  2489. zone_names = database.GetZoneList(name);
  2490. if(!zone_names)
  2491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2492. else
  2493. {
  2494. map<int32, string>::iterator itr;
  2495. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2496. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2497. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2498. safe_delete(zone_names);
  2499. }
  2500. }
  2501. else
  2502. {
  2503. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2504. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2505. }
  2506. }
  2507. safe_delete(zonename);
  2508. break;
  2509. }
  2510. case COMMAND_USE: {
  2511. Spawn* target = cmdTarget;
  2512. if (target->IsWidget())
  2513. ((Widget*)target)->HandleUse(client, "use");
  2514. break;
  2515. }
  2516. case COMMAND_OPEN: {
  2517. Spawn* target = cmdTarget;
  2518. if (target->IsWidget())
  2519. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2520. break;
  2521. }
  2522. case COMMAND_CASTSPELL: {
  2523. if (sep && sep->arg[0] && sep->IsNumber(0))
  2524. {
  2525. int8 tier = 1;
  2526. if (sep->arg[1] && sep->IsNumber(1))
  2527. tier = atoul(sep->arg[1]);
  2528. int32 spellid = atoul(sep->arg[0]);
  2529. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2530. if (spell)
  2531. {
  2532. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2533. SpellProcess* spellProcess = 0;
  2534. // Get the current zones spell process
  2535. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2536. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2537. }
  2538. else
  2539. {
  2540. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2541. }
  2542. }
  2543. else if (sep && sep->arg[0])
  2544. {
  2545. database.FindSpell(client, (char*)sep->argplus[0]);
  2546. }
  2547. else
  2548. {
  2549. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2550. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2551. }
  2552. break;
  2553. }
  2554. case COMMAND_ATTACK:
  2555. case COMMAND_AUTO_ATTACK:{
  2556. int8 type = 1;
  2557. Player* player = client->GetPlayer();
  2558. if(!player)
  2559. break;
  2560. bool incombat = player->EngagedInCombat();
  2561. if(sep && sep->arg[0] && sep->IsNumber(0))
  2562. type = atoi(sep->arg[0]);
  2563. if(client->GetPlayer()->GetHP() == 0){
  2564. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2565. break;
  2566. }
  2567. if(type == 0){
  2568. if(incombat)
  2569. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2570. player->InCombat(false);
  2571. player->InCombat(false, true);
  2572. player->SetRangeAttack(false);
  2573. }
  2574. else {
  2575. if(type == 2){
  2576. player->InCombat(false);
  2577. if(incombat && player->GetRangeAttack()){
  2578. player->SetRangeAttack(false);
  2579. player->InCombat(false, true);
  2580. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2581. }
  2582. else{
  2583. player->SetRangeAttack(true);
  2584. player->InCombat(true, true);
  2585. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2586. }
  2587. }
  2588. else {
  2589. player->InCombat(false, true);
  2590. player->SetRangeAttack(false);
  2591. player->InCombat(true);
  2592. if(!incombat)
  2593. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2594. }
  2595. /*else
  2596. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2597. }
  2598. player->SetCharSheetChanged(true);
  2599. break;
  2600. }
  2601. case COMMAND_DEPOP:{
  2602. bool allow_respawns = false;
  2603. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2604. if(atoi(sep->arg[0]) == 1)
  2605. allow_respawns = true;
  2606. }
  2607. client->GetCurrentZone()->Depop(allow_respawns);
  2608. break;
  2609. }
  2610. case COMMAND_REPOP:{
  2611. client->GetCurrentZone()->Depop(false, true);
  2612. break;
  2613. }
  2614. case COMMAND_BUYBACK:{
  2615. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2616. // 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
  2617. int64 id = atoi64(sep->arg[0]);
  2618. // get the first int32, the item id
  2619. //int32 item_id = (int32)id;
  2620. // get the second int32, the unique id
  2621. int32 unique_id = (int32)(id>>32);
  2622. int8 quantity = atoi(sep->arg[1]);
  2623. if(quantity == 255)
  2624. quantity = 1;
  2625. client->BuyBack(unique_id, quantity);
  2626. }
  2627. break;
  2628. }
  2629. case COMMAND_MERCHANT_BUY:{
  2630. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2631. int32 item_id = atoul(sep->arg[0]);
  2632. int8 quantity = atoi(sep->arg[1]);
  2633. client->BuyItem(item_id, quantity);
  2634. }
  2635. break;
  2636. }
  2637. case COMMAND_MERCHANT_SELL:{
  2638. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2639. // 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
  2640. int64 id = atoi64(sep->arg[0]);
  2641. // get the first int32, the item id
  2642. int32 item_id = (int32)id;
  2643. // get the second int32, the unique id
  2644. int32 unique_id = (int32)(id>>32);
  2645. int8 quantity = atoi(sep->arg[1]);
  2646. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2647. client->SellItem(item_id, quantity, unique_id);
  2648. }
  2649. break;
  2650. }
  2651. case COMMAND_MENDER_REPAIR: {
  2652. if (sep && sep->arg[0] && sep->IsNumber(0))
  2653. client->RepairItem(atoul(sep->arg[0]));
  2654. break;
  2655. }
  2656. case COMMAND_MENDER_REPAIR_ALL: {
  2657. client->RepairAllItems();
  2658. break;
  2659. }
  2660. case COMMAND_CANCEL_MERCHANT:{
  2661. client->SetMerchantTransaction(0);
  2662. break;
  2663. }
  2664. case COMMAND_START_MERCHANT:{
  2665. break;
  2666. }
  2667. case COMMAND_INVULNERABLE:{
  2668. sint8 val = -1;
  2669. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2670. val = atoi(sep->arg[0]);
  2671. //devn00b: Fix for linux builds
  2672. #if defined(__GNUC__)
  2673. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) 1 : 0);
  2674. #else
  2675. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2676. #endif
  2677. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2678. client->GetPlayer()->SetInvulnerable(val==1);
  2679. if(client->GetPlayer()->GetInvulnerable())
  2680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2681. else
  2682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2683. }
  2684. if(val == -1)
  2685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2686. break;
  2687. }
  2688. case COMMAND_REPAIR: {
  2689. Spawn* spawn = cmdTarget;
  2690. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2691. client->SetMerchantTransaction(spawn);
  2692. client->SendRepairList();
  2693. }
  2694. break;
  2695. }
  2696. case COMMAND_LOTTO: {
  2697. Spawn* spawn = cmdTarget;
  2698. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2699. client->SetMerchantTransaction(spawn);
  2700. client->ShowLottoWindow();
  2701. }
  2702. break;
  2703. }
  2704. case COMMAND_ACCEPT_REWARD:{
  2705. int32 unknown = 0;
  2706. int32 selectable_item_id = 0;
  2707. //Quest *quest = 0;
  2708. Collection *collection = 0;
  2709. /* no idea what the first argument is for (faction maybe?)
  2710. if the reward has a selectable item reward, it's sent as the second argument
  2711. if neither of these are included in the reward, there is no sep
  2712. 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
  2713. only 1 quest or collection reward may be displayed at a time */
  2714. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2715. unknown = atoul(sep->arg[0]);
  2716. selectable_item_id = atoul(sep->arg[1]);
  2717. }
  2718. //if ((quest = player->GetPendingQuestReward()))
  2719. // client->AcceptQuestRewards(quest, selectable_item_id);
  2720. /* the below needs to go away eventually and be redone */
  2721. int32 item_id = 0;
  2722. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2723. item_id = atoul(sep->arg[0]);
  2724. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2725. if(quest){
  2726. client->AcceptQuestReward(quest, item_id);
  2727. break;
  2728. }
  2729. if (collection = player->GetPendingCollectionReward())
  2730. client->AcceptCollectionRewards(collection, selectable_item_id);
  2731. else
  2732. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2733. break;
  2734. }
  2735. case COMMAND_BUY_FROM_BROKER:{
  2736. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2737. int32 item_id = atoul(sep->arg[0]);
  2738. int16 quantity = atoul(sep->arg[1]);
  2739. client->AddItem(item_id, quantity);
  2740. }
  2741. break;
  2742. }
  2743. case COMMAND_SEARCH_STORES_PAGE:{
  2744. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2745. int32 page = atoul(sep->arg[0]);
  2746. client->SearchStore(page);
  2747. }
  2748. break;
  2749. }
  2750. case COMMAND_SEARCH_STORES:{
  2751. if(sep && sep->arg[0][0]){
  2752. const char* values = sep->argplus[0];
  2753. if(values){
  2754. map<string, string> str_values = TranslateBrokerRequest(values);
  2755. vector<Item*>* items = master_item_list.GetItems(str_values);
  2756. if(items){
  2757. client->SetItemSearch(items);
  2758. client->SearchStore(0);
  2759. }
  2760. }
  2761. }
  2762. break;
  2763. }
  2764. case COMMAND_LUADEBUG:{
  2765. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2766. client->SetLuaDebugClient(true);
  2767. if(lua_interface)
  2768. lua_interface->UpdateDebugClients(client);
  2769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2770. }
  2771. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2772. client->SetLuaDebugClient(false);
  2773. if(lua_interface)
  2774. lua_interface->RemoveDebugClients(client);
  2775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2776. }
  2777. else{
  2778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2780. }
  2781. break;
  2782. }
  2783. case COMMAND_SPAWN_GROUP:
  2784. {
  2785. Spawn* target = cmdTarget;
  2786. if(target && target->IsPlayer() == false)
  2787. {
  2788. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2789. {
  2790. if(target->GetSpawnLocationPlacementID() > 0)
  2791. {
  2792. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2793. {
  2794. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2795. if(id > 0)
  2796. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2797. else
  2798. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2799. target->SetSpawnGroupID(id);
  2800. target->AddSpawnToGroup(target);
  2801. }
  2802. else
  2803. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2804. }
  2805. else
  2806. 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.");
  2807. }
  2808. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2809. {
  2810. if(sep->arg[1] && sep->IsNumber(1))
  2811. {
  2812. int32 group_id = atoul(sep->arg[1]);
  2813. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2814. if(leader)
  2815. {
  2816. leader->AddSpawnToGroup(target);
  2817. target->SetSpawnGroupID(group_id);
  2818. if(database.SpawnGroupAddSpawn(target, group_id))
  2819. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2820. else
  2821. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2822. }
  2823. else
  2824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2825. }
  2826. else
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2828. }
  2829. else if(target->GetSpawnGroupID() == 0)
  2830. {
  2831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2832. }
  2833. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2834. {
  2835. int32 group_id = target->GetSpawnGroupID();
  2836. target->RemoveSpawnFromGroup();
  2837. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2838. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2839. else
  2840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2841. }
  2842. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2843. {
  2844. int32 group_id = target->GetSpawnGroupID();
  2845. if(sep->arg[1] && sep->IsNumber(1))
  2846. {
  2847. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2848. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2849. else
  2850. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2851. }
  2852. else
  2853. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2854. }
  2855. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2856. {
  2857. int32 group_id = target->GetSpawnGroupID();
  2858. if(sep->arg[1] && sep->IsNumber(1))
  2859. {
  2860. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  2861. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  2862. else
  2863. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  2864. }
  2865. else
  2866. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  2867. }
  2868. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  2869. {
  2870. if(sep->arg[1] && sep->IsNumber(1))
  2871. {
  2872. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  2873. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  2874. else
  2875. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  2876. }
  2877. else
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  2879. }
  2880. else
  2881. {
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  2883. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  2884. }
  2885. }
  2886. else
  2887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  2888. break;
  2889. }
  2890. case COMMAND_SPAWN_COMBINE:{
  2891. Spawn* spawn = cmdTarget;
  2892. float radius = 0;
  2893. bool failed = true;
  2894. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  2895. failed = false;
  2896. if(spawn->GetSpawnGroupID() > 0){
  2897. 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.");
  2898. }
  2899. else if(sep->IsNumber(0)){
  2900. radius = atof(sep->arg[0]);
  2901. client->CombineSpawns(radius, spawn);
  2902. }
  2903. else{
  2904. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  2905. client->AddCombineSpawn(spawn);
  2906. }
  2907. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  2908. client->RemoveCombineSpawn(spawn);
  2909. }
  2910. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  2911. const char* name = 0;
  2912. if(sep->arg[1] && sep->arg[1][0])
  2913. name = sep->argplus[1];
  2914. client->SaveCombineSpawns(name);
  2915. }
  2916. else
  2917. failed = true;
  2918. }
  2919. }
  2920. if(failed){
  2921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  2922. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  2923. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  2924. }
  2925. break;
  2926. }
  2927. case COMMAND_SPAWN_CREATE:{
  2928. Spawn* spawn = 0;
  2929. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2930. spawn = new Object();
  2931. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2932. }
  2933. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2934. spawn = new GroundSpawn();
  2935. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2936. }
  2937. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2938. spawn = new Sign();
  2939. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2940. }
  2941. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2942. spawn = new NPC();
  2943. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2944. spawn->appearance.pos.collision_radius = 32;
  2945. spawn->secondary_command_list_id = 0;
  2946. spawn->primary_command_list_id = 0;
  2947. spawn->appearance.display_name = 1;
  2948. spawn->appearance.show_level = 1;
  2949. spawn->appearance.attackable = 1;
  2950. }
  2951. else{
  2952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  2953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  2954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  2955. break;
  2956. }
  2957. spawn->SetID(Spawn::NextID());
  2958. spawn->SetX(client->GetPlayer()->GetX());
  2959. spawn->SetY(client->GetPlayer()->GetY());
  2960. spawn->SetZ(client->GetPlayer()->GetZ());
  2961. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2962. spawn->SetSpawnOrigX(spawn->GetX());
  2963. spawn->SetSpawnOrigY(spawn->GetY());
  2964. spawn->SetSpawnOrigZ(spawn->GetZ());
  2965. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2966. spawn->appearance.targetable = 1;
  2967. spawn->appearance.race = 255;
  2968. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2969. spawn->SetModelType(atoi(sep->arg[1]));
  2970. spawn->SetAdventureClass(atoi(sep->arg[2]));
  2971. spawn->SetLevel(atoi(sep->arg[3]));
  2972. spawn->SetName(sep->arg[4]);
  2973. if(sep->arg[5][0] && sep->IsNumber(5))
  2974. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  2975. if(sep->arg[6][0] && sep->IsNumber(6))
  2976. spawn->size = atoi(sep->arg[6]);
  2977. if(spawn->GetTotalHP() == 0){
  2978. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  2979. spawn->SetHP(25*spawn->GetLevel() + 1);
  2980. }
  2981. if(spawn->GetTotalPower() == 0){
  2982. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  2983. spawn->SetPower(25*spawn->GetLevel() + 1);
  2984. }
  2985. client->GetCurrentZone()->AddSpawn(spawn);
  2986. break;
  2987. }
  2988. case COMMAND_SPAWN_EQUIPMENT:{
  2989. Spawn* spawn = cmdTarget;
  2990. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  2991. int8 slot = atoi(sep->arg[0]);
  2992. int16 type = atoi(sep->arg[1]);
  2993. int8 red = 0;
  2994. int8 green = 0;
  2995. int8 blue = 0;
  2996. int8 h_red = 0;
  2997. int8 h_green = 0;
  2998. int8 h_blue = 0;
  2999. if(sep->arg[2])
  3000. red = atoi(sep->arg[2]);
  3001. if(sep->arg[3])
  3002. green = atoi(sep->arg[3]);
  3003. if(sep->arg[4])
  3004. blue = atoi(sep->arg[4]);
  3005. if(sep->arg[5])
  3006. h_red = atoi(sep->arg[5]);
  3007. if(sep->arg[6])
  3008. h_green = atoi(sep->arg[6]);
  3009. if(sep->arg[7])
  3010. h_blue = atoi(sep->arg[7]);
  3011. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3012. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3013. }
  3014. else{
  3015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3018. }
  3019. break;
  3020. }
  3021. case COMMAND_SPAWN_DETAILS:{
  3022. Spawn* spawn = cmdTarget;
  3023. if(spawn){
  3024. const char* type = "NPC";
  3025. if(spawn->IsObject())
  3026. type = "Object";
  3027. else if(spawn->IsSign())
  3028. type = "Sign";
  3029. else if(spawn->IsWidget())
  3030. type = "Widget";
  3031. else if(spawn->IsGroundSpawn())
  3032. type = "GroundSpawn";
  3033. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3034. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3035. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3036. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3037. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3038. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3039. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3040. 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());
  3041. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3042. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3043. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3044. if(spawn->IsEntity()){
  3045. 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());
  3046. 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());
  3047. }
  3048. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3049. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3050. 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());
  3051. 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);
  3052. if (spawn->IsNPC())
  3053. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3054. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3055. if (packet) {
  3056. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3057. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3058. packet->setDataByName("book_title", title.c_str());
  3059. packet->setDataByName("book_type", "simple");
  3060. packet->setDataByName("unknown2", 1);
  3061. packet->setDataByName("unknown5", 1, 4);
  3062. packet->setArrayLengthByName("num_pages", 4);
  3063. string details;
  3064. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3065. details += "Type: " + string(type) + "\n";
  3066. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3067. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3068. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3069. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3070. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3071. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3072. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3073. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3074. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3075. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3076. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3077. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3078. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3079. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3080. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3081. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3082. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3083. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3084. char x[16];
  3085. sprintf(x, "%.2f", spawn->GetX());
  3086. char y[16];
  3087. sprintf(y, "%.2f", spawn->GetY());
  3088. char z[16];
  3089. sprintf(z, "%.2f", spawn->GetZ());
  3090. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3091. string details2;
  3092. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3093. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3094. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3095. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3096. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3097. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3098. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3099. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3100. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3101. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3102. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3103. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3104. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3105. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3106. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3107. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3108. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3109. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3110. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3111. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3112. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3113. string details3;
  3114. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3115. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3116. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3117. string details4;
  3118. if (spawn->IsEntity()) {
  3119. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3120. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3121. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3122. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3123. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3124. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3125. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3126. if (spawn->IsNPC()) {
  3127. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3128. }
  3129. }
  3130. //details2 += "" + to_string() + "\n";
  3131. packet->setArrayDataByName("page_text", details.c_str());
  3132. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3133. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3134. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3135. client->QueuePacket(packet->serialize());
  3136. safe_delete(packet);
  3137. }
  3138. }
  3139. else if (sep && sep->arg[0][0] && sep->IsNumber(0))
  3140. {
  3141. float radius = atof(sep->arg[0]);
  3142. if ( !client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius) )
  3143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3144. }
  3145. else {
  3146. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3147. 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.");
  3148. }
  3149. break;
  3150. }
  3151. case COMMAND_SPAWN_TARGET:{
  3152. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3153. int32 spawn_id = atoul(sep->arg[0]);
  3154. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3155. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3156. }
  3157. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3158. float distance = atof(sep->arg[1]);
  3159. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3160. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3161. }
  3162. else{
  3163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3165. }
  3166. break;
  3167. }
  3168. case COMMAND_SPAWN_SET:
  3169. {
  3170. Spawn* spawn = cmdTarget;
  3171. sint16 set_type = -1;
  3172. string type_str;
  3173. if (spawn)
  3174. {
  3175. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3176. 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)
  3177. {
  3178. // set the type, which will be 0 if location or list or invalid
  3179. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3180. }
  3181. if(set_type > 0)
  3182. {
  3183. // check if spawn set is NOT a char update, or not location, or isn't a number
  3184. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_LASTNAME) && 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)
  3185. {
  3186. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3187. }
  3188. else
  3189. {
  3190. string name = string(spawn->GetName());
  3191. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3192. {
  3193. if(set_type == SPAWN_SET_VALUE_NAME)
  3194. {
  3195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3196. }
  3197. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3198. {
  3199. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3200. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3201. }
  3202. else
  3203. {
  3204. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3205. }
  3206. if(set_type != SPAWN_SET_VALUE_FACTION)
  3207. {
  3208. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3209. }
  3210. 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))
  3211. {
  3212. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3213. {
  3214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3215. }
  3216. else if(spawn->GetSpawnLocationID() > 0)
  3217. {
  3218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3219. }
  3220. }
  3221. else
  3222. {
  3223. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3224. {
  3225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3226. }
  3227. else if(spawn->GetDatabaseID() > 0)
  3228. {
  3229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3230. }
  3231. }
  3232. }
  3233. }
  3234. }
  3235. else if(set_type == 0)
  3236. {
  3237. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3238. map<string, int8>::iterator itr;
  3239. int i=0;
  3240. string list;
  3241. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3242. {
  3243. if(i==10)
  3244. {
  3245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3246. i = 0;
  3247. }
  3248. if(i>0)
  3249. {
  3250. list.append(", ").append(itr->first);
  3251. }
  3252. else
  3253. {
  3254. list = itr->first;
  3255. }
  3256. }
  3257. if(list.length() > 0)
  3258. {
  3259. // if 1 or more, display in client.
  3260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3261. }
  3262. }
  3263. else
  3264. {
  3265. // syntax fail
  3266. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3267. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3270. }
  3271. }
  3272. break;
  3273. }
  3274. case COMMAND_SPAWN_REMOVE:{
  3275. Spawn* spawn = cmdTarget;
  3276. if(spawn && !spawn->IsPlayer()){
  3277. if(spawn->GetSpawnLocationID() > 0){
  3278. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3279. bool delete_spawn = false;
  3280. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3281. if(atoi(sep->arg[0]) == 1)
  3282. delete_spawn = true;
  3283. }
  3284. if(delete_spawn)
  3285. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3286. else
  3287. spawn->SetSpawnLocationID(0);
  3288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3289. }
  3290. else
  3291. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3292. }
  3293. else
  3294. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3295. }
  3296. else{
  3297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3300. }
  3301. break;
  3302. }
  3303. case COMMAND_SPAWN_LIST:{
  3304. if(sep && sep->arg[0][0]){
  3305. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3306. vector<string>::iterator itr;
  3307. if(results){
  3308. for(itr=results->begin();itr!=results->end();itr++){
  3309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3310. }
  3311. safe_delete(results);
  3312. }
  3313. else
  3314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3315. }
  3316. else{
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3320. }
  3321. break;
  3322. }
  3323. case COMMAND_SPAWN_ADD:{
  3324. Spawn* spawn = cmdTarget;
  3325. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3326. if(spawn->GetSpawnLocationID() > 0){
  3327. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3328. break;
  3329. }
  3330. if(spawn->GetDatabaseID() == 0){
  3331. if(database.SaveSpawnInfo(spawn)) {
  3332. char spawn_type[32];
  3333. memset(spawn_type, 0, sizeof(spawn_type));
  3334. if (spawn->IsNPC())
  3335. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3336. else if (spawn->IsObject())
  3337. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3338. else if (spawn->IsSign())
  3339. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3340. else if (spawn->IsGroundSpawn())
  3341. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3342. else
  3343. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3344. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3345. }
  3346. else
  3347. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3348. }
  3349. int32 spawn_group_id = 0;
  3350. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3351. spawn_group_id = database.GetNextSpawnLocation();
  3352. else
  3353. spawn_group_id = atol(sep->arg[0]);
  3354. int8 percent = 100;
  3355. if(sep->arg[2] && sep->IsNumber(2))
  3356. percent = atoi(sep->arg[2]);
  3357. spawn->SetSpawnLocationID(spawn_group_id);
  3358. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3359. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3360. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3361. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3362. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3363. else
  3364. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3365. }
  3366. else{
  3367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3370. }
  3371. break;
  3372. }
  3373. case COMMAND_SPAWN:{
  3374. int32 id = 0;
  3375. Spawn* spawn = 0;
  3376. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3377. id = atol(sep->arg[0]);
  3378. spawn = client->GetCurrentZone()->GetSpawn(id);
  3379. }
  3380. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3381. id = 0;
  3382. if(!id || !spawn){
  3383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3386. safe_delete(sep);
  3387. return;
  3388. }
  3389. if(sep && sep->arg[1][0]){
  3390. float x = atof(sep->arg[1]);
  3391. spawn->appearance.pos.X = x;
  3392. }
  3393. else
  3394. spawn->SetX(client->GetPlayer()->GetX(), false);
  3395. if(sep && sep->arg[2][0]){
  3396. float y = atof(sep->arg[2]);
  3397. spawn->appearance.pos.Y = y;
  3398. }
  3399. else
  3400. spawn->SetY(client->GetPlayer()->GetY(), false);
  3401. if(sep && sep->arg[3][0]){
  3402. float z = atof(sep->arg[3]);
  3403. spawn->appearance.pos.Z = z;
  3404. }
  3405. else
  3406. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3407. if(sep && sep->arg[4][0]){
  3408. float heading = atof(sep->arg[4]);
  3409. spawn->SetHeading(heading);
  3410. }
  3411. else
  3412. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3413. spawn->SetSpawnOrigX(spawn->GetX());
  3414. spawn->SetSpawnOrigY(spawn->GetY());
  3415. spawn->SetSpawnOrigZ(spawn->GetZ());
  3416. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3417. if(sep && sep->arg[5][0])
  3418. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3419. else
  3420. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3421. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3422. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3423. spawn->SetHP(spawn->GetTotalHP());
  3424. }
  3425. if(spawn->GetTotalPower() == 0){
  3426. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3427. spawn->SetPower(spawn->GetTotalPower());
  3428. }
  3429. const char* script = world.GetSpawnScript(id);
  3430. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3431. spawn->SetSpawnScript(string(script));
  3432. client->GetCurrentZone()->AddSpawn(spawn);
  3433. if(spawn->IsNPC())
  3434. spawn->GetZone()->AddLoot((NPC*)spawn);
  3435. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3436. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3437. break;
  3438. }
  3439. case COMMAND_ADMINFLAG:
  3440. {
  3441. if(sep && sep->arg[0]){
  3442. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3443. sint16 new_status = atoi(sep->arg[1]);
  3444. if(tmp_status == -10)
  3445. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3446. else if(tmp_status >= client->GetAdminStatus())
  3447. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3448. else if (new_status > client->GetAdminStatus())
  3449. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3450. else{
  3451. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3452. if (!client2)
  3453. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3454. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3455. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3456. if (client2) {
  3457. client2->SetAdminStatus(new_status);
  3458. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3459. }
  3460. }
  3461. else
  3462. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3463. }
  3464. }else{
  3465. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3466. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3467. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3468. }
  3469. break;
  3470. }
  3471. case COMMAND_CANNEDEMOTE:{
  3472. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3473. break;
  3474. }
  3475. case COMMAND_BROADCAST: {
  3476. if (sep && sep->arg[0])
  3477. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3478. else
  3479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3480. break;
  3481. }
  3482. case COMMAND_ANNOUNCE: {
  3483. if (sep && sep->arg[0])
  3484. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3485. else
  3486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3487. break;
  3488. }
  3489. case COMMAND_RELOAD_ITEMS:{
  3490. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3492. database.ReloadItemList();
  3493. database.LoadMerchantInformation();
  3494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3495. break;
  3496. }
  3497. case COMMAND_ENABLE_ABILITY_QUE:{
  3498. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3499. if(app)
  3500. client->QueuePacket(app);
  3501. break;
  3502. }
  3503. case COMMAND_ITEMSEARCH:{
  3504. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3505. if (packet) {
  3506. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3507. //packet->setDataByName("unknown", 1);
  3508. packet->setDataByName("unknown2", 5, 0);
  3509. packet->setDataByName("unknown2", 20, 1);
  3510. packet->setDataByName("unknown2", 58, 3);
  3511. packet->setDataByName("unknown2", 40, 4);
  3512. client->QueuePacket(packet->serialize());
  3513. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3514. if (packet2) {
  3515. packet2->setDataByName("char_id", client->GetCharacterID());
  3516. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3517. safe_delete(packet2);
  3518. }
  3519. safe_delete(packet);
  3520. }
  3521. break;
  3522. }
  3523. case COMMAND_ANIMTEST:{
  3524. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3525. if(command_packet){
  3526. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3527. if (cmdTarget)
  3528. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3529. command_packet->setDataByName ( "spawn_id" , id);
  3530. int animID = 1;
  3531. if(sep && sep->arg[0] && sep->IsNumber(0))
  3532. animID = atoi(sep->arg[0]);
  3533. VisualState* vs = NULL;
  3534. if(animID == 0)
  3535. {
  3536. vs = visual_states.FindVisualState(sep->arg[0]);
  3537. }
  3538. char msg[128];
  3539. sprintf(msg,"Animation Test ID: %i",animID);
  3540. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3541. if(vs != NULL)
  3542. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3543. else
  3544. command_packet->setDataByName ( "anim_type", animID );
  3545. command_packet->setDataByName ( "unknown0", 0 );
  3546. EQ2Packet* outapp = command_packet->serialize();
  3547. client->QueuePacket(outapp);
  3548. safe_delete(command_packet);
  3549. }
  3550. break;
  3551. }
  3552. case COMMAND_KICK:
  3553. {
  3554. if( sep == 0 || sep->arg[0] == 0)
  3555. {
  3556. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3557. }
  3558. else
  3559. {
  3560. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3561. if ( kickClient == client )
  3562. {
  3563. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3564. break;
  3565. }
  3566. else if(kickClient != NULL)
  3567. {
  3568. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3569. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3570. {
  3571. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3572. break;
  3573. }
  3574. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3575. kickClient->Disconnect();
  3576. }
  3577. else
  3578. {
  3579. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3580. }
  3581. }
  3582. break;
  3583. }
  3584. case COMMAND_LOCK:
  3585. {
  3586. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3587. int worldLocked = atoi(sep->arg[0]);
  3588. net.world_locked = worldLocked;
  3589. if ( worldLocked )
  3590. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3591. else
  3592. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3593. }
  3594. else
  3595. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3596. break;
  3597. }
  3598. case COMMAND_BAN:{
  3599. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3600. {
  3601. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3602. }
  3603. else
  3604. {
  3605. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3606. if ( kickClient == client )
  3607. {
  3608. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3609. break;
  3610. }
  3611. else if(kickClient != NULL)
  3612. {
  3613. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3614. if ( maxStatus > client->GetAdminStatus( ) ||
  3615. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3616. {
  3617. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3618. break;
  3619. }
  3620. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3621. int perm = atol(sep->arg[1]);
  3622. if ( perm == 1 )
  3623. database.UpdateAdminStatus(sep->arg[0],-2);
  3624. else
  3625. database.UpdateAdminStatus(sep->arg[0],-1);
  3626. kickClient->Disconnect();
  3627. }
  3628. else
  3629. {
  3630. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3631. }
  3632. }
  3633. break;
  3634. }
  3635. case COMMAND_SET_COMBAT_VOICE:{
  3636. int32 value = 0;
  3637. if(sep && sep->arg[0] && sep->IsNumber(0))
  3638. value = atoi(sep->arg[0]);
  3639. client->GetPlayer()->SetCombatVoice(value);
  3640. break;
  3641. }
  3642. case COMMAND_SET_EMOTE_VOICE:{
  3643. int32 value = 0;
  3644. if(sep && sep->arg[0] && sep->IsNumber(0))
  3645. value = atoi(sep->arg[0]);
  3646. client->GetPlayer()->SetEmoteVoice(value);
  3647. break;
  3648. }
  3649. case COMMAND_GIVEITEM:{
  3650. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3651. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3652. if ( itemToClient == NULL )
  3653. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3654. else
  3655. {
  3656. int32 item_id = atol(sep->arg[1]);
  3657. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3658. itemToClient->AddItem(item_id);
  3659. }
  3660. }
  3661. else
  3662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3663. break;
  3664. }
  3665. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3666. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3667. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3668. case COMMAND_SKILL :
  3669. case COMMAND_SKILL_ADD :
  3670. case COMMAND_SKILL_REMOVE :
  3671. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3672. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3673. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3674. case COMMAND_ENTITYCOMMAND :
  3675. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3676. case COMMAND_MERCHANT :
  3677. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3678. case COMMAND_APPEARANCE :
  3679. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3680. case COMMAND_TRACK : { Command_Track(client); break; }
  3681. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3682. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3683. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3684. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3685. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3686. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3687. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3688. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3689. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3690. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3691. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3692. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3693. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3694. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3695. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3696. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3697. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3698. case COMMAND_LOCATION : { Command_Location(client); break; }
  3699. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3700. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3701. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3702. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3703. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3704. case COMMAND_GRID : { Command_Grid(client); break; }
  3705. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3706. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3707. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3708. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3709. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3710. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3711. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3712. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3713. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3714. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3715. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3716. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3717. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3718. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3719. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3720. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3721. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3722. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3723. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3724. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3725. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3726. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3727. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3728. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3729. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3730. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3731. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3732. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3733. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3734. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3735. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3736. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3737. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3738. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3739. case COMMAND_TITLE : { Command_Title(client); break; }
  3740. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3741. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3742. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3743. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3744. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3745. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3746. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3747. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3748. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3749. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3750. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3751. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3752. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3753. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3754. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3755. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3756. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3757. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3758. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3759. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3760. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3761. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3762. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3763. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3764. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3765. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3766. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3767. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3768. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3769. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3770. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3771. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3772. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3773. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3774. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3775. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3776. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3777. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3778. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3779. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3780. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3781. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3782. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3783. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3784. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3785. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3786. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3787. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3788. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3789. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3790. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3791. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3792. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3793. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3794. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3795. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3796. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3797. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3798. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3799. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3800. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3801. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3802. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3803. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3804. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3805. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3806. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3807. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3808. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3809. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3810. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3811. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3812. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3813. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3814. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3815. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3816. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3817. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3818. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3819. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3820. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3821. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3822. case ADD_AA : { Add_AA(client, sep); break; }
  3823. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3824. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3825. case BACK_AA : { Back_AA(client, sep); break; }
  3826. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3827. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3828. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3829. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3830. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3831. default:
  3832. {
  3833. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3834. break;
  3835. }
  3836. }
  3837. safe_delete(sep);
  3838. }
  3839. /******************** New COMMAND Handler Functions ********************/
  3840. /*
  3841. Started breaking apart the huge switch() for commands into sepErate
  3842. functions so it is easier to locate the blocks of code by command
  3843. -- JA 2012.03.03
  3844. */
  3845. // sample function header
  3846. /*
  3847. Function:
  3848. Purpose :
  3849. Params :
  3850. Dev :
  3851. Example :
  3852. */
  3853. //void Commands::Command()
  3854. //{
  3855. //}
  3856. /*
  3857. Function: Command_AcceptAdvancement()
  3858. Purpose : Player accepts a new advancement option
  3859. Params : Spell ID
  3860. Dev : Jabantiz
  3861. */
  3862. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  3863. {
  3864. Player *player = client->GetPlayer();
  3865. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  3866. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  3867. if (!player->HasSpell(trait->spellID, 0, true))
  3868. {
  3869. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3870. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3871. }
  3872. else
  3873. {
  3874. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3875. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  3876. player->RemoveSpellBookEntry(spell->GetSpellID());
  3877. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3878. player->UnlockSpell(spell);
  3879. client->SendSpellUpdate(spell);
  3880. }
  3881. // Spell book update
  3882. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  3883. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  3884. }
  3885. /*
  3886. Function:
  3887. Purpose :
  3888. Params :
  3889. Dev :
  3890. Example :
  3891. */
  3892. void Commands::Command_AFK(Client* client, Seperator* sep)
  3893. {
  3894. Player* player = client->GetPlayer();
  3895. player->toggle_character_flag(CF_AFK);
  3896. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  3897. if (player->get_character_flag(CF_AFK))
  3898. {
  3899. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  3900. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  3901. if (sep && sep->argplus[0])
  3902. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  3903. else
  3904. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  3905. string message = string(player->GetName()) + " is going afk.";
  3906. Spawn* target = player->GetTarget();
  3907. if (target && target != player)
  3908. {
  3909. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  3910. player->GetGender() == 1 ? message += "he" : message += "she";
  3911. message += " is going afk.";
  3912. }
  3913. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  3914. }
  3915. /*else
  3916. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  3917. }
  3918. /*
  3919. Function: Command_Appearance()
  3920. Purpose : Handles /appearance commands
  3921. Params : list
  3922. Dev : Scatman
  3923. Example : /appearance list
  3924. */
  3925. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  3926. {
  3927. if( handler == COMMAND_APPEARANCE )
  3928. {
  3929. // /appearance command by itself shows help (to be extended)
  3930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3931. return;
  3932. }
  3933. else if( handler == COMMAND_APPEARANCE_LIST )
  3934. {
  3935. // /appearance list command expects "name" param
  3936. if (sep && sep->arg[0])
  3937. {
  3938. const char* appearance_name = sep->argplus[0];
  3939. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  3940. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  3941. if (appearances)
  3942. {
  3943. vector<int16>::iterator itr;
  3944. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  3945. {
  3946. int16 id = *itr;
  3947. string name = database.GetAppearanceName(id);
  3948. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  3949. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  3950. }
  3951. safe_delete(appearances);
  3952. }
  3953. }
  3954. else // no param
  3955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3956. }
  3957. }
  3958. /*
  3959. Function: Command_Claim()
  3960. Purpose :
  3961. Params :
  3962. Dev :
  3963. Example :
  3964. */
  3965. void Commands::Command_Claim(Client* client, Seperator* sep)
  3966. {
  3967. if (sep && sep->arg[0] && sep->IsNumber(0))
  3968. {
  3969. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  3971. }
  3972. else
  3973. client->ShowClaimWindow();
  3974. }
  3975. /*
  3976. Function: Command_ClearAllQueued()
  3977. Purpose :
  3978. Params :
  3979. Dev :
  3980. Example :
  3981. */
  3982. void Commands::Command_ClearAllQueued(Client* client)
  3983. {
  3984. ZoneServer* zone = client->GetPlayer()->GetZone();
  3985. if (zone && zone->GetSpellProcess())
  3986. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  3987. }
  3988. /*
  3989. Function: Command_CancelMaintained()
  3990. Purpose : Cancels maintained spells
  3991. Params : Maintained Spell Index
  3992. Dev : Zcoretri
  3993. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  3994. */
  3995. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  3996. {
  3997. if (sep && sep->arg[0] && sep->IsNumber(0))
  3998. {
  3999. int32 spell_index = atoul(sep->arg[0]);
  4000. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4001. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4002. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4003. // just not spelleffects/dets - Foof
  4004. //{
  4005. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4006. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4007. // }
  4008. //else
  4009. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4010. }
  4011. }
  4012. /*
  4013. Function: Command_Create()
  4014. Purpose : Handler for starting Tradeskilling table
  4015. Params :
  4016. Dev : Zcoretri
  4017. Example :
  4018. */
  4019. void Commands::Command_Create(Client* client, Seperator* sep)
  4020. {
  4021. PrintSep(sep, "COMMAND_CREATE");
  4022. client->SendRecipeList();
  4023. client->ShowRecipeBook();
  4024. }
  4025. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4026. {
  4027. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4028. if (sep && sep->arg[0] && sep->IsNumber(0))
  4029. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4030. }
  4031. /*
  4032. Function: Command_Distance()
  4033. Purpose : Displays distance from targeted spawn
  4034. Params :
  4035. Dev : Scatman
  4036. Example : /distance
  4037. */
  4038. void Commands::Command_Distance(Client* client)
  4039. {
  4040. Spawn* target = client->GetPlayer()->GetTarget();
  4041. if (target)
  4042. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4043. else
  4044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4045. }
  4046. /*
  4047. Function: Command_Duel()
  4048. Purpose : Handle the /duel commands - not yet implemented
  4049. Params : unknown
  4050. Dev :
  4051. Example :
  4052. */
  4053. void Commands::Command_Duel(Client* client, Seperator* sep)
  4054. {
  4055. PrintSep(sep, "COMMAND_DUEL");
  4056. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4057. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4058. }
  4059. /*
  4060. Function: Command_DuelBet()
  4061. Purpose : Handle the /duel commands - not yet implemented
  4062. Params : unknown
  4063. Dev :
  4064. Example :
  4065. */
  4066. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4067. {
  4068. PrintSep(sep, "COMMAND_DUELBET");
  4069. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4070. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4071. }
  4072. /*
  4073. Function: Command_DuelAccept()
  4074. Purpose : Handle the /duel commands - not yet implemented
  4075. Params : unknown
  4076. Dev :
  4077. Example :
  4078. */
  4079. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4080. {
  4081. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4082. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4083. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4084. }
  4085. /*
  4086. Function: Command_DuelDecline()
  4087. Purpose : Handle the /duel commands - not yet implemented
  4088. Params : unknown
  4089. Dev :
  4090. Example :
  4091. */
  4092. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4093. {
  4094. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4095. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4096. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4097. }
  4098. /*
  4099. Function: Command_DuelSurrender()
  4100. Purpose : Handle the /duel commands - not yet implemented
  4101. Params : unknown
  4102. Dev :
  4103. Example :
  4104. */
  4105. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4106. {
  4107. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4108. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4109. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4110. // JA, just messin around ;)
  4111. char surrender[64];
  4112. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4113. zone_list.HandleGlobalAnnouncement(surrender);
  4114. }
  4115. /*
  4116. Function: Command_DuelToggle()
  4117. Purpose : Handle the /duel commands - not yet implemented
  4118. Params : unknown
  4119. Dev :
  4120. Example :
  4121. */
  4122. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4123. {
  4124. PrintSep(sep, "COMMAND_DUEL");
  4125. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4126. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4127. }
  4128. /*
  4129. Function:
  4130. Purpose :
  4131. Params :
  4132. Dev :
  4133. Example :
  4134. */
  4135. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4136. {
  4137. if( handler == COMMAND_ENTITYCOMMAND )
  4138. {
  4139. // /entitycommand command by itself shows help (to be extended)
  4140. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4141. return;
  4142. }
  4143. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4144. {
  4145. // /entitycommand list command expects "name" param
  4146. if (sep && sep->arg[0])
  4147. {
  4148. const char* entity_command_name = sep->argplus[0];
  4149. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4150. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4151. map<int32, vector<EntityCommand*>*>::iterator itr;
  4152. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4153. {
  4154. vector<EntityCommand*>* entity_command_list = itr->second;
  4155. vector<EntityCommand*>::iterator itr2;
  4156. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4157. {
  4158. EntityCommand* entity_command = *itr2;
  4159. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4160. 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);
  4161. }
  4162. }
  4163. }
  4164. else // no command name
  4165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4166. }
  4167. }
  4168. /*
  4169. Function: Command_Follow()
  4170. Purpose : Handle the /follow command - not yet implemented
  4171. Params :
  4172. Dev :
  4173. Example :
  4174. */
  4175. void Commands::Command_Follow(Client* client, Seperator* sep)
  4176. {
  4177. PrintSep(sep, "COMMAND_FOLLOW");
  4178. // flag to toggle if the players target is in the players group
  4179. bool targetInGroup = false;
  4180. // get a pointer to the players group
  4181. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4182. // If the player has a group and has a target
  4183. if (gmi && client->GetPlayer()->GetTarget()) {
  4184. deque<GroupMemberInfo*>::iterator itr;
  4185. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4186. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4187. // Loop through the group members
  4188. for (itr = members->begin(); itr != members->end(); itr++) {
  4189. // If a group member matches a target
  4190. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4191. // toggle the flag and break the loop
  4192. targetInGroup = true;
  4193. break;
  4194. }
  4195. }
  4196. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4197. }
  4198. if (targetInGroup) {
  4199. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4200. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4201. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4202. client->GetPlayer()->info_changed = true;
  4203. client->GetPlayer()->changed = true;
  4204. }
  4205. else
  4206. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4207. }
  4208. /*
  4209. Function: Command_StopFollow()
  4210. Purpose : Handle the /stop_follow command - not yet implemented
  4211. Params :
  4212. Dev :
  4213. Example :
  4214. */
  4215. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4216. {
  4217. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4218. if (client->GetPlayer()->GetFollowTarget()) {
  4219. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4220. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4221. client->GetPlayer()->SetFollowTarget(0);
  4222. client->GetPlayer()->info_changed = true;
  4223. client->GetPlayer()->changed = true;
  4224. }
  4225. }
  4226. #include "../Zone/SPGrid.h"
  4227. /*
  4228. Function: Command_Grid()
  4229. Purpose : Show player's current Grid ID
  4230. Params :
  4231. Dev : Scatman
  4232. Example : /grid
  4233. */
  4234. void Commands::Command_Grid(Client* client)
  4235. {
  4236. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4237. if (client->GetCurrentZone()->Grid != nullptr) {
  4238. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4239. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4240. }
  4241. }
  4242. /*
  4243. Function: Command_Guild()
  4244. Purpose : Handler for all UI-related guild commands
  4245. Dev : Scatman
  4246. */
  4247. void Commands::Command_Guild(Client* client, Seperator* sep)
  4248. {
  4249. Guild* guild = client->GetPlayer()->GetGuild();
  4250. if (sep && sep->arg[0])
  4251. {
  4252. const char* command = sep->arg[0];
  4253. int32 length = strlen(command);
  4254. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4255. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4256. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4257. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4258. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4259. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4260. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4261. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4262. guild->KickGuildMember(client, sep->arg[1]);
  4263. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4264. guild->DemoteGuildMember(client, sep->arg[1]);
  4265. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4266. guild->PromoteGuildMember(client, sep->arg[1]);
  4267. else if (strncmp(command, "points", length) == 0 && guild)
  4268. {
  4269. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4270. {
  4271. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4272. {
  4273. float points = atof(sep->arg[2]);
  4274. const char* option = sep->arg[3];
  4275. const char* comment = sep->argplus[4];
  4276. if (strncmp(option, "all", strlen(option)) == 0)
  4277. guild->AddPointsToAll(client, points, comment);
  4278. else if (strncmp(option, "online", strlen(option)) == 0)
  4279. guild->AddPointsToAllOnline(client, points, comment);
  4280. else if (strncmp(option, "group", strlen(option)) == 0)
  4281. guild->AddPointsToGroup(client, points, comment);
  4282. else if (strncmp(option, "raid", strlen(option)) == 0)
  4283. guild->AddPointsToRaid(client, points, comment);
  4284. else
  4285. guild->AddPointsToGuildMember(client, points, option, comment);
  4286. }
  4287. }
  4288. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4289. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4290. else
  4291. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4292. }
  4293. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4294. guild->SetMOTD(sep->argplus[1]);
  4295. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4296. {
  4297. if (sep->arg[1])
  4298. {
  4299. const char* option = sep->arg[1];
  4300. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4301. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4302. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4303. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4304. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4305. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4306. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4307. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4308. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4309. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4310. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4311. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4312. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4313. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4314. else
  4315. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4316. }
  4317. else
  4318. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4319. }
  4320. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4321. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4322. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4323. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4324. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4325. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4326. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4327. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4328. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4329. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4330. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4331. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4332. else if (strncmp(command, "invite", length) == 0 && guild)
  4333. {
  4334. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4335. guild->InvitePlayer(client, sep->arg[1]);
  4336. else
  4337. {
  4338. Spawn* target = client->GetPlayer()->GetTarget();
  4339. if (target)
  4340. {
  4341. if (target->IsPlayer())
  4342. guild->InvitePlayer(client, target->GetName());
  4343. else
  4344. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4345. }
  4346. }
  4347. }
  4348. else if (strncmp(command, "accept", length) == 0)
  4349. {
  4350. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4351. if (pgi && pgi->guild && pgi->invited_by)
  4352. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4353. client->SetPendingGuildInvite(0);
  4354. }
  4355. else if (strncmp(command, "decline", length) == 0)
  4356. {
  4357. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4358. if (pgi && pgi->guild && pgi->invited_by)
  4359. {
  4360. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4361. if (client_inviter)
  4362. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4363. }
  4364. client->SetPendingGuildInvite(0);
  4365. }
  4366. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4367. {
  4368. const char* guild_name = sep->argplus[0];
  4369. if (!guild_list.GetGuild(guild_name))
  4370. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo()->group_id);
  4371. else
  4372. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4373. }
  4374. else if (strncmp(command, "search", length) == 0)
  4375. client->ShowGuildSearchWindow();
  4376. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4377. {
  4378. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4379. if (to_guild)
  4380. to_guild->SendGuildRecruitingDetails(client);
  4381. }
  4382. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4383. {
  4384. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4385. if (to_guild)
  4386. to_guild->SendGuildRecruitingImages(client);
  4387. }
  4388. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4389. {
  4390. if (sep->arg[1])
  4391. {
  4392. const char* option = sep->arg[1];
  4393. if (strncmp(option, "toggle", strlen(option)) == 0)
  4394. guild->ToggleGuildRecruiterAdventureClass(client);
  4395. }
  4396. else
  4397. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4398. }
  4399. else if (strncmp(command, "display_heraldry", length) == 0)
  4400. {
  4401. // JA: not sure this is right...
  4402. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4403. client->GetPlayer()->SetCharSheetChanged(true);
  4404. }
  4405. else
  4406. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4407. }
  4408. }
  4409. /*
  4410. Function: Command_GuildCreate()
  4411. Purpose : Display's in-game Guild Creation window
  4412. Dev : Scatman
  4413. */
  4414. void Commands::Command_CreateGuild(Client* client)
  4415. {
  4416. client->SendGuildCreateWindow();
  4417. }
  4418. /*
  4419. Function: Command_SetGuildOfficerNote()
  4420. Purpose :
  4421. Dev : Scatman
  4422. */
  4423. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4424. {
  4425. if (sep && sep->arg[0] && sep->arg[1])
  4426. {
  4427. Guild* guild = client->GetPlayer()->GetGuild();
  4428. if (guild)
  4429. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4430. }
  4431. }
  4432. /*
  4433. Function: Command_SetGuildMemberNote()
  4434. Purpose :
  4435. Dev : Scatman
  4436. */
  4437. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4438. {
  4439. if (sep && sep->arg[0] && sep->arg[1])
  4440. {
  4441. Guild* guild = client->GetPlayer()->GetGuild();
  4442. if (guild)
  4443. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4444. }
  4445. }
  4446. /*
  4447. Function: Command_GuildSay()
  4448. Purpose :
  4449. Dev : Scatman
  4450. */
  4451. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4452. {
  4453. Guild* guild = client->GetPlayer()->GetGuild();
  4454. if (guild)
  4455. {
  4456. if (sep && sep->arg[0])
  4457. guild->HandleGuildSay(client, sep->argplus[0]);
  4458. }
  4459. else
  4460. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4461. }
  4462. /*
  4463. Function: Command_OfficerSay()
  4464. Purpose :
  4465. Dev : Scatman
  4466. */
  4467. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4468. {
  4469. Guild* guild = client->GetPlayer()->GetGuild();
  4470. if (guild)
  4471. {
  4472. if (sep && sep->arg[0])
  4473. guild->HandleOfficerSay(client, sep->argplus[0]);
  4474. }
  4475. else
  4476. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4477. }
  4478. /*
  4479. Function: Command_Guilds()
  4480. Purpose : Shows help for /guild command
  4481. Params :
  4482. Dev : Scatman
  4483. Example :
  4484. */
  4485. void Commands::Command_Guilds(Client* client)
  4486. {
  4487. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4488. }
  4489. /*
  4490. Function: Command_GuildsAdd()
  4491. Purpose : Add's players to a guild
  4492. Params : guild_name|guild_id, player name
  4493. Dev : Scatman
  4494. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4495. */
  4496. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4497. {
  4498. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4499. {
  4500. Guild* guild = 0;
  4501. bool found = true;
  4502. if (sep->IsNumber(0))
  4503. {
  4504. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4505. if (!guild)
  4506. {
  4507. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4508. found = false;
  4509. }
  4510. }
  4511. else
  4512. {
  4513. guild = guild_list.GetGuild(sep->arg[0]);
  4514. if (!guild)
  4515. {
  4516. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4517. found = false;
  4518. }
  4519. }
  4520. if (found)
  4521. {
  4522. Client* to_client = 0;
  4523. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4524. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4525. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4526. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4527. if (to_client)
  4528. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4529. else
  4530. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4531. }
  4532. }
  4533. else
  4534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4535. }
  4536. /*
  4537. Function: Command_GuildsCreate()
  4538. Purpose : Creates a guild
  4539. Params : guild_name, player_name (optional)
  4540. Dev : Scatman
  4541. Example : /guilds create [guild name] (player name)
  4542. */
  4543. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4544. {
  4545. if (sep && sep->arg[0])
  4546. {
  4547. const char* guild_name = sep->arg[0];
  4548. if (!guild_list.GetGuild(guild_name))
  4549. {
  4550. bool ret = false;
  4551. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4552. {
  4553. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4554. if (to_client)
  4555. {
  4556. world.CreateGuild(guild_name, to_client);
  4557. ret = true;
  4558. }
  4559. else
  4560. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4561. }
  4562. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4563. {
  4564. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4565. if (to_client)
  4566. {
  4567. world.CreateGuild(guild_name, to_client);
  4568. ret = true;
  4569. }
  4570. }
  4571. else
  4572. {
  4573. world.CreateGuild(guild_name);
  4574. ret = true;
  4575. }
  4576. if (ret)
  4577. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4578. else
  4579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4580. }
  4581. else
  4582. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4583. }
  4584. else
  4585. 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.");
  4586. }
  4587. /*
  4588. Function: Command_GuildsDelete()
  4589. Purpose : Delete's a guild
  4590. Params : guild name
  4591. Dev : Scatman
  4592. Example : /guilds delete Test
  4593. */
  4594. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4595. {
  4596. if (sep && sep->arg[0])
  4597. {
  4598. Guild* guild = 0;
  4599. bool found = true;
  4600. if (sep->IsNumber(0))
  4601. {
  4602. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4603. if (!guild)
  4604. {
  4605. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4606. found = false;
  4607. }
  4608. }
  4609. else
  4610. {
  4611. guild = guild_list.GetGuild(sep->arg[0]);
  4612. if (!guild)
  4613. {
  4614. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4615. found = false;
  4616. }
  4617. }
  4618. if (found)
  4619. {
  4620. guild->RemoveAllGuildMembers();
  4621. database.DeleteGuild(guild);
  4622. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4623. guild_list.RemoveGuild(guild, true);
  4624. }
  4625. }
  4626. else
  4627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4628. }
  4629. /*
  4630. Function: Command_GuildsList()
  4631. Purpose : Lists current guilds on server
  4632. Params :
  4633. Dev : Scatman
  4634. Example : /guilds list
  4635. */
  4636. void Commands::Command_GuildsList(Client* client)
  4637. {
  4638. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4639. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4641. if (guilds->size() == 0)
  4642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4643. else {
  4644. while (itr.Next()) {
  4645. Guild* guild = itr.second;
  4646. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4647. }
  4648. }
  4649. }
  4650. /*
  4651. Function: Command_GuildsRemove()
  4652. Purpose : Removes a player from a guild
  4653. Params : guild name|guild id, player name
  4654. Dev : Scatman
  4655. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4656. */
  4657. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4658. {
  4659. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4660. {
  4661. Guild* guild = 0;
  4662. bool found = true;
  4663. if (sep->IsNumber(0))
  4664. {
  4665. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4666. if (!guild)
  4667. {
  4668. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4669. found = false;
  4670. }
  4671. }
  4672. else
  4673. {
  4674. guild = guild_list.GetGuild(sep->arg[0]);
  4675. if (!guild)
  4676. {
  4677. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4678. found = false;
  4679. }
  4680. }
  4681. if (found)
  4682. {
  4683. Client* to_client = 0;
  4684. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4685. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4686. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4687. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4688. if (to_client)
  4689. {
  4690. Player* to_player = to_client->GetPlayer();
  4691. if (to_player->GetGuild())
  4692. {
  4693. if (to_player->GetGuild() == guild)
  4694. {
  4695. guild->KickGuildMember(client, to_player->GetName());
  4696. }
  4697. else
  4698. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4699. }
  4700. else
  4701. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4702. }
  4703. else
  4704. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4705. }
  4706. }
  4707. else
  4708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4709. }
  4710. /*
  4711. Function: Command_InspectPlayer()
  4712. Purpose : Handle the Inspect functions
  4713. Params : Client to inspect
  4714. Dev : Scatman
  4715. Example : /inspect Scatman
  4716. */
  4717. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4718. {
  4719. if (sep && sep->arg[0])
  4720. {
  4721. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4722. if (inspect_client)
  4723. client->InspectPlayer(inspect_client->GetPlayer());
  4724. }
  4725. else
  4726. {
  4727. Spawn* target = client->GetPlayer()->GetTarget();
  4728. if (target && target->IsPlayer())
  4729. client->InspectPlayer((Player*)target);
  4730. }
  4731. }
  4732. /*
  4733. Function: Command_Inventory()
  4734. Purpose : Handle changes in player inventory
  4735. Params : <TBD>
  4736. Dev : All
  4737. Example : /inventory delete item_id
  4738. */
  4739. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4740. {
  4741. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4742. Player* player = client->GetPlayer();
  4743. if(sep && sep->arg[0][0])
  4744. {
  4745. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4746. if(client->GetPlayer()->GetHP() == 0)
  4747. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4748. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4749. {
  4750. int16 index = atoi(sep->arg[1]);
  4751. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4752. if(item)
  4753. {
  4754. if(item->GetItemScript() && lua_interface)
  4755. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4756. int32 bag_id = item->details.inv_slot_id;
  4757. database.DeleteItem(client->GetCharacterID(), item, 0);
  4758. client->GetPlayer()->item_list.DestroyItem(index);
  4759. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4760. client->QueuePacket(outapp);
  4761. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4762. if (outapp)
  4763. client->QueuePacket(outapp);
  4764. }
  4765. }
  4766. 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))
  4767. {
  4768. int16 from_index = atoi(sep->arg[1]);
  4769. sint16 to_slot = atoi(sep->arg[2]);
  4770. sint32 bag_id = atol(sep->arg[3]);
  4771. int8 charges = atoi(sep->arg[4]);
  4772. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4773. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4774. {
  4775. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4776. return;
  4777. }
  4778. sint32 old_inventory_id = 0;
  4779. if(item)
  4780. old_inventory_id = item->details.inv_slot_id;
  4781. //autobank
  4782. if (bag_id == -3 && to_slot == -1)
  4783. {
  4784. if (player->HasFreeBankSlot())
  4785. to_slot = player->FindFreeBankSlot();
  4786. else
  4787. {
  4788. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4789. return;
  4790. }
  4791. }
  4792. //auto inventory
  4793. if (bag_id == 0 && to_slot == -1)
  4794. {
  4795. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4796. {
  4797. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4798. return;
  4799. }
  4800. }
  4801. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4802. client->QueuePacket(outapp);
  4803. //removed from bag send update
  4804. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4805. {
  4806. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4807. if(outapp)
  4808. client->QueuePacket(outapp);
  4809. }
  4810. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4811. {
  4812. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4813. if(outapp)
  4814. client->QueuePacket(outapp);
  4815. }
  4816. }
  4817. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4818. {
  4819. if(client->GetPlayer()->EngagedInCombat())
  4820. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4821. else
  4822. {
  4823. int16 index = atoi(sep->arg[1]);
  4824. int8 slot_id = 255;
  4825. if(sep->arg[2][0] && sep->IsNumber(2))
  4826. slot_id = atoi(sep->arg[2]);
  4827. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4828. EQ2Packet* outapp = 0;
  4829. for(int32 i=0;i<packets.size();i++)
  4830. {
  4831. outapp = packets[i];
  4832. if(outapp)
  4833. client->QueuePacket(outapp);
  4834. }
  4835. client->GetPlayer()->ChangePrimaryWeapon();
  4836. client->GetPlayer()->ChangeSecondaryWeapon();
  4837. client->GetPlayer()->ChangeRangedWeapon();
  4838. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4839. client->QueuePacket(characterSheetPackets);
  4840. }
  4841. }
  4842. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4843. {
  4844. if (client->GetPlayer()->EngagedInCombat())
  4845. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  4846. else {
  4847. int16 index = atoi(sep->arg[1]);
  4848. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4849. if (item) {
  4850. // client->GetPlayer()->item_list.DestroyItem(index);
  4851. if (item->item_sets.size() > 0) {
  4852. for (int32 i = 0; i < item->item_sets.size(); i++) {
  4853. ItemSet* set = item->item_sets[i];
  4854. if (set->item_stack_size == 0)
  4855. set->item_stack_size += 1;
  4856. client->AddItem(set->item_id, set->item_stack_size);
  4857. }
  4858. }
  4859. }
  4860. client->RemoveItem(item, 1);
  4861. }
  4862. }
  4863. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  4864. {
  4865. if(client->GetPlayer()->EngagedInCombat())
  4866. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  4867. else
  4868. {
  4869. int16 index = atoi(sep->arg[1]);
  4870. sint32 bag_id = -999;
  4871. int8 to_slot = 255;
  4872. if(sep->arg[3][0])
  4873. {
  4874. if(sep->IsNumber(2))
  4875. bag_id = atol(sep->arg[2]);
  4876. if(sep->IsNumber(3))
  4877. to_slot = atoi(sep->arg[3]);
  4878. }
  4879. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  4880. EQ2Packet* outapp = 0;
  4881. for(int32 i=0;i<packets.size();i++)
  4882. {
  4883. outapp = packets[i];
  4884. if(outapp)
  4885. client->QueuePacket(outapp);
  4886. }
  4887. client->GetPlayer()->ChangePrimaryWeapon();
  4888. client->GetPlayer()->ChangeSecondaryWeapon();
  4889. client->GetPlayer()->ChangeRangedWeapon();
  4890. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4891. client->QueuePacket(characterSheetPackets);
  4892. }
  4893. }
  4894. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4895. {
  4896. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4897. int16 index1 = atoi(sep->arg[1]);
  4898. int16 index2 = atoi(sep->arg[2]);
  4899. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  4900. if(outapp)
  4901. client->QueuePacket(outapp);
  4902. else
  4903. {
  4904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  4905. return;
  4906. }
  4907. }
  4908. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4909. {
  4910. sint16 to_slot = atoi(sep->arg[1]);
  4911. sint32 bag_id = atoi(sep->arg[2]);
  4912. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  4913. if (item) {
  4914. //auto inventory
  4915. if (bag_id == 0 && to_slot == -1)
  4916. {
  4917. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4918. {
  4919. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  4920. return;
  4921. }
  4922. // Set the slot for the item
  4923. item->details.inv_slot_id = bag_id;
  4924. item->details.slot_id = to_slot;
  4925. // Flag the item so it gets saved in its new location
  4926. item->save_needed = true;
  4927. // Add the item to its new location
  4928. player->item_list.AddItem(item);
  4929. // Remove the item from the overflow list
  4930. player->item_list.RemoveOverflowItem(item);
  4931. // Send the inventory update packet
  4932. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4933. return;
  4934. }
  4935. else if (bag_id == -3 && to_slot == -1) {
  4936. // Auto Bank
  4937. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  4938. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  4939. return;
  4940. }
  4941. item->details.inv_slot_id = bag_id;
  4942. item->details.slot_id = to_slot;
  4943. item->save_needed = true;
  4944. player->item_list.AddItem(item);
  4945. player->item_list.RemoveOverflowItem(item);
  4946. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4947. }
  4948. else if (bag_id == -4) {
  4949. // Shared Bank
  4950. if (!player->item_list.SharedBankAddAllowed(item)) {
  4951. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  4952. return;
  4953. }
  4954. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  4955. if (tmp_item) {
  4956. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4957. return;
  4958. }
  4959. else {
  4960. item->details.inv_slot_id = bag_id;
  4961. item->details.slot_id = to_slot;
  4962. item->save_needed = true;
  4963. player->item_list.AddItem(item);
  4964. player->item_list.RemoveOverflowItem(item);
  4965. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4966. return;
  4967. }
  4968. }
  4969. else {
  4970. // Try to get an item from the given bag id and slot id
  4971. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  4972. // Check to see if we got an item, if we do send an error,
  4973. // if we don't put the overflow item into this slot
  4974. if (tmp_item) {
  4975. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4976. }
  4977. else {
  4978. item->details.inv_slot_id = bag_id;
  4979. item->details.slot_id = to_slot;
  4980. item->save_needed = true;
  4981. player->item_list.AddItem(item);
  4982. player->item_list.RemoveOverflowItem(item);
  4983. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4984. return;
  4985. }
  4986. }
  4987. }
  4988. }
  4989. }
  4990. else
  4991. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  4992. }
  4993. /*
  4994. Function: Command_IRC()
  4995. Purpose : Handle the IRC functions
  4996. Params : IRC Commands
  4997. Dev : Scatman
  4998. Example : /irc say #Channel Hello World!
  4999. */
  5000. void Commands::Command_IRC(Client* client, Seperator* sep)
  5001. {
  5002. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5003. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5004. return;
  5005. }
  5006. if (sep && sep->arg[0][0]) {
  5007. if (strcasecmp(sep->arg[0], "say") == 0) {
  5008. if (sep->arg[1][0] && sep->arg[2][0]) {
  5009. if (sep->IsNumber(sep->arg[1]))
  5010. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5011. else
  5012. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5013. }
  5014. else
  5015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5016. }
  5017. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5018. if (sep->arg[1][0])
  5019. irc.JoinChannel(client, sep->arg[1]);
  5020. else
  5021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5022. }
  5023. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5024. if (sep->arg[1][0])
  5025. irc.LeaveChannel(client, sep->arg[1]);
  5026. else
  5027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5028. }
  5029. else if (strcasecmp(sep->arg[0], "list") == 0)
  5030. irc.ListChannels(client);
  5031. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5032. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5033. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5034. else
  5035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5036. }
  5037. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5038. irc.DisconnectFromServer(client);
  5039. else
  5040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5041. }
  5042. else
  5043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5044. }
  5045. /*
  5046. Function: Command_Languages()
  5047. Purpose : Show's languages the player knows
  5048. Params :
  5049. Dev : Zcoretri
  5050. Example :
  5051. */
  5052. void Commands::Command_Languages(Client* client, Seperator* sep)
  5053. {
  5054. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5055. list<Language*>::iterator itr;
  5056. Language* language;
  5057. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5058. for(itr = languages->begin(); itr != languages->end(); itr++)
  5059. {
  5060. language = *itr;
  5061. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5062. }
  5063. }
  5064. /*
  5065. Function: Command_SetLanguage()
  5066. Purpose : Handles language commands
  5067. Params : Language ID
  5068. Dev : Zcoretri
  5069. Example :
  5070. */
  5071. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5072. {
  5073. Player* player = client->GetPlayer();
  5074. if (sep && sep->arg[0])
  5075. {
  5076. if(!sep->IsNumber(0))
  5077. {
  5078. //String passed in
  5079. const char* value = sep->arg[0];
  5080. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5081. {
  5082. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5083. client->SendLanguagesUpdate(0);
  5084. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5085. }
  5086. else
  5087. {
  5088. if(player->HasLanguage(value))
  5089. {
  5090. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5091. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5092. client->SendLanguagesUpdate(language->GetID());
  5093. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5094. }
  5095. else
  5096. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5097. }
  5098. }
  5099. else
  5100. {
  5101. //Number passed in
  5102. int32 id = atoul(sep->arg[0]);
  5103. if(player->HasLanguage(id))
  5104. {
  5105. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5106. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5107. client->SendLanguagesUpdate(id);
  5108. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5109. }
  5110. else
  5111. {
  5112. Language* language = master_languages_list.GetLanguage(id);
  5113. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5114. }
  5115. }
  5116. }
  5117. else
  5118. {
  5119. //No value was passed in
  5120. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5121. if(id > 0)
  5122. {
  5123. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5124. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5125. }
  5126. else
  5127. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5128. }
  5129. }
  5130. /*
  5131. Function: Command_LastName()
  5132. Purpose : Sets player surname
  5133. Params : Name text
  5134. Dev : theFoof
  5135. Example :
  5136. */
  5137. void Commands::Command_LastName(Client* client, Seperator* sep)
  5138. {
  5139. if (!client)
  5140. return;
  5141. if (sep && sep->arg[0])
  5142. {
  5143. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5144. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5145. return;
  5146. }
  5147. client->RemovePendingLastName();
  5148. uchar* checkname = (uchar*)sep->arg[0];
  5149. bool valid_name = true;
  5150. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5151. if (!alpha_check(checkname[i])) {
  5152. valid_name = false;
  5153. break;
  5154. }
  5155. }
  5156. if (!valid_name) {
  5157. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5158. return;
  5159. }
  5160. string last_name = (string)sep->arg[0];
  5161. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5162. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5163. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5164. client->SetPendingLastName(last_name);
  5165. client->SendLastNameConfirmation();
  5166. }
  5167. else
  5168. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5169. }
  5170. }
  5171. /*
  5172. Function: Command_ConfirmLastName()
  5173. Purpose : Confirms setting of player surname
  5174. Params : Name text
  5175. Dev : theFoof
  5176. Example :
  5177. */
  5178. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5179. {
  5180. if (!client)
  5181. return;
  5182. string* name = client->GetPendingLastName();
  5183. if (name){
  5184. Player* player = client->GetPlayer();
  5185. player->SetLastName(name->c_str(), false);
  5186. client->SendTitleUpdate();
  5187. player->SetCharSheetChanged(true);
  5188. client->RemovePendingLastName();
  5189. }
  5190. }
  5191. /*
  5192. Function: Command_Location()
  5193. Purpose : Display's Help for /location commands
  5194. Params :
  5195. Dev : Scatman
  5196. Example : /location = show's help for command
  5197. */
  5198. void Commands::Command_Location(Client* client)
  5199. {
  5200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5206. }
  5207. /*
  5208. Function: Command_LocationAdd()
  5209. Purpose : Add's a location to an existing location config
  5210. Params : location_id
  5211. Dev : Scatman
  5212. Example : /location add {location_id}
  5213. */
  5214. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5215. {
  5216. if (sep && sep->arg[0] && sep->IsNumber(0))
  5217. {
  5218. int32 location_id = atoul(sep->arg[0]);
  5219. float x = client->GetPlayer()->GetX();
  5220. float y = client->GetPlayer()->GetY();
  5221. float z = client->GetPlayer()->GetZ();
  5222. if (database.AddLocationPoint(location_id, x, y, z))
  5223. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5224. else
  5225. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5226. }
  5227. else
  5228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5229. }
  5230. /*
  5231. Function: Command_LocationCreate()
  5232. Purpose : Creates a new location config
  5233. Params : location name, 0/1 for include_y (optional)
  5234. Dev : Scatman
  5235. Example : /location create Test 1 = creates a new location named Test with include_y True
  5236. */
  5237. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5238. {
  5239. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5240. {
  5241. const char* name = sep->arg[0];
  5242. bool include_y = false;
  5243. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5244. include_y = true;
  5245. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5246. if (location_id > 0)
  5247. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5248. else
  5249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5250. }
  5251. else
  5252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5253. }
  5254. /*
  5255. Function: Command_LocationDelete()
  5256. Purpose : Delete's a location config and all it's location points
  5257. Params : location_id
  5258. Dev : Scatman
  5259. Example : /location delete {location_id}
  5260. */
  5261. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5262. {
  5263. if (sep && sep->arg[0] && sep->IsNumber(0))
  5264. {
  5265. int32 location_id = atoul(sep->arg[0]);
  5266. if (database.DeleteLocation(location_id))
  5267. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5268. else
  5269. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5270. }
  5271. else
  5272. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5273. }
  5274. /*
  5275. Function: Command_LocationList()
  5276. Purpose : Display's a list of location points
  5277. Params : location_id
  5278. Dev : Scatman
  5279. Example : /location list {location_id}
  5280. */
  5281. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5282. {
  5283. if (sep && sep->arg[0])
  5284. {
  5285. const char* option = sep->arg[0];
  5286. if (strncmp(option, "locations", strlen(option)) == 0)
  5287. database.ListLocations(client);
  5288. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5289. {
  5290. int32 location_id = atoul(sep->arg[1]);
  5291. database.ListLocationPoints(client, location_id);
  5292. }
  5293. else
  5294. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5295. }
  5296. else
  5297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5298. }
  5299. /*
  5300. Function: Command_LocationRemove()
  5301. Purpose : Removes a single location point from a location config
  5302. Params : location_point_id (gotten from /location list {id})
  5303. Dev : Scatman
  5304. Example : /location remove 1 = will remove location_point_id 1
  5305. */
  5306. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5307. {
  5308. if (sep && sep->arg[0] && sep->IsNumber(0))
  5309. {
  5310. int32 location_point_id = atoul(sep->arg[0]);
  5311. if (database.DeleteLocationPoint(location_point_id))
  5312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5313. else
  5314. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5315. }
  5316. else
  5317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5318. }
  5319. /*
  5320. Function: Command_Merchant()
  5321. Purpose : Handles Merchant commands
  5322. Params : list
  5323. Dev : Scatman
  5324. Example : /merchant list
  5325. */
  5326. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5327. {
  5328. if( handler == COMMAND_MERCHANT )
  5329. {
  5330. // /merchant command by itself shows help (to be extended)
  5331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5332. return;
  5333. }
  5334. else if( handler == COMMAND_MERCHANT_LIST )
  5335. {
  5336. // /merchant list command expects "description" param
  5337. if (sep && sep->arg[0])
  5338. {
  5339. const char* merchant_description = sep->argplus[0];
  5340. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5341. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5342. map<int32, MerchantInfo*>::iterator itr;
  5343. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5344. {
  5345. string description = database.GetMerchantDescription(itr->first);
  5346. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5347. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5348. }
  5349. }
  5350. else // no description
  5351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5352. }
  5353. }
  5354. /*
  5355. Function: Command_Modify()
  5356. Purpose : to replace our other "set" commands
  5357. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5358. Dev : John Adams
  5359. Example : /modify spell set name "Aegolism III"
  5360. */
  5361. void Commands::Command_Modify(Client* client)
  5362. {
  5363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5368. }
  5369. /*
  5370. Function: Command_ModifySpawn()
  5371. Purpose : replace "spawn set" commands
  5372. Params : Action : the action to perform (or special handler)
  5373. : Field : the DB field to change
  5374. : Value : what to set the value to
  5375. : Target : what object to change (my target, or spawn_id)
  5376. Dev : John Adams
  5377. Example : /modify spawn set name "Lady Vox"
  5378. :
  5379. Note : Special Handlers, like "zoneto" for Signs
  5380. : /modify spawn zoneto
  5381. : Will set a sign's zone x/y/z to my current coords
  5382. */
  5383. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5384. {
  5385. PrintSep(sep, "COMMAND_MODIFY");
  5386. // need at least 2 args for a valid command
  5387. if( sep && sep->arg[1] )
  5388. {
  5389. // JA: just a quick implementation because I need it :)
  5390. if (strcmp(sep->arg[0], "zoneto") == 0)
  5391. {
  5392. if( sep->IsNumber(1) )
  5393. {
  5394. int32 spawn_id = atoul(sep->arg[1]);
  5395. float x_coord = client->GetPlayer()->GetX();
  5396. float y_coord = client->GetPlayer()->GetY();
  5397. float z_coord = client->GetPlayer()->GetZ();
  5398. float h_coord = client->GetPlayer()->GetHeading();
  5399. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5400. }
  5401. else
  5402. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5403. }
  5404. }
  5405. else
  5406. Command_Modify(client);
  5407. }
  5408. /*
  5409. Function: Command_ModifyCharacter()
  5410. Purpose : to replace our other "set" commands
  5411. Params : Action : Add, Remove
  5412. : Field : copper, silver, gold, plat
  5413. : Value : min 1, max unlimited
  5414. : Target : Self, Player
  5415. Dev : Cynnar
  5416. Example : /modify character add gold 50
  5417. : /modify character remove silver 25
  5418. */
  5419. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5420. {
  5421. PrintSep(sep, "COMMAND_MODIFY");
  5422. int64 value = 0;
  5423. Player* player = client->GetPlayer();
  5424. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5425. player = (Player*)player->GetTarget();
  5426. // need at least 2 args for a valid command
  5427. if( sep && sep->arg[1] )
  5428. {
  5429. if (strcmp(sep->arg[0], "add") == 0)
  5430. {
  5431. if (strcmp(sep->arg[1], "copper") == 0)
  5432. {
  5433. value = atoi64(sep->arg[2]);
  5434. player->AddCoins(value);
  5435. if (client->GetPlayer() == player)
  5436. {
  5437. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5438. }
  5439. else {
  5440. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5441. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5442. }
  5443. }
  5444. else if (strcmp(sep->arg[1], "silver") == 0)
  5445. {
  5446. value = atoi64(sep->arg[2]) * 100;
  5447. player->AddCoins(value);
  5448. if (client->GetPlayer() == player)
  5449. {
  5450. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5451. }
  5452. else {
  5453. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5454. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5455. }
  5456. }
  5457. else if (strcmp(sep->arg[1], "gold") == 0)
  5458. {
  5459. value = atoi64(sep->arg[2]) * 10000;
  5460. player->AddCoins(value);
  5461. if (client->GetPlayer() == player)
  5462. {
  5463. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5464. }
  5465. else {
  5466. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5467. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5468. }
  5469. }
  5470. else if (strcmp(sep->arg[1], "plat") == 0)
  5471. {
  5472. value = atoi64(sep->arg[2]) * 1000000;
  5473. player->AddCoins(value);
  5474. if (client->GetPlayer() == player)
  5475. {
  5476. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5477. }
  5478. else {
  5479. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5480. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5481. }
  5482. }
  5483. else
  5484. {
  5485. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5486. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5487. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5488. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5489. }
  5490. }
  5491. else if (strcmp(sep->arg[0], "remove") == 0)
  5492. {
  5493. if (strcmp(sep->arg[1], "copper") == 0)
  5494. {
  5495. value = atoi64(sep->arg[2]);
  5496. player->RemoveCoins(value);
  5497. if (client->GetPlayer() == player)
  5498. {
  5499. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5500. }
  5501. else {
  5502. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5503. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5504. }
  5505. }
  5506. else if (strcmp(sep->arg[1], "silver") == 0)
  5507. {
  5508. value = atoi64(sep->arg[2]) * 100;
  5509. player->RemoveCoins(value);
  5510. if (client->GetPlayer() == player)
  5511. {
  5512. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5513. }
  5514. else {
  5515. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5516. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5517. }
  5518. }
  5519. else if (strcmp(sep->arg[1], "gold") == 0)
  5520. {
  5521. value = atoi64(sep->arg[2]) * 10000;
  5522. player->RemoveCoins(value);
  5523. if (client->GetPlayer() == player)
  5524. {
  5525. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5526. }
  5527. else {
  5528. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5529. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5530. }
  5531. }
  5532. else if (strcmp(sep->arg[1], "plat") == 0)
  5533. {
  5534. value = atoi64(sep->arg[2]) * 1000000;
  5535. player->RemoveCoins(value);
  5536. if (client->GetPlayer() == player)
  5537. {
  5538. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5539. }
  5540. else {
  5541. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5542. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5543. }
  5544. }
  5545. else
  5546. {
  5547. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5548. }
  5549. }
  5550. else if (strcmp(sep->arg[0], "set") == 0) {
  5551. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5552. int8 level = atoi(sep->arg[2]);
  5553. if (level > 0 && level < 256) {
  5554. if (player) {
  5555. if (client->GetPlayer() == player)
  5556. client->ChangeTSLevel(player->GetTSLevel(), level);
  5557. else
  5558. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5559. }
  5560. }
  5561. else
  5562. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5563. }
  5564. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5565. int8 tsclass = atoi(sep->arg[2]);
  5566. player->SetTradeskillClass(tsclass);
  5567. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5568. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5569. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5570. player->SetCharSheetChanged(true);
  5571. }
  5572. }
  5573. }
  5574. else
  5575. {
  5576. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5577. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5578. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5579. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5580. }
  5581. }
  5582. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5583. {
  5584. PrintSep(sep, "COMMAND_MODIFY");
  5585. // need at least 2 args for a valid command
  5586. if( sep && sep->arg[1] )
  5587. {
  5588. }
  5589. else
  5590. Command_Modify(client);
  5591. }
  5592. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5593. {
  5594. PrintSep(sep, "COMMAND_MODIFY");
  5595. // need at least 2 args for a valid command
  5596. if( sep && sep->arg[1] )
  5597. {
  5598. }
  5599. else
  5600. Command_Modify(client);
  5601. }
  5602. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5603. {
  5604. PrintSep(sep, "COMMAND_MODIFY");
  5605. // need at least 2 args for a valid command
  5606. if( sep && sep->arg[1] )
  5607. {
  5608. }
  5609. else
  5610. Command_Modify(client);
  5611. }
  5612. /*
  5613. Function: Command_ModifyQuest()
  5614. Purpose : to list players quest and completed quests
  5615. Params : Action : list, completed
  5616. : Target : Self, Player
  5617. Dev : Cynnar
  5618. Example : /modify quest list
  5619. : /modify quest completed
  5620. */
  5621. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5622. {
  5623. PrintSep(sep, "COMMAND_MODIFY");
  5624. int64 value = 0;
  5625. Player* player = client->GetPlayer();
  5626. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5627. player = (Player*)player->GetTarget();
  5628. // need at least 2 args for a valid command
  5629. if (sep && sep->arg[1])
  5630. {
  5631. if (strcmp(sep->arg[0], "list") == 0)
  5632. {
  5633. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5634. map<int32, Quest*>::iterator itr;
  5635. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5636. if (quests->size() == 0)
  5637. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5638. else
  5639. {
  5640. for (itr = quests->begin(); itr != quests->end(); itr++)
  5641. {
  5642. Quest* quest = itr->second;
  5643. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5644. }
  5645. }
  5646. }
  5647. else if (strcmp(sep->arg[0], "completed") == 0)
  5648. {
  5649. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5650. map<int32, Quest*>::iterator itr;
  5651. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5652. if (quests->size() == 0)
  5653. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5654. else
  5655. {
  5656. for (itr = quests->begin(); itr != quests->end(); itr++)
  5657. {
  5658. Quest* quest = itr->second;
  5659. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5660. }
  5661. }
  5662. }
  5663. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5664. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5665. else if (strcmp(sep->arg[0], "remove") == 0)
  5666. {
  5667. int32 quest_id = 0;
  5668. if (sep && sep->arg[1] && sep->IsNumber(1))
  5669. quest_id = atoul(sep->arg[1]);
  5670. if (quest_id > 0)
  5671. {
  5672. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5673. {
  5674. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5675. if (quest)
  5676. if (client->GetPlayer() == player)
  5677. {
  5678. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5679. }
  5680. else
  5681. {
  5682. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5683. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5684. }
  5685. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5686. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5687. }
  5688. client->RemovePlayerQuest(quest_id);
  5689. client->GetCurrentZone()->SendQuestUpdates(client);
  5690. }
  5691. }
  5692. else if (strcmp(sep->arg[0], "advance") == 0)
  5693. {
  5694. int32 quest_id = 0;
  5695. int32 step = 0;
  5696. if (sep && sep->arg[1] && sep->IsNumber(1))
  5697. {
  5698. quest_id = atoul(sep->arg[1]);
  5699. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5700. if (sep && sep->arg[2] && sep->IsNumber(1))
  5701. {
  5702. step = atoul(sep->arg[2]);
  5703. if (quest_id > 0 && step > 0)
  5704. {
  5705. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5706. {
  5707. if (client)
  5708. {
  5709. client->AddPendingQuestUpdate(quest_id, step);
  5710. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5711. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5712. }
  5713. }
  5714. }
  5715. else
  5716. {
  5717. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5718. }
  5719. }
  5720. else
  5721. {
  5722. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5723. }
  5724. }
  5725. else
  5726. {
  5727. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5728. }
  5729. }
  5730. else
  5731. {
  5732. Command_Modify(client);
  5733. }
  5734. }
  5735. else
  5736. {
  5737. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5738. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5739. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5740. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5741. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5742. }
  5743. }
  5744. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5745. {
  5746. PrintSep(sep, "COMMAND_MODIFY");
  5747. // need at least 2 args for a valid command
  5748. if( sep && sep->arg[1] )
  5749. {
  5750. if (strcmp(sep->arg[0], "add") == 0) {
  5751. const char* skill_name = sep->argplus[1];
  5752. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5753. if (skill) {
  5754. Player* player = 0;
  5755. Client* to_client = 0;
  5756. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5757. player = (Player*)client->GetPlayer()->GetTarget();
  5758. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5759. }
  5760. else {
  5761. player = client->GetPlayer();
  5762. to_client = client;
  5763. }
  5764. if (player)
  5765. {
  5766. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5767. {
  5768. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5769. if (to_client == client) {
  5770. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5771. }
  5772. else {
  5773. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5774. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5775. }
  5776. }
  5777. else
  5778. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5779. }
  5780. }
  5781. else
  5782. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5783. }
  5784. else if (strcmp(sep->arg[0], "remove") == 0) {
  5785. const char* skill_name = sep->argplus[1];
  5786. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5787. if (skill) {
  5788. Player* player = 0;
  5789. Client* to_client = 0;
  5790. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5791. player = (Player*)client->GetPlayer()->GetTarget();
  5792. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5793. }
  5794. else {
  5795. player = client->GetPlayer();
  5796. to_client = client;
  5797. }
  5798. if (player)
  5799. {
  5800. if (player->GetSkills()->HasSkill(skill->skill_id))
  5801. {
  5802. player->RemoveSkillFromDB(skill, true);
  5803. if (client == to_client) {
  5804. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5805. }
  5806. else {
  5807. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5808. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5809. }
  5810. }
  5811. else {
  5812. if (client == to_client)
  5813. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5814. else
  5815. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5816. }
  5817. }
  5818. }
  5819. else
  5820. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5821. }
  5822. else if (strcmp(sep->arg[0], "set") == 0) {
  5823. if (!sep->IsNumber(2)) {
  5824. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5825. return;
  5826. }
  5827. const char* skill_name = sep->arg[1];
  5828. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5829. if (skill) {
  5830. int16 val = atoi(sep->arg[2]);
  5831. Player* player = 0;
  5832. Client* to_client = 0;
  5833. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5834. player = (Player*)client->GetPlayer()->GetTarget();
  5835. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5836. }
  5837. else {
  5838. player = client->GetPlayer();
  5839. to_client = client;
  5840. }
  5841. if (player)
  5842. {
  5843. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  5844. player->GetSkills()->SetSkill(skill->skill_id, val);
  5845. if (client != to_client)
  5846. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  5847. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  5848. }
  5849. else {
  5850. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  5851. }
  5852. }
  5853. }
  5854. else {
  5855. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5856. }
  5857. }
  5858. else {
  5859. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5860. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5861. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5862. }
  5863. }
  5864. else {
  5865. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5866. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5867. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5868. }
  5869. }
  5870. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  5871. {
  5872. PrintSep(sep, "COMMAND_MODIFY");
  5873. // need at least 2 args for a valid command
  5874. if( sep && sep->arg[1] )
  5875. {
  5876. }
  5877. else
  5878. Command_Modify(client);
  5879. }
  5880. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  5881. {
  5882. PrintSep(sep, "COMMAND_MODIFY");
  5883. // need at least 2 args for a valid command
  5884. if( sep && sep->arg[1] )
  5885. {
  5886. }
  5887. else
  5888. Command_Modify(client);
  5889. }
  5890. /*
  5891. Function: Command_MOTD()
  5892. Purpose : Displays server MOTD
  5893. Params :
  5894. Dev : LethalEncounter
  5895. Example : /motd
  5896. */
  5897. void Commands::Command_MOTD(Client* client)
  5898. {
  5899. if (client)
  5900. ClientPacketFunctions::SendMOTD(client);
  5901. }
  5902. /*
  5903. Function: Command_Pet()
  5904. Purpose : Handle Pet {Command} commands
  5905. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  5906. Dev :
  5907. Example : /pet preserve_master
  5908. */
  5909. void Commands::Command_Pet(Client* client, Seperator* sep)
  5910. {
  5911. PrintSep(sep, "COMMAND_PET");
  5912. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  5913. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5914. if (strcmp(sep->arg[0], "hide") == 0) {
  5915. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  5916. Entity* pet = client->GetPlayer()->GetDeityPet();
  5917. if (pet) {
  5918. if (pet->IsPrivateSpawn())
  5919. client->GetPlayer()->HideDeityPet(false);
  5920. else
  5921. client->GetPlayer()->HideDeityPet(true);
  5922. }
  5923. pet = client->GetPlayer()->GetCosmeticPet();
  5924. if (pet) {
  5925. if (pet->IsPrivateSpawn())
  5926. client->GetPlayer()->HideCosmeticPet(false);
  5927. else
  5928. client->GetPlayer()->HideCosmeticPet(true);
  5929. }
  5930. return;
  5931. }
  5932. // below is for all combat pets
  5933. if (!client->GetPlayer()->HasPet()) {
  5934. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  5935. return;
  5936. }
  5937. if (strcmp(sep->arg[0], "stay") == 0) {
  5938. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  5939. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  5940. client->GetPlayer()->SetCharSheetChanged(true);
  5941. if (client->GetPlayer()->GetPet())
  5942. client->GetPlayer()->GetPet()->following = false;
  5943. if (client->GetPlayer()->GetCharmedPet())
  5944. client->GetPlayer()->GetCharmedPet()->following = false;
  5945. }
  5946. else if (strcmp(sep->arg[0], "follow") == 0) {
  5947. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  5948. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  5949. client->GetPlayer()->SetCharSheetChanged(true);
  5950. }
  5951. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  5952. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  5953. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  5954. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  5955. }
  5956. else {
  5957. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  5958. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  5959. }
  5960. client->GetPlayer()->SetCharSheetChanged(true);
  5961. }
  5962. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  5963. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  5964. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  5965. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  5966. }
  5967. else {
  5968. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  5969. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  5970. }
  5971. client->GetPlayer()->SetCharSheetChanged(true);
  5972. }
  5973. else if (strcmp(sep->arg[0], "backoff") == 0) {
  5974. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  5975. if (client->GetPlayer()->GetPet())
  5976. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  5977. if (client->GetPlayer()->GetCharmedPet())
  5978. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  5979. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  5980. client->GetPlayer()->SetCharSheetChanged(true);
  5981. }
  5982. else if (strcmp(sep->arg[0], "attack") == 0) {
  5983. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  5984. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  5985. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  5986. if (client->GetPlayer()->GetPet())
  5987. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5988. if (client->GetPlayer()->GetCharmedPet())
  5989. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5990. }
  5991. else
  5992. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  5993. }
  5994. else
  5995. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  5996. }
  5997. else if (strcmp(sep->arg[0], "getlost") == 0) {
  5998. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  5999. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6000. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6001. }
  6002. else
  6003. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6004. }
  6005. /*
  6006. Function: Command_PetName()
  6007. Purpose : Pet your name (???)
  6008. Params :
  6009. Dev :
  6010. Example :
  6011. */
  6012. void Commands::Command_PetName(Client* client, Seperator* sep)
  6013. {
  6014. PrintSep(sep, "COMMAND_PETNAME");
  6015. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6016. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6017. }
  6018. /*
  6019. Function: Command_NamePet()
  6020. Purpose : Name your pet
  6021. Params :
  6022. Dev :
  6023. Example :
  6024. */
  6025. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6026. {
  6027. PrintSep(sep, "COMMAND_NAME_PET");
  6028. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6029. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6030. }
  6031. /*
  6032. Function: Command_Rename()
  6033. Purpose : Renames existing pet
  6034. Params :
  6035. Dev :
  6036. Example :
  6037. */
  6038. void Commands::Command_Rename(Client* client, Seperator* sep)
  6039. {
  6040. PrintSep(sep, "COMMAND_RENAME");
  6041. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6042. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6043. }
  6044. /*
  6045. Function: Command_ConfirmRename()
  6046. Purpose : Confirms renaming your pet
  6047. Params :
  6048. Dev :
  6049. Example :
  6050. */
  6051. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6052. {
  6053. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6054. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6055. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6056. }
  6057. /*
  6058. Function: Command_PetOptions()
  6059. Purpose : Sets various pet options
  6060. Params :
  6061. Dev :
  6062. Example :
  6063. */
  6064. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6065. {
  6066. PrintSep(sep, "COMMAND_PETOPTIONS");
  6067. Player* player = client->GetPlayer();
  6068. Spawn* target = player->GetTarget();
  6069. if (!target)
  6070. return;
  6071. if (target == player->GetPet())
  6072. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6073. else if (target == player->GetCharmedPet())
  6074. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6075. else if (target == player->GetCosmeticPet())
  6076. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6077. else if (target == player->GetDeityPet())
  6078. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6079. }
  6080. /*
  6081. Function: Command_Random()
  6082. Purpose : Handles /random dice roll in-game
  6083. Params : 1-100
  6084. Dev : Scatman
  6085. Example : /randon 1 100
  6086. */
  6087. void Commands::Command_Random(Client* client, Seperator* sep)
  6088. {
  6089. char message[256] = {0};
  6090. if (sep)
  6091. {
  6092. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6093. 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])));
  6094. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6095. 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])));
  6096. else
  6097. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6098. }
  6099. else
  6100. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6101. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6102. }
  6103. /*
  6104. Function: Command_Randomize()
  6105. Purpose : Sets randomize (appearance) values for NPCs
  6106. Params : Attrib Name
  6107. Dev : Scatman
  6108. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6109. */
  6110. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6111. {
  6112. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6113. if (target)
  6114. {
  6115. if (target->IsNPC())
  6116. {
  6117. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6118. {
  6119. const char* value = sep->arg[0];
  6120. if (strncasecmp(value, "show", strlen(value)) == 0)
  6121. {
  6122. client->DisplayRandomizeFeatures(target->GetRandomize());
  6123. }
  6124. else
  6125. {
  6126. if (sep->arg[1] && sep->IsNumber(1))
  6127. {
  6128. int8 option = atoi(sep->arg[1]);
  6129. if (option == 0 || option == 1)
  6130. {
  6131. int32 feature = 0;
  6132. char feature_text[32] = {0};
  6133. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6134. feature = RANDOMIZE_GENDER;
  6135. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6136. }
  6137. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6138. feature = RANDOMIZE_RACE;
  6139. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6140. }
  6141. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6142. feature = RANDOMIZE_MODEL_TYPE;
  6143. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6144. }
  6145. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6146. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6147. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6148. }
  6149. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6150. feature = RANDOMIZE_HAIR_TYPE;
  6151. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6152. }
  6153. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6154. feature = RANDOMIZE_WING_TYPE;
  6155. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6156. }
  6157. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6158. feature = RANDOMIZE_CHEEK_TYPE;
  6159. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6160. }
  6161. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6162. feature = RANDOMIZE_CHIN_TYPE;
  6163. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6164. }
  6165. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6166. feature = RANDOMIZE_EAR_TYPE;
  6167. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6168. }
  6169. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6170. feature = RANDOMIZE_EYE_BROW_TYPE;
  6171. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6172. }
  6173. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6174. feature = RANDOMIZE_EYE_TYPE;
  6175. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6176. }
  6177. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6178. feature = RANDOMIZE_LIP_TYPE;
  6179. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6180. }
  6181. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6182. feature = RANDOMIZE_NOSE_TYPE;
  6183. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6184. }
  6185. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6186. feature = RANDOMIZE_EYE_COLOR;
  6187. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6188. }
  6189. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6190. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6191. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6192. }
  6193. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6194. feature = RANDOMIZE_HAIR_COLOR1;
  6195. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6196. }
  6197. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6198. feature = RANDOMIZE_HAIR_COLOR2;
  6199. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6200. }
  6201. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6202. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6203. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6204. }
  6205. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6206. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6207. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6208. }
  6209. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6210. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6211. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6212. }
  6213. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6214. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6215. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6216. }
  6217. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6218. feature = RANDOMIZE_SKIN_COLOR;
  6219. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6220. }
  6221. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6222. feature = RANDOMIZE_WING_COLOR1;
  6223. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6224. }
  6225. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6226. feature = RANDOMIZE_WING_COLOR2;
  6227. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6228. }
  6229. else {
  6230. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6231. 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'.");
  6232. }
  6233. if (feature > 0) {
  6234. if (option == 1) {
  6235. if (target->GetRandomize() & feature)
  6236. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6237. else {
  6238. target->AddRandomize(feature);
  6239. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6240. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6241. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6242. }
  6243. }
  6244. else {
  6245. if (target->GetRandomize() & feature) {
  6246. target->AddRandomize(-feature);
  6247. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6248. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6249. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6250. }
  6251. else
  6252. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6253. }
  6254. }
  6255. }
  6256. else
  6257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6258. }
  6259. else
  6260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6261. }
  6262. }
  6263. else {
  6264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6265. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6266. 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'.");
  6267. }
  6268. }
  6269. else
  6270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6271. }
  6272. else
  6273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6274. }
  6275. /*
  6276. Function: Command_ShowCloak()
  6277. Purpose : Character Settings combo box for Show Cloak
  6278. Params : true/false
  6279. Dev : John Adams
  6280. Example :
  6281. */
  6282. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6283. {
  6284. Player* player = client->GetPlayer();
  6285. if (sep && sep->arg[0])
  6286. {
  6287. const char* value = sep->arg[0];
  6288. if (strncasecmp(value, "true", strlen(value)) == 0)
  6289. {
  6290. player->set_character_flag(CF_SHOW_CLOAK);
  6291. player->reset_character_flag(CF2_SHOW_RANGED);
  6292. }
  6293. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6294. player->reset_character_flag(CF_SHOW_CLOAK);
  6295. else
  6296. {
  6297. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6298. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6299. }
  6300. }
  6301. }
  6302. /*
  6303. Function: Command_ShowHelm()
  6304. Purpose : Character Settings combo box for Show Helm
  6305. Params : true/false
  6306. Dev : John Adams
  6307. Example :
  6308. */
  6309. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6310. {
  6311. Player* player = client->GetPlayer();
  6312. if (sep && sep->arg[0])
  6313. {
  6314. const char* value = sep->arg[0];
  6315. if (strncasecmp(value, "true", strlen(value)) == 0)
  6316. {
  6317. player->reset_character_flag(CF_HIDE_HELM);
  6318. player->set_character_flag(CF_HIDE_HOOD);
  6319. }
  6320. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6321. player->set_character_flag(CF_HIDE_HELM);
  6322. else
  6323. {
  6324. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6325. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6326. }
  6327. }
  6328. }
  6329. /*
  6330. Function: Command_ShowHood()
  6331. Purpose : Character Settings combo box for Show Hood
  6332. Params : true/false
  6333. Dev : John Adams
  6334. Example :
  6335. */
  6336. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6337. {
  6338. Player* player = client->GetPlayer();
  6339. if (sep && sep->arg[0])
  6340. {
  6341. const char* value = sep->arg[0];
  6342. if (strncasecmp(value, "true", strlen(value)) == 0)
  6343. {
  6344. player->reset_character_flag(CF_HIDE_HOOD);
  6345. player->set_character_flag(CF_HIDE_HELM);
  6346. }
  6347. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6348. player->set_character_flag(CF_HIDE_HOOD);
  6349. else
  6350. {
  6351. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6352. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6353. }
  6354. }
  6355. }
  6356. /*
  6357. Function: Command_ShowHoodHelm()
  6358. Purpose : Character Settings combo box for Show Helm or Hood
  6359. Params : true/false
  6360. Dev : John Adams
  6361. Example :
  6362. */
  6363. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6364. {
  6365. Player* player = client->GetPlayer();
  6366. if (sep && sep->arg[0])
  6367. {
  6368. const char* value = sep->arg[0];
  6369. if (strncasecmp(value, "true", strlen(value)) == 0)
  6370. {
  6371. player->reset_character_flag(CF_HIDE_HOOD);
  6372. player->reset_character_flag(CF_HIDE_HELM);
  6373. }
  6374. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6375. {
  6376. // don't think we ever wind up in here...
  6377. player->set_character_flag(CF_HIDE_HOOD);
  6378. player->set_character_flag(CF_HIDE_HELM);
  6379. }
  6380. else
  6381. {
  6382. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6383. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6384. }
  6385. }
  6386. }
  6387. /*
  6388. Function: Command_ShowRanged()
  6389. Purpose : Character Settings combo box for Show Ranged weapon
  6390. Params : true/false
  6391. Dev : John Adams
  6392. Example :
  6393. */
  6394. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6395. {
  6396. Player* player = client->GetPlayer();
  6397. if (sep && sep->arg[0])
  6398. {
  6399. const char* value = sep->arg[0];
  6400. if (strncasecmp(value, "true", strlen(value)) == 0)
  6401. {
  6402. player->set_character_flag(CF2_SHOW_RANGED);
  6403. player->reset_character_flag(CF_SHOW_CLOAK);
  6404. }
  6405. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6406. player->reset_character_flag(CF2_SHOW_RANGED);
  6407. else
  6408. {
  6409. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6410. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6411. }
  6412. }
  6413. }
  6414. /*
  6415. Function:
  6416. Purpose :
  6417. Params :
  6418. Dev :
  6419. Example :
  6420. */
  6421. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6422. {
  6423. Player* player = 0;
  6424. Client* to_client = 0;
  6425. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6426. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6427. switch(handler)
  6428. {
  6429. case COMMAND_SKILL:
  6430. {
  6431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6433. break;
  6434. }
  6435. case COMMAND_SKILL_ADD:
  6436. {
  6437. if (sep && sep->arg[0])
  6438. {
  6439. const char* skill_name = sep->argplus[0];
  6440. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6441. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6442. {
  6443. player = to_client->GetPlayer();
  6444. if (player)
  6445. {
  6446. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6447. {
  6448. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6449. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6450. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6451. }
  6452. else
  6453. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6454. }
  6455. }
  6456. else if (skill) // add skill to yourself
  6457. {
  6458. player = client->GetPlayer();
  6459. if (player)
  6460. {
  6461. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6462. {
  6463. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6464. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6465. }
  6466. else
  6467. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6468. }
  6469. }
  6470. else
  6471. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6472. }
  6473. else
  6474. {
  6475. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6477. }
  6478. break;
  6479. }
  6480. case COMMAND_SKILL_REMOVE:
  6481. {
  6482. if (sep && sep->arg[0])
  6483. {
  6484. const char* skill_name = sep->argplus[0];
  6485. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6486. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6487. {
  6488. player = to_client->GetPlayer();
  6489. if (player)
  6490. {
  6491. if (player->GetSkills()->HasSkill(skill->skill_id))
  6492. {
  6493. player->RemoveSkillFromDB(skill, true);
  6494. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6495. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6496. }
  6497. else
  6498. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6499. }
  6500. }
  6501. else if(skill) // remove skill from yourself
  6502. {
  6503. Player* player = client->GetPlayer();
  6504. if (player)
  6505. {
  6506. if (player->GetSkills()->HasSkill(skill->skill_id))
  6507. {
  6508. player->RemoveSkillFromDB(skill, true);
  6509. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6510. }
  6511. else
  6512. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6513. }
  6514. }
  6515. else
  6516. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6517. }
  6518. else
  6519. {
  6520. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6522. }
  6523. break;
  6524. }
  6525. case COMMAND_SKILL_LIST:
  6526. {
  6527. if (sep && sep->arg[0])
  6528. {
  6529. const char* skill_name = sep->argplus[0];
  6530. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6531. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6532. map<int32, Skill*>::iterator itr;
  6533. if (skills && skills->size() > 0)
  6534. {
  6535. for (itr = skills->begin(); itr != skills->end(); itr++)
  6536. {
  6537. Skill* skill = itr->second;
  6538. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6539. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6540. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6541. }
  6542. }
  6543. }
  6544. else
  6545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6546. break;
  6547. }
  6548. }
  6549. }
  6550. /*
  6551. Function: Command_SpawnTemplate()
  6552. Purpose : Create or Use defined Spawn Templates
  6553. Params : create, save, rempve, list
  6554. Dev : John Adams
  6555. Example : /spawn template create "Test"
  6556. */
  6557. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6558. {
  6559. if (sep == NULL || sep->arg[0] == NULL)
  6560. {
  6561. 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.");
  6562. return;
  6563. }
  6564. // got params, continue
  6565. const char * template_cmd = sep->arg[0];
  6566. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6567. {
  6568. if (!sep->IsSet(1))
  6569. {
  6570. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6571. 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.");
  6572. return;
  6573. }
  6574. map<int32, string>* template_names = 0;
  6575. if (sep->IsNumber(1))
  6576. {
  6577. int32 location_id = 0;
  6578. location_id = atoi(sep->arg[1]);
  6579. template_names = database.GetSpawnTemplateListByID(location_id);
  6580. }
  6581. else
  6582. {
  6583. const char* name = 0;
  6584. name = sep->argplus[1];
  6585. template_names = database.GetSpawnTemplateListByName(name);
  6586. }
  6587. if(!template_names)
  6588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6589. else
  6590. {
  6591. map<int32, string>::iterator itr;
  6592. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6593. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6594. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6595. safe_delete(template_names);
  6596. }
  6597. }
  6598. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6599. {
  6600. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6601. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6602. {
  6603. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6604. {
  6605. // first, lookup to see if template name already exists
  6606. const char* name = 0;
  6607. name = sep->argplus[1];
  6608. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6609. if(!template_names)
  6610. {
  6611. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6612. if( new_template_id > 0 )
  6613. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6614. else
  6615. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6616. }
  6617. else
  6618. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6619. }
  6620. else
  6621. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6622. }
  6623. else
  6624. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6625. }
  6626. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6627. {
  6628. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6629. {
  6630. int32 template_id = 0;
  6631. template_id = atoi(sep->arg[1]);
  6632. if (database.RemoveSpawnTemplate(template_id))
  6633. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6634. else
  6635. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6636. }
  6637. else
  6638. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6639. }
  6640. // Renamed create to spawn
  6641. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6642. {
  6643. if (sep && sep->arg[1][0])
  6644. {
  6645. int32 new_location = 0;
  6646. if (sep->IsNumber(1))
  6647. {
  6648. int32 template_id = 0;
  6649. template_id = atoi(sep->arg[1]);
  6650. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6651. if( new_location > 0 )
  6652. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6653. else
  6654. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6655. }
  6656. else
  6657. {
  6658. const char* name = 0;
  6659. name = sep->argplus[1];
  6660. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6661. if( new_location > 0 )
  6662. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6663. else
  6664. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6665. }
  6666. }
  6667. else
  6668. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6669. }
  6670. else
  6671. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6672. }
  6673. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6674. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6675. float new_speed = atof(sep->arg[0]);
  6676. if (new_speed > 0.0f)
  6677. {
  6678. client->GetPlayer()->SetSpeed(new_speed);
  6679. client->GetPlayer()->SetCharSheetChanged(true);
  6680. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6681. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6682. }
  6683. else
  6684. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6685. }
  6686. else{
  6687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6688. }
  6689. }
  6690. /*
  6691. Function: Command_StationMarketPlace()
  6692. Purpose : just trying to eat the console spam for now
  6693. Params :
  6694. Dev : John
  6695. */
  6696. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6697. {
  6698. PrintSep(sep, "COMMAND_SMP");
  6699. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6700. // can't seem to reduce it any more get rid of it completely...
  6701. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6702. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6703. if (packet) {
  6704. packet->setDataByName("account_id", client->GetAccountID());
  6705. packet->setDataByName("character_id", client->GetCharacterID());
  6706. packet->setDataByName("unknown1", 1, 5);
  6707. packet->setDataByName("unknown1", 26, 6);
  6708. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6709. packet->setDataByName("unknown3", 248, 1);
  6710. client->QueuePacket(packet->serialize());
  6711. }
  6712. safe_delete(packet);
  6713. }
  6714. }
  6715. /*
  6716. Function: Command_StopDrinking()
  6717. Purpose : Stops player from auto-consuming drink
  6718. Params :
  6719. Dev : Zcoretri
  6720. Example : /stopdrinking
  6721. */
  6722. void Commands::Command_StopDrinking(Client* client)
  6723. {
  6724. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6725. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6726. }
  6727. /*
  6728. Function: Command_StopEating()
  6729. Purpose : Stops player from auto-consuming food
  6730. Params :
  6731. Dev : Zcoretri
  6732. Example : /stopeating
  6733. */
  6734. void Commands::Command_StopEating(Client* client)
  6735. {
  6736. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6737. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6738. }
  6739. /*
  6740. Function: Command_Title()
  6741. Purpose : Help for /title command
  6742. Params : n/a
  6743. Dev : Zcoretri
  6744. Example : /title
  6745. */
  6746. void Commands::Command_Title(Client* client)
  6747. {
  6748. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6749. }
  6750. /*
  6751. Function: Command_TitleList()
  6752. Purpose : List available titles for player
  6753. Params : n/a
  6754. Dev : Zcoretri
  6755. Example : /title list
  6756. */
  6757. void Commands::Command_TitleList(Client* client)
  6758. {
  6759. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6760. list<Title*>::iterator itr;
  6761. Title* title;
  6762. int16 i = 0;
  6763. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6764. for(itr = titles->begin(); itr != titles->end(); itr++)
  6765. {
  6766. title = *itr;
  6767. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6768. i++;
  6769. }
  6770. }
  6771. /*
  6772. Function: Command_TitleSetPrefix()
  6773. Purpose : Set Prefix title for player
  6774. Params : Title ID
  6775. Dev : Zcoretri
  6776. Example : /title setprefix 1
  6777. */
  6778. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6779. {
  6780. if (sep && sep->arg[0] && sep->IsNumber(0))
  6781. {
  6782. int32 index = atoul(sep->arg[0]);
  6783. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6784. client->SendTitleUpdate();
  6785. }
  6786. }
  6787. /*
  6788. Function: Command_TitleSetSuffix()
  6789. Purpose : Set Suffix title for player
  6790. Params : Title ID
  6791. Dev : Zcoretri
  6792. Example : /title setsuffix 1
  6793. */
  6794. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6795. {
  6796. if (sep && sep->arg[0] && sep->IsNumber(0))
  6797. {
  6798. int32 index = atoul(sep->arg[0]);
  6799. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6800. client->SendTitleUpdate();
  6801. }
  6802. }
  6803. /*
  6804. Function: Command_TitleFix()
  6805. Purpose : Fix title for player (???)
  6806. Params :
  6807. Dev : Zcoretri
  6808. Example :
  6809. */
  6810. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6811. {
  6812. PrintSep(sep, "COMMAND_TITLE_FIX");
  6813. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6814. }
  6815. /*
  6816. Function: Command_Toggle_Anonymous()
  6817. Purpose : Toggles player Anonymous
  6818. Params :
  6819. Dev : paulgh
  6820. Example : /anon
  6821. */
  6822. void Commands::Command_Toggle_Anonymous(Client* client)
  6823. {
  6824. Player* player = client->GetPlayer();
  6825. player->toggle_character_flag(CF_ANONYMOUS);
  6826. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6827. if (player->get_character_flag(CF_ANONYMOUS))
  6828. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6829. else
  6830. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6831. }
  6832. /*
  6833. Function: Command_Toggle_AutoConsume()
  6834. Purpose : Toggles player food/drink auto consume
  6835. Params : unknown
  6836. Dev : paulgh
  6837. Example : /set_auto_consume
  6838. */
  6839. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  6840. {
  6841. Player* player = client->GetPlayer();
  6842. if (sep && sep->arg[0])
  6843. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  6844. if (sep && sep->arg[0] && sep->IsNumber(0))
  6845. {
  6846. int8 slot = atoi(sep->arg[0]);
  6847. int8 flag = atoi(sep->arg[1]);
  6848. if (slot == EQ2_FOOD_SLOT)
  6849. {
  6850. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  6851. player->SetCharSheetChanged(true);
  6852. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6853. if (flag == 1)
  6854. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  6855. else
  6856. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  6857. }
  6858. else
  6859. {
  6860. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  6861. player->SetCharSheetChanged(true);
  6862. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6863. if (flag == 1)
  6864. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  6865. else
  6866. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  6867. }
  6868. }
  6869. }
  6870. /*
  6871. Function: Command_Toggle_BonusXP()
  6872. Purpose : Toggles player Bonus XP
  6873. Params :
  6874. Dev : John Adams
  6875. Example : /disable_char_bonus_exp
  6876. */
  6877. void Commands::Command_Toggle_BonusXP(Client* client)
  6878. {
  6879. Player* player = client->GetPlayer();
  6880. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  6881. player->SetCharSheetChanged(true);
  6882. }
  6883. /*
  6884. Function: Command_Toggle_CombatXP()
  6885. Purpose : Toggles player Adventure XP
  6886. Params :
  6887. Dev : John Adams
  6888. Example : /disable_combat_exp
  6889. */
  6890. void Commands::Command_Toggle_CombatXP(Client* client)
  6891. {
  6892. Player* player = client->GetPlayer();
  6893. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  6894. player->SetCharSheetChanged(true);
  6895. }
  6896. /*
  6897. Function: Command_Toggle_GMHide()
  6898. Purpose : Toggles hiding player GM status
  6899. Params :
  6900. Dev : Scatman
  6901. Example : /gm_hide
  6902. */
  6903. void Commands::Command_Toggle_GMHide(Client* client)
  6904. {
  6905. Player* player = client->GetPlayer();
  6906. player->toggle_character_flag(CF_HIDE_STATUS);
  6907. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  6908. }
  6909. /*
  6910. Function: Command_Toggle_GMVanish()
  6911. Purpose : Toggles hiding GM players from /who searches
  6912. Params :
  6913. Dev : Scatman
  6914. Example : /gm_vanish
  6915. */
  6916. void Commands::Command_Toggle_GMVanish(Client* client)
  6917. {
  6918. Player* player = client->GetPlayer();
  6919. player->toggle_character_flag(CF_GM_HIDDEN);
  6920. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  6921. }
  6922. /*
  6923. Function: Command_Toggle_Illusions()
  6924. Purpose : Toggles player illusion form
  6925. Params : not sure sep is needed, testing
  6926. Dev : paulgh
  6927. Example : /hide_illusions
  6928. */
  6929. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  6930. {
  6931. if (sep && sep->arg[0])
  6932. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  6933. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  6934. }
  6935. /*
  6936. Function: Command_Toggle_LFG()
  6937. Purpose : Toggles player LFG Flag
  6938. Params :
  6939. Dev : paulgh
  6940. Example : /lfg
  6941. */
  6942. void Commands::Command_Toggle_LFG(Client* client)
  6943. {
  6944. Player* player = client->GetPlayer();
  6945. player->toggle_character_flag(CF_LFG);
  6946. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  6947. if (player->get_character_flag(CF_LFG))
  6948. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  6949. else
  6950. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  6951. }
  6952. /*
  6953. Function: Command_Toggle_LFW()
  6954. Purpose : Toggles player LFW Flag
  6955. Params :
  6956. Dev : paulgh
  6957. Example : /lfw
  6958. */
  6959. void Commands::Command_Toggle_LFW(Client* client)
  6960. {
  6961. Player* player = client->GetPlayer();
  6962. player->toggle_character_flag(CF_LFW);
  6963. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  6964. if (player->get_character_flag(CF_LFW))
  6965. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  6966. else
  6967. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  6968. }
  6969. /*
  6970. Function: Command_Toggle_QuestXP()
  6971. Purpose : Toggles player Quest XP
  6972. Params :
  6973. Dev : John Adams
  6974. Example : /disable_quest_exp
  6975. */
  6976. void Commands::Command_Toggle_QuestXP(Client* client)
  6977. {
  6978. Player* player = client->GetPlayer();
  6979. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  6980. player->SetCharSheetChanged(true);
  6981. }
  6982. /*
  6983. Function: Command_Toggle_Roleplaying()
  6984. Purpose : Toggles player Roleplaying flag
  6985. Params :
  6986. Dev : paulgh
  6987. Example : /role
  6988. */
  6989. void Commands::Command_Toggle_Roleplaying(Client* client)
  6990. {
  6991. Player* player = client->GetPlayer();
  6992. player->toggle_character_flag(CF_ROLEPLAYING);
  6993. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  6994. if (player->get_character_flag(CF_ROLEPLAYING))
  6995. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  6996. else
  6997. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  6998. }
  6999. void Commands::Command_Toggle_Duels(Client* client)
  7000. {
  7001. Player* player = client->GetPlayer();
  7002. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7003. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7004. }
  7005. void Commands::Command_Toggle_Trades(Client* client)
  7006. {
  7007. Player* player = client->GetPlayer();
  7008. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7009. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7010. }
  7011. void Commands::Command_Toggle_Guilds(Client* client)
  7012. {
  7013. Player* player = client->GetPlayer();
  7014. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7015. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7016. }
  7017. void Commands::Command_Toggle_Groups(Client* client)
  7018. {
  7019. Player* player = client->GetPlayer();
  7020. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7021. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7022. }
  7023. void Commands::Command_Toggle_Raids(Client* client)
  7024. {
  7025. Player* player = client->GetPlayer();
  7026. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7027. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7028. }
  7029. void Commands::Command_Toggle_LON(Client* client)
  7030. {
  7031. Player* player = client->GetPlayer();
  7032. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7033. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7034. }
  7035. void Commands::Command_Toggle_VoiceChat(Client* client)
  7036. {
  7037. Player* player = client->GetPlayer();
  7038. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7039. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7040. }
  7041. /*
  7042. Function: Command_TradeStart()
  7043. Purpose : Starts item/coin trade between players
  7044. Params :
  7045. Dev :
  7046. Example :
  7047. */
  7048. #include "../Trade.h"
  7049. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7050. {
  7051. PrintSep(sep, "COMMAND_START_TRADE");
  7052. Entity* trader = client->GetPlayer();
  7053. Entity* trader2 = 0;
  7054. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7055. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7056. if (spawn) {
  7057. if (spawn->IsEntity())
  7058. trader2 = (Entity*)spawn;
  7059. }
  7060. }
  7061. else if (client->GetPlayer()->GetTarget()) {
  7062. if (client->GetPlayer()->GetTarget()->IsEntity())
  7063. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7064. }
  7065. // can only trade with player or bots
  7066. if (trader && trader2) {
  7067. if (trader == trader2) {
  7068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7069. }
  7070. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7071. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7072. if (trader->trade)
  7073. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7074. else if (trader2->trade)
  7075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7076. else {
  7077. Trade* trade = new Trade(trader, trader2);
  7078. trader->trade = trade;
  7079. trader2->trade = trade;
  7080. }
  7081. }
  7082. else {
  7083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7084. }
  7085. }
  7086. else
  7087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7088. }
  7089. /*
  7090. Function: Command_Track()
  7091. Purpose : Starts/Stops Tracking for a player
  7092. Params :
  7093. Dev : Scatman
  7094. Example : /track
  7095. */
  7096. void Commands::Command_Track(Client* client)
  7097. {
  7098. if (!client->GetPlayer()->GetIsTracking())
  7099. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7100. else
  7101. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7102. }
  7103. /*
  7104. Function: Command_TradeAccept()
  7105. Purpose : Accepts item/coin trade between players
  7106. Params :
  7107. Dev :
  7108. Example :
  7109. */
  7110. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7111. {
  7112. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7113. Trade* trade = client->GetPlayer()->trade;
  7114. if (trade) {
  7115. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7116. if (trade_complete)
  7117. safe_delete(trade);
  7118. }
  7119. else
  7120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7121. }
  7122. /*
  7123. Function: Command_TradeReject()
  7124. Purpose : Rejects item/coin trade between players
  7125. Params :
  7126. Dev :
  7127. Example :
  7128. */
  7129. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7130. {
  7131. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7132. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7133. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7134. }
  7135. /*
  7136. Function: Command_TradeCancel()
  7137. Purpose : Cancels item/coin trade between players
  7138. Params :
  7139. Dev :
  7140. Example :
  7141. */
  7142. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7143. {
  7144. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7145. Trade* trade = client->GetPlayer()->trade;
  7146. if (trade) {
  7147. trade->CancelTrade(client->GetPlayer());
  7148. safe_delete(trade);
  7149. }
  7150. else
  7151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7152. }
  7153. /*
  7154. Function: Command_TradeSetCoin()
  7155. Purpose : Sets coin trade between players
  7156. Params :
  7157. Dev :
  7158. Example :
  7159. */
  7160. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7161. {
  7162. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7163. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7164. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7165. }
  7166. /*
  7167. Function: Command_TradeAddCoin()
  7168. Purpose : Adds coin to trade between players
  7169. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7170. Dev :
  7171. Example :
  7172. */
  7173. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7174. {
  7175. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7176. Trade* trade = client->GetPlayer()->trade;
  7177. if (trade) {
  7178. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7179. int32 amount = atoi(sep->arg[0]);
  7180. int64 val = 0;
  7181. switch (handler) {
  7182. case COMMAND_ADD_TRADE_COPPER:
  7183. {
  7184. val = amount;
  7185. trade->AddCoinToTrade(client->GetPlayer(), val);
  7186. break;
  7187. }
  7188. case COMMAND_ADD_TRADE_SILVER:
  7189. {
  7190. val = amount * 100;
  7191. trade->AddCoinToTrade(client->GetPlayer(), val);
  7192. break;
  7193. }
  7194. case COMMAND_ADD_TRADE_GOLD:
  7195. {
  7196. val = amount * 10000;
  7197. trade->AddCoinToTrade(client->GetPlayer(), val);
  7198. break;
  7199. }
  7200. case COMMAND_ADD_TRADE_PLAT:
  7201. {
  7202. val = amount * 1000000;
  7203. trade->AddCoinToTrade(client->GetPlayer(), val);
  7204. break;
  7205. }
  7206. default:
  7207. {
  7208. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7209. break;
  7210. }
  7211. }
  7212. }
  7213. else
  7214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7215. }
  7216. else
  7217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7218. }
  7219. /*
  7220. Function: Command_TradeRemoveCoin()
  7221. Purpose : Removes coin from trade between players
  7222. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7223. Dev :
  7224. Example :
  7225. */
  7226. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7227. {
  7228. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7229. Trade* trade = client->GetPlayer()->trade;
  7230. if (trade) {
  7231. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7232. int32 amount = atoi(sep->arg[0]);
  7233. int64 val = 0;
  7234. switch (handler) {
  7235. case COMMAND_REMOVE_TRADE_COPPER:
  7236. {
  7237. val = amount;
  7238. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7239. break;
  7240. }
  7241. case COMMAND_REMOVE_TRADE_SILVER:
  7242. {
  7243. val = amount * 100;
  7244. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7245. break;
  7246. }
  7247. case COMMAND_REMOVE_TRADE_GOLD:
  7248. {
  7249. val = amount * 10000;
  7250. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7251. break;
  7252. }
  7253. case COMMAND_REMOVE_TRADE_PLAT:
  7254. {
  7255. val = amount * 1000000;
  7256. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7257. break;
  7258. }
  7259. default:
  7260. {
  7261. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7262. break;
  7263. }
  7264. }
  7265. }
  7266. else
  7267. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7268. }
  7269. else
  7270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7271. }
  7272. /*
  7273. Function: Command_TradeAddItem()
  7274. Purpose : Adds item to trade between players
  7275. Params :
  7276. Dev :
  7277. Example :
  7278. */
  7279. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7280. {
  7281. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7282. /*
  7283. arg[0] = item index
  7284. arg[1] = slot
  7285. arg[2] = quantity
  7286. */
  7287. if (!client->GetPlayer()->trade) {
  7288. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7290. return;
  7291. }
  7292. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7293. Item* item = 0;
  7294. int32 index = atoi(sep->arg[0]);
  7295. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7296. if (item) {
  7297. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7298. if (result == 1)
  7299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7300. else if (result == 2)
  7301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7302. else if (result == 3)
  7303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7304. else if (result == 255)
  7305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7306. }
  7307. else {
  7308. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7309. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7310. }
  7311. }
  7312. else
  7313. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7314. }
  7315. /*
  7316. Function: Command_TradeRemoveItem()
  7317. Purpose : Removes item from trade between players
  7318. Params :
  7319. Dev :
  7320. Example :
  7321. */
  7322. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7323. {
  7324. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7325. /*
  7326. arg[0] = trade window slot
  7327. */
  7328. Trade* trade = client->GetPlayer()->trade;
  7329. if (trade) {
  7330. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7331. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7332. }
  7333. else
  7334. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7335. }
  7336. else
  7337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7338. }
  7339. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7340. {
  7341. Item *item = 0;
  7342. sint32 crc;
  7343. if (sep) {
  7344. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7345. if (client->GetVersion() < 1096) {
  7346. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7347. {
  7348. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7349. crc = atol(sep->arg[2]);
  7350. }
  7351. }
  7352. else {
  7353. // From the broker and links in chat
  7354. if (strcmp(sep->arg[0], "crc") == 0) {
  7355. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7356. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7357. crc = atol(sep->arg[3]);
  7358. }
  7359. }
  7360. // From inventory
  7361. if (strcmp(sep->arg[0], "dbid") == 0) {
  7362. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7363. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7364. crc = atol(sep->arg[4]);
  7365. }
  7366. }
  7367. }
  7368. if (item)
  7369. client->ShowDressingRoom(item, crc);
  7370. }
  7371. }
  7372. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7373. const char *channel_name, *password = NULL;
  7374. if (sep == NULL || !sep->IsSet(0)) {
  7375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7376. return;
  7377. }
  7378. channel_name = sep->arg[0];
  7379. if (sep->IsSet(1))
  7380. password = sep->arg[1];
  7381. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7382. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7383. return;
  7384. }
  7385. if (chat.IsInChannel(client, channel_name)) {
  7386. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7387. return;
  7388. }
  7389. if (chat.HasPassword(channel_name)) {
  7390. if (password == NULL) {
  7391. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7392. return;
  7393. }
  7394. if (!chat.PasswordMatches(channel_name, password)) {
  7395. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7396. return;
  7397. }
  7398. }
  7399. if (!chat.JoinChannel(client, channel_name))
  7400. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7401. }
  7402. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7403. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7404. Command_JoinChannel(client, sep);
  7405. }
  7406. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7407. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7409. PrintSep(sep, "tellchannel");
  7410. return;
  7411. }
  7412. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7413. }
  7414. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7415. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7416. if (!p) return;
  7417. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7418. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7419. //}
  7420. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7421. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7422. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7423. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7424. if (packet) {
  7425. client->QueuePacket(packet->serialize());
  7426. safe_delete(packet);
  7427. }
  7428. }*/
  7429. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7430. int32 numFaces = 0;
  7431. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7432. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7433. map<int32, vector<Face*> >::iterator itr;
  7434. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7435. numFaces += (*itr).second.size();
  7436. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7437. }*/
  7438. //uchar blah[] = {
  7439. // 1208 - OP_EQUpdateStoreCmd
  7440. // /*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
  7441. // /*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
  7442. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7443. // /*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
  7444. /*};
  7445. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7446. int8 val = 0;
  7447. int16 pos = 0;
  7448. int idx = 0;
  7449. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7450. pos = atoi(sep2->arg[idx]);
  7451. val = atoi(sep2->arg[idx+1]);
  7452. memset(blah+pos, val, 1);
  7453. idx+=2;
  7454. }
  7455. DumpPacket(blah, sizeof(blah));
  7456. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7457. if (client->GetPlayer()->GetTarget()) {
  7458. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7459. if (packet) {
  7460. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7461. packet->setDataByName("size", 0);
  7462. packet->setDataByName("unknown2", 0);
  7463. EQ2Packet* app = packet->serialize();
  7464. client->QueuePacket(app);
  7465. safe_delete(packet);
  7466. }
  7467. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7468. if (set_pov) {
  7469. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7470. EQ2Packet* app_pov = set_pov->serialize();
  7471. client->QueuePacket(app_pov);
  7472. safe_delete(set_pov);
  7473. }
  7474. }
  7475. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7476. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7477. if (packet) {
  7478. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7479. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7480. else
  7481. packet->setDataByName("Type", 2);
  7482. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7483. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7484. else
  7485. packet->setDataByName("race_id", 0);
  7486. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7487. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7488. else
  7489. packet->setDataByName("gender", 2);
  7490. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7491. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7492. else
  7493. packet->setDataByName("unknown", 0, 0);
  7494. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7495. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7496. else
  7497. packet->setDataByName("unknown", 0, 1);
  7498. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7499. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7500. else
  7501. packet->setDataByName("unknown", 0, 2);
  7502. client->QueuePacket(packet->serialize());
  7503. }
  7504. safe_delete(packet);
  7505. safe_delete(sep2);
  7506. }
  7507. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7508. const char *channel_name;
  7509. if (sep == NULL || !sep->IsSet(0)) {
  7510. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7511. PrintSep(sep);
  7512. return;
  7513. }
  7514. channel_name = sep->arg[0];
  7515. if (!chat.IsInChannel(client, channel_name))
  7516. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7517. else if (!chat.LeaveChannel(client, channel_name))
  7518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7519. }
  7520. /*
  7521. Function:
  7522. Purpose :
  7523. Params :
  7524. Dev :
  7525. Example :
  7526. */
  7527. void Commands::Command_WeaponStats(Client* client)
  7528. {
  7529. Player* player = client->GetPlayer();
  7530. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7531. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7532. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7533. client->SimpleMessage(0, "Primary:");
  7534. if (primary) {
  7535. client->Message(0, "Name: %s", primary->name.c_str());
  7536. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7537. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7538. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7539. client->Message(0, "Proc Percent: %d%%", 0);
  7540. client->Message(0, "Procs Per Minute: %d", 0);
  7541. }
  7542. else {
  7543. client->SimpleMessage(0, "Name: fist");
  7544. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7545. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7546. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7547. client->Message(0, "Proc Percent: %d%%", 0);
  7548. client->Message(0, "Procs Per Minute: %d", 0);
  7549. }
  7550. client->SimpleMessage(0, " ");
  7551. client->SimpleMessage(0, " ");
  7552. if (secondary) {
  7553. client->SimpleMessage(0, "Secondary:");
  7554. client->Message(0, "Name: %s", secondary->name.c_str());
  7555. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7556. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7557. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7558. client->Message(0, "Proc Percent: %d%%", 0);
  7559. client->Message(0, "Procs Per Minute: %d", 0);
  7560. client->SimpleMessage(0, " ");
  7561. client->SimpleMessage(0, " ");
  7562. }
  7563. client->SimpleMessage(0, "Ranged:");
  7564. if (ranged) {
  7565. client->Message(0, "Name: %s", ranged->name.c_str());
  7566. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7567. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7568. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7569. client->Message(0, "Proc Percent: %d%%", 0);
  7570. client->Message(0, "Procs Per Minute: %d", 0);
  7571. }
  7572. else
  7573. client->SimpleMessage(0, "None");
  7574. }
  7575. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7576. const char *channel_name;
  7577. if (sep == NULL || !sep->IsSet(0)) {
  7578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7579. return;
  7580. }
  7581. channel_name = sep->arg[0];
  7582. if (!chat.ChannelExists(channel_name))
  7583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7584. else
  7585. chat.SendChannelUserList(client, channel_name);
  7586. }
  7587. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7588. {
  7589. ZoneServer* zone = 0;
  7590. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7591. if (zone_id > 0)
  7592. {
  7593. zone = zone_list.Get(zone_id, false);
  7594. if (zone)
  7595. {
  7596. zone->SetSafeX(client->GetPlayer()->GetX());
  7597. zone->SetSafeY(client->GetPlayer()->GetY());
  7598. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7599. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7600. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7602. else
  7603. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7604. }
  7605. }
  7606. }
  7607. /*
  7608. Function:
  7609. Purpose :
  7610. Params :
  7611. Dev :
  7612. Example :
  7613. */
  7614. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7615. {
  7616. ZoneInfo* zone_info = new ZoneInfo;
  7617. if (sep && sep->arg[0])
  7618. {
  7619. if (sep->IsNumber(0))
  7620. zone_info->id = atoi(sep->arg[0]);
  7621. else
  7622. zone_info->id = database.GetZoneID(sep->arg[0]);
  7623. if (zone_info->id > 0)
  7624. {
  7625. database.LoadZoneInfo(zone_info);
  7626. 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);
  7627. 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);
  7628. 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);
  7629. 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);
  7630. 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);
  7631. 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);
  7632. 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);
  7633. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7634. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7635. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7636. }
  7637. else
  7638. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7639. }
  7640. else
  7641. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7642. safe_delete(zone_info);
  7643. }
  7644. /*
  7645. Function:
  7646. Purpose :
  7647. Params :
  7648. Dev :
  7649. Example :
  7650. */
  7651. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7652. {
  7653. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7654. {
  7655. ZoneServer* zone = 0;
  7656. int32 zone_id = 0;
  7657. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7658. {
  7659. zone_id = atoi(sep->arg[0]);
  7660. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7661. }
  7662. else
  7663. {
  7664. zone_id = database.GetZoneID(sep->arg[0]);
  7665. if (zone_id > 0)
  7666. zone = zone_list.Get(sep->arg[0], false);
  7667. }
  7668. if (zone_id > 0)
  7669. {
  7670. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7671. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7672. else
  7673. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7674. }
  7675. else
  7676. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7677. }
  7678. else
  7679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7680. }
  7681. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7682. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7684. return;
  7685. }
  7686. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7687. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7688. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7689. }
  7690. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7691. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7692. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7693. return;
  7694. }
  7695. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7696. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7697. }
  7698. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7699. Spawn* spawn = client->GetPlayer()->GetTarget();
  7700. if(spawn) {
  7701. client->SetMerchantTransaction(spawn);
  7702. if (spawn->GetMerchantID() > 0){
  7703. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7704. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7705. client->SendBuyMerchantList(sell);
  7706. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7707. client->SendSellMerchantList(sell);
  7708. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7709. client->SendBuyBackList(sell);
  7710. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7711. if (packet) {
  7712. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7713. packet->setDataByName("type", 16);
  7714. EQ2Packet* outapp = packet->serialize();
  7715. if (outapp)
  7716. client->QueuePacket(outapp);
  7717. safe_delete(packet);
  7718. }
  7719. }
  7720. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7721. client->SendRepairList();
  7722. }
  7723. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7724. }
  7725. void Commands::Command_Weather(Client* client, Seperator* sep)
  7726. {
  7727. //PrintSep(sep, "Weather");
  7728. if( sep && sep->arg[0] )
  7729. {
  7730. ZoneServer* zsZone = client->GetCurrentZone();
  7731. const char* value = sep->arg[0];
  7732. // process single-param commands first
  7733. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7734. {
  7735. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7736. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7737. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7738. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7739. }
  7740. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7741. {
  7742. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7743. zsZone->ProcessWeather();
  7744. }
  7745. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7746. {
  7747. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7748. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7749. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7750. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7751. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7752. zsZone->SetWeatherPattern(1);
  7753. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7754. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7755. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7756. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7757. zsZone->ProcessWeather();
  7758. }
  7759. // process commands with params
  7760. if( sep->arg[1] )
  7761. {
  7762. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7763. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7764. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7765. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7766. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7767. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7768. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7769. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7770. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7771. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7772. }
  7773. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7774. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7775. zsZone->SetRain(zsZone->GetCurrentWeather());
  7776. }
  7777. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7778. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7779. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7780. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7781. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7782. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7783. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7784. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7785. }
  7786. }
  7787. else
  7788. {
  7789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7792. return;
  7793. }
  7794. }
  7795. void Commands::Command_Select(Client* client, Seperator* sep) {
  7796. if (sep && sep->arg[1]) {
  7797. Spawn* spawn = client->GetPlayer()->GetTarget();
  7798. if (spawn && strlen(sep->arg[1]) > 0)
  7799. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7800. }
  7801. }
  7802. /*
  7803. Function: Command_ConsumeFood()
  7804. Purpose : Consume Food/Drink and apply mods
  7805. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7806. Dev : Zcoretri
  7807. Example : /consume_food 22
  7808. */
  7809. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7810. if (sep && sep->arg[0] && sep->IsNumber(0))
  7811. {
  7812. Player* player = client->GetPlayer();
  7813. int8 slot = atoi(sep->arg[0]);
  7814. Item* item = player->GetEquipmentList()->GetItem(slot);
  7815. if(item) {
  7816. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7817. if(item->GetItemScript() && lua_interface){
  7818. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7819. if (slot == 22)
  7820. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7821. else
  7822. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7823. }
  7824. }
  7825. if (item->details.count > 1) {
  7826. item->details.count -= 1;
  7827. item->save_needed = true;
  7828. }
  7829. else {
  7830. player->GetEquipmentList()->RemoveItem(slot, true);
  7831. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7832. }
  7833. client->GetPlayer()->SetCharSheetChanged(true);
  7834. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7835. }
  7836. }
  7837. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  7838. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7839. if (atoi(sep->arg[0]) == 1) {
  7840. client->GetPlayer()->GetInfoStruct()->vision = 4;
  7841. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  7842. client->GetPlayer()->SetCharSheetChanged(true);
  7843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  7844. }
  7845. else {
  7846. client->GetPlayer()->GetInfoStruct()->vision = 0;
  7847. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  7848. client->GetPlayer()->SetCharSheetChanged(true);
  7849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  7850. }
  7851. }
  7852. else
  7853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  7854. }
  7855. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  7856. {
  7857. if(sep)
  7858. {
  7859. string data;
  7860. if(sep->arg[0]){
  7861. data = string(sep->arg[0]);
  7862. }
  7863. for(int i=1;i<sep->GetMaxArgNum();i++){
  7864. if(sep->arg[i])
  7865. data.append(" ").append(sep->arg[i]);
  7866. }
  7867. const char* target_name = 0;
  7868. int32 spawn_id = 0;
  7869. if(client->GetPlayer()->GetTarget())
  7870. {
  7871. target_name = client->GetPlayer()->GetTarget()->GetName();
  7872. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7873. }
  7874. else
  7875. target_name = "N/A";
  7876. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  7877. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  7878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  7879. else
  7880. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  7881. }
  7882. }
  7883. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  7884. PrintSep(sep, "Command_Attune_Inv");
  7885. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7886. // Get the item index from the first parameter
  7887. int16 index = atoi(sep->arg[0]);
  7888. // Check to see if this is a valid item index for the player, if not exit out of the function
  7889. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  7890. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  7891. return;
  7892. }
  7893. // Get the item
  7894. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  7895. if(item) {
  7896. // Valid item lets check to make sure this item is attunable, if not return out
  7897. if (!item->CheckFlag(ATTUNEABLE)) {
  7898. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  7899. return;
  7900. }
  7901. // Remove the attunable flag
  7902. item->generic_info.item_flags -= ATTUNEABLE;
  7903. // Set the attuned flag
  7904. item->generic_info.item_flags += ATTUNED;
  7905. // Flag this item for saving
  7906. item->save_needed = true;
  7907. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  7908. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  7909. EQ2Packet* outapp = 0;
  7910. for (int32 i=0;i<packets.size();i++) {
  7911. outapp = packets[i];
  7912. if(outapp)
  7913. client->QueuePacket(outapp);
  7914. }
  7915. }
  7916. }
  7917. }
  7918. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  7919. PrintSep(sep, "Command_Reset_Zone_Timer");
  7920. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7921. int32 db_id = atoul(sep->arg[0]);
  7922. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  7923. if (data) {
  7924. // TODO: add a check to timers to ensure it can be reset
  7925. // Delete the character from the instance
  7926. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  7927. data->instance_id = 0;
  7928. // Update the success time and set to 0 so the player can enter it again
  7929. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  7930. data->last_success_timestamp = 0;
  7931. }
  7932. }*/
  7933. }
  7934. void Commands::Command_Player(Client* client, Seperator* sep) {
  7935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  7936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  7937. }
  7938. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  7939. // /player coins add 10
  7940. // /player coins add plat 10
  7941. Player* player = client->GetPlayer();
  7942. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7943. player = (Player*)player->GetTarget();
  7944. if (sep && sep->arg[0] && sep->arg[1]) {
  7945. const char* action = sep->arg[0];
  7946. int64 value = 0;
  7947. if (strncasecmp(action, "add", strlen(action)) == 0) {
  7948. if (sep->IsNumber(1)) {
  7949. value = atoi64(sep->arg[1]);
  7950. player->AddCoins(value);
  7951. if (client->GetPlayer() == player)
  7952. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7953. else {
  7954. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7955. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7956. }
  7957. return;
  7958. }
  7959. else if (sep->arg[2] && sep->IsNumber(2)) {
  7960. const char* type = sep->arg[1];
  7961. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  7962. value = atoi64(sep->arg[2]);
  7963. }
  7964. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  7965. value = atoi64(sep->arg[2]) * 100;
  7966. }
  7967. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  7968. value = atoi64(sep->arg[2]) * 10000;
  7969. }
  7970. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  7971. value = atoi64(sep->arg[2]) * 1000000;
  7972. }
  7973. player->AddCoins(value);
  7974. if (client->GetPlayer() == player)
  7975. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7976. else {
  7977. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7978. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7979. }
  7980. return;
  7981. }
  7982. }
  7983. }
  7984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  7985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  7986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  7987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  7988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  7989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  7990. }
  7991. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  7992. PrintSep(sep, "ACHIEVEMENT_ADD");
  7993. if (sep && sep->IsSet(0)) {
  7994. int32 spell_id = atoul(sep->arg[1]);
  7995. int8 spell_tier = 0;
  7996. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  7997. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  7998. // addspellbookentry here
  7999. if (spell_tier >= data->maxRank) {
  8000. return;
  8001. }
  8002. if (!spell_tier) {
  8003. spell_tier = 1;
  8004. }
  8005. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8006. {
  8007. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8008. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8009. client->GetPlayer()->UnlockSpell(spell);
  8010. client->SendSpellUpdate(spell);
  8011. }
  8012. else
  8013. {
  8014. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8015. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8016. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8017. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8018. client->GetPlayer()->UnlockSpell(spell);
  8019. client->SendSpellUpdate(spell);
  8020. }
  8021. // cast spell here
  8022. if (!spell_tier)
  8023. spell_tier = 1;
  8024. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8025. if (spell) {
  8026. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8027. }
  8028. }
  8029. else {
  8030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8031. }
  8032. master_aa_list.DisplayAA(client, 0, 0);
  8033. }
  8034. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8035. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8036. if (packet) {
  8037. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8038. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8039. char command[255];
  8040. url = "browser " + url;
  8041. int32 spawn_id = 0;
  8042. int32 zone_id = 0;
  8043. string type;
  8044. if (client->GetCurrentZone())
  8045. zone_id = client->GetCurrentZone()->GetZoneID();
  8046. if (client->GetPlayer()->GetTarget()) {
  8047. Spawn* target = client->GetPlayer()->GetTarget();
  8048. if (target->IsWidget())
  8049. type = "widgets";
  8050. else if (target->IsSign())
  8051. type = "signs";
  8052. else if (target->IsObject())
  8053. type = "objects";
  8054. else if (target->IsNPC())
  8055. type = "npcs";
  8056. else if (target->IsGroundSpawn())
  8057. type = "ground";
  8058. else
  8059. type = "spawn";
  8060. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8061. }
  8062. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8063. packet->setDataByName("accept_command", command);
  8064. }
  8065. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8066. char command[255];
  8067. url = "browser " + url;
  8068. if (client->GetPlayer()->GetTarget())
  8069. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8070. packet->setDataByName("accept_command", command);
  8071. }
  8072. else {
  8073. string command = "browser " + url;
  8074. packet->setDataByName("accept_command", command.c_str());
  8075. }
  8076. packet->setDataByName("text", "Open the web editor?");
  8077. packet->setDataByName("accept_text", "Open");
  8078. packet->setDataByName("cancel_text", "Cancel");
  8079. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8080. packet->setDataByName("unknown2", 50);
  8081. packet->setDataByName("unknown4", 1);
  8082. client->QueuePacket(packet->serialize());
  8083. safe_delete(packet);
  8084. }
  8085. }
  8086. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8087. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8088. return;
  8089. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8090. if(client->GetCurrentRez()->active)
  8091. client->AcceptResurrection();
  8092. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8093. }
  8094. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8095. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8096. return;
  8097. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8098. if(client->GetCurrentRez()->active)
  8099. client->GetCurrentRez()->should_delete = true;
  8100. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8101. }
  8102. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8103. PrintSep(sep, "Switch_AA_Profile");
  8104. if (sep && sep->IsSet(0)) {
  8105. string type = sep->arg[0];
  8106. int8 newtemplate = atoul(sep->arg[1]);
  8107. master_aa_list.DisplayAA(client, newtemplate, 1);
  8108. }
  8109. }
  8110. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8111. PrintSep(sep, "Get_AA_Xml");
  8112. if (sep && sep->IsSet(0)) {
  8113. string tabnum = sep->arg[0];
  8114. string spellid = sep->arg[1];
  8115. }
  8116. }
  8117. void Commands::Add_AA(Client* client, Seperator* sep) {
  8118. PrintSep(sep, "Add_AA");
  8119. if (sep && sep->IsSet(0)) {
  8120. int32 spell_id = atoul(sep->arg[1]);
  8121. int8 spell_tier = 0;
  8122. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8123. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8124. // addspellbookentry here
  8125. if (spell_tier >= data->maxRank) {
  8126. return;
  8127. }
  8128. if (!spell_tier) {
  8129. spell_tier = 1;
  8130. }
  8131. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8132. {
  8133. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8134. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8135. client->GetPlayer()->UnlockSpell(spell);
  8136. client->SendSpellUpdate(spell);
  8137. }
  8138. else
  8139. {
  8140. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8141. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8142. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8143. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8144. client->GetPlayer()->UnlockSpell(spell);
  8145. client->SendSpellUpdate(spell);
  8146. }
  8147. // cast spell here
  8148. if (!spell_tier)
  8149. spell_tier = 1;
  8150. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8151. if (spell) {
  8152. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8153. }
  8154. }
  8155. else {
  8156. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8157. }
  8158. master_aa_list.DisplayAA(client, 0, 0);
  8159. }
  8160. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8161. PrintSep(sep, "Commit_AA_Profile");
  8162. if (sep && sep->IsSet(0)) {
  8163. }
  8164. }
  8165. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8166. PrintSep(sep, "Begin_AA_Profile");
  8167. if (sep && sep->IsSet(0)) {
  8168. master_aa_list.DisplayAA(client, 100, 2);
  8169. }
  8170. }
  8171. void Commands::Back_AA(Client* client, Seperator* sep) {
  8172. if (sep && sep->IsSet(0)) {
  8173. PrintSep(sep, "Back_AA");
  8174. }
  8175. }
  8176. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8177. if (sep && sep->IsSet(0)) {
  8178. PrintSep(sep, "Remove_AA");
  8179. }
  8180. }
  8181. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8182. MasterAAList master_aa_list;
  8183. PrintSep(sep, "Cancel_AA_Profile");
  8184. master_aa_list.DisplayAA(client, 0, 0);
  8185. }
  8186. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8187. if (sep && sep->IsSet(0)) {
  8188. PrintSep(sep, "Save_AA_Profile");
  8189. }
  8190. }
  8191. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8192. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8193. if (!sep->IsNumber(0)) return;
  8194. int32 request_id = atoul(sep->arg[0]);
  8195. if (!sep->IsNumber(1)) return;
  8196. sint32 item_id = atoi(sep->arg[1]);
  8197. if (client->IsCurrentTransmuteID(request_id)) {
  8198. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8199. }
  8200. else if (client->IsCurrentTransmuteID(item_id)) {
  8201. if (!sep->IsSet(2)) return;
  8202. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8203. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8204. }
  8205. }
  8206. }