Commands.cpp 327 KB

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