Commands.cpp 320 KB

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