Commands.cpp 310 KB

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