Commands.cpp 329 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. break;
  1062. }
  1063. case COMMAND_RELOADSTRUCTS: {
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1065. configReader.ReloadStructs();
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1067. break;
  1068. }
  1069. case COMMAND_RELOAD_QUESTS: {
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1071. master_quest_list.Reload();
  1072. client_list.ReloadQuests();
  1073. zone_list.ReloadClientQuests();
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1075. break;
  1076. }
  1077. case COMMAND_RELOAD_SPAWNS: {
  1078. client->GetCurrentZone()->ReloadSpawns();
  1079. break;
  1080. }
  1081. case COMMAND_RELOAD_SPELLS: {
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1083. zone_list.DeleteSpellProcess();
  1084. master_spell_list.Reload();
  1085. if (lua_interface)
  1086. lua_interface->ReloadSpells();
  1087. zone_list.LoadSpellProcess();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1093. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1094. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_ZONESCRIPTS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1100. world.ResetZoneScripts();
  1101. database.LoadZoneScriptData();
  1102. if (lua_interface)
  1103. lua_interface->DestroyZoneScripts();
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1105. break;
  1106. }
  1107. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1109. client->GetCurrentZone()->ClearEntityCommands();
  1110. database.LoadEntityCommands(client->GetCurrentZone());
  1111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1112. break;
  1113. }
  1114. case COMMAND_RELOAD_FACTIONS: {
  1115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1116. master_faction_list.Clear();
  1117. database.LoadFactionList();
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_MAIL: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1123. zone_list.ReloadMail();
  1124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1125. break;
  1126. }
  1127. case COMMAND_RELOAD_GUILDS: {
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1129. world.ReloadGuilds();
  1130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1131. break;
  1132. }
  1133. case COMMAND_RELOAD_LOCATIONS: {
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1135. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1136. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1138. break;
  1139. }
  1140. case COMMAND_RELOAD_RULES: {
  1141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1142. database.LoadRuleSets(true);
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_TRANSPORTERS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1148. database.LoadTransporters(client->GetCurrentZone());
  1149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1150. break;
  1151. }
  1152. case COMMAND_READ: {
  1153. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1154. if (strcmp(sep->arg[0], "read") == 0) {
  1155. int32 item_index = atol(sep->arg[1]);
  1156. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1157. if (item) {
  1158. Spawn* spawn = cmdTarget;
  1159. int8 numpages = item->book_pages.size();
  1160. string page1 = string(item->book_pages[0]->page_text.data);
  1161. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1162. string title = item->name;
  1163. if (packet) {
  1164. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1165. packet->setDataByName("book_title", title.c_str());
  1166. packet->setDataByName("book_type", "simple");
  1167. packet->setDataByName("unknown2", 1);
  1168. packet->setDataByName("unknown5", 1, 4);
  1169. packet->setArrayLengthByName("num_pages", numpages);
  1170. for (int8 pages = 1; pages <= numpages; pages++) {
  1171. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1172. string page = string(item->book_pages[pages-1]->page_text.data);
  1173. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1174. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1175. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1176. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1177. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1178. // Need to add support for images
  1179. }
  1180. client->QueuePacket(packet->serialize());
  1181. safe_delete(packet);
  1182. }
  1183. break;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. case COMMAND_USEABILITY:{
  1189. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1190. if (client->GetPlayer()->GetHP() == 0) {
  1191. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1192. }
  1193. else {
  1194. int32 spell_id = atoul(sep->arg[0]);
  1195. int8 spell_tier = 0;
  1196. if (sep->arg[1][0] && sep->IsNumber(1))
  1197. spell_tier = atoi(sep->arg[1]);
  1198. else
  1199. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1200. if (!spell_tier)
  1201. spell_tier = 1;
  1202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1203. if (spell) {
  1204. 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)
  1205. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1206. else
  1207. {
  1208. if (cmdTarget)
  1209. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1210. else
  1211. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1212. }
  1213. }
  1214. }
  1215. }
  1216. else if (cmdTarget && cmdTarget->IsWidget())
  1217. {
  1218. Widget* widget = (Widget*)cmdTarget;
  1219. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1220. }
  1221. else
  1222. {
  1223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_INFO:{
  1228. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1229. if(strcmp(sep->arg[0], "inventory") == 0){
  1230. int32 item_index = atol(sep->arg[1]);
  1231. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1232. if(item){
  1233. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1234. break;
  1235. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1236. //DumpPacket(app);
  1237. client->QueuePacket(app);
  1238. if(item->GetItemScript() && lua_interface)
  1239. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1240. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1241. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1242. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1243. client->AddPendingQuest(quest);
  1244. }
  1245. }
  1246. else
  1247. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1248. }
  1249. else if(strcmp(sep->arg[0], "equipment") == 0){
  1250. int32 item_index = atol(sep->arg[1]);
  1251. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1252. if(item){
  1253. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1254. client->QueuePacket(app);
  1255. if(item->GetItemScript() && lua_interface)
  1256. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1257. }
  1258. else
  1259. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1260. }
  1261. 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){
  1262. int32 item_id = atoul(sep->arg[1]);
  1263. Item* item = master_item_list.GetItem(item_id);
  1264. if(item){
  1265. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1266. client->QueuePacket(app);
  1267. }
  1268. else
  1269. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1270. }
  1271. else if (strcmp(sep->arg[0], "spell") == 0) {
  1272. sint32 spell_id = atol(sep->arg[1]);
  1273. int8 tier = atoi(sep->arg[3]);
  1274. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1275. if (outapp)
  1276. client->QueuePacket(outapp);
  1277. else
  1278. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1279. }
  1280. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1281. sint32 spell_id = atol(sep->arg[2]);
  1282. int8 group = atoi(sep->arg[1]);
  1283. AltAdvanceData* data = 0;
  1284. SpellBookEntry* spellentry = 0;
  1285. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1287. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1288. if (outapp)
  1289. client->QueuePacket(outapp);
  1290. else
  1291. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1292. }
  1293. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1294. sint32 spell_id = atol(sep->arg[1]);
  1295. int8 tier = atoi(sep->arg[2]);
  1296. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1297. if (outapp)
  1298. client->QueuePacket(outapp);
  1299. else
  1300. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1301. }
  1302. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1303. sint32 recipe_id = atol(sep->arg[1]);
  1304. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1305. if(outapp)
  1306. client->QueuePacket(outapp);
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1311. int32 slot = atol(sep->arg[1]);
  1312. int32 spell_id = atol(sep->arg[2]);
  1313. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1314. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1315. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1316. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1317. if(outapp)
  1318. client->QueuePacket(outapp);
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. else if (strcmp(sep->arg[0], "effect") == 0) {
  1323. int32 spell_id = atol(sep->arg[1]);
  1324. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1325. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1326. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1327. if (outapp){
  1328. client->QueuePacket(outapp);
  1329. }
  1330. else
  1331. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1332. }
  1333. }
  1334. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1335. Item* item = player->item_list.GetOverflowItem();
  1336. if(item) {
  1337. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1338. client->QueuePacket(app);
  1339. }
  1340. else
  1341. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1342. }
  1343. else
  1344. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1345. break;
  1346. }
  1347. case COMMAND_USE_EQUIPPED_ITEM:{
  1348. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1349. int32 slot_id = atoul(sep->arg[0]);
  1350. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1351. if (item && item->generic_info.usable && item->GetItemScript())
  1352. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1353. }
  1354. break;
  1355. }
  1356. case COMMAND_USE_ITEM: {
  1357. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1358. int32 item_index = atoul(sep->arg[0]);
  1359. Item* item = player->item_list.GetItemFromIndex(item_index);
  1360. if (item && item->GetItemScript()) {
  1361. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1362. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1363. else {
  1364. if (item->generic_info.display_charges > 0) {
  1365. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1366. item->generic_info.display_charges -= 1;
  1367. item->save_needed = true;
  1368. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1369. }
  1370. }
  1371. }
  1372. }
  1373. break;
  1374. }
  1375. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1376. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1377. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1378. if (item) {
  1379. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1380. if(item->generic_info.item_type == 6) {
  1381. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1382. int8 old_slot = 0;
  1383. if (spell) {
  1384. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1385. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1386. player->RemoveSpellBookEntry(spell->GetSpellID());
  1387. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1388. player->UnlockSpell(spell);
  1389. client->SendSpellUpdate(spell);
  1390. database.DeleteItem(client->GetCharacterID(), item, 0);
  1391. player->item_list.RemoveItem(item, true);
  1392. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1393. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1394. }
  1395. }
  1396. else
  1397. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1398. }
  1399. else if(item->generic_info.item_type == 7){
  1400. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1401. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1402. // if valid recipe book and the player doesn't have it
  1403. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1404. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1405. safe_delete(recipe_book);
  1406. }
  1407. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1408. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1409. // Add recipe book to the players list
  1410. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1411. // Get a list of all recipes this book contains
  1412. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1413. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1414. // Create the packet to send to update the players recipe list
  1415. PacketStruct* packet = 0;
  1416. if (client->GetRecipeListSent()) {
  1417. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1418. if (packet)
  1419. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1420. }
  1421. // loop through the list
  1422. vector<Recipe*>::iterator itr;
  1423. int16 i = 0;
  1424. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1425. // check to see if the player already has this recipe some how
  1426. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1427. // Player doesn't already have this recipe so lets add it
  1428. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1429. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1430. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1431. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1432. if (packet && client->GetRecipeListSent()) {
  1433. packet->setArrayDataByName("id", recipe->GetID(), i);
  1434. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1435. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1436. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1437. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1438. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1439. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1440. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1441. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1442. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1443. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1444. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1445. i++;
  1446. }
  1447. }
  1448. }
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1450. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1451. database.DeleteItem(client->GetCharacterID(), item, 0);
  1452. client->GetPlayer()->item_list.RemoveItem(item, true);
  1453. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1454. if (packet && client->GetRecipeListSent())
  1455. client->QueuePacket(packet->serialize());
  1456. safe_delete(packet);
  1457. }
  1458. else {
  1459. if (recipe_book)
  1460. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1461. safe_delete(recipe_book);
  1462. }
  1463. }
  1464. }
  1465. else
  1466. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1467. }
  1468. break;
  1469. }
  1470. case COMMAND_SUMMONITEM: {
  1471. if (sep && sep->IsNumber(0)) {
  1472. int32 item_id = atol(sep->arg[0]);
  1473. int32 quantity = 1;
  1474. if (sep->arg[1] && sep->IsNumber(1))
  1475. quantity = atoi(sep->arg[1]);
  1476. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1477. client->AddItemToBank(item_id,quantity);
  1478. }
  1479. else {
  1480. client->AddItem(item_id, quantity);
  1481. }
  1482. }
  1483. else {
  1484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1486. }
  1487. break;
  1488. }
  1489. case COMMAND_COLLECTION_ADDITEM: {
  1490. // takes 2 params: collection_id, slot
  1491. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1492. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1493. if (item)
  1494. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1495. else
  1496. 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]));
  1497. }
  1498. else
  1499. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1500. break;
  1501. }
  1502. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1503. // takes 1 param: slot
  1504. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1505. int i = 0;
  1506. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1507. printf("\t%u: %s\n", i, sep->arg[i]);
  1508. i++;
  1509. }
  1510. break;
  1511. }
  1512. case COMMAND_WHO:{
  1513. const char* who = 0;
  1514. if(sep && sep->arg[0]){
  1515. //cout << "Who query: \n";
  1516. who = sep->argplus[0];
  1517. //cout << who << endl;
  1518. }
  1519. zone_list.ProcessWhoQuery(who, client);
  1520. break;
  1521. }
  1522. case COMMAND_SELECT_JUNCTION:{
  1523. 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__);
  1524. int32 choice = 0;
  1525. if(sep && sep->arg[0] && sep->IsNumber(0))
  1526. choice = atoul(sep->arg[0]);
  1527. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1528. client->HandlePlayerRevive(choice);
  1529. }
  1530. break;
  1531. }
  1532. case COMMAND_SPAWN_MOVE: {
  1533. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1534. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1535. if (packet) {
  1536. float unknown2_3 = 0;
  1537. int8 placement_mode = 0;
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1539. if (sep && sep->arg[0][0]) {
  1540. if (strcmp(sep->arg[0], "wall") == 0) {
  1541. placement_mode = 2;
  1542. unknown2_3 = 150;
  1543. }
  1544. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1545. placement_mode = 1;
  1546. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1547. {
  1548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1549. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1550. }
  1551. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1552. {
  1553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1554. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1555. }
  1556. else if (strcmp(sep->arg[0], "myloc") == 0)
  1557. {
  1558. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1559. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1560. safe_delete(packet);
  1561. break;
  1562. }
  1563. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1564. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1565. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1566. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1567. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1568. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1569. safe_delete(packet);
  1570. break;
  1571. }
  1572. }
  1573. packet->setDataByName("placement_mode", placement_mode);
  1574. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1575. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1576. packet->setDataByName("unknown", 1); //size
  1577. packet->setDataByName("unknown2", 1); //size 2
  1578. packet->setDataByName("unknown2", .5, 1); //size 3
  1579. packet->setDataByName("unknown2", 3, 2);
  1580. packet->setDataByName("unknown2", unknown2_3, 3);
  1581. packet->setDataByName("max_distance", 500);
  1582. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1583. client->QueuePacket(packet->serialize());
  1584. safe_delete(packet);
  1585. }
  1586. }
  1587. else {
  1588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1590. }
  1591. break;
  1592. }
  1593. case COMMAND_HAIL:{
  1594. Spawn* spawn = cmdTarget;
  1595. if(spawn && spawn->GetTargetable())
  1596. {
  1597. char tmp[75] = {0};
  1598. sprintf(tmp, "Hail, %s", spawn->GetName());
  1599. bool show_bubble = true;
  1600. if (spawn->IsNPC())
  1601. show_bubble = false;
  1602. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1603. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1604. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1605. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1606. else
  1607. spawn->ProcessMovement();
  1608. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1609. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1610. }
  1611. }
  1612. else {
  1613. string tmp = "Hail";
  1614. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1615. }
  1616. break;
  1617. }
  1618. case COMMAND_SAY:{
  1619. if (sep && sep->arg[0][0]) {
  1620. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1621. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1622. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1623. }
  1624. else
  1625. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1626. break;
  1627. }
  1628. case COMMAND_TELL:{
  1629. if(sep && sep->arg[0] && sep->argplus[1]){
  1630. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1631. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1632. }else
  1633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1634. break;
  1635. }
  1636. case COMMAND_SHOUT:{
  1637. if(sep && sep->arg[0][0])
  1638. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1639. else
  1640. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1641. break;
  1642. }
  1643. case COMMAND_AUCTION:{
  1644. if(sep && sep->arg[0][0])
  1645. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1646. else
  1647. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1648. break;
  1649. }
  1650. case COMMAND_OOC:{
  1651. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1652. if(sep && sep->arg[0][0])
  1653. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1654. else
  1655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1656. break;
  1657. }
  1658. case COMMAND_EMOTE:{
  1659. if(sep && sep->arg[0][0])
  1660. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1661. else
  1662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1663. break;
  1664. }
  1665. case COMMAND_RACE:{
  1666. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1667. if(sep->arg[1][0] && sep->IsNumber(1)){
  1668. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1669. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1670. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1671. client->GetPlayer()->SetCharSheetChanged(true);
  1672. }
  1673. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1674. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1675. //client->QueuePacket(outapp);
  1676. }
  1677. else{
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1680. }
  1681. break;
  1682. }
  1683. case COMMAND_BANK_DEPOSIT:{
  1684. if(client->GetBanker() && sep && sep->arg[0]){
  1685. int64 amount = 0;
  1686. string deposit = string(sep->arg[0]);
  1687. amount = atoi64(deposit.c_str());
  1688. client->BankDeposit(amount);
  1689. }
  1690. break;
  1691. }
  1692. case COMMAND_BANK_WITHDRAWAL:{
  1693. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1694. int64 amount = 0;
  1695. string deposit = string(sep->arg[0]);
  1696. amount = atoi64(deposit.c_str());
  1697. client->BankWithdrawal(amount);
  1698. }
  1699. break;
  1700. }
  1701. case COMMAND_BANK_CANCEL:{
  1702. Spawn* banker = cmdTarget;
  1703. client->Bank(banker, true);
  1704. break;
  1705. }
  1706. case COMMAND_BANK:{
  1707. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1708. Spawn* banker = cmdTarget;
  1709. client->Bank(banker);
  1710. break;
  1711. }
  1712. case COMMAND_GUILD_BANK:{
  1713. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1714. //Spawn* banker = client->GetPlayer()->GetTarget();
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1716. break;
  1717. }
  1718. case COMMAND_START_MAIL: {
  1719. client->SetMailTransaction(cmdTarget);
  1720. client->SendMailList();
  1721. break;
  1722. }
  1723. case COMMAND_CANCEL_MAIL: {
  1724. client->SetMailTransaction(0);
  1725. break;
  1726. }
  1727. case COMMAND_GET_MAIL_MESSAGE: {
  1728. if (sep && sep->arg[0] && sep->IsNumber(0))
  1729. client->DisplayMailMessage(atoul(sep->arg[0]));
  1730. break;
  1731. }
  1732. case COMMAND_ADD_MAIL_PLAT: {
  1733. if (sep && sep->arg[0] && sep->IsNumber(0))
  1734. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1735. break;
  1736. }
  1737. case COMMAND_ADD_MAIL_GOLD: {
  1738. if (sep && sep->arg[0] && sep->IsNumber(0))
  1739. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1740. break;
  1741. }
  1742. case COMMAND_ADD_MAIL_SILVER: {
  1743. if (sep && sep->arg[0] && sep->IsNumber(0))
  1744. client->AddMailCoin(0, atoul(sep->arg[0]));
  1745. break;
  1746. }
  1747. case COMMAND_ADD_MAIL_COPPER: {
  1748. if (sep && sep->arg[0] && sep->IsNumber(0))
  1749. client->AddMailCoin(atoul(sep->arg[0]));
  1750. break;
  1751. }
  1752. case COMMAND_SET_MAIL_ITEM: {
  1753. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1754. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1755. break;
  1756. }
  1757. case COMMAND_REMOVE_MAIL_PLAT: {
  1758. if (sep && sep->arg[0] && sep->IsNumber(0))
  1759. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1760. break;
  1761. }
  1762. case COMMAND_REMOVE_MAIL_GOLD: {
  1763. if (sep && sep->arg[0] && sep->IsNumber(0))
  1764. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1765. break;
  1766. }
  1767. case COMMAND_REMOVE_MAIL_SILVER: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1770. break;
  1771. }
  1772. case COMMAND_REMOVE_MAIL_COPPER: {
  1773. if (sep && sep->arg[0] && sep->IsNumber(0))
  1774. client->RemoveMailCoin(atoul(sep->arg[0]));
  1775. break;
  1776. }
  1777. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1778. if (sep && sep->arg[0] && sep->IsNumber(0))
  1779. client->TakeMailAttachments(atoul(sep->arg[0]));
  1780. break;
  1781. }
  1782. case COMMAND_CANCEL_SEND_MAIL: {
  1783. client->CancelSendMail();
  1784. break;
  1785. }
  1786. case COMMAND_DELETE_MAIL_MESSAGE: {
  1787. if (sep && sep->arg[0] && sep->IsNumber(0))
  1788. client->DeleteMail(atoul(sep->arg[0]), true);
  1789. break;
  1790. }
  1791. case COMMAND_REPORT_SPAM: {
  1792. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1793. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1794. break;
  1795. }
  1796. case COMMAND_KILL:{
  1797. Spawn* dead = 0;
  1798. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1799. dead=client->GetPlayer();
  1800. client->GetPlayer()->SetHP(0);
  1801. client->GetPlayer()->KillSpawn(dead);
  1802. }else{
  1803. dead= cmdTarget;
  1804. if(dead && dead->IsPlayer() == false){
  1805. dead->SetHP(0);
  1806. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1807. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1808. else
  1809. client->GetPlayer()->KillSpawn(dead);
  1810. }else{
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1813. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1814. }
  1815. }
  1816. break;
  1817. }
  1818. case COMMAND_LEVEL:{
  1819. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1820. int16 new_level = atoi(sep->arg[ndx]);
  1821. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1822. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1823. else {
  1824. if (new_level < 1)
  1825. new_level = 1;
  1826. if (new_level > 255)
  1827. new_level = 255;
  1828. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1829. client->GetPlayer()->SetXP(1);
  1830. client->GetPlayer()->SetNeededXP();
  1831. }
  1832. }else
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1834. break;
  1835. }
  1836. case COMMAND_SIT: {
  1837. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1838. if(client->GetPlayer()->GetHP() > 0){
  1839. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1841. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1842. }
  1843. break;
  1844. }
  1845. case COMMAND_STAND: {
  1846. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1847. if(client->GetPlayer()->GetHP() > 0){
  1848. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1850. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1851. }
  1852. break;
  1853. }
  1854. case COMMAND_CLASS:{
  1855. if(sep && sep->arg[ndx][0]){
  1856. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1857. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1858. }else
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1860. break;
  1861. }
  1862. case COMMAND_GENDER:{
  1863. if(sep && sep->arg[ndx][0]){
  1864. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1865. client->GetPlayer()->SetCharSheetChanged(true);
  1866. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1867. }else{
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1871. }
  1872. break;
  1873. }
  1874. case COMMAND_FLYMODE:{
  1875. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1876. PrintSep(sep, "COMMAND_FLYMODE");
  1877. int8 val = atoi(sep->arg[0]);
  1878. ClientPacketFunctions::SendFlyMode(client, val);
  1879. }
  1880. else{
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1883. }
  1884. break;
  1885. }
  1886. case COMMAND_LOOT_LIST:{
  1887. Spawn* spawn = cmdTarget;
  1888. if(spawn && spawn->IsEntity()){
  1889. if (sep && sep->arg[0]) {
  1890. if (!spawn->GetDatabaseID())
  1891. {
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1893. break;
  1894. }
  1895. else if (!spawn->IsNPC())
  1896. {
  1897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1898. break;
  1899. }
  1900. bool reloadLoot = false;
  1901. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1905. {
  1906. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1907. reloadLoot = true;
  1908. }
  1909. else
  1910. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1911. }
  1912. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1913. {
  1914. int32 loottable_id = atoul(sep->arg[1]);
  1915. if (loottable_id > 0)
  1916. {
  1917. database.AddLootTableToSpawn(spawn, loottable_id);
  1918. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1919. reloadLoot = true;
  1920. }
  1921. else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1923. }
  1924. else if (!stricmp(sep->arg[0], "clearall"))
  1925. {
  1926. if (database.RemoveSpawnLootTable(spawn, 0))
  1927. {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1929. reloadLoot = true;
  1930. }
  1931. else
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1933. }
  1934. else
  1935. {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1940. break;
  1941. }
  1942. if (reloadLoot)
  1943. {
  1944. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1945. if (spawn->IsNPC())
  1946. {
  1947. Entity* ent = (Entity*)spawn;
  1948. ent->SetLootCoins(0);
  1949. ent->ClearLootList();
  1950. spawn->GetZone()->AddLoot((NPC*)spawn);
  1951. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1952. }
  1953. }
  1954. break; // nothing further this is the end of these sub commands
  1955. }
  1956. else
  1957. {
  1958. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1959. if (loot_list.size() > 0) {
  1960. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1961. vector<int32>::iterator list_itr;
  1962. LootTable* table = 0;
  1963. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1964. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1965. if (table)
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1967. }
  1968. }
  1969. Entity* target = (Entity*)spawn;
  1970. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1971. vector<Item*>* items = target->GetLootItems();
  1972. if (items) {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1974. vector<Item*>::iterator itr;
  1975. Item* item = 0;
  1976. for (itr = items->begin(); itr != items->end(); itr++) {
  1977. item = *itr;
  1978. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1979. }
  1980. }
  1981. else
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1983. }
  1984. }
  1985. break;
  1986. }
  1987. case COMMAND_LOOT_SETCOIN:{
  1988. Spawn* spawn = cmdTarget;
  1989. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1990. Entity* target = (Entity*)spawn;
  1991. target->SetLootCoins(atoul(sep->arg[0]));
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1993. }
  1994. else
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1996. break;
  1997. }
  1998. case COMMAND_LOOT_ADDITEM:{
  1999. Spawn* spawn = cmdTarget;
  2000. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2001. Entity* target = (Entity*)spawn;
  2002. int16 charges = 1;
  2003. if(sep->arg[1] && sep->IsNumber(1))
  2004. charges = atoi(sep->arg[1]);
  2005. target->AddLootItem(atoul(sep->arg[0]), charges);
  2006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2007. }
  2008. else
  2009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2010. break;
  2011. }
  2012. case COMMAND_LOOT_REMOVEITEM:{
  2013. Spawn* spawn = cmdTarget;
  2014. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2015. Entity* target = (Entity*)spawn;
  2016. target->LootItem(atoul(sep->arg[0]));
  2017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2018. }
  2019. else
  2020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2021. break;
  2022. }
  2023. case COMMAND_LOOT_CORPSE:
  2024. case COMMAND_DISARM:
  2025. case COMMAND_LOOT:{
  2026. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2027. {
  2028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2029. break;
  2030. }
  2031. if(cmdTarget && cmdTarget->IsEntity()){
  2032. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2033. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2034. client->OpenChest((Entity*)cmdTarget, true);
  2035. else
  2036. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2037. if (!((Entity*)cmdTarget)->HasLoot()){
  2038. if (((Entity*)cmdTarget)->IsNPC())
  2039. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2040. }
  2041. }
  2042. else
  2043. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2044. }
  2045. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2047. break;
  2048. }
  2049. case COMMAND_RELOADSPAWNSCRIPTS:{
  2050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2051. if (lua_interface)
  2052. lua_interface->SetSpawnScriptsReloading(true);
  2053. world.ResetSpawnScripts();
  2054. database.LoadSpawnScriptData();
  2055. if(lua_interface) {
  2056. lua_interface->DestroySpawnScripts();
  2057. lua_interface->SetSpawnScriptsReloading(false);
  2058. }
  2059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2060. break;
  2061. }
  2062. case COMMAND_RELOADLUASYSTEM:{
  2063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2064. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2065. safe_delete(lua_interface);
  2066. lua_interface = new LuaInterface();
  2067. if(lua_interface)
  2068. lua_interface->SetSpawnScriptsReloading(true);
  2069. if(lua_interface && debug_clients.size() > 0){
  2070. map<Client*, int32>::iterator itr;
  2071. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2072. if(lua_interface)
  2073. lua_interface->UpdateDebugClients(itr->first);
  2074. }
  2075. }
  2076. world.ResetSpawnScripts();
  2077. database.LoadSpawnScriptData();
  2078. world.ResetZoneScripts();
  2079. database.LoadZoneScriptData();
  2080. int32 quest_count = database.LoadQuests();
  2081. zone_list.DeleteSpellProcess();
  2082. master_spell_list.Reload();
  2083. int32 spell_count = 0;
  2084. if(lua_interface) {
  2085. lua_interface->DestroySpawnScripts();
  2086. lua_interface->DestroySpells();
  2087. spell_count = database.LoadSpellScriptData();
  2088. lua_interface->SetSpawnScriptsReloading(false);
  2089. }
  2090. zone_list.LoadSpellProcess();
  2091. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2092. break;
  2093. }
  2094. case COMMAND_DECLINE_QUEST:{
  2095. int32 quest_id = 0;
  2096. if(sep && sep->arg[0] && sep->IsNumber(0))
  2097. quest_id = atoul(sep->arg[0]);
  2098. if(quest_id > 0){
  2099. Quest* quest = client->GetPendingQuest(quest_id);
  2100. if(quest){
  2101. client->RemovePendingQuest(quest);
  2102. if(lua_interface)
  2103. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2104. safe_delete(quest);
  2105. client->GetCurrentZone()->SendQuestUpdates(client);
  2106. }
  2107. }
  2108. break;
  2109. }
  2110. case COMMAND_DELETE_QUEST:{
  2111. int32 quest_id = 0;
  2112. if(sep && sep->arg[0] && sep->IsNumber(0))
  2113. quest_id = atoul(sep->arg[0]);
  2114. if(quest_id > 0){
  2115. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2116. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2117. if (quest)
  2118. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2119. }
  2120. client->RemovePlayerQuest(quest_id);
  2121. client->GetCurrentZone()->SendQuestUpdates(client);
  2122. }
  2123. break;
  2124. }
  2125. case COMMAND_ACCEPT_QUEST:{
  2126. int32 quest_id = 0;
  2127. if(sep && sep->arg[0] && sep->IsNumber(0))
  2128. quest_id = atoul(sep->arg[0]);
  2129. if(quest_id > 0){
  2130. Quest* quest = client->GetPendingQuest(quest_id);
  2131. if(quest){
  2132. client->RemovePendingQuest(quest);
  2133. client->AddPlayerQuest(quest);
  2134. client->GetCurrentZone()->SendQuestUpdates(client);
  2135. // If character has already completed this quest once update the given date in the database
  2136. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2137. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2138. if (quest2)
  2139. quest->SetCompleteCount(quest2->GetCompleteCount());
  2140. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2141. }
  2142. }
  2143. }
  2144. break;
  2145. }
  2146. case COMMAND_NAME:{
  2147. if(sep && sep->arg[ndx][0]){
  2148. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2149. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2150. client->GetPlayer()->SetCharSheetChanged(true);
  2151. }else
  2152. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2153. break;
  2154. }
  2155. case COMMAND_GROUPSAY:{
  2156. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2157. if(sep && sep->arg[0] && gmi)
  2158. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2159. break;
  2160. }
  2161. case COMMAND_GROUPINVITE: {
  2162. Entity* target = 0;
  2163. Client* target_client = 0;
  2164. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2165. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2166. return;
  2167. }
  2168. // name provided with command so it has to be a player, npc not supported here
  2169. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2170. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2171. if (target_client) {
  2172. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2173. target = 0;
  2174. else
  2175. target = target_client->GetPlayer();
  2176. }
  2177. }
  2178. // if name was not provided use the players target, npc or player supported here
  2179. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2180. target = (Entity*)client->GetPlayer()->GetTarget();
  2181. if (target->IsPlayer()) {
  2182. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2183. }
  2184. }
  2185. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2186. if (result == 0) {
  2187. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2188. if (target_client) {
  2189. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2190. if (packet) {
  2191. packet->setDataByName("type", 1);
  2192. packet->setDataByName("name", client->GetPlayer()->GetName());
  2193. packet->setDataByName("unknown2", 1);
  2194. target_client->QueuePacket(packet->serialize());
  2195. safe_delete(packet);
  2196. }
  2197. }
  2198. }
  2199. else if (result == 1)
  2200. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2201. else if (result == 2)
  2202. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2203. else if (result == 3)
  2204. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2205. else if (result == 4)
  2206. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2207. else if (result == 5)
  2208. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2209. else if (result == 6)
  2210. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2211. else
  2212. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2213. break;
  2214. }
  2215. case COMMAND_GROUPDISBAND: {
  2216. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2217. if (gmi) { // TODO: Leader check
  2218. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2219. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2220. }
  2221. break;
  2222. }
  2223. case COMMAND_GROUP_LEAVE: {
  2224. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2225. if (gmi) {
  2226. int32 group_id = gmi->group_id;
  2227. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2228. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2229. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2230. }
  2231. else {
  2232. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2233. }
  2234. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2235. }
  2236. break;
  2237. }
  2238. case COMMAND_FRIEND_ADD:{
  2239. string name = "";
  2240. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2241. name = database.GetPlayerName(sep->arg[0]);
  2242. else if(cmdTarget && cmdTarget->IsPlayer())
  2243. name = string(cmdTarget->GetName());
  2244. if(name.length() > 0){
  2245. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2246. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2247. client->GetPlayer()->RemoveIgnore(name.c_str());
  2248. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2249. client->SendChatRelationship(3, name.c_str());
  2250. }
  2251. client->GetPlayer()->AddFriend(name.c_str(), true);
  2252. client->SendChatRelationship(0, name.c_str());
  2253. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2254. if(zone_list.GetClientByCharName(name))
  2255. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2256. }
  2257. else
  2258. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2259. }
  2260. else
  2261. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2262. break;
  2263. }
  2264. case COMMAND_FRIEND_REMOVE:{
  2265. string name = "";
  2266. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2267. name = database.GetPlayerName(sep->arg[0]);
  2268. else if(cmdTarget && cmdTarget->IsPlayer())
  2269. name = string(cmdTarget->GetName());
  2270. if(name.length() > 0){
  2271. client->GetPlayer()->RemoveFriend(name.c_str());
  2272. client->SendChatRelationship(1, name.c_str());
  2273. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2274. }
  2275. else
  2276. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2277. break;
  2278. }
  2279. case COMMAND_FRIENDS:{
  2280. break;
  2281. }
  2282. case COMMAND_IGNORE_ADD:{
  2283. string name = "";
  2284. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2285. name = database.GetPlayerName(sep->arg[0]);
  2286. else if(cmdTarget && cmdTarget->IsPlayer())
  2287. name = string(cmdTarget->GetName());
  2288. if(name.length() > 0){
  2289. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2290. if(client->GetPlayer()->IsFriend(name.c_str())){
  2291. client->GetPlayer()->RemoveFriend(name.c_str());
  2292. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2293. client->SendChatRelationship(1, name.c_str());
  2294. }
  2295. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2296. client->SendChatRelationship(2, name.c_str());
  2297. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2298. }
  2299. else
  2300. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2301. }
  2302. else
  2303. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2304. break;
  2305. }
  2306. case COMMAND_IGNORE_REMOVE:{
  2307. string name = "";
  2308. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2309. name = database.GetPlayerName(sep->arg[0]);
  2310. else if(cmdTarget && cmdTarget->IsPlayer())
  2311. name = string(cmdTarget->GetName());
  2312. if(name.length() > 0){
  2313. client->GetPlayer()->RemoveIgnore(name.c_str());
  2314. client->SendChatRelationship(3, name.c_str());
  2315. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2316. }
  2317. break;
  2318. }
  2319. case COMMAND_IGNORES:{
  2320. break;
  2321. }
  2322. case COMMAND_GROUP_KICK:{
  2323. Entity* kicked = 0;
  2324. Client* kicked_client = 0;
  2325. int32 group_id = 0;
  2326. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2327. return;
  2328. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2329. if (sep && sep->arg[0]) {
  2330. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2331. if (kicked_client)
  2332. kicked = kicked_client->GetPlayer();
  2333. }
  2334. else if (cmdTarget && cmdTarget->IsEntity()) {
  2335. kicked = (Entity*)cmdTarget;
  2336. }
  2337. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2338. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2339. if (kicked)
  2340. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2341. if(send_kicked_message)
  2342. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2343. else
  2344. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2345. if (kicked_client)
  2346. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2347. break;
  2348. }
  2349. case COMMAND_GROUP_MAKE_LEADER:{
  2350. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2351. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2352. return;
  2353. }
  2354. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2355. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2356. if (new_leader) {
  2357. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2358. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2359. }
  2360. }
  2361. else
  2362. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2363. }
  2364. else if (cmdTarget && cmdTarget->IsPlayer())
  2365. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2366. else
  2367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2368. break;
  2369. }
  2370. case COMMAND_GROUP_ACCEPT_INVITE: {
  2371. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2372. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2373. if (result == 0)
  2374. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2375. else if (result == 1)
  2376. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2377. else if (result == 2)
  2378. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2379. else
  2380. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2381. }
  2382. break;
  2383. }
  2384. case COMMAND_GROUP_DECLINE_INVITE: {
  2385. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2386. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2387. }
  2388. break;
  2389. }
  2390. case COMMAND_SUMMON:{
  2391. char* search_name = 0;
  2392. if(sep && sep->arg[0][0])
  2393. search_name = sep->arg[0];
  2394. if(!search_name && !cmdTarget){
  2395. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2396. 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.");
  2397. }
  2398. else{
  2399. if(!client->Summon(search_name))
  2400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2401. }
  2402. break;
  2403. }
  2404. case COMMAND_GOTO:{
  2405. const char* search_name = 0;
  2406. if(sep && sep->arg[0][0])
  2407. search_name = sep->argplus[0];
  2408. if(!search_name && !cmdTarget){
  2409. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2410. 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.");
  2411. }
  2412. else{
  2413. if(!client->GotoSpawn(search_name))
  2414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2415. }
  2416. break;
  2417. }
  2418. case COMMAND_MOVE:{
  2419. bool success = false;
  2420. try{
  2421. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2422. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2423. if(app){
  2424. client->QueuePacket(app);
  2425. success = true;
  2426. }
  2427. }
  2428. }
  2429. catch(...){}
  2430. if(!success){
  2431. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2432. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2433. }
  2434. break;
  2435. }
  2436. case COMMAND_SETTIME:{
  2437. if(sep && sep->arg[0]){
  2438. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2439. if(sep->arg[1] && sep->IsNumber(1))
  2440. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2441. if(sep->arg[2] && sep->IsNumber(2))
  2442. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2443. if(sep->arg[3] && sep->IsNumber(3))
  2444. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2445. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2446. }
  2447. else{
  2448. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2449. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2450. }
  2451. break;
  2452. }
  2453. case COMMAND_VERSION:{
  2454. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2455. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2456. break;
  2457. }
  2458. case COMMAND_ZONE:{
  2459. string* zonename = 0;
  2460. int32 instanceID = 0;
  2461. const char* zone = 0;
  2462. int32 zone_id = 0;
  2463. bool listSearch = false;
  2464. bool isInstance = false;
  2465. ZoneServer* zsZone = 0;
  2466. if(sep && sep->arg[0][0])
  2467. {
  2468. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2469. listSearch = true;
  2470. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2471. {
  2472. zone_list.SendZoneList(client);
  2473. break;
  2474. }
  2475. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2476. {
  2477. if(sep->IsNumber(1))
  2478. instanceID = atol(sep->arg[1]);
  2479. }
  2480. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2481. {
  2482. PrintSep(sep, "ZONE LOCK");
  2483. if(sep->IsNumber(1))
  2484. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2485. else
  2486. zsZone = zone_list.Get(sep->arg[1], false);
  2487. if( zsZone )
  2488. {
  2489. zsZone->SetZoneLockState(true);
  2490. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2491. }
  2492. else
  2493. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2494. break;
  2495. }
  2496. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2497. {
  2498. PrintSep(sep, "ZONE UNLOCK");
  2499. if(sep->IsNumber(1))
  2500. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2501. else
  2502. zsZone = zone_list.Get(sep->arg[1], false);
  2503. if( zsZone )
  2504. {
  2505. zsZone->SetZoneLockState(false);
  2506. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2507. }
  2508. else
  2509. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2510. break;
  2511. }
  2512. else
  2513. {
  2514. if(sep->IsNumber(0))
  2515. {
  2516. zone_id = atoul(sep->arg[0]);
  2517. zonename = database.GetZoneName(zone_id);
  2518. if(zonename)
  2519. zone = zonename->c_str();
  2520. }
  2521. else
  2522. zone = sep->arg[0];
  2523. }
  2524. if(instanceID > 0)
  2525. {
  2526. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2527. if(zsInstance != NULL)
  2528. {
  2529. instanceID = zsInstance->GetInstanceID();
  2530. zone = zsInstance->GetZoneName();
  2531. zone_id = zsInstance->GetZoneID();
  2532. isInstance = true;
  2533. }
  2534. }
  2535. }
  2536. if(!listSearch)
  2537. {
  2538. if(!zone)
  2539. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2540. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2541. zone_id != client->GetCurrentZone()->GetZoneID())
  2542. {
  2543. if(database.VerifyZone(zone))
  2544. {
  2545. if(client->CheckZoneAccess(zone))
  2546. {
  2547. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2548. if(isInstance)
  2549. client->Zone(instanceID,true,true);
  2550. else
  2551. client->Zone(zone);
  2552. }
  2553. }
  2554. else
  2555. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2556. }
  2557. else
  2558. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2559. }
  2560. else
  2561. {
  2562. const char* name = 0;
  2563. if(sep && sep->arg[1][0])
  2564. {
  2565. map<int32, string>* zone_names;
  2566. name = sep->argplus[1];
  2567. sint16 status = client->GetAdminStatus();
  2568. if( status > 0 )
  2569. {
  2570. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2571. zone_names = database.GetZoneList(name, true);
  2572. }
  2573. else
  2574. zone_names = database.GetZoneList(name);
  2575. if(!zone_names)
  2576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2577. else
  2578. {
  2579. map<int32, string>::iterator itr;
  2580. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2581. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2582. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2583. safe_delete(zone_names);
  2584. }
  2585. }
  2586. else
  2587. {
  2588. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2589. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2590. }
  2591. }
  2592. safe_delete(zonename);
  2593. break;
  2594. }
  2595. case COMMAND_USE: {
  2596. Spawn* target = cmdTarget;
  2597. if (target->IsWidget())
  2598. ((Widget*)target)->HandleUse(client, "use");
  2599. break;
  2600. }
  2601. case COMMAND_OPEN: {
  2602. Spawn* target = cmdTarget;
  2603. if (target->IsWidget())
  2604. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2605. break;
  2606. }
  2607. case COMMAND_CASTSPELL: {
  2608. if (sep && sep->arg[0] && sep->IsNumber(0))
  2609. {
  2610. int8 tier = 1;
  2611. if (sep->arg[1] && sep->IsNumber(1))
  2612. tier = atoul(sep->arg[1]);
  2613. int32 spellid = atoul(sep->arg[0]);
  2614. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2615. if (spell)
  2616. {
  2617. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2618. SpellProcess* spellProcess = 0;
  2619. // Get the current zones spell process
  2620. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2621. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2622. }
  2623. else
  2624. {
  2625. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2626. }
  2627. }
  2628. else if (sep && sep->arg[0])
  2629. {
  2630. database.FindSpell(client, (char*)sep->argplus[0]);
  2631. }
  2632. else
  2633. {
  2634. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2635. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2636. }
  2637. break;
  2638. }
  2639. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2640. if (sep && sep->GetArgNumber() == 4)
  2641. {
  2642. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2643. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2644. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2645. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2646. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2647. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2648. ClientPacketFunctions::SendSkillSlotMappings(client);
  2649. }
  2650. else
  2651. {
  2652. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2653. }
  2654. break;
  2655. }
  2656. case COMMAND_MOVE_ITEM:
  2657. {
  2658. int32 id = 0;
  2659. if (sep->IsNumber(0))
  2660. id = atoul(sep->arg[0]);
  2661. Spawn* spawn = 0;
  2662. if (id == 0)
  2663. {
  2664. spawn = cmdTarget;
  2665. }
  2666. else
  2667. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2668. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2669. break;
  2670. client->SendMoveObjectMode(spawn, 0);
  2671. break;
  2672. }
  2673. case COMMAND_PICKUP:
  2674. {
  2675. int32 id = 0;
  2676. if (sep->IsNumber(0))
  2677. id = atoul(sep->arg[0]);
  2678. Spawn* spawn = 0;
  2679. if (id == 0)
  2680. {
  2681. spawn = cmdTarget;
  2682. }
  2683. else
  2684. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2685. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2686. break;
  2687. client->AddItem(spawn->GetPickupItemID(), 1);
  2688. Query query;
  2689. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  2690. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2691. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2692. }
  2693. // we had a UI Window displayed, update the house items
  2694. if ( id > 0 )
  2695. client->GetCurrentZone()->SendHouseItems(client);
  2696. break;
  2697. }
  2698. case COMMAND_HOUSE_DEPOSIT:
  2699. {
  2700. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2701. // arg0 = ??? (set to 3)
  2702. // arg1 = coin (in copper)
  2703. // arg2 = status? (not implemented yet)
  2704. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2705. if (ph && sep && sep->IsNumber(1))
  2706. {
  2707. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2708. if (client->GetPlayer()->RemoveCoins(outVal))
  2709. {
  2710. char query[256];
  2711. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2712. if (itr != ph->depositsMap.end())
  2713. {
  2714. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2715. }
  2716. else
  2717. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2718. if (database.RunQuery(query, strnlen(query, 256)))
  2719. {
  2720. ph->escrow_coins += outVal;
  2721. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2722. database.LoadDeposits(ph);
  2723. client->PlaySound("coin_cha_ching");
  2724. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2725. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2726. }
  2727. else
  2728. {
  2729. client->GetPlayer()->AddCoins(outVal);
  2730. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2731. }
  2732. }
  2733. }
  2734. break;
  2735. }
  2736. case COMMAND_HOUSE:
  2737. {
  2738. if (sep && sep->IsNumber(0))
  2739. {
  2740. int32 unique_id = atoi(sep->arg[0]);
  2741. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2742. HouseZone* hz = 0;
  2743. if (ph)
  2744. hz = world.GetHouseZone(ph->house_id);
  2745. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2746. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2747. }
  2748. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2749. {
  2750. // inside a house or something? Send the access window
  2751. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2752. HouseZone* hz = 0;
  2753. if ( ph )
  2754. hz = world.GetHouseZone(ph->house_id);
  2755. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2756. client->GetCurrentZone()->SendHouseItems(client);
  2757. }
  2758. break;
  2759. }
  2760. case COMMAND_HOUSE_UI:
  2761. {
  2762. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2763. {
  2764. int32 unique_id = atoi(sep->arg[0]);
  2765. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2766. HouseZone* hz = 0;
  2767. if ( ph )
  2768. hz = world.GetHouseZone(ph->house_id);
  2769. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2770. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2771. }
  2772. break;
  2773. }
  2774. case COMMAND_PLACE_HOUSE_ITEM: {
  2775. if (sep && sep->IsNumber(0))
  2776. {
  2777. int32 uniqueid = atoi(sep->arg[0]);
  2778. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2779. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2780. if (item && item->IsHouseItem())
  2781. {
  2782. if (!client->HasOwnerOrEditAccess())
  2783. {
  2784. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2785. break;
  2786. }
  2787. else if (!item->generic_info.appearance_id)
  2788. {
  2789. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  2790. break;
  2791. }
  2792. if (client->GetTempPlacementSpawn())
  2793. {
  2794. Spawn* tmp = client->GetTempPlacementSpawn();
  2795. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2796. delete tmp;
  2797. client->SetTempPlacementSpawn(nullptr);
  2798. }
  2799. Spawn* spawn = new Object();
  2800. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2801. spawn->SetID(Spawn::NextID());
  2802. spawn->SetX(client->GetPlayer()->GetX());
  2803. spawn->SetY(client->GetPlayer()->GetY());
  2804. spawn->SetZ(client->GetPlayer()->GetZ());
  2805. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2806. spawn->SetSpawnOrigX(spawn->GetX());
  2807. spawn->SetSpawnOrigY(spawn->GetY());
  2808. spawn->SetSpawnOrigZ(spawn->GetZ());
  2809. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2810. spawn->appearance.targetable = 1;
  2811. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2812. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2813. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2814. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2815. spawn->SetZone(client->GetCurrentZone());
  2816. client->GetCurrentZone()->SendSpawn(spawn, client);
  2817. client->SetTempPlacementSpawn(spawn);
  2818. client->SetPlacementUniqueItemID(uniqueid);
  2819. client->SendMoveObjectMode(spawn, 0);
  2820. }
  2821. }
  2822. break;
  2823. }
  2824. case COMMAND_GM:
  2825. {
  2826. if (sep->arg[0] && sep->arg[1])
  2827. {
  2828. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2829. if (strcmp(sep->arg[0], "vision") == 0)
  2830. {
  2831. client->GetPlayer()->SetGMVision(onOff);
  2832. #if defined(__GNUC__)
  2833. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2834. #else
  2835. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2836. #endif
  2837. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2838. if (onOff)
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2840. else
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2842. }
  2843. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2844. {
  2845. client->SetLuaDebugClient(onOff);
  2846. #if defined(__GNUC__)
  2847. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2848. #else
  2849. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2850. #endif
  2851. if (onOff)
  2852. {
  2853. if (lua_interface)
  2854. lua_interface->UpdateDebugClients(client);
  2855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2856. }
  2857. else
  2858. {
  2859. if (lua_interface)
  2860. lua_interface->RemoveDebugClients(client);
  2861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2862. }
  2863. }
  2864. }
  2865. break;
  2866. }
  2867. case COMMAND_ATTACK:
  2868. case COMMAND_AUTO_ATTACK:{
  2869. int8 type = 1;
  2870. Player* player = client->GetPlayer();
  2871. if(!player)
  2872. break;
  2873. bool incombat = player->EngagedInCombat();
  2874. if(sep && sep->arg[0] && sep->IsNumber(0))
  2875. type = atoi(sep->arg[0]);
  2876. if(client->GetPlayer()->GetHP() == 0){
  2877. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2878. break;
  2879. }
  2880. if(type == 0){
  2881. if(incombat)
  2882. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2883. player->InCombat(false);
  2884. player->InCombat(false, true);
  2885. player->SetRangeAttack(false);
  2886. }
  2887. else {
  2888. if(type == 2){
  2889. player->InCombat(false);
  2890. if(incombat && player->GetRangeAttack()){
  2891. player->SetRangeAttack(false);
  2892. player->InCombat(false, true);
  2893. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2894. }
  2895. else{
  2896. player->SetRangeAttack(true);
  2897. player->InCombat(true, true);
  2898. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2899. }
  2900. }
  2901. else {
  2902. player->InCombat(false, true);
  2903. player->SetRangeAttack(false);
  2904. player->InCombat(true);
  2905. if(!incombat)
  2906. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2907. }
  2908. /*else
  2909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2910. }
  2911. player->SetCharSheetChanged(true);
  2912. break;
  2913. }
  2914. case COMMAND_DEPOP:{
  2915. bool allow_respawns = false;
  2916. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2917. if(atoi(sep->arg[0]) == 1)
  2918. allow_respawns = true;
  2919. }
  2920. client->GetCurrentZone()->Depop(allow_respawns);
  2921. break;
  2922. }
  2923. case COMMAND_REPOP:{
  2924. client->GetCurrentZone()->Depop(false, true);
  2925. break;
  2926. }
  2927. case COMMAND_BUYBACK:{
  2928. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2929. // 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
  2930. int64 id = atoi64(sep->arg[0]);
  2931. // get the first int32, the item id
  2932. //int32 item_id = (int32)id;
  2933. // get the second int32, the unique id
  2934. int32 unique_id = (int32)(id>>32);
  2935. int8 quantity = atoi(sep->arg[1]);
  2936. if(quantity == 255)
  2937. quantity = 1;
  2938. client->BuyBack(unique_id, quantity);
  2939. }
  2940. break;
  2941. }
  2942. case COMMAND_MERCHANT_BUY:{
  2943. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2944. int32 item_id = atoul(sep->arg[0]);
  2945. int8 quantity = atoi(sep->arg[1]);
  2946. client->BuyItem(item_id, quantity);
  2947. }
  2948. break;
  2949. }
  2950. case COMMAND_MERCHANT_SELL:{
  2951. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2952. // 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
  2953. int64 id = atoi64(sep->arg[0]);
  2954. // get the first int32, the item id
  2955. int32 item_id = (int32)id;
  2956. // get the second int32, the unique id
  2957. int32 unique_id = (int32)(id>>32);
  2958. int8 quantity = atoi(sep->arg[1]);
  2959. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2960. client->SellItem(item_id, quantity, unique_id);
  2961. }
  2962. break;
  2963. }
  2964. case COMMAND_MENDER_REPAIR: {
  2965. if (sep && sep->arg[0] && sep->IsNumber(0))
  2966. client->RepairItem(atoul(sep->arg[0]));
  2967. break;
  2968. }
  2969. case COMMAND_MENDER_REPAIR_ALL: {
  2970. client->RepairAllItems();
  2971. break;
  2972. }
  2973. case COMMAND_CANCEL_MERCHANT:{
  2974. client->SetMerchantTransaction(0);
  2975. break;
  2976. }
  2977. case COMMAND_START_MERCHANT:{
  2978. break;
  2979. }
  2980. case COMMAND_INVULNERABLE:{
  2981. sint8 val = -1;
  2982. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2983. val = atoi(sep->arg[0]);
  2984. //devn00b: Fix for linux builds
  2985. #if defined(__GNUC__)
  2986. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2987. #else
  2988. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2989. #endif
  2990. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2991. client->GetPlayer()->SetInvulnerable(val==1);
  2992. if(client->GetPlayer()->GetInvulnerable())
  2993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2994. else
  2995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2996. }
  2997. if(val == -1)
  2998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2999. break;
  3000. }
  3001. case COMMAND_REPAIR: {
  3002. Spawn* spawn = cmdTarget;
  3003. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3004. client->SendHailCommand(spawn);
  3005. client->SetMerchantTransaction(spawn);
  3006. client->SendRepairList();
  3007. }
  3008. break;
  3009. }
  3010. case COMMAND_LOTTO: {
  3011. Spawn* spawn = cmdTarget;
  3012. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3013. client->SetMerchantTransaction(spawn);
  3014. client->ShowLottoWindow();
  3015. }
  3016. break;
  3017. }
  3018. case COMMAND_ACCEPT_REWARD:{
  3019. int32 unknown = 0;
  3020. int32 selectable_item_id = 0;
  3021. //Quest *quest = 0;
  3022. Collection *collection = 0;
  3023. /* no idea what the first argument is for (faction maybe?)
  3024. if the reward has a selectable item reward, it's sent as the second argument
  3025. if neither of these are included in the reward, there is no sep
  3026. 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
  3027. only 1 quest or collection reward may be displayed at a time */
  3028. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3029. unknown = atoul(sep->arg[0]);
  3030. selectable_item_id = atoul(sep->arg[1]);
  3031. }
  3032. //if ((quest = player->GetPendingQuestReward()))
  3033. // client->AcceptQuestRewards(quest, selectable_item_id);
  3034. /* the below needs to go away eventually and be redone */
  3035. int32 item_id = 0;
  3036. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3037. item_id = atoul(sep->arg[0]);
  3038. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3039. if(quest){
  3040. client->AcceptQuestReward(quest, item_id);
  3041. break;
  3042. }
  3043. if (collection = player->GetPendingCollectionReward())
  3044. client->AcceptCollectionRewards(collection, selectable_item_id);
  3045. else
  3046. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3047. break;
  3048. }
  3049. case COMMAND_BUY_FROM_BROKER:{
  3050. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3051. int32 item_id = atoul(sep->arg[0]);
  3052. int16 quantity = atoul(sep->arg[1]);
  3053. client->AddItem(item_id, quantity);
  3054. }
  3055. break;
  3056. }
  3057. case COMMAND_SEARCH_STORES_PAGE:{
  3058. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3059. int32 page = atoul(sep->arg[0]);
  3060. client->SearchStore(page);
  3061. }
  3062. break;
  3063. }
  3064. case COMMAND_SEARCH_STORES:{
  3065. if(sep && sep->arg[0][0]){
  3066. const char* values = sep->argplus[0];
  3067. if(values){
  3068. map<string, string> str_values = TranslateBrokerRequest(values);
  3069. vector<Item*>* items = master_item_list.GetItems(str_values);
  3070. if(items){
  3071. client->SetItemSearch(items);
  3072. client->SearchStore(0);
  3073. }
  3074. }
  3075. }
  3076. break;
  3077. }
  3078. case COMMAND_LUADEBUG:{
  3079. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3080. client->SetLuaDebugClient(true);
  3081. if(lua_interface)
  3082. lua_interface->UpdateDebugClients(client);
  3083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3084. }
  3085. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3086. client->SetLuaDebugClient(false);
  3087. if(lua_interface)
  3088. lua_interface->RemoveDebugClients(client);
  3089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3090. }
  3091. else{
  3092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3094. }
  3095. break;
  3096. }
  3097. case COMMAND_SPAWN_GROUP:
  3098. {
  3099. Spawn* target = cmdTarget;
  3100. if(target && target->IsPlayer() == false)
  3101. {
  3102. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3103. {
  3104. if(target->GetSpawnLocationPlacementID() > 0)
  3105. {
  3106. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3107. {
  3108. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3109. if(id > 0)
  3110. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3111. else
  3112. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3113. target->SetSpawnGroupID(id);
  3114. target->AddSpawnToGroup(target);
  3115. }
  3116. else
  3117. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3118. }
  3119. else
  3120. 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.");
  3121. }
  3122. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3123. {
  3124. if(sep->arg[1] && sep->IsNumber(1))
  3125. {
  3126. int32 group_id = atoul(sep->arg[1]);
  3127. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3128. if(leader)
  3129. {
  3130. leader->AddSpawnToGroup(target);
  3131. target->SetSpawnGroupID(group_id);
  3132. if(database.SpawnGroupAddSpawn(target, group_id))
  3133. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3134. else
  3135. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3136. }
  3137. else
  3138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3139. }
  3140. else
  3141. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3142. }
  3143. else if(target->GetSpawnGroupID() == 0)
  3144. {
  3145. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3146. }
  3147. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3148. {
  3149. int32 group_id = target->GetSpawnGroupID();
  3150. target->RemoveSpawnFromGroup();
  3151. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3152. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3153. else
  3154. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3155. }
  3156. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3157. {
  3158. int32 group_id = target->GetSpawnGroupID();
  3159. if(sep->arg[1] && sep->IsNumber(1))
  3160. {
  3161. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3162. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3163. else
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3165. }
  3166. else
  3167. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3168. }
  3169. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3170. {
  3171. int32 group_id = target->GetSpawnGroupID();
  3172. if(sep->arg[1] && sep->IsNumber(1))
  3173. {
  3174. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3175. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3176. else
  3177. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3178. }
  3179. else
  3180. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3181. }
  3182. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3183. {
  3184. if(sep->arg[1] && sep->IsNumber(1))
  3185. {
  3186. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3187. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3188. else
  3189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3190. }
  3191. else
  3192. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3193. }
  3194. else
  3195. {
  3196. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3197. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3198. }
  3199. }
  3200. else
  3201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3202. break;
  3203. }
  3204. case COMMAND_SPAWN_COMBINE:{
  3205. Spawn* spawn = cmdTarget;
  3206. float radius = 0;
  3207. bool failed = true;
  3208. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3209. failed = false;
  3210. if(spawn->GetSpawnGroupID() > 0){
  3211. 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.");
  3212. }
  3213. else if(sep->IsNumber(0)){
  3214. radius = atof(sep->arg[0]);
  3215. client->CombineSpawns(radius, spawn);
  3216. }
  3217. else{
  3218. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3219. client->AddCombineSpawn(spawn);
  3220. }
  3221. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3222. client->RemoveCombineSpawn(spawn);
  3223. }
  3224. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3225. const char* name = 0;
  3226. if(sep->arg[1] && sep->arg[1][0])
  3227. name = sep->argplus[1];
  3228. client->SaveCombineSpawns(name);
  3229. }
  3230. else
  3231. failed = true;
  3232. }
  3233. }
  3234. if(failed){
  3235. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3237. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3238. }
  3239. break;
  3240. }
  3241. case COMMAND_SPAWN_CREATE:{
  3242. Spawn* spawn = 0;
  3243. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3244. spawn = new Object();
  3245. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3246. }
  3247. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3248. spawn = new GroundSpawn();
  3249. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3250. }
  3251. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3252. spawn = new Sign();
  3253. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3254. }
  3255. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3256. spawn = new NPC();
  3257. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3258. spawn->appearance.pos.collision_radius = 32;
  3259. spawn->secondary_command_list_id = 0;
  3260. spawn->primary_command_list_id = 0;
  3261. spawn->appearance.display_name = 1;
  3262. spawn->appearance.show_level = 1;
  3263. spawn->appearance.attackable = 1;
  3264. }
  3265. else{
  3266. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3267. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3269. break;
  3270. }
  3271. spawn->SetID(Spawn::NextID());
  3272. spawn->SetX(client->GetPlayer()->GetX());
  3273. spawn->SetY(client->GetPlayer()->GetY());
  3274. spawn->SetZ(client->GetPlayer()->GetZ());
  3275. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3276. spawn->SetSpawnOrigX(spawn->GetX());
  3277. spawn->SetSpawnOrigY(spawn->GetY());
  3278. spawn->SetSpawnOrigZ(spawn->GetZ());
  3279. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3280. spawn->appearance.targetable = 1;
  3281. spawn->appearance.race = 255;
  3282. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3283. spawn->SetModelType(atoi(sep->arg[1]));
  3284. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3285. spawn->SetLevel(atoi(sep->arg[3]));
  3286. spawn->SetName(sep->arg[4]);
  3287. if(sep->arg[5][0] && sep->IsNumber(5))
  3288. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3289. if(sep->arg[6][0] && sep->IsNumber(6))
  3290. spawn->size = atoi(sep->arg[6]);
  3291. if(spawn->GetTotalHP() == 0){
  3292. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3293. spawn->SetHP(25*spawn->GetLevel() + 1);
  3294. }
  3295. if(spawn->GetTotalPower() == 0){
  3296. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3297. spawn->SetPower(25*spawn->GetLevel() + 1);
  3298. }
  3299. client->GetCurrentZone()->AddSpawn(spawn);
  3300. break;
  3301. }
  3302. case COMMAND_SPAWN_EQUIPMENT:{
  3303. Spawn* spawn = cmdTarget;
  3304. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3305. int8 slot = atoi(sep->arg[0]);
  3306. int16 type = atoi(sep->arg[1]);
  3307. int8 red = 0;
  3308. int8 green = 0;
  3309. int8 blue = 0;
  3310. int8 h_red = 0;
  3311. int8 h_green = 0;
  3312. int8 h_blue = 0;
  3313. if(sep->arg[2])
  3314. red = atoi(sep->arg[2]);
  3315. if(sep->arg[3])
  3316. green = atoi(sep->arg[3]);
  3317. if(sep->arg[4])
  3318. blue = atoi(sep->arg[4]);
  3319. if(sep->arg[5])
  3320. h_red = atoi(sep->arg[5]);
  3321. if(sep->arg[6])
  3322. h_green = atoi(sep->arg[6]);
  3323. if(sep->arg[7])
  3324. h_blue = atoi(sep->arg[7]);
  3325. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3326. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3327. }
  3328. else{
  3329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3332. }
  3333. break;
  3334. }
  3335. case COMMAND_SPAWN_DETAILS:{
  3336. Spawn* spawn = cmdTarget;
  3337. if (sep && sep->arg[0][0]) {
  3338. if (cmdTarget)
  3339. {
  3340. if (ToLower(string(sep->arg[0])) == "los")
  3341. {
  3342. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3343. if (hasLOS)
  3344. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3345. else
  3346. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3347. break;
  3348. }
  3349. else if (ToLower(string(sep->arg[0])) == "bestz")
  3350. {
  3351. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3352. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3353. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3354. break;
  3355. }
  3356. else if (ToLower(string(sep->arg[0])) == "pathto")
  3357. {
  3358. break;
  3359. }
  3360. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3361. {
  3362. break;
  3363. }
  3364. }
  3365. if (sep->IsNumber(0))
  3366. {
  3367. float radius = atof(sep->arg[0]);
  3368. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3370. break;
  3371. }
  3372. }
  3373. if(spawn){
  3374. const char* type = "NPC";
  3375. if(spawn->IsObject())
  3376. type = "Object";
  3377. else if(spawn->IsSign())
  3378. type = "Sign";
  3379. else if(spawn->IsWidget())
  3380. type = "Widget";
  3381. else if(spawn->IsGroundSpawn())
  3382. type = "GroundSpawn";
  3383. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3384. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3385. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3386. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3387. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3388. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3389. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3390. 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());
  3391. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3392. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3393. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3394. if(spawn->IsEntity()){
  3395. 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());
  3396. 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());
  3397. }
  3398. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3399. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3400. 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());
  3401. 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);
  3402. if (spawn->IsNPC())
  3403. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3404. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3405. if (packet) {
  3406. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3407. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3408. packet->setDataByName("book_title", title.c_str());
  3409. packet->setDataByName("book_type", "simple");
  3410. packet->setDataByName("unknown2", 1);
  3411. packet->setDataByName("unknown5", 1, 4);
  3412. packet->setArrayLengthByName("num_pages", 4);
  3413. string details;
  3414. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3415. details += "Type: " + string(type) + "\n";
  3416. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3417. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3418. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3419. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3420. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3421. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3422. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3423. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3424. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3425. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3426. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3427. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3428. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3429. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3430. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3431. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3432. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3433. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3434. char x[16];
  3435. sprintf(x, "%.2f", spawn->GetX());
  3436. char y[16];
  3437. sprintf(y, "%.2f", spawn->GetY());
  3438. char z[16];
  3439. sprintf(z, "%.2f", spawn->GetZ());
  3440. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3441. string details2;
  3442. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3443. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3444. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3445. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3446. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3447. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3448. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3449. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3450. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3451. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3452. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3453. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3454. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3455. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3456. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3457. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3458. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3459. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3460. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3461. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3462. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3463. string details3;
  3464. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3465. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3466. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3467. string details4;
  3468. if (spawn->IsEntity()) {
  3469. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3470. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3471. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3472. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3473. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3474. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3475. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3476. if (spawn->IsNPC()) {
  3477. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3478. }
  3479. }
  3480. //details2 += "" + to_string() + "\n";
  3481. packet->setArrayDataByName("page_text", details.c_str());
  3482. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3483. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3484. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3485. client->QueuePacket(packet->serialize());
  3486. safe_delete(packet);
  3487. }
  3488. }
  3489. else {
  3490. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will display information about the currently selected spawn, or in the case of specifying a numerical radius will show minor details about spawns in the players radius.");
  3492. }
  3493. break;
  3494. }
  3495. case COMMAND_SPAWN_TARGET:{
  3496. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3497. int32 spawn_id = atoul(sep->arg[0]);
  3498. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3499. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3500. }
  3501. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3502. float distance = atof(sep->arg[1]);
  3503. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3504. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3505. }
  3506. else{
  3507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3508. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3509. }
  3510. break;
  3511. }
  3512. case COMMAND_SPAWN_SET:
  3513. {
  3514. Spawn* spawn = cmdTarget;
  3515. sint16 set_type = -1;
  3516. string type_str;
  3517. if (spawn)
  3518. {
  3519. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3520. 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)
  3521. {
  3522. // set the type, which will be 0 if location or list or invalid
  3523. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3524. }
  3525. if(set_type > 0)
  3526. {
  3527. // check if spawn set is NOT a char update, or not location, or isn't a number
  3528. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3529. {
  3530. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3531. }
  3532. else
  3533. {
  3534. string name = string(spawn->GetName());
  3535. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3536. {
  3537. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3538. {
  3539. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3540. }
  3541. else if(set_type == SPAWN_SET_VALUE_NAME)
  3542. {
  3543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3544. }
  3545. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3546. {
  3547. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3548. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3549. }
  3550. else
  3551. {
  3552. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3553. }
  3554. switch (set_type)
  3555. {
  3556. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3557. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3558. case SPAWN_SET_VALUE_FACTION:
  3559. {
  3560. // not applicable
  3561. break;
  3562. }
  3563. default:
  3564. {
  3565. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3566. break;
  3567. }
  3568. }
  3569. 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))
  3570. {
  3571. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3572. {
  3573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3574. }
  3575. else if(spawn->GetSpawnLocationID() > 0)
  3576. {
  3577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3578. }
  3579. }
  3580. else
  3581. {
  3582. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3583. {
  3584. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3585. }
  3586. else if(spawn->GetDatabaseID() > 0)
  3587. {
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3589. }
  3590. }
  3591. }
  3592. }
  3593. }
  3594. else if(set_type == 0)
  3595. {
  3596. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3597. map<string, int8>::iterator itr;
  3598. int i=0;
  3599. string list;
  3600. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3601. {
  3602. if(i==10)
  3603. {
  3604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3605. i = 0;
  3606. }
  3607. if(i>0)
  3608. {
  3609. list.append(", ").append(itr->first);
  3610. }
  3611. else
  3612. {
  3613. list = itr->first;
  3614. }
  3615. }
  3616. if(list.length() > 0)
  3617. {
  3618. // if 1 or more, display in client.
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3620. }
  3621. }
  3622. else
  3623. {
  3624. // syntax fail
  3625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3629. }
  3630. }
  3631. break;
  3632. }
  3633. case COMMAND_SPAWN_REMOVE:{
  3634. Spawn* spawn = cmdTarget;
  3635. if(spawn && !spawn->IsPlayer()){
  3636. if(spawn->GetSpawnLocationID() > 0){
  3637. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3638. bool delete_spawn = false;
  3639. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3640. if(atoi(sep->arg[0]) == 1)
  3641. delete_spawn = true;
  3642. }
  3643. if(delete_spawn)
  3644. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3645. else
  3646. spawn->SetSpawnLocationID(0);
  3647. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3648. }
  3649. else
  3650. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3651. }
  3652. else
  3653. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3654. }
  3655. else{
  3656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3659. }
  3660. break;
  3661. }
  3662. case COMMAND_SPAWN_LIST:{
  3663. if(sep && sep->arg[0][0]){
  3664. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3665. vector<string>::iterator itr;
  3666. if(results){
  3667. for(itr=results->begin();itr!=results->end();itr++){
  3668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3669. }
  3670. safe_delete(results);
  3671. }
  3672. else
  3673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3674. }
  3675. else{
  3676. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3679. }
  3680. break;
  3681. }
  3682. case COMMAND_SPAWN_ADD:{
  3683. Spawn* spawn = cmdTarget;
  3684. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3685. if(spawn->GetSpawnLocationID() > 0){
  3686. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3687. break;
  3688. }
  3689. if(spawn->GetDatabaseID() == 0){
  3690. if(database.SaveSpawnInfo(spawn)) {
  3691. char spawn_type[32];
  3692. memset(spawn_type, 0, sizeof(spawn_type));
  3693. if (spawn->IsNPC())
  3694. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3695. else if (spawn->IsObject())
  3696. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3697. else if (spawn->IsSign())
  3698. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3699. else if (spawn->IsGroundSpawn())
  3700. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3701. else
  3702. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3703. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3704. }
  3705. else
  3706. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3707. }
  3708. int32 spawn_group_id = 0;
  3709. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3710. spawn_group_id = database.GetNextSpawnLocation();
  3711. else
  3712. spawn_group_id = atol(sep->arg[0]);
  3713. int8 percent = 100;
  3714. if(sep->arg[2] && sep->IsNumber(2))
  3715. percent = atoi(sep->arg[2]);
  3716. spawn->SetSpawnLocationID(spawn_group_id);
  3717. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3718. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3719. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3720. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3721. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3722. else
  3723. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3724. }
  3725. else{
  3726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3729. }
  3730. break;
  3731. }
  3732. case COMMAND_SPAWN:{
  3733. int32 id = 0;
  3734. Spawn* spawn = 0;
  3735. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3736. id = atol(sep->arg[0]);
  3737. spawn = client->GetCurrentZone()->GetSpawn(id);
  3738. }
  3739. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3740. id = 0;
  3741. if(!id || !spawn){
  3742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3745. safe_delete(sep);
  3746. return;
  3747. }
  3748. if(sep && sep->arg[1][0]){
  3749. float x = atof(sep->arg[1]);
  3750. spawn->appearance.pos.X = x;
  3751. }
  3752. else
  3753. spawn->SetX(client->GetPlayer()->GetX(), false);
  3754. if(sep && sep->arg[2][0]){
  3755. float y = atof(sep->arg[2]);
  3756. spawn->appearance.pos.Y = y;
  3757. }
  3758. else
  3759. spawn->SetY(client->GetPlayer()->GetY(), false);
  3760. if(sep && sep->arg[3][0]){
  3761. float z = atof(sep->arg[3]);
  3762. spawn->appearance.pos.Z = z;
  3763. }
  3764. else
  3765. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3766. if(sep && sep->arg[4][0]){
  3767. float heading = atof(sep->arg[4]);
  3768. spawn->SetHeading(heading);
  3769. }
  3770. else
  3771. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3772. spawn->SetSpawnOrigX(spawn->GetX());
  3773. spawn->SetSpawnOrigY(spawn->GetY());
  3774. spawn->SetSpawnOrigZ(spawn->GetZ());
  3775. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3776. if(sep && sep->arg[5][0])
  3777. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3778. else
  3779. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3780. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3781. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3782. spawn->SetHP(spawn->GetTotalHP());
  3783. }
  3784. if(spawn->GetTotalPower() == 0){
  3785. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3786. spawn->SetPower(spawn->GetTotalPower());
  3787. }
  3788. const char* script = world.GetSpawnScript(id);
  3789. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3790. spawn->SetSpawnScript(string(script));
  3791. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3792. client->GetCurrentZone()->AddSpawn(spawn);
  3793. if(spawn->IsNPC())
  3794. spawn->GetZone()->AddLoot((NPC*)spawn);
  3795. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3796. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3797. break;
  3798. }
  3799. case COMMAND_ADMINFLAG:
  3800. {
  3801. if(sep && sep->arg[0]){
  3802. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3803. sint16 new_status = atoi(sep->arg[1]);
  3804. if(tmp_status == -10)
  3805. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3806. else if(tmp_status >= client->GetAdminStatus())
  3807. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3808. else if (new_status > client->GetAdminStatus())
  3809. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3810. else{
  3811. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3812. if (!client2)
  3813. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3814. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3815. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3816. if (client2) {
  3817. client2->SetAdminStatus(new_status);
  3818. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3819. }
  3820. }
  3821. else
  3822. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3823. }
  3824. }else{
  3825. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3826. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3827. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3828. }
  3829. break;
  3830. }
  3831. case COMMAND_CANNEDEMOTE:{
  3832. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3833. break;
  3834. }
  3835. case COMMAND_BROADCAST: {
  3836. if (sep && sep->arg[0])
  3837. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3838. else
  3839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3840. break;
  3841. }
  3842. case COMMAND_ANNOUNCE: {
  3843. if (sep && sep->arg[0])
  3844. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3845. else
  3846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3847. break;
  3848. }
  3849. case COMMAND_RELOAD_ITEMS:{
  3850. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3852. database.ReloadItemList();
  3853. database.LoadMerchantInformation();
  3854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3855. break;
  3856. }
  3857. case COMMAND_ENABLE_ABILITY_QUE:{
  3858. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3859. if(app)
  3860. client->QueuePacket(app);
  3861. break;
  3862. }
  3863. case COMMAND_ITEMSEARCH:{
  3864. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3865. if (packet) {
  3866. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3867. //packet->setDataByName("unknown", 1);
  3868. packet->setDataByName("unknown2", 5, 0);
  3869. packet->setDataByName("unknown2", 20, 1);
  3870. packet->setDataByName("unknown2", 58, 3);
  3871. packet->setDataByName("unknown2", 40, 4);
  3872. client->QueuePacket(packet->serialize());
  3873. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3874. if (packet2) {
  3875. packet2->setDataByName("char_id", client->GetCharacterID());
  3876. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3877. safe_delete(packet2);
  3878. }
  3879. safe_delete(packet);
  3880. }
  3881. break;
  3882. }
  3883. case COMMAND_ANIMTEST:{
  3884. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3885. if(command_packet){
  3886. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3887. if (cmdTarget)
  3888. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3889. command_packet->setDataByName ( "spawn_id" , id);
  3890. int animID = 1;
  3891. if(sep && sep->arg[0] && sep->IsNumber(0))
  3892. animID = atoi(sep->arg[0]);
  3893. VisualState* vs = NULL;
  3894. if(animID == 0)
  3895. {
  3896. vs = visual_states.FindVisualState(sep->arg[0]);
  3897. }
  3898. char msg[128];
  3899. sprintf(msg,"Animation Test ID: %i",animID);
  3900. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3901. if(vs != NULL)
  3902. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3903. else
  3904. command_packet->setDataByName ( "anim_type", animID );
  3905. command_packet->setDataByName ( "unknown0", 0 );
  3906. EQ2Packet* outapp = command_packet->serialize();
  3907. client->QueuePacket(outapp);
  3908. safe_delete(command_packet);
  3909. }
  3910. break;
  3911. }
  3912. case COMMAND_KICK:
  3913. {
  3914. if( sep == 0 || sep->arg[0] == 0)
  3915. {
  3916. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3917. }
  3918. else
  3919. {
  3920. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3921. if ( kickClient == client )
  3922. {
  3923. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3924. break;
  3925. }
  3926. else if(kickClient != NULL)
  3927. {
  3928. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3929. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3930. {
  3931. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3932. break;
  3933. }
  3934. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3935. kickClient->Disconnect();
  3936. }
  3937. else
  3938. {
  3939. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3940. }
  3941. }
  3942. break;
  3943. }
  3944. case COMMAND_LOCK:
  3945. {
  3946. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3947. int worldLocked = atoi(sep->arg[0]);
  3948. net.world_locked = worldLocked;
  3949. if ( worldLocked )
  3950. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3951. else
  3952. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3953. }
  3954. else
  3955. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3956. break;
  3957. }
  3958. case COMMAND_BAN:{
  3959. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3960. {
  3961. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3962. }
  3963. else
  3964. {
  3965. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3966. if ( kickClient == client )
  3967. {
  3968. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3969. break;
  3970. }
  3971. else if(kickClient != NULL)
  3972. {
  3973. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3974. if ( maxStatus > client->GetAdminStatus( ) ||
  3975. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3976. {
  3977. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3978. break;
  3979. }
  3980. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3981. int perm = atol(sep->arg[1]);
  3982. if ( perm == 1 )
  3983. database.UpdateAdminStatus(sep->arg[0],-2);
  3984. else
  3985. database.UpdateAdminStatus(sep->arg[0],-1);
  3986. kickClient->Disconnect();
  3987. }
  3988. else
  3989. {
  3990. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3991. }
  3992. }
  3993. break;
  3994. }
  3995. case COMMAND_SET_COMBAT_VOICE:{
  3996. int32 value = 0;
  3997. if(sep && sep->arg[0] && sep->IsNumber(0))
  3998. value = atoi(sep->arg[0]);
  3999. client->GetPlayer()->SetCombatVoice(value);
  4000. break;
  4001. }
  4002. case COMMAND_SET_EMOTE_VOICE:{
  4003. int32 value = 0;
  4004. if(sep && sep->arg[0] && sep->IsNumber(0))
  4005. value = atoi(sep->arg[0]);
  4006. client->GetPlayer()->SetEmoteVoice(value);
  4007. break;
  4008. }
  4009. case COMMAND_GIVEITEM:{
  4010. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4011. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4012. if ( itemToClient == NULL )
  4013. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4014. else
  4015. {
  4016. int32 item_id = atol(sep->arg[1]);
  4017. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4018. itemToClient->AddItem(item_id);
  4019. }
  4020. }
  4021. else
  4022. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4023. break;
  4024. }
  4025. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4026. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4027. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4028. case COMMAND_SKILL :
  4029. case COMMAND_SKILL_ADD :
  4030. case COMMAND_SKILL_REMOVE :
  4031. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4032. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4033. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4034. case COMMAND_ENTITYCOMMAND :
  4035. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4036. case COMMAND_MERCHANT :
  4037. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4038. case COMMAND_APPEARANCE :
  4039. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4040. case COMMAND_TRACK : { Command_Track(client); break; }
  4041. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4042. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4043. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4044. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4045. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4046. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4047. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4048. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4049. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4050. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4051. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4052. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4053. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4054. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4055. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4056. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4057. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4058. case COMMAND_LOCATION : { Command_Location(client); break; }
  4059. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4060. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4061. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4062. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4063. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4064. case COMMAND_GRID : { Command_Grid(client); break; }
  4065. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4066. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4067. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4068. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4069. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4070. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4071. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4072. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4073. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4074. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4075. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4076. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4077. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4078. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4079. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4080. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4081. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4082. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4083. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4084. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4085. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4086. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4087. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4088. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4089. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4090. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4091. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4092. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4093. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4094. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4095. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4096. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4097. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4098. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4099. case COMMAND_TITLE : { Command_Title(client); break; }
  4100. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4101. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4102. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4103. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4104. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4105. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4106. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4107. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4108. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4109. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4110. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4111. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4112. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4113. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4114. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4115. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4116. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4117. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4118. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4119. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4120. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4121. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4122. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4123. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4124. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4125. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4126. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4127. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4128. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4129. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4130. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4131. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4132. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4133. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4134. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4135. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4136. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4137. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4138. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4139. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4140. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4141. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4142. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4143. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4144. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4145. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4146. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4147. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4148. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4149. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4150. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4151. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4152. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4153. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4154. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4155. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4156. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4157. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4158. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4159. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4160. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4161. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4162. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4163. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4164. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4165. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4166. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4167. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4168. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4169. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4170. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4171. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4172. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4173. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4174. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4175. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4176. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4177. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4178. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4179. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4180. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4181. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4182. case ADD_AA : { Add_AA(client, sep); break; }
  4183. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4184. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4185. case BACK_AA : { Back_AA(client, sep); break; }
  4186. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4187. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4188. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4189. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4190. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4191. default:
  4192. {
  4193. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4194. break;
  4195. }
  4196. }
  4197. safe_delete(sep);
  4198. }
  4199. /******************** New COMMAND Handler Functions ********************/
  4200. /*
  4201. Started breaking apart the huge switch() for commands into sepErate
  4202. functions so it is easier to locate the blocks of code by command
  4203. -- JA 2012.03.03
  4204. */
  4205. // sample function header
  4206. /*
  4207. Function:
  4208. Purpose :
  4209. Params :
  4210. Dev :
  4211. Example :
  4212. */
  4213. //void Commands::Command()
  4214. //{
  4215. //}
  4216. /*
  4217. Function: Command_AcceptAdvancement()
  4218. Purpose : Player accepts a new advancement option
  4219. Params : Spell ID
  4220. Dev : Jabantiz
  4221. */
  4222. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4223. {
  4224. Player *player = client->GetPlayer();
  4225. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4226. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4227. if (!player->HasSpell(trait->spellID, 0, true))
  4228. {
  4229. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4230. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4231. }
  4232. else
  4233. {
  4234. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4235. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4236. player->RemoveSpellBookEntry(spell->GetSpellID());
  4237. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4238. player->UnlockSpell(spell);
  4239. client->SendSpellUpdate(spell);
  4240. }
  4241. // Spell book update
  4242. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4243. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4244. }
  4245. /*
  4246. Function:
  4247. Purpose :
  4248. Params :
  4249. Dev :
  4250. Example :
  4251. */
  4252. void Commands::Command_AFK(Client* client, Seperator* sep)
  4253. {
  4254. Player* player = client->GetPlayer();
  4255. player->toggle_character_flag(CF_AFK);
  4256. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4257. if (player->get_character_flag(CF_AFK))
  4258. {
  4259. //LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4260. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  4261. if (sep && sep->argplus[0])
  4262. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4263. else
  4264. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4265. string message = string(player->GetName()) + " is going afk.";
  4266. Spawn* target = player->GetTarget();
  4267. if (target && target != player)
  4268. {
  4269. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4270. player->GetGender() == 1 ? message += "he" : message += "she";
  4271. message += " is going afk.";
  4272. }
  4273. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4274. }
  4275. else
  4276. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  4277. }
  4278. /*
  4279. Function: Command_Appearance()
  4280. Purpose : Handles /appearance commands
  4281. Params : list
  4282. Dev : Scatman
  4283. Example : /appearance list
  4284. */
  4285. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4286. {
  4287. if( handler == COMMAND_APPEARANCE )
  4288. {
  4289. // /appearance command by itself shows help (to be extended)
  4290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4291. return;
  4292. }
  4293. else if( handler == COMMAND_APPEARANCE_LIST )
  4294. {
  4295. // /appearance list command expects "name" param
  4296. if (sep && sep->arg[0])
  4297. {
  4298. const char* appearance_name = sep->argplus[0];
  4299. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4300. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4301. if (appearances)
  4302. {
  4303. vector<int16>::iterator itr;
  4304. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4305. {
  4306. int16 id = *itr;
  4307. string name = database.GetAppearanceName(id);
  4308. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4309. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4310. }
  4311. safe_delete(appearances);
  4312. }
  4313. }
  4314. else // no param
  4315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4316. }
  4317. }
  4318. /*
  4319. Function: Command_Claim()
  4320. Purpose :
  4321. Params :
  4322. Dev :
  4323. Example :
  4324. */
  4325. void Commands::Command_Claim(Client* client, Seperator* sep)
  4326. {
  4327. if (sep && sep->arg[0] && sep->IsNumber(0))
  4328. {
  4329. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4331. }
  4332. else
  4333. client->ShowClaimWindow();
  4334. }
  4335. /*
  4336. Function: Command_ClearAllQueued()
  4337. Purpose :
  4338. Params :
  4339. Dev :
  4340. Example :
  4341. */
  4342. void Commands::Command_ClearAllQueued(Client* client)
  4343. {
  4344. ZoneServer* zone = client->GetPlayer()->GetZone();
  4345. if (zone && zone->GetSpellProcess())
  4346. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4347. }
  4348. /*
  4349. Function: Command_CancelMaintained()
  4350. Purpose : Cancels maintained spells
  4351. Params : Maintained Spell Index
  4352. Dev : Zcoretri
  4353. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4354. */
  4355. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4356. {
  4357. if (sep && sep->arg[0] && sep->IsNumber(0))
  4358. {
  4359. int32 spell_index = atoul(sep->arg[0]);
  4360. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4361. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4362. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4363. // just not spelleffects/dets - Foof
  4364. //{
  4365. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4366. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4367. // }
  4368. //else
  4369. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4370. }
  4371. }
  4372. /*
  4373. Function: Command_Create()
  4374. Purpose : Handler for starting Tradeskilling table
  4375. Params :
  4376. Dev : Zcoretri
  4377. Example :
  4378. */
  4379. void Commands::Command_Create(Client* client, Seperator* sep)
  4380. {
  4381. PrintSep(sep, "COMMAND_CREATE");
  4382. client->SendRecipeList();
  4383. client->ShowRecipeBook();
  4384. }
  4385. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4386. {
  4387. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4388. if (sep && sep->arg[0] && sep->IsNumber(0))
  4389. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4390. }
  4391. /*
  4392. Function: Command_Distance()
  4393. Purpose : Displays distance from targeted spawn
  4394. Params :
  4395. Dev : Scatman
  4396. Example : /distance
  4397. */
  4398. void Commands::Command_Distance(Client* client)
  4399. {
  4400. Spawn* target = client->GetPlayer()->GetTarget();
  4401. if (target)
  4402. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4403. else
  4404. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4405. }
  4406. /*
  4407. Function: Command_Duel()
  4408. Purpose : Handle the /duel commands - not yet implemented
  4409. Params : unknown
  4410. Dev :
  4411. Example :
  4412. */
  4413. void Commands::Command_Duel(Client* client, Seperator* sep)
  4414. {
  4415. PrintSep(sep, "COMMAND_DUEL");
  4416. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4417. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4418. }
  4419. /*
  4420. Function: Command_DuelBet()
  4421. Purpose : Handle the /duel commands - not yet implemented
  4422. Params : unknown
  4423. Dev :
  4424. Example :
  4425. */
  4426. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4427. {
  4428. PrintSep(sep, "COMMAND_DUELBET");
  4429. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4430. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4431. }
  4432. /*
  4433. Function: Command_DuelAccept()
  4434. Purpose : Handle the /duel commands - not yet implemented
  4435. Params : unknown
  4436. Dev :
  4437. Example :
  4438. */
  4439. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4440. {
  4441. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4442. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4443. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4444. }
  4445. /*
  4446. Function: Command_DuelDecline()
  4447. Purpose : Handle the /duel commands - not yet implemented
  4448. Params : unknown
  4449. Dev :
  4450. Example :
  4451. */
  4452. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4453. {
  4454. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4455. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4456. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4457. }
  4458. /*
  4459. Function: Command_DuelSurrender()
  4460. Purpose : Handle the /duel commands - not yet implemented
  4461. Params : unknown
  4462. Dev :
  4463. Example :
  4464. */
  4465. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4466. {
  4467. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4468. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4469. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4470. // JA, just messin around ;)
  4471. char surrender[64];
  4472. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4473. zone_list.HandleGlobalAnnouncement(surrender);
  4474. }
  4475. /*
  4476. Function: Command_DuelToggle()
  4477. Purpose : Handle the /duel commands - not yet implemented
  4478. Params : unknown
  4479. Dev :
  4480. Example :
  4481. */
  4482. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4483. {
  4484. PrintSep(sep, "COMMAND_DUEL");
  4485. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4486. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4487. }
  4488. /*
  4489. Function:
  4490. Purpose :
  4491. Params :
  4492. Dev :
  4493. Example :
  4494. */
  4495. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4496. {
  4497. if( handler == COMMAND_ENTITYCOMMAND )
  4498. {
  4499. // /entitycommand command by itself shows help (to be extended)
  4500. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4501. return;
  4502. }
  4503. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4504. {
  4505. // /entitycommand list command expects "name" param
  4506. if (sep && sep->arg[0])
  4507. {
  4508. const char* entity_command_name = sep->argplus[0];
  4509. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4510. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4511. map<int32, vector<EntityCommand*>*>::iterator itr;
  4512. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4513. {
  4514. vector<EntityCommand*>* entity_command_list = itr->second;
  4515. vector<EntityCommand*>::iterator itr2;
  4516. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4517. {
  4518. EntityCommand* entity_command = *itr2;
  4519. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4520. 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);
  4521. }
  4522. }
  4523. }
  4524. else // no command name
  4525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4526. }
  4527. }
  4528. /*
  4529. Function: Command_Follow()
  4530. Purpose : Handle the /follow command - not yet implemented
  4531. Params :
  4532. Dev :
  4533. Example :
  4534. */
  4535. void Commands::Command_Follow(Client* client, Seperator* sep)
  4536. {
  4537. PrintSep(sep, "COMMAND_FOLLOW");
  4538. // flag to toggle if the players target is in the players group
  4539. bool targetInGroup = false;
  4540. // get a pointer to the players group
  4541. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4542. // If the player has a group and has a target
  4543. if (gmi && client->GetPlayer()->GetTarget()) {
  4544. deque<GroupMemberInfo*>::iterator itr;
  4545. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4546. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4547. // Loop through the group members
  4548. for (itr = members->begin(); itr != members->end(); itr++) {
  4549. // If a group member matches a target
  4550. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4551. // toggle the flag and break the loop
  4552. targetInGroup = true;
  4553. break;
  4554. }
  4555. }
  4556. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4557. }
  4558. if (targetInGroup) {
  4559. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4560. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4561. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4562. client->GetPlayer()->info_changed = true;
  4563. client->GetPlayer()->changed = true;
  4564. }
  4565. else
  4566. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4567. }
  4568. /*
  4569. Function: Command_StopFollow()
  4570. Purpose : Handle the /stop_follow command - not yet implemented
  4571. Params :
  4572. Dev :
  4573. Example :
  4574. */
  4575. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4576. {
  4577. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4578. if (client->GetPlayer()->GetFollowTarget()) {
  4579. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4580. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4581. client->GetPlayer()->SetFollowTarget(0);
  4582. client->GetPlayer()->info_changed = true;
  4583. client->GetPlayer()->changed = true;
  4584. }
  4585. }
  4586. #include "../Zone/SPGrid.h"
  4587. /*
  4588. Function: Command_Grid()
  4589. Purpose : Show player's current Grid ID
  4590. Params :
  4591. Dev : Scatman
  4592. Example : /grid
  4593. */
  4594. void Commands::Command_Grid(Client* client)
  4595. {
  4596. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4597. if (client->GetCurrentZone()->Grid != nullptr) {
  4598. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4599. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4600. }
  4601. }
  4602. /*
  4603. Function: Command_Guild()
  4604. Purpose : Handler for all UI-related guild commands
  4605. Dev : Scatman
  4606. */
  4607. void Commands::Command_Guild(Client* client, Seperator* sep)
  4608. {
  4609. Guild* guild = client->GetPlayer()->GetGuild();
  4610. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4611. {
  4612. const char* command = sep->arg[0];
  4613. int32 length = strlen(command);
  4614. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4615. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4616. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4617. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4618. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4619. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4620. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4621. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4622. guild->KickGuildMember(client, sep->arg[1]);
  4623. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4624. guild->DemoteGuildMember(client, sep->arg[1]);
  4625. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4626. guild->PromoteGuildMember(client, sep->arg[1]);
  4627. else if (strncmp(command, "points", length) == 0 && guild)
  4628. {
  4629. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4630. {
  4631. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4632. {
  4633. float points = atof(sep->arg[2]);
  4634. const char* option = sep->arg[3];
  4635. const char* comment = sep->argplus[4];
  4636. if (strncmp(option, "all", strlen(option)) == 0)
  4637. guild->AddPointsToAll(client, points, comment);
  4638. else if (strncmp(option, "online", strlen(option)) == 0)
  4639. guild->AddPointsToAllOnline(client, points, comment);
  4640. else if (strncmp(option, "group", strlen(option)) == 0)
  4641. guild->AddPointsToGroup(client, points, comment);
  4642. else if (strncmp(option, "raid", strlen(option)) == 0)
  4643. guild->AddPointsToRaid(client, points, comment);
  4644. else
  4645. guild->AddPointsToGuildMember(client, points, option, comment);
  4646. }
  4647. }
  4648. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4649. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4650. else
  4651. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4652. }
  4653. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4654. guild->SetMOTD(sep->argplus[1]);
  4655. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4656. {
  4657. if (sep->arg[1])
  4658. {
  4659. const char* option = sep->arg[1];
  4660. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4661. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4662. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4663. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4664. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4665. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4666. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4667. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4668. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4669. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4670. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4671. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4672. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4673. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4674. else
  4675. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4676. }
  4677. else
  4678. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4679. }
  4680. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4681. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4682. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4683. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4684. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4685. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4686. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4687. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4688. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4689. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4690. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4691. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4692. else if (strncmp(command, "invite", length) == 0 && guild)
  4693. {
  4694. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4695. guild->InvitePlayer(client, sep->arg[1]);
  4696. else
  4697. {
  4698. Spawn* target = client->GetPlayer()->GetTarget();
  4699. if (target)
  4700. {
  4701. if (target->IsPlayer())
  4702. guild->InvitePlayer(client, target->GetName());
  4703. else
  4704. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4705. }
  4706. }
  4707. }
  4708. else if (strncmp(command, "accept", length) == 0)
  4709. {
  4710. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4711. if (pgi && pgi->guild && pgi->invited_by)
  4712. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4713. client->SetPendingGuildInvite(0);
  4714. }
  4715. else if (strncmp(command, "decline", length) == 0)
  4716. {
  4717. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4718. if (pgi && pgi->guild && pgi->invited_by)
  4719. {
  4720. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4721. if (client_inviter)
  4722. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4723. }
  4724. client->SetPendingGuildInvite(0);
  4725. }
  4726. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4727. {
  4728. const char* guild_name = sep->argplus[1];
  4729. if (!guild_list.GetGuild(guild_name))
  4730. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4731. else
  4732. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4733. }
  4734. else if (strncmp(command, "search", length) == 0)
  4735. client->ShowGuildSearchWindow();
  4736. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4737. {
  4738. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4739. if (to_guild)
  4740. to_guild->SendGuildRecruitingDetails(client);
  4741. }
  4742. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4743. {
  4744. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4745. if (to_guild)
  4746. to_guild->SendGuildRecruitingImages(client);
  4747. }
  4748. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4749. {
  4750. if (sep->arg[1])
  4751. {
  4752. const char* option = sep->arg[1];
  4753. if (strncmp(option, "toggle", strlen(option)) == 0)
  4754. guild->ToggleGuildRecruiterAdventureClass(client);
  4755. }
  4756. else
  4757. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4758. }
  4759. else if (strncmp(command, "display_heraldry", length) == 0)
  4760. {
  4761. // JA: not sure this is right...
  4762. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4763. client->GetPlayer()->SetCharSheetChanged(true);
  4764. }
  4765. else
  4766. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4767. }
  4768. }
  4769. /*
  4770. Function: Command_GuildCreate()
  4771. Purpose : Display's in-game Guild Creation window
  4772. Dev : Scatman
  4773. */
  4774. void Commands::Command_CreateGuild(Client* client)
  4775. {
  4776. client->SendGuildCreateWindow();
  4777. }
  4778. /*
  4779. Function: Command_SetGuildOfficerNote()
  4780. Purpose :
  4781. Dev : Scatman
  4782. */
  4783. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4784. {
  4785. if (sep && sep->arg[0] && sep->arg[1])
  4786. {
  4787. Guild* guild = client->GetPlayer()->GetGuild();
  4788. if (guild)
  4789. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4790. }
  4791. }
  4792. /*
  4793. Function: Command_SetGuildMemberNote()
  4794. Purpose :
  4795. Dev : Scatman
  4796. */
  4797. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4798. {
  4799. if (sep && sep->arg[0] && sep->arg[1])
  4800. {
  4801. Guild* guild = client->GetPlayer()->GetGuild();
  4802. if (guild)
  4803. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4804. }
  4805. }
  4806. /*
  4807. Function: Command_GuildSay()
  4808. Purpose :
  4809. Dev : Scatman
  4810. */
  4811. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4812. {
  4813. Guild* guild = client->GetPlayer()->GetGuild();
  4814. if (guild)
  4815. {
  4816. if (sep && sep->arg[0])
  4817. guild->HandleGuildSay(client, sep->argplus[0]);
  4818. }
  4819. else
  4820. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4821. }
  4822. /*
  4823. Function: Command_OfficerSay()
  4824. Purpose :
  4825. Dev : Scatman
  4826. */
  4827. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4828. {
  4829. Guild* guild = client->GetPlayer()->GetGuild();
  4830. if (guild)
  4831. {
  4832. if (sep && sep->arg[0])
  4833. guild->HandleOfficerSay(client, sep->argplus[0]);
  4834. }
  4835. else
  4836. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4837. }
  4838. /*
  4839. Function: Command_Guilds()
  4840. Purpose : Shows help for /guild command
  4841. Params :
  4842. Dev : Scatman
  4843. Example :
  4844. */
  4845. void Commands::Command_Guilds(Client* client)
  4846. {
  4847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4848. }
  4849. /*
  4850. Function: Command_GuildsAdd()
  4851. Purpose : Add's players to a guild
  4852. Params : guild_name|guild_id, player name
  4853. Dev : Scatman
  4854. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4855. */
  4856. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4857. {
  4858. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4859. {
  4860. Guild* guild = 0;
  4861. bool found = true;
  4862. if (sep->IsNumber(0))
  4863. {
  4864. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4865. if (!guild)
  4866. {
  4867. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4868. found = false;
  4869. }
  4870. }
  4871. else
  4872. {
  4873. guild = guild_list.GetGuild(sep->arg[0]);
  4874. if (!guild)
  4875. {
  4876. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4877. found = false;
  4878. }
  4879. }
  4880. if (found)
  4881. {
  4882. Client* to_client = 0;
  4883. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4884. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4885. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4886. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4887. if (to_client)
  4888. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4889. else
  4890. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4891. }
  4892. }
  4893. else
  4894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4895. }
  4896. /*
  4897. Function: Command_GuildsCreate()
  4898. Purpose : Creates a guild
  4899. Params : guild_name, player_name (optional)
  4900. Dev : Scatman
  4901. Example : /guilds create [guild name] (player name)
  4902. */
  4903. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4904. {
  4905. if (sep && sep->arg[0])
  4906. {
  4907. const char* guild_name = sep->arg[0];
  4908. if (!guild_list.GetGuild(guild_name))
  4909. {
  4910. bool ret = false;
  4911. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4912. {
  4913. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4914. if (to_client)
  4915. {
  4916. world.CreateGuild(guild_name, to_client);
  4917. ret = true;
  4918. }
  4919. else
  4920. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4921. }
  4922. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4923. {
  4924. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4925. if (to_client)
  4926. {
  4927. world.CreateGuild(guild_name, to_client);
  4928. ret = true;
  4929. }
  4930. }
  4931. else
  4932. {
  4933. world.CreateGuild(guild_name);
  4934. ret = true;
  4935. }
  4936. if (ret)
  4937. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4938. else
  4939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4940. }
  4941. else
  4942. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4943. }
  4944. else
  4945. 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.");
  4946. }
  4947. /*
  4948. Function: Command_GuildsDelete()
  4949. Purpose : Delete's a guild
  4950. Params : guild name
  4951. Dev : Scatman
  4952. Example : /guilds delete Test
  4953. */
  4954. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4955. {
  4956. if (sep && sep->arg[0])
  4957. {
  4958. Guild* guild = 0;
  4959. bool found = true;
  4960. if (sep->IsNumber(0))
  4961. {
  4962. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4963. if (!guild)
  4964. {
  4965. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4966. found = false;
  4967. }
  4968. }
  4969. else
  4970. {
  4971. guild = guild_list.GetGuild(sep->arg[0]);
  4972. if (!guild)
  4973. {
  4974. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4975. found = false;
  4976. }
  4977. }
  4978. if (found)
  4979. {
  4980. guild->RemoveAllGuildMembers();
  4981. database.DeleteGuild(guild);
  4982. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4983. guild_list.RemoveGuild(guild, true);
  4984. }
  4985. }
  4986. else
  4987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4988. }
  4989. /*
  4990. Function: Command_GuildsList()
  4991. Purpose : Lists current guilds on server
  4992. Params :
  4993. Dev : Scatman
  4994. Example : /guilds list
  4995. */
  4996. void Commands::Command_GuildsList(Client* client)
  4997. {
  4998. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4999. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5001. if (guilds->size() == 0)
  5002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5003. else {
  5004. while (itr.Next()) {
  5005. Guild* guild = itr.second;
  5006. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5007. }
  5008. }
  5009. }
  5010. /*
  5011. Function: Command_GuildsRemove()
  5012. Purpose : Removes a player from a guild
  5013. Params : guild name|guild id, player name
  5014. Dev : Scatman
  5015. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5016. */
  5017. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5018. {
  5019. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5020. {
  5021. Guild* guild = 0;
  5022. bool found = true;
  5023. if (sep->IsNumber(0))
  5024. {
  5025. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5026. if (!guild)
  5027. {
  5028. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5029. found = false;
  5030. }
  5031. }
  5032. else
  5033. {
  5034. guild = guild_list.GetGuild(sep->arg[0]);
  5035. if (!guild)
  5036. {
  5037. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5038. found = false;
  5039. }
  5040. }
  5041. if (found)
  5042. {
  5043. Client* to_client = 0;
  5044. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5045. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5046. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5047. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5048. if (to_client)
  5049. {
  5050. Player* to_player = to_client->GetPlayer();
  5051. if (to_player->GetGuild())
  5052. {
  5053. if (to_player->GetGuild() == guild)
  5054. {
  5055. guild->KickGuildMember(client, to_player->GetName());
  5056. }
  5057. else
  5058. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5059. }
  5060. else
  5061. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5062. }
  5063. else
  5064. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5065. }
  5066. }
  5067. else
  5068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5069. }
  5070. /*
  5071. Function: Command_InspectPlayer()
  5072. Purpose : Handle the Inspect functions
  5073. Params : Client to inspect
  5074. Dev : Scatman
  5075. Example : /inspect Scatman
  5076. */
  5077. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5078. {
  5079. if (sep && sep->arg[0])
  5080. {
  5081. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5082. if (inspect_client)
  5083. client->InspectPlayer(inspect_client->GetPlayer());
  5084. }
  5085. else
  5086. {
  5087. Spawn* target = client->GetPlayer()->GetTarget();
  5088. if (target && target->IsPlayer())
  5089. client->InspectPlayer((Player*)target);
  5090. }
  5091. }
  5092. /*
  5093. Function: Command_Inventory()
  5094. Purpose : Handle changes in player inventory
  5095. Params : <TBD>
  5096. Dev : All
  5097. Example : /inventory delete item_id
  5098. */
  5099. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5100. {
  5101. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5102. Player* player = client->GetPlayer();
  5103. if(sep && sep->arg[0][0])
  5104. {
  5105. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5106. if(client->GetPlayer()->GetHP() == 0)
  5107. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5108. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5109. {
  5110. int16 index = atoi(sep->arg[1]);
  5111. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5112. if(item)
  5113. {
  5114. if(item->GetItemScript() && lua_interface)
  5115. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5116. int32 bag_id = item->details.inv_slot_id;
  5117. database.DeleteItem(client->GetCharacterID(), item, 0);
  5118. client->GetPlayer()->item_list.DestroyItem(index);
  5119. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5120. client->QueuePacket(outapp);
  5121. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5122. if (outapp)
  5123. client->QueuePacket(outapp);
  5124. }
  5125. }
  5126. 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))
  5127. {
  5128. int16 from_index = atoi(sep->arg[1]);
  5129. sint16 to_slot = atoi(sep->arg[2]);
  5130. sint32 bag_id = atol(sep->arg[3]);
  5131. int8 charges = atoi(sep->arg[4]);
  5132. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5133. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5134. {
  5135. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5136. return;
  5137. }
  5138. sint32 old_inventory_id = 0;
  5139. if(item)
  5140. old_inventory_id = item->details.inv_slot_id;
  5141. //autobank
  5142. if (bag_id == -3 && to_slot == -1)
  5143. {
  5144. if (player->HasFreeBankSlot())
  5145. to_slot = player->FindFreeBankSlot();
  5146. else
  5147. {
  5148. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5149. return;
  5150. }
  5151. }
  5152. //auto inventory
  5153. if (bag_id == 0 && to_slot == -1)
  5154. {
  5155. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5156. {
  5157. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5158. return;
  5159. }
  5160. }
  5161. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5162. client->QueuePacket(outapp);
  5163. //removed from bag send update
  5164. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5165. {
  5166. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5167. if(outapp)
  5168. client->QueuePacket(outapp);
  5169. }
  5170. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5171. {
  5172. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5173. if(outapp)
  5174. client->QueuePacket(outapp);
  5175. }
  5176. }
  5177. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5178. {
  5179. if(client->GetPlayer()->EngagedInCombat())
  5180. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5181. else
  5182. {
  5183. int16 index = atoi(sep->arg[1]);
  5184. int8 slot_id = 255;
  5185. if(sep->arg[2][0] && sep->IsNumber(2))
  5186. slot_id = atoi(sep->arg[2]);
  5187. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5188. EQ2Packet* outapp = 0;
  5189. for(int32 i=0;i<packets.size();i++)
  5190. {
  5191. outapp = packets[i];
  5192. if(outapp)
  5193. client->QueuePacket(outapp);
  5194. }
  5195. client->GetPlayer()->ChangePrimaryWeapon();
  5196. client->GetPlayer()->ChangeSecondaryWeapon();
  5197. client->GetPlayer()->ChangeRangedWeapon();
  5198. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5199. client->QueuePacket(characterSheetPackets);
  5200. }
  5201. }
  5202. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5203. {
  5204. if (client->GetPlayer()->EngagedInCombat())
  5205. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5206. else {
  5207. int16 index = atoi(sep->arg[1]);
  5208. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5209. if (item) {
  5210. // client->GetPlayer()->item_list.DestroyItem(index);
  5211. if (item->item_sets.size() > 0) {
  5212. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5213. ItemSet* set = item->item_sets[i];
  5214. if (set->item_stack_size == 0)
  5215. set->item_stack_size += 1;
  5216. client->AddItem(set->item_id, set->item_stack_size);
  5217. }
  5218. }
  5219. }
  5220. client->RemoveItem(item, 1);
  5221. }
  5222. }
  5223. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5224. {
  5225. if(client->GetPlayer()->EngagedInCombat())
  5226. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5227. else
  5228. {
  5229. int16 index = atoi(sep->arg[1]);
  5230. sint32 bag_id = -999;
  5231. int8 to_slot = 255;
  5232. if(sep->arg[3][0])
  5233. {
  5234. if(sep->IsNumber(2))
  5235. bag_id = atol(sep->arg[2]);
  5236. if(sep->IsNumber(3))
  5237. to_slot = atoi(sep->arg[3]);
  5238. }
  5239. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5240. EQ2Packet* outapp = 0;
  5241. for(int32 i=0;i<packets.size();i++)
  5242. {
  5243. outapp = packets[i];
  5244. if(outapp)
  5245. client->QueuePacket(outapp);
  5246. }
  5247. client->GetPlayer()->ChangePrimaryWeapon();
  5248. client->GetPlayer()->ChangeSecondaryWeapon();
  5249. client->GetPlayer()->ChangeRangedWeapon();
  5250. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5251. client->QueuePacket(characterSheetPackets);
  5252. }
  5253. }
  5254. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5255. {
  5256. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5257. int16 index1 = atoi(sep->arg[1]);
  5258. int16 index2 = atoi(sep->arg[2]);
  5259. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5260. if(outapp)
  5261. client->QueuePacket(outapp);
  5262. else
  5263. {
  5264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5265. return;
  5266. }
  5267. }
  5268. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5269. {
  5270. sint16 to_slot = atoi(sep->arg[1]);
  5271. sint32 bag_id = atoi(sep->arg[2]);
  5272. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5273. if (item) {
  5274. //auto inventory
  5275. if (bag_id == 0 && to_slot == -1)
  5276. {
  5277. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5278. {
  5279. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5280. return;
  5281. }
  5282. // Set the slot for the item
  5283. item->details.inv_slot_id = bag_id;
  5284. item->details.slot_id = to_slot;
  5285. // Flag the item so it gets saved in its new location
  5286. item->save_needed = true;
  5287. // Add the item to its new location
  5288. player->item_list.AddItem(item);
  5289. // Remove the item from the overflow list
  5290. player->item_list.RemoveOverflowItem(item);
  5291. // Send the inventory update packet
  5292. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5293. return;
  5294. }
  5295. else if (bag_id == -3 && to_slot == -1) {
  5296. // Auto Bank
  5297. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5298. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5299. return;
  5300. }
  5301. item->details.inv_slot_id = bag_id;
  5302. item->details.slot_id = to_slot;
  5303. item->save_needed = true;
  5304. player->item_list.AddItem(item);
  5305. player->item_list.RemoveOverflowItem(item);
  5306. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5307. }
  5308. else if (bag_id == -4) {
  5309. // Shared Bank
  5310. if (!player->item_list.SharedBankAddAllowed(item)) {
  5311. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5312. return;
  5313. }
  5314. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5315. if (tmp_item) {
  5316. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5317. return;
  5318. }
  5319. else {
  5320. item->details.inv_slot_id = bag_id;
  5321. item->details.slot_id = to_slot;
  5322. item->save_needed = true;
  5323. player->item_list.AddItem(item);
  5324. player->item_list.RemoveOverflowItem(item);
  5325. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5326. return;
  5327. }
  5328. }
  5329. else {
  5330. // Try to get an item from the given bag id and slot id
  5331. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5332. // Check to see if we got an item, if we do send an error,
  5333. // if we don't put the overflow item into this slot
  5334. if (tmp_item) {
  5335. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5336. }
  5337. else {
  5338. item->details.inv_slot_id = bag_id;
  5339. item->details.slot_id = to_slot;
  5340. item->save_needed = true;
  5341. player->item_list.AddItem(item);
  5342. player->item_list.RemoveOverflowItem(item);
  5343. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5344. return;
  5345. }
  5346. }
  5347. }
  5348. }
  5349. }
  5350. else
  5351. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5352. }
  5353. /*
  5354. Function: Command_IRC()
  5355. Purpose : Handle the IRC functions
  5356. Params : IRC Commands
  5357. Dev : Scatman
  5358. Example : /irc say #Channel Hello World!
  5359. */
  5360. void Commands::Command_IRC(Client* client, Seperator* sep)
  5361. {
  5362. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5363. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5364. return;
  5365. }
  5366. if (sep && sep->arg[0][0]) {
  5367. if (strcasecmp(sep->arg[0], "say") == 0) {
  5368. if (sep->arg[1][0] && sep->arg[2][0]) {
  5369. if (sep->IsNumber(sep->arg[1]))
  5370. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5371. else
  5372. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5373. }
  5374. else
  5375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5376. }
  5377. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5378. if (sep->arg[1][0])
  5379. irc.JoinChannel(client, sep->arg[1]);
  5380. else
  5381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5382. }
  5383. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5384. if (sep->arg[1][0])
  5385. irc.LeaveChannel(client, sep->arg[1]);
  5386. else
  5387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5388. }
  5389. else if (strcasecmp(sep->arg[0], "list") == 0)
  5390. irc.ListChannels(client);
  5391. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5392. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5393. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5394. else
  5395. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5396. }
  5397. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5398. irc.DisconnectFromServer(client);
  5399. else
  5400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5401. }
  5402. else
  5403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5404. }
  5405. /*
  5406. Function: Command_Languages()
  5407. Purpose : Show's languages the player knows
  5408. Params :
  5409. Dev : Zcoretri
  5410. Example :
  5411. */
  5412. void Commands::Command_Languages(Client* client, Seperator* sep)
  5413. {
  5414. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5415. list<Language*>::iterator itr;
  5416. Language* language;
  5417. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5418. for(itr = languages->begin(); itr != languages->end(); itr++)
  5419. {
  5420. language = *itr;
  5421. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5422. }
  5423. }
  5424. /*
  5425. Function: Command_SetLanguage()
  5426. Purpose : Handles language commands
  5427. Params : Language ID
  5428. Dev : Zcoretri
  5429. Example :
  5430. */
  5431. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5432. {
  5433. Player* player = client->GetPlayer();
  5434. if (sep && sep->arg[0])
  5435. {
  5436. if(!sep->IsNumber(0))
  5437. {
  5438. //String passed in
  5439. const char* value = sep->arg[0];
  5440. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5441. {
  5442. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5443. client->SendLanguagesUpdate(0);
  5444. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5445. }
  5446. else
  5447. {
  5448. if(player->HasLanguage(value))
  5449. {
  5450. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5451. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5452. client->SendLanguagesUpdate(language->GetID());
  5453. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5454. }
  5455. else
  5456. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5457. }
  5458. }
  5459. else
  5460. {
  5461. //Number passed in
  5462. int32 id = atoul(sep->arg[0]);
  5463. if(player->HasLanguage(id))
  5464. {
  5465. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5466. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5467. client->SendLanguagesUpdate(id);
  5468. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5469. }
  5470. else
  5471. {
  5472. Language* language = master_languages_list.GetLanguage(id);
  5473. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5474. }
  5475. }
  5476. }
  5477. else
  5478. {
  5479. //No value was passed in
  5480. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5481. if(id > 0)
  5482. {
  5483. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5484. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5485. }
  5486. else
  5487. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5488. }
  5489. }
  5490. /*
  5491. Function: Command_LastName()
  5492. Purpose : Sets player surname
  5493. Params : Name text
  5494. Dev : theFoof
  5495. Example :
  5496. */
  5497. void Commands::Command_LastName(Client* client, Seperator* sep)
  5498. {
  5499. if (!client)
  5500. return;
  5501. if (sep && sep->arg[0])
  5502. {
  5503. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5504. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5505. return;
  5506. }
  5507. client->RemovePendingLastName();
  5508. uchar* checkname = (uchar*)sep->arg[0];
  5509. bool valid_name = true;
  5510. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5511. if (!alpha_check(checkname[i])) {
  5512. valid_name = false;
  5513. break;
  5514. }
  5515. }
  5516. if (!valid_name) {
  5517. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5518. return;
  5519. }
  5520. string last_name = (string)sep->arg[0];
  5521. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5522. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5523. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5524. client->SetPendingLastName(last_name);
  5525. client->SendLastNameConfirmation();
  5526. }
  5527. else
  5528. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5529. }
  5530. }
  5531. /*
  5532. Function: Command_ConfirmLastName()
  5533. Purpose : Confirms setting of player surname
  5534. Params : Name text
  5535. Dev : theFoof
  5536. Example :
  5537. */
  5538. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5539. {
  5540. if (!client)
  5541. return;
  5542. string* name = client->GetPendingLastName();
  5543. if (name){
  5544. Player* player = client->GetPlayer();
  5545. player->SetLastName(name->c_str(), false);
  5546. client->SendTitleUpdate();
  5547. player->SetCharSheetChanged(true);
  5548. client->RemovePendingLastName();
  5549. }
  5550. }
  5551. /*
  5552. Function: Command_Location()
  5553. Purpose : Display's Help for /location commands
  5554. Params :
  5555. Dev : Scatman
  5556. Example : /location = show's help for command
  5557. */
  5558. void Commands::Command_Location(Client* client)
  5559. {
  5560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5561. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5562. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5566. }
  5567. /*
  5568. Function: Command_LocationAdd()
  5569. Purpose : Add's a location to an existing location config
  5570. Params : location_id
  5571. Dev : Scatman
  5572. Example : /location add {location_id}
  5573. */
  5574. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5575. {
  5576. if (sep && sep->arg[0] && sep->IsNumber(0))
  5577. {
  5578. int32 location_id = atoul(sep->arg[0]);
  5579. float x = client->GetPlayer()->GetX();
  5580. float y = client->GetPlayer()->GetY();
  5581. float z = client->GetPlayer()->GetZ();
  5582. if (database.AddLocationPoint(location_id, x, y, z))
  5583. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5584. else
  5585. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5586. }
  5587. else
  5588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5589. }
  5590. /*
  5591. Function: Command_LocationCreate()
  5592. Purpose : Creates a new location config
  5593. Params : location name, 0/1 for include_y (optional)
  5594. Dev : Scatman
  5595. Example : /location create Test 1 = creates a new location named Test with include_y True
  5596. */
  5597. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5598. {
  5599. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5600. {
  5601. const char* name = sep->arg[0];
  5602. bool include_y = false;
  5603. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5604. include_y = true;
  5605. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5606. if (location_id > 0)
  5607. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5608. else
  5609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5610. }
  5611. else
  5612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5613. }
  5614. /*
  5615. Function: Command_LocationDelete()
  5616. Purpose : Delete's a location config and all it's location points
  5617. Params : location_id
  5618. Dev : Scatman
  5619. Example : /location delete {location_id}
  5620. */
  5621. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5622. {
  5623. if (sep && sep->arg[0] && sep->IsNumber(0))
  5624. {
  5625. int32 location_id = atoul(sep->arg[0]);
  5626. if (database.DeleteLocation(location_id))
  5627. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5628. else
  5629. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5630. }
  5631. else
  5632. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5633. }
  5634. /*
  5635. Function: Command_LocationList()
  5636. Purpose : Display's a list of location points
  5637. Params : location_id
  5638. Dev : Scatman
  5639. Example : /location list {location_id}
  5640. */
  5641. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5642. {
  5643. if (sep && sep->arg[0])
  5644. {
  5645. const char* option = sep->arg[0];
  5646. if (strncmp(option, "locations", strlen(option)) == 0)
  5647. database.ListLocations(client);
  5648. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5649. {
  5650. int32 location_id = atoul(sep->arg[1]);
  5651. database.ListLocationPoints(client, location_id);
  5652. }
  5653. else
  5654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5655. }
  5656. else
  5657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5658. }
  5659. /*
  5660. Function: Command_LocationRemove()
  5661. Purpose : Removes a single location point from a location config
  5662. Params : location_point_id (gotten from /location list {id})
  5663. Dev : Scatman
  5664. Example : /location remove 1 = will remove location_point_id 1
  5665. */
  5666. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5667. {
  5668. if (sep && sep->arg[0] && sep->IsNumber(0))
  5669. {
  5670. int32 location_point_id = atoul(sep->arg[0]);
  5671. if (database.DeleteLocationPoint(location_point_id))
  5672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5673. else
  5674. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5675. }
  5676. else
  5677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5678. }
  5679. /*
  5680. Function: Command_Merchant()
  5681. Purpose : Handles Merchant commands
  5682. Params : list
  5683. Dev : Scatman
  5684. Example : /merchant list
  5685. */
  5686. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5687. {
  5688. if( handler == COMMAND_MERCHANT )
  5689. {
  5690. // /merchant command by itself shows help (to be extended)
  5691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5692. return;
  5693. }
  5694. else if( handler == COMMAND_MERCHANT_LIST )
  5695. {
  5696. // /merchant list command expects "description" param
  5697. if (sep && sep->arg[0])
  5698. {
  5699. const char* merchant_description = sep->argplus[0];
  5700. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5701. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5702. map<int32, MerchantInfo*>::iterator itr;
  5703. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5704. {
  5705. string description = database.GetMerchantDescription(itr->first);
  5706. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5707. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5708. }
  5709. }
  5710. else // no description
  5711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5712. }
  5713. }
  5714. /*
  5715. Function: Command_Modify()
  5716. Purpose : to replace our other "set" commands
  5717. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5718. Dev : John Adams
  5719. Example : /modify spell set name "Aegolism III"
  5720. */
  5721. void Commands::Command_Modify(Client* client)
  5722. {
  5723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5725. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5728. }
  5729. /*
  5730. Function: Command_ModifySpawn()
  5731. Purpose : replace "spawn set" commands
  5732. Params : Action : the action to perform (or special handler)
  5733. : Field : the DB field to change
  5734. : Value : what to set the value to
  5735. : Target : what object to change (my target, or spawn_id)
  5736. Dev : John Adams
  5737. Example : /modify spawn set name "Lady Vox"
  5738. :
  5739. Note : Special Handlers, like "zoneto" for Signs
  5740. : /modify spawn zoneto
  5741. : Will set a sign's zone x/y/z to my current coords
  5742. */
  5743. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5744. {
  5745. PrintSep(sep, "COMMAND_MODIFY");
  5746. // need at least 2 args for a valid command
  5747. if( sep && sep->arg[1] )
  5748. {
  5749. // JA: just a quick implementation because I need it :)
  5750. if (strcmp(sep->arg[0], "zoneto") == 0)
  5751. {
  5752. if( sep->IsNumber(1) )
  5753. {
  5754. int32 spawn_id = atoul(sep->arg[1]);
  5755. float x_coord = client->GetPlayer()->GetX();
  5756. float y_coord = client->GetPlayer()->GetY();
  5757. float z_coord = client->GetPlayer()->GetZ();
  5758. float h_coord = client->GetPlayer()->GetHeading();
  5759. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5760. }
  5761. else
  5762. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5763. }
  5764. }
  5765. else
  5766. Command_Modify(client);
  5767. }
  5768. /*
  5769. Function: Command_ModifyCharacter()
  5770. Purpose : to replace our other "set" commands
  5771. Params : Action : Add, Remove
  5772. : Field : copper, silver, gold, plat
  5773. : Value : min 1, max unlimited
  5774. : Target : Self, Player
  5775. Dev : Cynnar
  5776. Example : /modify character add gold 50
  5777. : /modify character remove silver 25
  5778. */
  5779. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5780. {
  5781. PrintSep(sep, "COMMAND_MODIFY");
  5782. int64 value = 0;
  5783. Player* player = client->GetPlayer();
  5784. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5785. player = (Player*)player->GetTarget();
  5786. // need at least 2 args for a valid command
  5787. if( sep && sep->arg[1] )
  5788. {
  5789. if (strcmp(sep->arg[0], "add") == 0)
  5790. {
  5791. if (strcmp(sep->arg[1], "copper") == 0)
  5792. {
  5793. value = atoi64(sep->arg[2]);
  5794. player->AddCoins(value);
  5795. if (client->GetPlayer() == player)
  5796. {
  5797. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5798. }
  5799. else {
  5800. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5801. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5802. }
  5803. }
  5804. else if (strcmp(sep->arg[1], "silver") == 0)
  5805. {
  5806. value = atoi64(sep->arg[2]) * 100;
  5807. player->AddCoins(value);
  5808. if (client->GetPlayer() == player)
  5809. {
  5810. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5811. }
  5812. else {
  5813. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5814. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5815. }
  5816. }
  5817. else if (strcmp(sep->arg[1], "gold") == 0)
  5818. {
  5819. value = atoi64(sep->arg[2]) * 10000;
  5820. player->AddCoins(value);
  5821. if (client->GetPlayer() == player)
  5822. {
  5823. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5824. }
  5825. else {
  5826. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5827. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5828. }
  5829. }
  5830. else if (strcmp(sep->arg[1], "plat") == 0)
  5831. {
  5832. value = atoi64(sep->arg[2]) * 1000000;
  5833. player->AddCoins(value);
  5834. if (client->GetPlayer() == player)
  5835. {
  5836. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5837. }
  5838. else {
  5839. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5840. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5841. }
  5842. }
  5843. else
  5844. {
  5845. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5846. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5847. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5848. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5849. }
  5850. }
  5851. else if (strcmp(sep->arg[0], "remove") == 0)
  5852. {
  5853. if (strcmp(sep->arg[1], "copper") == 0)
  5854. {
  5855. value = atoi64(sep->arg[2]);
  5856. player->RemoveCoins(value);
  5857. if (client->GetPlayer() == player)
  5858. {
  5859. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5860. }
  5861. else {
  5862. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5863. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5864. }
  5865. }
  5866. else if (strcmp(sep->arg[1], "silver") == 0)
  5867. {
  5868. value = atoi64(sep->arg[2]) * 100;
  5869. player->RemoveCoins(value);
  5870. if (client->GetPlayer() == player)
  5871. {
  5872. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5873. }
  5874. else {
  5875. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5876. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5877. }
  5878. }
  5879. else if (strcmp(sep->arg[1], "gold") == 0)
  5880. {
  5881. value = atoi64(sep->arg[2]) * 10000;
  5882. player->RemoveCoins(value);
  5883. if (client->GetPlayer() == player)
  5884. {
  5885. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5886. }
  5887. else {
  5888. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5889. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5890. }
  5891. }
  5892. else if (strcmp(sep->arg[1], "plat") == 0)
  5893. {
  5894. value = atoi64(sep->arg[2]) * 1000000;
  5895. player->RemoveCoins(value);
  5896. if (client->GetPlayer() == player)
  5897. {
  5898. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5899. }
  5900. else {
  5901. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5902. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5903. }
  5904. }
  5905. else
  5906. {
  5907. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5908. }
  5909. }
  5910. else if (strcmp(sep->arg[0], "set") == 0) {
  5911. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5912. int8 level = atoi(sep->arg[2]);
  5913. if (level > 0 && level < 256) {
  5914. if (player) {
  5915. if (client->GetPlayer() == player)
  5916. client->ChangeTSLevel(player->GetTSLevel(), level);
  5917. else
  5918. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5919. }
  5920. }
  5921. else
  5922. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5923. }
  5924. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5925. int8 tsclass = atoi(sep->arg[2]);
  5926. player->SetTradeskillClass(tsclass);
  5927. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5928. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5929. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5930. player->SetCharSheetChanged(true);
  5931. }
  5932. }
  5933. }
  5934. else
  5935. {
  5936. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5937. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5938. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5939. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5940. }
  5941. }
  5942. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5943. {
  5944. PrintSep(sep, "COMMAND_MODIFY");
  5945. // need at least 2 args for a valid command
  5946. if( sep && sep->arg[1] )
  5947. {
  5948. }
  5949. else
  5950. Command_Modify(client);
  5951. }
  5952. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5953. {
  5954. PrintSep(sep, "COMMAND_MODIFY");
  5955. // need at least 2 args for a valid command
  5956. if( sep && sep->arg[1] )
  5957. {
  5958. }
  5959. else
  5960. Command_Modify(client);
  5961. }
  5962. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5963. {
  5964. PrintSep(sep, "COMMAND_MODIFY");
  5965. // need at least 2 args for a valid command
  5966. if( sep && sep->arg[1] )
  5967. {
  5968. }
  5969. else
  5970. Command_Modify(client);
  5971. }
  5972. /*
  5973. Function: Command_ModifyQuest()
  5974. Purpose : to list players quest and completed quests
  5975. Params : Action : list, completed
  5976. : Target : Self, Player
  5977. Dev : Cynnar
  5978. Example : /modify quest list
  5979. : /modify quest completed
  5980. */
  5981. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5982. {
  5983. PrintSep(sep, "COMMAND_MODIFY");
  5984. int64 value = 0;
  5985. Player* player = client->GetPlayer();
  5986. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5987. player = (Player*)player->GetTarget();
  5988. // need at least 2 args for a valid command
  5989. if (sep && sep->arg[1])
  5990. {
  5991. if (strcmp(sep->arg[0], "list") == 0)
  5992. {
  5993. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5994. map<int32, Quest*>::iterator itr;
  5995. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5996. if (quests->size() == 0)
  5997. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5998. else
  5999. {
  6000. for (itr = quests->begin(); itr != quests->end(); itr++)
  6001. {
  6002. Quest* quest = itr->second;
  6003. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6004. }
  6005. }
  6006. }
  6007. else if (strcmp(sep->arg[0], "completed") == 0)
  6008. {
  6009. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6010. map<int32, Quest*>::iterator itr;
  6011. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6012. if (quests->size() == 0)
  6013. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6014. else
  6015. {
  6016. for (itr = quests->begin(); itr != quests->end(); itr++)
  6017. {
  6018. Quest* quest = itr->second;
  6019. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6020. }
  6021. }
  6022. }
  6023. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6024. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6025. else if (strcmp(sep->arg[0], "remove") == 0)
  6026. {
  6027. int32 quest_id = 0;
  6028. if (sep && sep->arg[1] && sep->IsNumber(1))
  6029. quest_id = atoul(sep->arg[1]);
  6030. if (quest_id > 0)
  6031. {
  6032. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6033. {
  6034. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6035. if (quest)
  6036. if (client->GetPlayer() == player)
  6037. {
  6038. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6039. }
  6040. else
  6041. {
  6042. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6043. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6044. }
  6045. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6046. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6047. }
  6048. client->RemovePlayerQuest(quest_id);
  6049. client->GetCurrentZone()->SendQuestUpdates(client);
  6050. }
  6051. }
  6052. else if (strcmp(sep->arg[0], "advance") == 0)
  6053. {
  6054. int32 quest_id = 0;
  6055. int32 step = 0;
  6056. if (sep && sep->arg[1] && sep->IsNumber(1))
  6057. {
  6058. quest_id = atoul(sep->arg[1]);
  6059. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6060. if (sep && sep->arg[2] && sep->IsNumber(1))
  6061. {
  6062. step = atoul(sep->arg[2]);
  6063. if (quest_id > 0 && step > 0)
  6064. {
  6065. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6066. {
  6067. if (client)
  6068. {
  6069. client->AddPendingQuestUpdate(quest_id, step);
  6070. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6071. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6072. }
  6073. }
  6074. }
  6075. else
  6076. {
  6077. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6078. }
  6079. }
  6080. else
  6081. {
  6082. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6083. }
  6084. }
  6085. else
  6086. {
  6087. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6088. }
  6089. }
  6090. else
  6091. {
  6092. Command_Modify(client);
  6093. }
  6094. }
  6095. else
  6096. {
  6097. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6098. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6099. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6100. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6101. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6102. }
  6103. }
  6104. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6105. {
  6106. PrintSep(sep, "COMMAND_MODIFY");
  6107. // need at least 2 args for a valid command
  6108. if( sep && sep->arg[1] )
  6109. {
  6110. if (strcmp(sep->arg[0], "add") == 0) {
  6111. const char* skill_name = sep->argplus[1];
  6112. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6113. if (skill) {
  6114. Player* player = 0;
  6115. Client* to_client = 0;
  6116. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6117. player = (Player*)client->GetPlayer()->GetTarget();
  6118. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6119. }
  6120. else {
  6121. player = client->GetPlayer();
  6122. to_client = client;
  6123. }
  6124. if (player)
  6125. {
  6126. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6127. {
  6128. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6129. if (to_client == client) {
  6130. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6131. }
  6132. else {
  6133. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6134. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6135. }
  6136. }
  6137. else
  6138. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6139. }
  6140. }
  6141. else
  6142. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6143. }
  6144. else if (strcmp(sep->arg[0], "remove") == 0) {
  6145. const char* skill_name = sep->argplus[1];
  6146. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6147. if (skill) {
  6148. Player* player = 0;
  6149. Client* to_client = 0;
  6150. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6151. player = (Player*)client->GetPlayer()->GetTarget();
  6152. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6153. }
  6154. else {
  6155. player = client->GetPlayer();
  6156. to_client = client;
  6157. }
  6158. if (player)
  6159. {
  6160. if (player->GetSkills()->HasSkill(skill->skill_id))
  6161. {
  6162. player->RemoveSkillFromDB(skill, true);
  6163. if (client == to_client) {
  6164. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6165. }
  6166. else {
  6167. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6168. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6169. }
  6170. }
  6171. else {
  6172. if (client == to_client)
  6173. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6174. else
  6175. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6176. }
  6177. }
  6178. }
  6179. else
  6180. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6181. }
  6182. else if (strcmp(sep->arg[0], "set") == 0) {
  6183. if (!sep->IsNumber(2)) {
  6184. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6185. return;
  6186. }
  6187. const char* skill_name = sep->arg[1];
  6188. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6189. if (skill) {
  6190. int16 val = atoi(sep->arg[2]);
  6191. Player* player = 0;
  6192. Client* to_client = 0;
  6193. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6194. player = (Player*)client->GetPlayer()->GetTarget();
  6195. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6196. }
  6197. else {
  6198. player = client->GetPlayer();
  6199. to_client = client;
  6200. }
  6201. if (player)
  6202. {
  6203. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6204. player->GetSkills()->SetSkill(skill->skill_id, val);
  6205. if (client != to_client)
  6206. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6207. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6208. }
  6209. else {
  6210. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6211. }
  6212. }
  6213. }
  6214. else {
  6215. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6216. }
  6217. }
  6218. else {
  6219. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6220. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6221. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6222. }
  6223. }
  6224. else {
  6225. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6226. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6227. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6228. }
  6229. }
  6230. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6231. {
  6232. PrintSep(sep, "COMMAND_MODIFY");
  6233. // need at least 2 args for a valid command
  6234. if( sep && sep->arg[1] )
  6235. {
  6236. }
  6237. else
  6238. Command_Modify(client);
  6239. }
  6240. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6241. {
  6242. PrintSep(sep, "COMMAND_MODIFY");
  6243. // need at least 2 args for a valid command
  6244. if( sep && sep->arg[1] )
  6245. {
  6246. }
  6247. else
  6248. Command_Modify(client);
  6249. }
  6250. /*
  6251. Function: Command_MOTD()
  6252. Purpose : Displays server MOTD
  6253. Params :
  6254. Dev : LethalEncounter
  6255. Example : /motd
  6256. */
  6257. void Commands::Command_MOTD(Client* client)
  6258. {
  6259. if (client)
  6260. ClientPacketFunctions::SendMOTD(client);
  6261. }
  6262. /*
  6263. Function: Command_Pet()
  6264. Purpose : Handle Pet {Command} commands
  6265. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6266. Dev :
  6267. Example : /pet preserve_master
  6268. */
  6269. void Commands::Command_Pet(Client* client, Seperator* sep)
  6270. {
  6271. PrintSep(sep, "COMMAND_PET");
  6272. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6273. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6274. if (strcmp(sep->arg[0], "hide") == 0) {
  6275. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6276. Entity* pet = client->GetPlayer()->GetDeityPet();
  6277. if (pet) {
  6278. if (pet->IsPrivateSpawn())
  6279. client->GetPlayer()->HideDeityPet(false);
  6280. else
  6281. client->GetPlayer()->HideDeityPet(true);
  6282. }
  6283. pet = client->GetPlayer()->GetCosmeticPet();
  6284. if (pet) {
  6285. if (pet->IsPrivateSpawn())
  6286. client->GetPlayer()->HideCosmeticPet(false);
  6287. else
  6288. client->GetPlayer()->HideCosmeticPet(true);
  6289. }
  6290. return;
  6291. }
  6292. // below is for all combat pets
  6293. if (!client->GetPlayer()->HasPet()) {
  6294. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6295. return;
  6296. }
  6297. if (strcmp(sep->arg[0], "stay") == 0) {
  6298. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6299. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6300. client->GetPlayer()->SetCharSheetChanged(true);
  6301. if (client->GetPlayer()->GetPet())
  6302. client->GetPlayer()->GetPet()->following = false;
  6303. if (client->GetPlayer()->GetCharmedPet())
  6304. client->GetPlayer()->GetCharmedPet()->following = false;
  6305. }
  6306. else if (strcmp(sep->arg[0], "follow") == 0) {
  6307. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6308. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6309. client->GetPlayer()->SetCharSheetChanged(true);
  6310. }
  6311. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6312. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6313. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6314. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6315. }
  6316. else {
  6317. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6318. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6319. }
  6320. client->GetPlayer()->SetCharSheetChanged(true);
  6321. }
  6322. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6323. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6324. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6325. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6326. }
  6327. else {
  6328. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6329. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6330. }
  6331. client->GetPlayer()->SetCharSheetChanged(true);
  6332. }
  6333. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6334. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6335. if (client->GetPlayer()->GetPet())
  6336. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6337. if (client->GetPlayer()->GetCharmedPet())
  6338. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6339. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6340. client->GetPlayer()->SetCharSheetChanged(true);
  6341. }
  6342. else if (strcmp(sep->arg[0], "attack") == 0) {
  6343. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6344. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6345. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6346. if (client->GetPlayer()->GetPet())
  6347. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6348. if (client->GetPlayer()->GetCharmedPet())
  6349. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6350. }
  6351. else
  6352. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6353. }
  6354. else
  6355. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6356. }
  6357. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6358. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6359. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6360. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6361. }
  6362. else
  6363. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6364. }
  6365. /*
  6366. Function: Command_PetName()
  6367. Purpose : Pet your name (???)
  6368. Params :
  6369. Dev :
  6370. Example :
  6371. */
  6372. void Commands::Command_PetName(Client* client, Seperator* sep)
  6373. {
  6374. PrintSep(sep, "COMMAND_PETNAME");
  6375. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6376. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6377. }
  6378. /*
  6379. Function: Command_NamePet()
  6380. Purpose : Name your pet
  6381. Params :
  6382. Dev :
  6383. Example :
  6384. */
  6385. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6386. {
  6387. PrintSep(sep, "COMMAND_NAME_PET");
  6388. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6389. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6390. }
  6391. /*
  6392. Function: Command_Rename()
  6393. Purpose : Renames existing pet
  6394. Params :
  6395. Dev :
  6396. Example :
  6397. */
  6398. void Commands::Command_Rename(Client* client, Seperator* sep)
  6399. {
  6400. PrintSep(sep, "COMMAND_RENAME");
  6401. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6402. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6403. }
  6404. /*
  6405. Function: Command_ConfirmRename()
  6406. Purpose : Confirms renaming your pet
  6407. Params :
  6408. Dev :
  6409. Example :
  6410. */
  6411. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6412. {
  6413. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6414. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6415. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6416. }
  6417. /*
  6418. Function: Command_PetOptions()
  6419. Purpose : Sets various pet options
  6420. Params :
  6421. Dev :
  6422. Example :
  6423. */
  6424. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6425. {
  6426. PrintSep(sep, "COMMAND_PETOPTIONS");
  6427. Player* player = client->GetPlayer();
  6428. Spawn* target = player->GetTarget();
  6429. if (!target)
  6430. return;
  6431. if (target == player->GetPet())
  6432. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6433. else if (target == player->GetCharmedPet())
  6434. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6435. else if (target == player->GetCosmeticPet())
  6436. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6437. else if (target == player->GetDeityPet())
  6438. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6439. }
  6440. /*
  6441. Function: Command_Random()
  6442. Purpose : Handles /random dice roll in-game
  6443. Params : 1-100
  6444. Dev : Scatman
  6445. Example : /randon 1 100
  6446. */
  6447. void Commands::Command_Random(Client* client, Seperator* sep)
  6448. {
  6449. char message[256] = {0};
  6450. if (sep)
  6451. {
  6452. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6453. 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])));
  6454. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6455. 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])));
  6456. else
  6457. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6458. }
  6459. else
  6460. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6461. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6462. }
  6463. /*
  6464. Function: Command_Randomize()
  6465. Purpose : Sets randomize (appearance) values for NPCs
  6466. Params : Attrib Name
  6467. Dev : Scatman
  6468. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6469. */
  6470. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6471. {
  6472. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6473. if (target)
  6474. {
  6475. if (target->IsNPC())
  6476. {
  6477. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6478. {
  6479. const char* value = sep->arg[0];
  6480. if (strncasecmp(value, "show", strlen(value)) == 0)
  6481. {
  6482. client->DisplayRandomizeFeatures(target->GetRandomize());
  6483. }
  6484. else
  6485. {
  6486. if (sep->arg[1] && sep->IsNumber(1))
  6487. {
  6488. int8 option = atoi(sep->arg[1]);
  6489. if (option == 0 || option == 1)
  6490. {
  6491. int32 feature = 0;
  6492. char feature_text[32] = {0};
  6493. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6494. feature = RANDOMIZE_GENDER;
  6495. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6496. }
  6497. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6498. feature = RANDOMIZE_RACE;
  6499. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6500. }
  6501. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6502. feature = RANDOMIZE_MODEL_TYPE;
  6503. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6504. }
  6505. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6506. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6507. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6508. }
  6509. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6510. feature = RANDOMIZE_HAIR_TYPE;
  6511. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6512. }
  6513. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6514. feature = RANDOMIZE_WING_TYPE;
  6515. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6516. }
  6517. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6518. feature = RANDOMIZE_CHEEK_TYPE;
  6519. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6520. }
  6521. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6522. feature = RANDOMIZE_CHIN_TYPE;
  6523. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6524. }
  6525. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6526. feature = RANDOMIZE_EAR_TYPE;
  6527. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6528. }
  6529. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6530. feature = RANDOMIZE_EYE_BROW_TYPE;
  6531. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6532. }
  6533. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6534. feature = RANDOMIZE_EYE_TYPE;
  6535. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6536. }
  6537. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6538. feature = RANDOMIZE_LIP_TYPE;
  6539. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6540. }
  6541. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6542. feature = RANDOMIZE_NOSE_TYPE;
  6543. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6544. }
  6545. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6546. feature = RANDOMIZE_EYE_COLOR;
  6547. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6548. }
  6549. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6550. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6551. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6552. }
  6553. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6554. feature = RANDOMIZE_HAIR_COLOR1;
  6555. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6556. }
  6557. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6558. feature = RANDOMIZE_HAIR_COLOR2;
  6559. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6560. }
  6561. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6562. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6563. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6564. }
  6565. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6566. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6567. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6568. }
  6569. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6570. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6571. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6572. }
  6573. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6574. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6575. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6576. }
  6577. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6578. feature = RANDOMIZE_SKIN_COLOR;
  6579. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6580. }
  6581. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6582. feature = RANDOMIZE_WING_COLOR1;
  6583. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6584. }
  6585. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6586. feature = RANDOMIZE_WING_COLOR2;
  6587. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6588. }
  6589. else {
  6590. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6591. 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'.");
  6592. }
  6593. if (feature > 0) {
  6594. if (option == 1) {
  6595. if (target->GetRandomize() & feature)
  6596. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6597. else {
  6598. target->AddRandomize(feature);
  6599. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6600. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6601. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6602. }
  6603. }
  6604. else {
  6605. if (target->GetRandomize() & feature) {
  6606. target->AddRandomize(-feature);
  6607. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6608. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6609. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6610. }
  6611. else
  6612. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6613. }
  6614. }
  6615. }
  6616. else
  6617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6618. }
  6619. else
  6620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6621. }
  6622. }
  6623. else {
  6624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6626. 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'.");
  6627. }
  6628. }
  6629. else
  6630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6631. }
  6632. else
  6633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6634. }
  6635. /*
  6636. Function: Command_ShowCloak()
  6637. Purpose : Character Settings combo box for Show Cloak
  6638. Params : true/false
  6639. Dev : John Adams
  6640. Example :
  6641. */
  6642. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6643. {
  6644. Player* player = client->GetPlayer();
  6645. if (sep && sep->arg[0])
  6646. {
  6647. const char* value = sep->arg[0];
  6648. if (strncasecmp(value, "true", strlen(value)) == 0)
  6649. {
  6650. player->set_character_flag(CF_SHOW_CLOAK);
  6651. player->reset_character_flag(CF2_SHOW_RANGED);
  6652. }
  6653. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6654. player->reset_character_flag(CF_SHOW_CLOAK);
  6655. else
  6656. {
  6657. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6658. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6659. }
  6660. }
  6661. }
  6662. /*
  6663. Function: Command_ShowHelm()
  6664. Purpose : Character Settings combo box for Show Helm
  6665. Params : true/false
  6666. Dev : John Adams
  6667. Example :
  6668. */
  6669. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6670. {
  6671. Player* player = client->GetPlayer();
  6672. if (sep && sep->arg[0])
  6673. {
  6674. const char* value = sep->arg[0];
  6675. if (strncasecmp(value, "true", strlen(value)) == 0)
  6676. {
  6677. player->reset_character_flag(CF_HIDE_HELM);
  6678. player->set_character_flag(CF_HIDE_HOOD);
  6679. }
  6680. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6681. player->set_character_flag(CF_HIDE_HELM);
  6682. else
  6683. {
  6684. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6685. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6686. }
  6687. }
  6688. }
  6689. /*
  6690. Function: Command_ShowHood()
  6691. Purpose : Character Settings combo box for Show Hood
  6692. Params : true/false
  6693. Dev : John Adams
  6694. Example :
  6695. */
  6696. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6697. {
  6698. Player* player = client->GetPlayer();
  6699. if (sep && sep->arg[0])
  6700. {
  6701. const char* value = sep->arg[0];
  6702. if (strncasecmp(value, "true", strlen(value)) == 0)
  6703. {
  6704. player->reset_character_flag(CF_HIDE_HOOD);
  6705. player->set_character_flag(CF_HIDE_HELM);
  6706. }
  6707. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6708. player->set_character_flag(CF_HIDE_HOOD);
  6709. else
  6710. {
  6711. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6712. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6713. }
  6714. }
  6715. }
  6716. /*
  6717. Function: Command_ShowHoodHelm()
  6718. Purpose : Character Settings combo box for Show Helm or Hood
  6719. Params : true/false
  6720. Dev : John Adams
  6721. Example :
  6722. */
  6723. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6724. {
  6725. Player* player = client->GetPlayer();
  6726. if (sep && sep->arg[0])
  6727. {
  6728. const char* value = sep->arg[0];
  6729. if (strncasecmp(value, "true", strlen(value)) == 0)
  6730. {
  6731. player->reset_character_flag(CF_HIDE_HOOD);
  6732. player->reset_character_flag(CF_HIDE_HELM);
  6733. }
  6734. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6735. {
  6736. // don't think we ever wind up in here...
  6737. player->set_character_flag(CF_HIDE_HOOD);
  6738. player->set_character_flag(CF_HIDE_HELM);
  6739. }
  6740. else
  6741. {
  6742. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6743. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6744. }
  6745. }
  6746. }
  6747. /*
  6748. Function: Command_ShowRanged()
  6749. Purpose : Character Settings combo box for Show Ranged weapon
  6750. Params : true/false
  6751. Dev : John Adams
  6752. Example :
  6753. */
  6754. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6755. {
  6756. Player* player = client->GetPlayer();
  6757. if (sep && sep->arg[0])
  6758. {
  6759. const char* value = sep->arg[0];
  6760. if (strncasecmp(value, "true", strlen(value)) == 0)
  6761. {
  6762. player->set_character_flag(CF2_SHOW_RANGED);
  6763. player->reset_character_flag(CF_SHOW_CLOAK);
  6764. }
  6765. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6766. player->reset_character_flag(CF2_SHOW_RANGED);
  6767. else
  6768. {
  6769. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6770. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6771. }
  6772. }
  6773. }
  6774. /*
  6775. Function:
  6776. Purpose :
  6777. Params :
  6778. Dev :
  6779. Example :
  6780. */
  6781. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6782. {
  6783. Player* player = 0;
  6784. Client* to_client = 0;
  6785. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6786. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6787. switch(handler)
  6788. {
  6789. case COMMAND_SKILL:
  6790. {
  6791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6793. break;
  6794. }
  6795. case COMMAND_SKILL_ADD:
  6796. {
  6797. if (sep && sep->arg[0])
  6798. {
  6799. const char* skill_name = sep->argplus[0];
  6800. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6801. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6802. {
  6803. player = to_client->GetPlayer();
  6804. if (player)
  6805. {
  6806. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6807. {
  6808. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6809. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6810. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6811. }
  6812. else
  6813. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6814. }
  6815. }
  6816. else if (skill) // add skill to yourself
  6817. {
  6818. player = client->GetPlayer();
  6819. if (player)
  6820. {
  6821. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6822. {
  6823. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6824. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6825. }
  6826. else
  6827. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6828. }
  6829. }
  6830. else
  6831. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6832. }
  6833. else
  6834. {
  6835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6837. }
  6838. break;
  6839. }
  6840. case COMMAND_SKILL_REMOVE:
  6841. {
  6842. if (sep && sep->arg[0])
  6843. {
  6844. const char* skill_name = sep->argplus[0];
  6845. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6846. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6847. {
  6848. player = to_client->GetPlayer();
  6849. if (player)
  6850. {
  6851. if (player->GetSkills()->HasSkill(skill->skill_id))
  6852. {
  6853. player->RemoveSkillFromDB(skill, true);
  6854. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6855. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6856. }
  6857. else
  6858. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6859. }
  6860. }
  6861. else if(skill) // remove skill from yourself
  6862. {
  6863. Player* player = client->GetPlayer();
  6864. if (player)
  6865. {
  6866. if (player->GetSkills()->HasSkill(skill->skill_id))
  6867. {
  6868. player->RemoveSkillFromDB(skill, true);
  6869. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6870. }
  6871. else
  6872. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6873. }
  6874. }
  6875. else
  6876. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6877. }
  6878. else
  6879. {
  6880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6882. }
  6883. break;
  6884. }
  6885. case COMMAND_SKILL_LIST:
  6886. {
  6887. if (sep && sep->arg[0])
  6888. {
  6889. const char* skill_name = sep->argplus[0];
  6890. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6891. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6892. map<int32, Skill*>::iterator itr;
  6893. if (skills && skills->size() > 0)
  6894. {
  6895. for (itr = skills->begin(); itr != skills->end(); itr++)
  6896. {
  6897. Skill* skill = itr->second;
  6898. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6899. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6900. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6901. }
  6902. }
  6903. }
  6904. else
  6905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6906. break;
  6907. }
  6908. }
  6909. }
  6910. /*
  6911. Function: Command_SpawnTemplate()
  6912. Purpose : Create or Use defined Spawn Templates
  6913. Params : create, save, rempve, list
  6914. Dev : John Adams
  6915. Example : /spawn template create "Test"
  6916. */
  6917. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6918. {
  6919. if (sep == NULL || sep->arg[0] == NULL)
  6920. {
  6921. 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.");
  6922. return;
  6923. }
  6924. // got params, continue
  6925. const char * template_cmd = sep->arg[0];
  6926. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6927. {
  6928. if (!sep->IsSet(1))
  6929. {
  6930. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6931. 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.");
  6932. return;
  6933. }
  6934. map<int32, string>* template_names = 0;
  6935. if (sep->IsNumber(1))
  6936. {
  6937. int32 location_id = 0;
  6938. location_id = atoi(sep->arg[1]);
  6939. template_names = database.GetSpawnTemplateListByID(location_id);
  6940. }
  6941. else
  6942. {
  6943. const char* name = 0;
  6944. name = sep->argplus[1];
  6945. template_names = database.GetSpawnTemplateListByName(name);
  6946. }
  6947. if(!template_names)
  6948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6949. else
  6950. {
  6951. map<int32, string>::iterator itr;
  6952. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6953. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6954. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6955. safe_delete(template_names);
  6956. }
  6957. }
  6958. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6959. {
  6960. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6961. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6962. {
  6963. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6964. {
  6965. // first, lookup to see if template name already exists
  6966. const char* name = 0;
  6967. name = sep->argplus[1];
  6968. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6969. if(!template_names)
  6970. {
  6971. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6972. if( new_template_id > 0 )
  6973. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6974. else
  6975. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6976. }
  6977. else
  6978. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6979. }
  6980. else
  6981. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6982. }
  6983. else
  6984. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6985. }
  6986. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6987. {
  6988. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6989. {
  6990. int32 template_id = 0;
  6991. template_id = atoi(sep->arg[1]);
  6992. if (database.RemoveSpawnTemplate(template_id))
  6993. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6994. else
  6995. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6996. }
  6997. else
  6998. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6999. }
  7000. // Renamed create to spawn
  7001. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7002. {
  7003. if (sep && sep->arg[1][0])
  7004. {
  7005. int32 new_location = 0;
  7006. if (sep->IsNumber(1))
  7007. {
  7008. int32 template_id = 0;
  7009. template_id = atoi(sep->arg[1]);
  7010. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7011. if( new_location > 0 )
  7012. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7013. else
  7014. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7015. }
  7016. else
  7017. {
  7018. const char* name = 0;
  7019. name = sep->argplus[1];
  7020. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7021. if( new_location > 0 )
  7022. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7023. else
  7024. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7025. }
  7026. }
  7027. else
  7028. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7029. }
  7030. else
  7031. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7032. }
  7033. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7034. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7035. float new_speed = atof(sep->arg[0]);
  7036. if (new_speed > 0.0f)
  7037. {
  7038. client->GetPlayer()->SetSpeed(new_speed, true);
  7039. client->GetPlayer()->SetCharSheetChanged(true);
  7040. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7041. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7042. }
  7043. else
  7044. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7045. }
  7046. else{
  7047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7048. }
  7049. }
  7050. /*
  7051. Function: Command_StationMarketPlace()
  7052. Purpose : just trying to eat the console spam for now
  7053. Params :
  7054. Dev : John
  7055. */
  7056. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7057. {
  7058. PrintSep(sep, "COMMAND_SMP");
  7059. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7060. // can't seem to reduce it any more get rid of it completely...
  7061. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7062. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7063. if (packet) {
  7064. packet->setDataByName("account_id", client->GetAccountID());
  7065. packet->setDataByName("character_id", client->GetCharacterID());
  7066. packet->setDataByName("unknown1", 1, 5);
  7067. packet->setDataByName("unknown1", 26, 6);
  7068. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7069. packet->setDataByName("unknown3", 248, 1);
  7070. client->QueuePacket(packet->serialize());
  7071. }
  7072. safe_delete(packet);
  7073. }
  7074. }
  7075. /*
  7076. Function: Command_StopDrinking()
  7077. Purpose : Stops player from auto-consuming drink
  7078. Params :
  7079. Dev : Zcoretri
  7080. Example : /stopdrinking
  7081. */
  7082. void Commands::Command_StopDrinking(Client* client)
  7083. {
  7084. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7085. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7086. }
  7087. /*
  7088. Function: Command_StopEating()
  7089. Purpose : Stops player from auto-consuming food
  7090. Params :
  7091. Dev : Zcoretri
  7092. Example : /stopeating
  7093. */
  7094. void Commands::Command_StopEating(Client* client)
  7095. {
  7096. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7097. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7098. }
  7099. /*
  7100. Function: Command_Title()
  7101. Purpose : Help for /title command
  7102. Params : n/a
  7103. Dev : Zcoretri
  7104. Example : /title
  7105. */
  7106. void Commands::Command_Title(Client* client)
  7107. {
  7108. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7109. }
  7110. /*
  7111. Function: Command_TitleList()
  7112. Purpose : List available titles for player
  7113. Params : n/a
  7114. Dev : Zcoretri
  7115. Example : /title list
  7116. */
  7117. void Commands::Command_TitleList(Client* client)
  7118. {
  7119. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7120. list<Title*>::iterator itr;
  7121. Title* title;
  7122. int16 i = 0;
  7123. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7124. for(itr = titles->begin(); itr != titles->end(); itr++)
  7125. {
  7126. title = *itr;
  7127. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7128. i++;
  7129. }
  7130. }
  7131. /*
  7132. Function: Command_TitleSetPrefix()
  7133. Purpose : Set Prefix title for player
  7134. Params : Title ID
  7135. Dev : Zcoretri
  7136. Example : /title setprefix 1
  7137. */
  7138. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7139. {
  7140. if (sep && sep->arg[0] && sep->IsNumber(0))
  7141. {
  7142. int32 index = atoul(sep->arg[0]);
  7143. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7144. client->SendTitleUpdate();
  7145. }
  7146. }
  7147. /*
  7148. Function: Command_TitleSetSuffix()
  7149. Purpose : Set Suffix title for player
  7150. Params : Title ID
  7151. Dev : Zcoretri
  7152. Example : /title setsuffix 1
  7153. */
  7154. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7155. {
  7156. if (sep && sep->arg[0] && sep->IsNumber(0))
  7157. {
  7158. int32 index = atoul(sep->arg[0]);
  7159. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7160. client->SendTitleUpdate();
  7161. }
  7162. }
  7163. /*
  7164. Function: Command_TitleFix()
  7165. Purpose : Fix title for player (???)
  7166. Params :
  7167. Dev : Zcoretri
  7168. Example :
  7169. */
  7170. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7171. {
  7172. PrintSep(sep, "COMMAND_TITLE_FIX");
  7173. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7174. }
  7175. /*
  7176. Function: Command_Toggle_Anonymous()
  7177. Purpose : Toggles player Anonymous
  7178. Params :
  7179. Dev : paulgh
  7180. Example : /anon
  7181. */
  7182. void Commands::Command_Toggle_Anonymous(Client* client)
  7183. {
  7184. Player* player = client->GetPlayer();
  7185. player->toggle_character_flag(CF_ANONYMOUS);
  7186. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7187. if (player->get_character_flag(CF_ANONYMOUS))
  7188. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7189. else
  7190. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7191. }
  7192. /*
  7193. Function: Command_Toggle_AutoConsume()
  7194. Purpose : Toggles player food/drink auto consume
  7195. Params : unknown
  7196. Dev : paulgh
  7197. Example : /set_auto_consume
  7198. */
  7199. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7200. {
  7201. Player* player = client->GetPlayer();
  7202. if (sep && sep->arg[0])
  7203. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7204. if (sep && sep->arg[0] && sep->IsNumber(0))
  7205. {
  7206. int8 slot = atoi(sep->arg[0]);
  7207. int8 flag = atoi(sep->arg[1]);
  7208. if (slot == EQ2_FOOD_SLOT)
  7209. {
  7210. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7211. player->SetCharSheetChanged(true);
  7212. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7213. if (flag == 1)
  7214. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7215. else
  7216. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7217. }
  7218. else
  7219. {
  7220. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7221. player->SetCharSheetChanged(true);
  7222. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7223. if (flag == 1)
  7224. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7225. else
  7226. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7227. }
  7228. }
  7229. }
  7230. /*
  7231. Function: Command_Toggle_BonusXP()
  7232. Purpose : Toggles player Bonus XP
  7233. Params :
  7234. Dev : John Adams
  7235. Example : /disable_char_bonus_exp
  7236. */
  7237. void Commands::Command_Toggle_BonusXP(Client* client)
  7238. {
  7239. Player* player = client->GetPlayer();
  7240. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7241. player->SetCharSheetChanged(true);
  7242. }
  7243. /*
  7244. Function: Command_Toggle_CombatXP()
  7245. Purpose : Toggles player Adventure XP
  7246. Params :
  7247. Dev : John Adams
  7248. Example : /disable_combat_exp
  7249. */
  7250. void Commands::Command_Toggle_CombatXP(Client* client)
  7251. {
  7252. Player* player = client->GetPlayer();
  7253. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7254. player->SetCharSheetChanged(true);
  7255. }
  7256. /*
  7257. Function: Command_Toggle_GMHide()
  7258. Purpose : Toggles hiding player GM status
  7259. Params :
  7260. Dev : Scatman
  7261. Example : /gm_hide
  7262. */
  7263. void Commands::Command_Toggle_GMHide(Client* client)
  7264. {
  7265. Player* player = client->GetPlayer();
  7266. player->toggle_character_flag(CF_HIDE_STATUS);
  7267. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7268. }
  7269. /*
  7270. Function: Command_Toggle_GMVanish()
  7271. Purpose : Toggles hiding GM players from /who searches
  7272. Params :
  7273. Dev : Scatman
  7274. Example : /gm_vanish
  7275. */
  7276. void Commands::Command_Toggle_GMVanish(Client* client)
  7277. {
  7278. Player* player = client->GetPlayer();
  7279. player->toggle_character_flag(CF_GM_HIDDEN);
  7280. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7281. }
  7282. /*
  7283. Function: Command_Toggle_Illusions()
  7284. Purpose : Toggles player illusion form
  7285. Params : not sure sep is needed, testing
  7286. Dev : paulgh
  7287. Example : /hide_illusions
  7288. */
  7289. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7290. {
  7291. if (sep && sep->arg[0])
  7292. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7293. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7294. }
  7295. /*
  7296. Function: Command_Toggle_LFG()
  7297. Purpose : Toggles player LFG Flag
  7298. Params :
  7299. Dev : paulgh
  7300. Example : /lfg
  7301. */
  7302. void Commands::Command_Toggle_LFG(Client* client)
  7303. {
  7304. Player* player = client->GetPlayer();
  7305. player->toggle_character_flag(CF_LFG);
  7306. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7307. if (player->get_character_flag(CF_LFG))
  7308. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7309. else
  7310. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7311. }
  7312. /*
  7313. Function: Command_Toggle_LFW()
  7314. Purpose : Toggles player LFW Flag
  7315. Params :
  7316. Dev : paulgh
  7317. Example : /lfw
  7318. */
  7319. void Commands::Command_Toggle_LFW(Client* client)
  7320. {
  7321. Player* player = client->GetPlayer();
  7322. player->toggle_character_flag(CF_LFW);
  7323. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7324. if (player->get_character_flag(CF_LFW))
  7325. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7326. else
  7327. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7328. }
  7329. /*
  7330. Function: Command_Toggle_QuestXP()
  7331. Purpose : Toggles player Quest XP
  7332. Params :
  7333. Dev : John Adams
  7334. Example : /disable_quest_exp
  7335. */
  7336. void Commands::Command_Toggle_QuestXP(Client* client)
  7337. {
  7338. Player* player = client->GetPlayer();
  7339. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7340. player->SetCharSheetChanged(true);
  7341. }
  7342. /*
  7343. Function: Command_Toggle_Roleplaying()
  7344. Purpose : Toggles player Roleplaying flag
  7345. Params :
  7346. Dev : paulgh
  7347. Example : /role
  7348. */
  7349. void Commands::Command_Toggle_Roleplaying(Client* client)
  7350. {
  7351. Player* player = client->GetPlayer();
  7352. player->toggle_character_flag(CF_ROLEPLAYING);
  7353. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7354. if (player->get_character_flag(CF_ROLEPLAYING))
  7355. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7356. else
  7357. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7358. }
  7359. void Commands::Command_Toggle_Duels(Client* client)
  7360. {
  7361. Player* player = client->GetPlayer();
  7362. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7363. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7364. }
  7365. void Commands::Command_Toggle_Trades(Client* client)
  7366. {
  7367. Player* player = client->GetPlayer();
  7368. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7369. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7370. }
  7371. void Commands::Command_Toggle_Guilds(Client* client)
  7372. {
  7373. Player* player = client->GetPlayer();
  7374. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7375. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7376. }
  7377. void Commands::Command_Toggle_Groups(Client* client)
  7378. {
  7379. Player* player = client->GetPlayer();
  7380. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7381. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7382. }
  7383. void Commands::Command_Toggle_Raids(Client* client)
  7384. {
  7385. Player* player = client->GetPlayer();
  7386. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7387. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7388. }
  7389. void Commands::Command_Toggle_LON(Client* client)
  7390. {
  7391. Player* player = client->GetPlayer();
  7392. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7393. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7394. }
  7395. void Commands::Command_Toggle_VoiceChat(Client* client)
  7396. {
  7397. Player* player = client->GetPlayer();
  7398. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7399. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7400. }
  7401. /*
  7402. Function: Command_TradeStart()
  7403. Purpose : Starts item/coin trade between players
  7404. Params :
  7405. Dev :
  7406. Example :
  7407. */
  7408. #include "../Trade.h"
  7409. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7410. {
  7411. PrintSep(sep, "COMMAND_START_TRADE");
  7412. Entity* trader = client->GetPlayer();
  7413. Entity* trader2 = 0;
  7414. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7415. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7416. if (spawn) {
  7417. if (spawn->IsEntity())
  7418. trader2 = (Entity*)spawn;
  7419. }
  7420. }
  7421. else if (client->GetPlayer()->GetTarget()) {
  7422. if (client->GetPlayer()->GetTarget()->IsEntity())
  7423. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7424. }
  7425. // can only trade with player or bots
  7426. if (trader && trader2) {
  7427. if (trader == trader2) {
  7428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7429. }
  7430. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7431. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7432. if (trader->trade)
  7433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7434. else if (trader2->trade)
  7435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7436. else {
  7437. Trade* trade = new Trade(trader, trader2);
  7438. trader->trade = trade;
  7439. trader2->trade = trade;
  7440. }
  7441. }
  7442. else {
  7443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7444. }
  7445. }
  7446. else
  7447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7448. }
  7449. /*
  7450. Function: Command_Track()
  7451. Purpose : Starts/Stops Tracking for a player
  7452. Params :
  7453. Dev : Scatman
  7454. Example : /track
  7455. */
  7456. void Commands::Command_Track(Client* client)
  7457. {
  7458. if (!client->GetPlayer()->GetIsTracking())
  7459. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7460. else
  7461. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7462. }
  7463. /*
  7464. Function: Command_TradeAccept()
  7465. Purpose : Accepts item/coin trade between players
  7466. Params :
  7467. Dev :
  7468. Example :
  7469. */
  7470. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7471. {
  7472. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7473. Trade* trade = client->GetPlayer()->trade;
  7474. if (trade) {
  7475. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7476. if (trade_complete)
  7477. safe_delete(trade);
  7478. }
  7479. else
  7480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7481. }
  7482. /*
  7483. Function: Command_TradeReject()
  7484. Purpose : Rejects item/coin trade between players
  7485. Params :
  7486. Dev :
  7487. Example :
  7488. */
  7489. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7490. {
  7491. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7492. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7493. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7494. }
  7495. /*
  7496. Function: Command_TradeCancel()
  7497. Purpose : Cancels item/coin trade between players
  7498. Params :
  7499. Dev :
  7500. Example :
  7501. */
  7502. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7503. {
  7504. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7505. Trade* trade = client->GetPlayer()->trade;
  7506. if (trade) {
  7507. trade->CancelTrade(client->GetPlayer());
  7508. safe_delete(trade);
  7509. }
  7510. else
  7511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7512. }
  7513. /*
  7514. Function: Command_TradeSetCoin()
  7515. Purpose : Sets coin trade between players
  7516. Params :
  7517. Dev :
  7518. Example :
  7519. */
  7520. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7521. {
  7522. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7523. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7524. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7525. }
  7526. /*
  7527. Function: Command_TradeAddCoin()
  7528. Purpose : Adds coin to trade between players
  7529. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7530. Dev :
  7531. Example :
  7532. */
  7533. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7534. {
  7535. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7536. Trade* trade = client->GetPlayer()->trade;
  7537. if (trade) {
  7538. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7539. int32 amount = atoi(sep->arg[0]);
  7540. int64 val = 0;
  7541. switch (handler) {
  7542. case COMMAND_ADD_TRADE_COPPER:
  7543. {
  7544. val = amount;
  7545. trade->AddCoinToTrade(client->GetPlayer(), val);
  7546. break;
  7547. }
  7548. case COMMAND_ADD_TRADE_SILVER:
  7549. {
  7550. val = amount * 100;
  7551. trade->AddCoinToTrade(client->GetPlayer(), val);
  7552. break;
  7553. }
  7554. case COMMAND_ADD_TRADE_GOLD:
  7555. {
  7556. val = amount * 10000;
  7557. trade->AddCoinToTrade(client->GetPlayer(), val);
  7558. break;
  7559. }
  7560. case COMMAND_ADD_TRADE_PLAT:
  7561. {
  7562. val = amount * 1000000;
  7563. trade->AddCoinToTrade(client->GetPlayer(), val);
  7564. break;
  7565. }
  7566. default:
  7567. {
  7568. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7569. break;
  7570. }
  7571. }
  7572. }
  7573. else
  7574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7575. }
  7576. else
  7577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7578. }
  7579. /*
  7580. Function: Command_TradeRemoveCoin()
  7581. Purpose : Removes coin from trade between players
  7582. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7583. Dev :
  7584. Example :
  7585. */
  7586. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7587. {
  7588. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7589. Trade* trade = client->GetPlayer()->trade;
  7590. if (trade) {
  7591. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7592. int32 amount = atoi(sep->arg[0]);
  7593. int64 val = 0;
  7594. switch (handler) {
  7595. case COMMAND_REMOVE_TRADE_COPPER:
  7596. {
  7597. val = amount;
  7598. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7599. break;
  7600. }
  7601. case COMMAND_REMOVE_TRADE_SILVER:
  7602. {
  7603. val = amount * 100;
  7604. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7605. break;
  7606. }
  7607. case COMMAND_REMOVE_TRADE_GOLD:
  7608. {
  7609. val = amount * 10000;
  7610. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7611. break;
  7612. }
  7613. case COMMAND_REMOVE_TRADE_PLAT:
  7614. {
  7615. val = amount * 1000000;
  7616. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7617. break;
  7618. }
  7619. default:
  7620. {
  7621. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7622. break;
  7623. }
  7624. }
  7625. }
  7626. else
  7627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7628. }
  7629. else
  7630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7631. }
  7632. /*
  7633. Function: Command_TradeAddItem()
  7634. Purpose : Adds item to trade between players
  7635. Params :
  7636. Dev :
  7637. Example :
  7638. */
  7639. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7640. {
  7641. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7642. /*
  7643. arg[0] = item index
  7644. arg[1] = slot
  7645. arg[2] = quantity
  7646. */
  7647. if (!client->GetPlayer()->trade) {
  7648. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7650. return;
  7651. }
  7652. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7653. Item* item = 0;
  7654. int32 index = atoi(sep->arg[0]);
  7655. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7656. if (item) {
  7657. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7658. if (result == 1)
  7659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7660. else if (result == 2)
  7661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7662. else if (result == 3)
  7663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7664. else if (result == 255)
  7665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7666. }
  7667. else {
  7668. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7669. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7670. }
  7671. }
  7672. else
  7673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7674. }
  7675. /*
  7676. Function: Command_TradeRemoveItem()
  7677. Purpose : Removes item from trade between players
  7678. Params :
  7679. Dev :
  7680. Example :
  7681. */
  7682. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7683. {
  7684. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7685. /*
  7686. arg[0] = trade window slot
  7687. */
  7688. Trade* trade = client->GetPlayer()->trade;
  7689. if (trade) {
  7690. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7691. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7692. }
  7693. else
  7694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7695. }
  7696. else
  7697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7698. }
  7699. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7700. {
  7701. Item *item = 0;
  7702. sint32 crc;
  7703. if (sep) {
  7704. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7705. if (client->GetVersion() < 1096) {
  7706. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7707. {
  7708. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7709. crc = atol(sep->arg[2]);
  7710. }
  7711. }
  7712. else {
  7713. // From the broker and links in chat
  7714. if (strcmp(sep->arg[0], "crc") == 0) {
  7715. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7716. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7717. crc = atol(sep->arg[3]);
  7718. }
  7719. }
  7720. // From inventory
  7721. if (strcmp(sep->arg[0], "dbid") == 0) {
  7722. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7723. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7724. crc = atol(sep->arg[4]);
  7725. }
  7726. }
  7727. }
  7728. if (item)
  7729. client->ShowDressingRoom(item, crc);
  7730. }
  7731. }
  7732. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7733. const char *channel_name, *password = NULL;
  7734. if (sep == NULL || !sep->IsSet(0)) {
  7735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7736. return;
  7737. }
  7738. channel_name = sep->arg[0];
  7739. if (sep->IsSet(1))
  7740. password = sep->arg[1];
  7741. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7742. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7743. return;
  7744. }
  7745. if (chat.IsInChannel(client, channel_name)) {
  7746. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7747. return;
  7748. }
  7749. if (chat.HasPassword(channel_name)) {
  7750. if (password == NULL) {
  7751. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7752. return;
  7753. }
  7754. if (!chat.PasswordMatches(channel_name, password)) {
  7755. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7756. return;
  7757. }
  7758. }
  7759. if (!chat.JoinChannel(client, channel_name))
  7760. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7761. }
  7762. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7763. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7764. Command_JoinChannel(client, sep);
  7765. }
  7766. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7767. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7769. PrintSep(sep, "tellchannel");
  7770. return;
  7771. }
  7772. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7773. }
  7774. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7775. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7776. if (!p) return;
  7777. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7778. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7779. //}
  7780. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7781. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7782. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7783. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7784. if (packet) {
  7785. client->QueuePacket(packet->serialize());
  7786. safe_delete(packet);
  7787. }
  7788. }*/
  7789. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7790. int32 numFaces = 0;
  7791. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7792. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7793. map<int32, vector<Face*> >::iterator itr;
  7794. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7795. numFaces += (*itr).second.size();
  7796. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7797. }*/
  7798. //uchar blah[] = {
  7799. // 1208 - OP_EQUpdateStoreCmd
  7800. // /*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
  7801. // /*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
  7802. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7803. // /*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
  7804. /*};
  7805. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7806. int8 val = 0;
  7807. int16 pos = 0;
  7808. int idx = 0;
  7809. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7810. pos = atoi(sep2->arg[idx]);
  7811. val = atoi(sep2->arg[idx+1]);
  7812. memset(blah+pos, val, 1);
  7813. idx+=2;
  7814. }
  7815. DumpPacket(blah, sizeof(blah));
  7816. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7817. if (client->GetPlayer()->GetTarget()) {
  7818. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7819. if (packet) {
  7820. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7821. packet->setDataByName("size", 0);
  7822. packet->setDataByName("unknown2", 0);
  7823. EQ2Packet* app = packet->serialize();
  7824. client->QueuePacket(app);
  7825. safe_delete(packet);
  7826. }
  7827. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7828. if (set_pov) {
  7829. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7830. EQ2Packet* app_pov = set_pov->serialize();
  7831. client->QueuePacket(app_pov);
  7832. safe_delete(set_pov);
  7833. }
  7834. }
  7835. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7836. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7837. if (packet) {
  7838. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7839. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7840. else
  7841. packet->setDataByName("Type", 2);
  7842. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7843. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7844. else
  7845. packet->setDataByName("race_id", 0);
  7846. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7847. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7848. else
  7849. packet->setDataByName("gender", 2);
  7850. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7851. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7852. else
  7853. packet->setDataByName("unknown", 0, 0);
  7854. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7855. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7856. else
  7857. packet->setDataByName("unknown", 0, 1);
  7858. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7859. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7860. else
  7861. packet->setDataByName("unknown", 0, 2);
  7862. client->QueuePacket(packet->serialize());
  7863. }
  7864. safe_delete(packet);
  7865. safe_delete(sep2);
  7866. }
  7867. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7868. const char *channel_name;
  7869. if (sep == NULL || !sep->IsSet(0)) {
  7870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7871. PrintSep(sep);
  7872. return;
  7873. }
  7874. channel_name = sep->arg[0];
  7875. if (!chat.IsInChannel(client, channel_name))
  7876. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7877. else if (!chat.LeaveChannel(client, channel_name))
  7878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7879. }
  7880. /*
  7881. Function:
  7882. Purpose :
  7883. Params :
  7884. Dev :
  7885. Example :
  7886. */
  7887. void Commands::Command_WeaponStats(Client* client)
  7888. {
  7889. Player* player = client->GetPlayer();
  7890. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7891. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7892. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7893. client->SimpleMessage(0, "Primary:");
  7894. if (primary) {
  7895. client->Message(0, "Name: %s", primary->name.c_str());
  7896. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7897. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7898. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7899. client->Message(0, "Proc Percent: %d%%", 0);
  7900. client->Message(0, "Procs Per Minute: %d", 0);
  7901. }
  7902. else {
  7903. client->SimpleMessage(0, "Name: fist");
  7904. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7905. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7906. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7907. client->Message(0, "Proc Percent: %d%%", 0);
  7908. client->Message(0, "Procs Per Minute: %d", 0);
  7909. }
  7910. client->SimpleMessage(0, " ");
  7911. client->SimpleMessage(0, " ");
  7912. if (secondary) {
  7913. client->SimpleMessage(0, "Secondary:");
  7914. client->Message(0, "Name: %s", secondary->name.c_str());
  7915. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7916. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7917. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7918. client->Message(0, "Proc Percent: %d%%", 0);
  7919. client->Message(0, "Procs Per Minute: %d", 0);
  7920. client->SimpleMessage(0, " ");
  7921. client->SimpleMessage(0, " ");
  7922. }
  7923. client->SimpleMessage(0, "Ranged:");
  7924. if (ranged) {
  7925. client->Message(0, "Name: %s", ranged->name.c_str());
  7926. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7927. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7928. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7929. client->Message(0, "Proc Percent: %d%%", 0);
  7930. client->Message(0, "Procs Per Minute: %d", 0);
  7931. }
  7932. else
  7933. client->SimpleMessage(0, "None");
  7934. }
  7935. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7936. const char *channel_name;
  7937. if (sep == NULL || !sep->IsSet(0)) {
  7938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7939. return;
  7940. }
  7941. channel_name = sep->arg[0];
  7942. if (!chat.ChannelExists(channel_name))
  7943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7944. else
  7945. chat.SendChannelUserList(client, channel_name);
  7946. }
  7947. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7948. {
  7949. ZoneServer* zone = 0;
  7950. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7951. if (zone_id > 0)
  7952. {
  7953. zone = zone_list.Get(zone_id, false);
  7954. if (zone)
  7955. {
  7956. zone->SetSafeX(client->GetPlayer()->GetX());
  7957. zone->SetSafeY(client->GetPlayer()->GetY());
  7958. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7959. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7960. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7962. else
  7963. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7964. }
  7965. }
  7966. }
  7967. /*
  7968. Function:
  7969. Purpose :
  7970. Params :
  7971. Dev :
  7972. Example :
  7973. */
  7974. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7975. {
  7976. ZoneInfo* zone_info = new ZoneInfo;
  7977. if (sep && sep->arg[0])
  7978. {
  7979. if (sep->IsNumber(0))
  7980. zone_info->id = atoi(sep->arg[0]);
  7981. else
  7982. zone_info->id = database.GetZoneID(sep->arg[0]);
  7983. if (zone_info->id > 0)
  7984. {
  7985. database.LoadZoneInfo(zone_info);
  7986. 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);
  7987. 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);
  7988. 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);
  7989. 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);
  7990. 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);
  7991. 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);
  7992. 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);
  7993. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7994. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7995. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7996. }
  7997. else
  7998. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7999. }
  8000. else
  8001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8002. safe_delete(zone_info);
  8003. }
  8004. /*
  8005. Function:
  8006. Purpose :
  8007. Params :
  8008. Dev :
  8009. Example :
  8010. */
  8011. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8012. {
  8013. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8014. {
  8015. ZoneServer* zone = 0;
  8016. int32 zone_id = 0;
  8017. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8018. {
  8019. zone_id = atoi(sep->arg[0]);
  8020. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8021. }
  8022. else
  8023. {
  8024. zone_id = database.GetZoneID(sep->arg[0]);
  8025. if (zone_id > 0)
  8026. zone = zone_list.Get(sep->arg[0], false);
  8027. }
  8028. if (zone_id > 0)
  8029. {
  8030. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8031. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8032. else
  8033. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8034. }
  8035. else
  8036. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8037. }
  8038. else
  8039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8040. }
  8041. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8042. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8044. return;
  8045. }
  8046. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8047. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8048. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8049. }
  8050. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8051. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8053. return;
  8054. }
  8055. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8056. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8057. }
  8058. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8059. Spawn* spawn = client->GetPlayer()->GetTarget();
  8060. if(spawn) {
  8061. client->SetMerchantTransaction(spawn);
  8062. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8063. client->SendHailCommand(spawn);
  8064. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8065. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8066. client->SendBuyMerchantList(sell);
  8067. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8068. client->SendSellMerchantList(sell);
  8069. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8070. client->SendBuyBackList(sell);
  8071. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8072. if (packet) {
  8073. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8074. packet->setDataByName("type", 16);
  8075. EQ2Packet* outapp = packet->serialize();
  8076. if (outapp)
  8077. client->QueuePacket(outapp);
  8078. safe_delete(packet);
  8079. }
  8080. }
  8081. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8082. client->SendRepairList();
  8083. }
  8084. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8085. }
  8086. void Commands::Command_Weather(Client* client, Seperator* sep)
  8087. {
  8088. //PrintSep(sep, "Weather");
  8089. if( sep && sep->arg[0] )
  8090. {
  8091. ZoneServer* zsZone = client->GetCurrentZone();
  8092. const char* value = sep->arg[0];
  8093. // process single-param commands first
  8094. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8095. {
  8096. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8097. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8098. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8099. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  8100. }
  8101. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  8102. {
  8103. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8104. zsZone->ProcessWeather();
  8105. }
  8106. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  8107. {
  8108. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  8109. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  8110. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  8111. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  8112. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  8113. zsZone->SetWeatherPattern(1);
  8114. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  8115. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  8116. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  8117. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8118. zsZone->ProcessWeather();
  8119. }
  8120. // process commands with params
  8121. if( sep->arg[1] )
  8122. {
  8123. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  8124. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  8125. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  8126. zsZone->SetWeatherType(atoi(sep->arg[1]));
  8127. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  8128. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  8129. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  8130. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  8131. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  8132. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  8133. }
  8134. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  8135. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  8136. zsZone->SetRain(zsZone->GetCurrentWeather());
  8137. }
  8138. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  8139. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  8140. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  8141. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  8142. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8143. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  8144. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8145. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  8146. }
  8147. }
  8148. else
  8149. {
  8150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  8151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  8152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  8153. return;
  8154. }
  8155. }
  8156. void Commands::Command_Select(Client* client, Seperator* sep) {
  8157. if (sep && sep->arg[1]) {
  8158. Spawn* spawn = client->GetPlayer()->GetTarget();
  8159. if (spawn && strlen(sep->arg[1]) > 0)
  8160. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  8161. }
  8162. }
  8163. /*
  8164. Function: Command_ConsumeFood()
  8165. Purpose : Consume Food/Drink and apply mods
  8166. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  8167. Dev : Zcoretri
  8168. Example : /consume_food 22
  8169. */
  8170. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  8171. if (sep && sep->arg[0] && sep->IsNumber(0))
  8172. {
  8173. Player* player = client->GetPlayer();
  8174. int8 slot = atoi(sep->arg[0]);
  8175. Item* item = player->GetEquipmentList()->GetItem(slot);
  8176. if(item) {
  8177. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  8178. if(item->GetItemScript() && lua_interface){
  8179. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  8180. if (slot == 22)
  8181. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  8182. else
  8183. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  8184. }
  8185. }
  8186. if (item->details.count > 1) {
  8187. item->details.count -= 1;
  8188. item->save_needed = true;
  8189. }
  8190. else {
  8191. player->GetEquipmentList()->RemoveItem(slot, true);
  8192. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  8193. }
  8194. client->GetPlayer()->SetCharSheetChanged(true);
  8195. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8196. }
  8197. }
  8198. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  8199. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8200. if (atoi(sep->arg[0]) == 1) {
  8201. client->GetPlayer()->GetInfoStruct()->vision = 4;
  8202. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  8203. client->GetPlayer()->SetCharSheetChanged(true);
  8204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  8205. }
  8206. else {
  8207. client->GetPlayer()->GetInfoStruct()->vision = 0;
  8208. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  8209. client->GetPlayer()->SetCharSheetChanged(true);
  8210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  8211. }
  8212. }
  8213. else
  8214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  8215. }
  8216. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  8217. {
  8218. if(sep)
  8219. {
  8220. string data;
  8221. if(sep->arg[0]){
  8222. data = string(sep->arg[0]);
  8223. }
  8224. for(int i=1;i<sep->GetMaxArgNum();i++){
  8225. if(sep->arg[i])
  8226. data.append(" ").append(sep->arg[i]);
  8227. }
  8228. const char* target_name = 0;
  8229. int32 spawn_id = 0;
  8230. if(client->GetPlayer()->GetTarget())
  8231. {
  8232. target_name = client->GetPlayer()->GetTarget()->GetName();
  8233. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8234. }
  8235. else
  8236. target_name = "N/A";
  8237. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  8238. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  8239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  8240. else
  8241. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  8242. }
  8243. }
  8244. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  8245. PrintSep(sep, "Command_Attune_Inv");
  8246. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8247. // Get the item index from the first parameter
  8248. int16 index = atoi(sep->arg[0]);
  8249. // Check to see if this is a valid item index for the player, if not exit out of the function
  8250. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  8251. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  8252. return;
  8253. }
  8254. // Get the item
  8255. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  8256. if(item) {
  8257. // Valid item lets check to make sure this item is attunable, if not return out
  8258. if (!item->CheckFlag(ATTUNEABLE)) {
  8259. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  8260. return;
  8261. }
  8262. // Remove the attunable flag
  8263. item->generic_info.item_flags -= ATTUNEABLE;
  8264. // Set the attuned flag
  8265. item->generic_info.item_flags += ATTUNED;
  8266. // Flag this item for saving
  8267. item->save_needed = true;
  8268. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  8269. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  8270. EQ2Packet* outapp = 0;
  8271. for (int32 i=0;i<packets.size();i++) {
  8272. outapp = packets[i];
  8273. if(outapp)
  8274. client->QueuePacket(outapp);
  8275. }
  8276. }
  8277. }
  8278. }
  8279. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  8280. PrintSep(sep, "Command_Reset_Zone_Timer");
  8281. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8282. int32 db_id = atoul(sep->arg[0]);
  8283. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  8284. if (data) {
  8285. // TODO: add a check to timers to ensure it can be reset
  8286. // Delete the character from the instance
  8287. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  8288. data->instance_id = 0;
  8289. // Update the success time and set to 0 so the player can enter it again
  8290. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  8291. data->last_success_timestamp = 0;
  8292. }
  8293. }*/
  8294. }
  8295. void Commands::Command_Player(Client* client, Seperator* sep) {
  8296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  8297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  8298. }
  8299. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  8300. // /player coins add 10
  8301. // /player coins add plat 10
  8302. Player* player = client->GetPlayer();
  8303. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  8304. player = (Player*)player->GetTarget();
  8305. if (sep && sep->arg[0] && sep->arg[1]) {
  8306. const char* action = sep->arg[0];
  8307. int64 value = 0;
  8308. if (strncasecmp(action, "add", strlen(action)) == 0) {
  8309. if (sep->IsNumber(1)) {
  8310. value = atoi64(sep->arg[1]);
  8311. player->AddCoins(value);
  8312. if (client->GetPlayer() == player)
  8313. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8314. else {
  8315. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8316. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8317. }
  8318. return;
  8319. }
  8320. else if (sep->arg[2] && sep->IsNumber(2)) {
  8321. const char* type = sep->arg[1];
  8322. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  8323. value = atoi64(sep->arg[2]);
  8324. }
  8325. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  8326. value = atoi64(sep->arg[2]) * 100;
  8327. }
  8328. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  8329. value = atoi64(sep->arg[2]) * 10000;
  8330. }
  8331. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  8332. value = atoi64(sep->arg[2]) * 1000000;
  8333. }
  8334. player->AddCoins(value);
  8335. if (client->GetPlayer() == player)
  8336. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8337. else {
  8338. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8339. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8340. }
  8341. return;
  8342. }
  8343. }
  8344. }
  8345. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  8346. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  8347. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  8348. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  8349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  8350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  8351. }
  8352. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  8353. PrintSep(sep, "ACHIEVEMENT_ADD");
  8354. if (sep && sep->IsSet(0)) {
  8355. int32 spell_id = atoul(sep->arg[1]);
  8356. int8 spell_tier = 0;
  8357. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8358. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8359. // addspellbookentry here
  8360. if (spell_tier >= data->maxRank) {
  8361. return;
  8362. }
  8363. if (!spell_tier) {
  8364. spell_tier = 1;
  8365. }
  8366. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8367. {
  8368. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8369. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8370. client->GetPlayer()->UnlockSpell(spell);
  8371. client->SendSpellUpdate(spell);
  8372. }
  8373. else
  8374. {
  8375. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8376. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8377. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8378. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8379. client->GetPlayer()->UnlockSpell(spell);
  8380. client->SendSpellUpdate(spell);
  8381. }
  8382. // cast spell here
  8383. if (!spell_tier)
  8384. spell_tier = 1;
  8385. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8386. if (spell) {
  8387. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8388. }
  8389. }
  8390. else {
  8391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8392. }
  8393. master_aa_list.DisplayAA(client, 0, 0);
  8394. }
  8395. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8396. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8397. if (packet) {
  8398. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8399. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8400. char command[255];
  8401. url = "browser " + url;
  8402. int32 spawn_id = 0;
  8403. int32 zone_id = 0;
  8404. string type;
  8405. if (client->GetCurrentZone())
  8406. zone_id = client->GetCurrentZone()->GetZoneID();
  8407. if (client->GetPlayer()->GetTarget()) {
  8408. Spawn* target = client->GetPlayer()->GetTarget();
  8409. if (target->IsWidget())
  8410. type = "widgets";
  8411. else if (target->IsSign())
  8412. type = "signs";
  8413. else if (target->IsObject())
  8414. type = "objects";
  8415. else if (target->IsNPC())
  8416. type = "npcs";
  8417. else if (target->IsGroundSpawn())
  8418. type = "ground";
  8419. else
  8420. type = "spawn";
  8421. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8422. }
  8423. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8424. packet->setDataByName("accept_command", command);
  8425. }
  8426. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8427. char command[255];
  8428. url = "browser " + url;
  8429. if (client->GetPlayer()->GetTarget())
  8430. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8431. packet->setDataByName("accept_command", command);
  8432. }
  8433. else {
  8434. string command = "browser " + url;
  8435. packet->setDataByName("accept_command", command.c_str());
  8436. }
  8437. packet->setDataByName("text", "Open the web editor?");
  8438. packet->setDataByName("accept_text", "Open");
  8439. packet->setDataByName("cancel_text", "Cancel");
  8440. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8441. packet->setDataByName("unknown2", 50);
  8442. packet->setDataByName("unknown4", 1);
  8443. client->QueuePacket(packet->serialize());
  8444. safe_delete(packet);
  8445. }
  8446. }
  8447. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8448. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8449. return;
  8450. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8451. if(client->GetCurrentRez()->active)
  8452. client->AcceptResurrection();
  8453. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8454. }
  8455. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8456. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8457. return;
  8458. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8459. if(client->GetCurrentRez()->active)
  8460. client->GetCurrentRez()->should_delete = true;
  8461. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8462. }
  8463. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8464. PrintSep(sep, "Switch_AA_Profile");
  8465. if (sep && sep->IsSet(0)) {
  8466. string type = sep->arg[0];
  8467. int8 newtemplate = atoul(sep->arg[1]);
  8468. master_aa_list.DisplayAA(client, newtemplate, 1);
  8469. }
  8470. }
  8471. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8472. PrintSep(sep, "Get_AA_Xml");
  8473. if (sep && sep->IsSet(0)) {
  8474. string tabnum = sep->arg[0];
  8475. string spellid = sep->arg[1];
  8476. }
  8477. }
  8478. void Commands::Add_AA(Client* client, Seperator* sep) {
  8479. PrintSep(sep, "Add_AA");
  8480. if (sep && sep->IsSet(0)) {
  8481. int32 spell_id = atoul(sep->arg[1]);
  8482. int8 spell_tier = 0;
  8483. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8484. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8485. // addspellbookentry here
  8486. if (spell_tier >= data->maxRank) {
  8487. return;
  8488. }
  8489. if (!spell_tier) {
  8490. spell_tier = 1;
  8491. }
  8492. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8493. {
  8494. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8495. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8496. client->GetPlayer()->UnlockSpell(spell);
  8497. client->SendSpellUpdate(spell);
  8498. }
  8499. else
  8500. {
  8501. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8502. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8503. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8504. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8505. client->GetPlayer()->UnlockSpell(spell);
  8506. client->SendSpellUpdate(spell);
  8507. }
  8508. // cast spell here
  8509. if (!spell_tier)
  8510. spell_tier = 1;
  8511. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8512. if (spell) {
  8513. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8514. }
  8515. }
  8516. else {
  8517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8518. }
  8519. master_aa_list.DisplayAA(client, 0, 0);
  8520. }
  8521. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8522. PrintSep(sep, "Commit_AA_Profile");
  8523. if (sep && sep->IsSet(0)) {
  8524. }
  8525. }
  8526. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8527. PrintSep(sep, "Begin_AA_Profile");
  8528. if (sep && sep->IsSet(0)) {
  8529. master_aa_list.DisplayAA(client, 100, 2);
  8530. }
  8531. }
  8532. void Commands::Back_AA(Client* client, Seperator* sep) {
  8533. if (sep && sep->IsSet(0)) {
  8534. PrintSep(sep, "Back_AA");
  8535. }
  8536. }
  8537. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8538. if (sep && sep->IsSet(0)) {
  8539. PrintSep(sep, "Remove_AA");
  8540. }
  8541. }
  8542. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8543. MasterAAList master_aa_list;
  8544. PrintSep(sep, "Cancel_AA_Profile");
  8545. master_aa_list.DisplayAA(client, 0, 0);
  8546. }
  8547. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8548. if (sep && sep->IsSet(0)) {
  8549. PrintSep(sep, "Save_AA_Profile");
  8550. }
  8551. }
  8552. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8553. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8554. if (!sep->IsNumber(0)) return;
  8555. int32 request_id = atoul(sep->arg[0]);
  8556. if (!sep->IsNumber(1)) return;
  8557. sint32 item_id = atoi(sep->arg[1]);
  8558. if (client->IsCurrentTransmuteID(request_id)) {
  8559. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8560. }
  8561. else if (client->IsCurrentTransmuteID(item_id)) {
  8562. if (!sep->IsSet(2)) return;
  8563. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8564. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8565. }
  8566. }
  8567. }