Commands.cpp 318 KB

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