Commands.cpp 362 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. break;
  1062. }
  1063. case COMMAND_RELOADSTRUCTS: {
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1065. configReader.ReloadStructs();
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1067. break;
  1068. }
  1069. case COMMAND_RELOAD_QUESTS: {
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1071. master_quest_list.Reload();
  1072. client_list.ReloadQuests();
  1073. zone_list.ReloadClientQuests();
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1075. break;
  1076. }
  1077. case COMMAND_RELOAD_SPAWNS: {
  1078. client->GetCurrentZone()->ReloadSpawns();
  1079. break;
  1080. }
  1081. case COMMAND_RELOAD_SPELLS: {
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1083. zone_list.DeleteSpellProcess();
  1084. master_spell_list.Reload();
  1085. if (lua_interface)
  1086. lua_interface->ReloadSpells();
  1087. zone_list.LoadSpellProcess();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1093. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1094. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_ZONESCRIPTS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1100. world.ResetZoneScripts();
  1101. database.LoadZoneScriptData();
  1102. if (lua_interface)
  1103. lua_interface->DestroyZoneScripts();
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1105. break;
  1106. }
  1107. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1109. client->GetCurrentZone()->ClearEntityCommands();
  1110. database.LoadEntityCommands(client->GetCurrentZone());
  1111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1112. break;
  1113. }
  1114. case COMMAND_RELOAD_FACTIONS: {
  1115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1116. master_faction_list.Clear();
  1117. database.LoadFactionList();
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_MAIL: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1123. zone_list.ReloadMail();
  1124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1125. break;
  1126. }
  1127. case COMMAND_RELOAD_GUILDS: {
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1129. world.ReloadGuilds();
  1130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1131. break;
  1132. }
  1133. case COMMAND_RELOAD_LOCATIONS: {
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1135. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1136. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1138. break;
  1139. }
  1140. case COMMAND_RELOAD_RULES: {
  1141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1142. database.LoadRuleSets(true);
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_TRANSPORTERS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1148. database.LoadTransporters(client->GetCurrentZone());
  1149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1150. break;
  1151. }
  1152. case COMMAND_READ: {
  1153. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1154. if (strcmp(sep->arg[0], "read") == 0) {
  1155. int32 item_index = atol(sep->arg[1]);
  1156. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1157. if (item) {
  1158. Spawn* spawn = cmdTarget;
  1159. int8 numpages = item->book_pages.size();
  1160. string page1 = string(item->book_pages[0]->page_text.data);
  1161. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1162. string title = item->name;
  1163. if (packet) {
  1164. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1165. packet->setDataByName("book_title", title.c_str());
  1166. packet->setDataByName("book_type", "simple");
  1167. packet->setDataByName("unknown2", 1);
  1168. packet->setDataByName("unknown5", 1, 4);
  1169. packet->setArrayLengthByName("num_pages", numpages);
  1170. for (int8 pages = 1; pages <= numpages; pages++) {
  1171. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1172. string page = string(item->book_pages[pages-1]->page_text.data);
  1173. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1174. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1175. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1176. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1177. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1178. // Need to add support for images
  1179. }
  1180. client->QueuePacket(packet->serialize());
  1181. safe_delete(packet);
  1182. }
  1183. break;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. case COMMAND_USEABILITY:{
  1189. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1190. if (client->GetPlayer()->GetHP() == 0) {
  1191. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1192. }
  1193. else {
  1194. int32 spell_id = atoul(sep->arg[0]);
  1195. int8 spell_tier = 0;
  1196. if (sep->arg[1][0] && sep->IsNumber(1))
  1197. spell_tier = atoi(sep->arg[1]);
  1198. else
  1199. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1200. if (!spell_tier)
  1201. spell_tier = 1;
  1202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1203. if (spell) {
  1204. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1205. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1206. else
  1207. {
  1208. if (cmdTarget)
  1209. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1210. else
  1211. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1212. }
  1213. }
  1214. }
  1215. }
  1216. else if (cmdTarget && cmdTarget->IsWidget())
  1217. {
  1218. Widget* widget = (Widget*)cmdTarget;
  1219. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1220. }
  1221. else
  1222. {
  1223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_INFO:{
  1228. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1229. if(strcmp(sep->arg[0], "inventory") == 0){
  1230. int32 item_index = atol(sep->arg[1]);
  1231. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1232. if(item){
  1233. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1234. break;
  1235. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1236. //DumpPacket(app);
  1237. client->QueuePacket(app);
  1238. if(item->GetItemScript() && lua_interface)
  1239. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1240. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1241. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1242. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1243. client->AddPendingQuest(quest);
  1244. }
  1245. }
  1246. else
  1247. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1248. }
  1249. else if(strcmp(sep->arg[0], "equipment") == 0){
  1250. int32 item_index = atol(sep->arg[1]);
  1251. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1252. if(item){
  1253. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1254. client->QueuePacket(app);
  1255. if(item->GetItemScript() && lua_interface)
  1256. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1257. }
  1258. else
  1259. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1260. }
  1261. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1262. int32 item_id = atoul(sep->arg[1]);
  1263. Item* item = master_item_list.GetItem(item_id);
  1264. if(item){
  1265. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1266. client->QueuePacket(app);
  1267. }
  1268. else
  1269. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1270. }
  1271. else if (strcmp(sep->arg[0], "spell") == 0) {
  1272. sint32 spell_id = atol(sep->arg[1]);
  1273. int8 tier = atoi(sep->arg[3]);
  1274. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1275. if (outapp)
  1276. client->QueuePacket(outapp);
  1277. else
  1278. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1279. }
  1280. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1281. sint32 spell_id = atol(sep->arg[2]);
  1282. int8 group = atoi(sep->arg[1]);
  1283. AltAdvanceData* data = 0;
  1284. SpellBookEntry* spellentry = 0;
  1285. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1287. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1288. if (outapp)
  1289. client->QueuePacket(outapp);
  1290. else
  1291. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1292. }
  1293. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1294. sint32 spell_id = atol(sep->arg[1]);
  1295. int8 tier = atoi(sep->arg[2]);
  1296. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1297. if (outapp)
  1298. client->QueuePacket(outapp);
  1299. else
  1300. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1301. }
  1302. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1303. sint32 recipe_id = atol(sep->arg[1]);
  1304. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1305. if(outapp)
  1306. client->QueuePacket(outapp);
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1311. int32 slot = atol(sep->arg[1]);
  1312. int32 spell_id = atol(sep->arg[2]);
  1313. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1314. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1315. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1316. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1317. if(outapp)
  1318. client->QueuePacket(outapp);
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. else if (strcmp(sep->arg[0], "effect") == 0) {
  1323. int32 spell_id = atol(sep->arg[1]);
  1324. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1325. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1326. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1327. if (outapp){
  1328. client->QueuePacket(outapp);
  1329. }
  1330. else
  1331. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1332. }
  1333. }
  1334. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1335. Item* item = player->item_list.GetOverflowItem();
  1336. if(item) {
  1337. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1338. client->QueuePacket(app);
  1339. }
  1340. else
  1341. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1342. }
  1343. else
  1344. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1345. break;
  1346. }
  1347. case COMMAND_USE_EQUIPPED_ITEM:{
  1348. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1349. int32 slot_id = atoul(sep->arg[0]);
  1350. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1351. if (item && item->generic_info.usable && item->GetItemScript())
  1352. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1353. }
  1354. break;
  1355. }
  1356. case COMMAND_USE_ITEM: {
  1357. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1358. int32 item_index = atoul(sep->arg[0]);
  1359. Item* item = player->item_list.GetItemFromIndex(item_index);
  1360. if (item && item->GetItemScript()) {
  1361. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1362. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1363. else {
  1364. if (item->generic_info.display_charges > 0) {
  1365. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1366. item->generic_info.display_charges -= 1;
  1367. item->save_needed = true;
  1368. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1369. }
  1370. }
  1371. }
  1372. }
  1373. break;
  1374. }
  1375. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1376. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1377. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1378. if (item) {
  1379. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1380. if(item->generic_info.item_type == 6) {
  1381. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1382. int8 old_slot = 0;
  1383. if (spell) {
  1384. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1385. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1386. player->RemoveSpellBookEntry(spell->GetSpellID());
  1387. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1388. player->UnlockSpell(spell);
  1389. client->SendSpellUpdate(spell);
  1390. database.DeleteItem(client->GetCharacterID(), item, 0);
  1391. player->item_list.RemoveItem(item, true);
  1392. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1393. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1394. }
  1395. }
  1396. else
  1397. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1398. }
  1399. else if(item->generic_info.item_type == 7){
  1400. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1401. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1402. // if valid recipe book and the player doesn't have it
  1403. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1404. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1405. safe_delete(recipe_book);
  1406. }
  1407. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1408. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1409. // Add recipe book to the players list
  1410. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1411. // Get a list of all recipes this book contains
  1412. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1413. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1414. // Create the packet to send to update the players recipe list
  1415. PacketStruct* packet = 0;
  1416. if (client->GetRecipeListSent()) {
  1417. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1418. if (packet)
  1419. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1420. }
  1421. // loop through the list
  1422. vector<Recipe*>::iterator itr;
  1423. int16 i = 0;
  1424. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1425. // check to see if the player already has this recipe some how
  1426. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1427. // Player doesn't already have this recipe so lets add it
  1428. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1429. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1430. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1431. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1432. if (packet && client->GetRecipeListSent()) {
  1433. packet->setArrayDataByName("id", recipe->GetID(), i);
  1434. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1435. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1436. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1437. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1438. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1439. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1440. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1441. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1442. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1443. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1444. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1445. i++;
  1446. }
  1447. }
  1448. }
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1450. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1451. database.DeleteItem(client->GetCharacterID(), item, 0);
  1452. client->GetPlayer()->item_list.RemoveItem(item, true);
  1453. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1454. if (packet && client->GetRecipeListSent())
  1455. client->QueuePacket(packet->serialize());
  1456. safe_delete(packet);
  1457. }
  1458. else {
  1459. if (recipe_book)
  1460. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1461. safe_delete(recipe_book);
  1462. }
  1463. }
  1464. }
  1465. else
  1466. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1467. }
  1468. break;
  1469. }
  1470. case COMMAND_SUMMONITEM: {
  1471. if (sep && sep->IsNumber(0)) {
  1472. int32 item_id = atol(sep->arg[0]);
  1473. int32 quantity = 1;
  1474. if (sep->arg[1] && sep->IsNumber(1))
  1475. quantity = atoi(sep->arg[1]);
  1476. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1477. client->AddItemToBank(item_id,quantity);
  1478. }
  1479. else {
  1480. client->AddItem(item_id, quantity);
  1481. }
  1482. }
  1483. else {
  1484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1486. }
  1487. break;
  1488. }
  1489. case COMMAND_COLLECTION_ADDITEM: {
  1490. // takes 2 params: collection_id, slot
  1491. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1492. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1493. if (item)
  1494. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1495. else
  1496. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1497. }
  1498. else
  1499. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1500. break;
  1501. }
  1502. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1503. // takes 1 param: slot
  1504. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1505. int i = 0;
  1506. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1507. printf("\t%u: %s\n", i, sep->arg[i]);
  1508. i++;
  1509. }
  1510. break;
  1511. }
  1512. case COMMAND_WHO:{
  1513. const char* who = 0;
  1514. if(sep && sep->arg[0]){
  1515. //cout << "Who query: \n";
  1516. who = sep->argplus[0];
  1517. //cout << who << endl;
  1518. }
  1519. zone_list.ProcessWhoQuery(who, client);
  1520. break;
  1521. }
  1522. case COMMAND_SELECT_JUNCTION:{
  1523. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1524. int32 choice = 0;
  1525. if(sep && sep->arg[0] && sep->IsNumber(0))
  1526. choice = atoul(sep->arg[0]);
  1527. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1528. client->HandlePlayerRevive(choice);
  1529. }
  1530. break;
  1531. }
  1532. case COMMAND_SPAWN_MOVE: {
  1533. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1534. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1535. if (packet) {
  1536. float unknown2_3 = 0;
  1537. int8 placement_mode = 0;
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1539. if (sep && sep->arg[0][0]) {
  1540. if (strcmp(sep->arg[0], "wall") == 0) {
  1541. placement_mode = 2;
  1542. unknown2_3 = 150;
  1543. }
  1544. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1545. placement_mode = 1;
  1546. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1547. {
  1548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1549. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1550. }
  1551. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1552. {
  1553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1554. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1555. }
  1556. else if (strcmp(sep->arg[0], "myloc") == 0)
  1557. {
  1558. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1559. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1560. safe_delete(packet);
  1561. break;
  1562. }
  1563. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1564. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1565. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1566. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1567. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1568. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1569. safe_delete(packet);
  1570. break;
  1571. }
  1572. }
  1573. packet->setDataByName("placement_mode", placement_mode);
  1574. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1575. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1576. packet->setDataByName("unknown", 1); //size
  1577. packet->setDataByName("unknown2", 1); //size 2
  1578. packet->setDataByName("unknown2", .5, 1); //size 3
  1579. packet->setDataByName("unknown2", 3, 2);
  1580. packet->setDataByName("unknown2", unknown2_3, 3);
  1581. packet->setDataByName("max_distance", 500);
  1582. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1583. client->QueuePacket(packet->serialize());
  1584. safe_delete(packet);
  1585. }
  1586. }
  1587. else {
  1588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1590. }
  1591. break;
  1592. }
  1593. case COMMAND_HAIL:{
  1594. Spawn* spawn = cmdTarget;
  1595. if(spawn && spawn->GetTargetable())
  1596. {
  1597. char tmp[75] = {0};
  1598. sprintf(tmp, "Hail, %s", spawn->GetName());
  1599. bool show_bubble = true;
  1600. if (spawn->IsNPC())
  1601. show_bubble = false;
  1602. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1603. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1604. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1605. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1606. else
  1607. spawn->ProcessMovement();
  1608. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1609. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1610. }
  1611. }
  1612. else {
  1613. string tmp = "Hail";
  1614. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1615. }
  1616. break;
  1617. }
  1618. case COMMAND_SAY:{
  1619. if (sep && sep->arg[0][0]) {
  1620. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1621. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1622. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1623. }
  1624. else
  1625. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1626. break;
  1627. }
  1628. case COMMAND_TELL:{
  1629. if(sep && sep->arg[0] && sep->argplus[1]){
  1630. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1631. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1632. }else
  1633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1634. break;
  1635. }
  1636. case COMMAND_SHOUT:{
  1637. if(sep && sep->arg[0][0])
  1638. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1639. else
  1640. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1641. break;
  1642. }
  1643. case COMMAND_AUCTION:{
  1644. if(sep && sep->arg[0][0])
  1645. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1646. else
  1647. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1648. break;
  1649. }
  1650. case COMMAND_OOC:{
  1651. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1652. if(sep && sep->arg[0][0])
  1653. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1654. else
  1655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1656. break;
  1657. }
  1658. case COMMAND_EMOTE:{
  1659. if(sep && sep->arg[0][0])
  1660. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1661. else
  1662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1663. break;
  1664. }
  1665. case COMMAND_RACE:{
  1666. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1667. if(sep->arg[1][0] && sep->IsNumber(1)){
  1668. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1669. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1670. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1671. client->GetPlayer()->SetCharSheetChanged(true);
  1672. }
  1673. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1674. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1675. //client->QueuePacket(outapp);
  1676. }
  1677. else{
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1680. }
  1681. break;
  1682. }
  1683. case COMMAND_BANK_DEPOSIT:{
  1684. if(client->GetBanker() && sep && sep->arg[0]){
  1685. int64 amount = 0;
  1686. string deposit = string(sep->arg[0]);
  1687. amount = atoi64(deposit.c_str());
  1688. client->BankDeposit(amount);
  1689. }
  1690. break;
  1691. }
  1692. case COMMAND_BANK_WITHDRAWAL:{
  1693. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1694. int64 amount = 0;
  1695. string deposit = string(sep->arg[0]);
  1696. amount = atoi64(deposit.c_str());
  1697. client->BankWithdrawal(amount);
  1698. }
  1699. break;
  1700. }
  1701. case COMMAND_BANK_CANCEL:{
  1702. Spawn* banker = cmdTarget;
  1703. client->Bank(banker, true);
  1704. break;
  1705. }
  1706. case COMMAND_BANK:{
  1707. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1708. Spawn* banker = cmdTarget;
  1709. client->Bank(banker);
  1710. break;
  1711. }
  1712. case COMMAND_GUILD_BANK:{
  1713. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1714. //Spawn* banker = client->GetPlayer()->GetTarget();
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1716. break;
  1717. }
  1718. case COMMAND_START_MAIL: {
  1719. client->SetMailTransaction(cmdTarget);
  1720. client->SendMailList();
  1721. break;
  1722. }
  1723. case COMMAND_CANCEL_MAIL: {
  1724. client->SetMailTransaction(0);
  1725. break;
  1726. }
  1727. case COMMAND_GET_MAIL_MESSAGE: {
  1728. if (sep && sep->arg[0] && sep->IsNumber(0))
  1729. client->DisplayMailMessage(atoul(sep->arg[0]));
  1730. break;
  1731. }
  1732. case COMMAND_ADD_MAIL_PLAT: {
  1733. if (sep && sep->arg[0] && sep->IsNumber(0))
  1734. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1735. break;
  1736. }
  1737. case COMMAND_ADD_MAIL_GOLD: {
  1738. if (sep && sep->arg[0] && sep->IsNumber(0))
  1739. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1740. break;
  1741. }
  1742. case COMMAND_ADD_MAIL_SILVER: {
  1743. if (sep && sep->arg[0] && sep->IsNumber(0))
  1744. client->AddMailCoin(0, atoul(sep->arg[0]));
  1745. break;
  1746. }
  1747. case COMMAND_ADD_MAIL_COPPER: {
  1748. if (sep && sep->arg[0] && sep->IsNumber(0))
  1749. client->AddMailCoin(atoul(sep->arg[0]));
  1750. break;
  1751. }
  1752. case COMMAND_SET_MAIL_ITEM: {
  1753. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1754. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1755. break;
  1756. }
  1757. case COMMAND_REMOVE_MAIL_PLAT: {
  1758. if (sep && sep->arg[0] && sep->IsNumber(0))
  1759. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1760. break;
  1761. }
  1762. case COMMAND_REMOVE_MAIL_GOLD: {
  1763. if (sep && sep->arg[0] && sep->IsNumber(0))
  1764. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1765. break;
  1766. }
  1767. case COMMAND_REMOVE_MAIL_SILVER: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1770. break;
  1771. }
  1772. case COMMAND_REMOVE_MAIL_COPPER: {
  1773. if (sep && sep->arg[0] && sep->IsNumber(0))
  1774. client->RemoveMailCoin(atoul(sep->arg[0]));
  1775. break;
  1776. }
  1777. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1778. if (sep && sep->arg[0] && sep->IsNumber(0))
  1779. client->TakeMailAttachments(atoul(sep->arg[0]));
  1780. break;
  1781. }
  1782. case COMMAND_CANCEL_SEND_MAIL: {
  1783. client->CancelSendMail();
  1784. break;
  1785. }
  1786. case COMMAND_DELETE_MAIL_MESSAGE: {
  1787. if (sep && sep->arg[0] && sep->IsNumber(0))
  1788. client->DeleteMail(atoul(sep->arg[0]), true);
  1789. break;
  1790. }
  1791. case COMMAND_REPORT_SPAM: {
  1792. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1793. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1794. break;
  1795. }
  1796. case COMMAND_KILL:{
  1797. Spawn* dead = 0;
  1798. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1799. dead=client->GetPlayer();
  1800. client->GetPlayer()->SetHP(0);
  1801. client->GetPlayer()->KillSpawn(dead);
  1802. }else{
  1803. dead= cmdTarget;
  1804. if(dead && dead->IsPlayer() == false){
  1805. dead->SetHP(0);
  1806. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1807. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1808. else
  1809. client->GetPlayer()->KillSpawn(dead);
  1810. }else{
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1813. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1814. }
  1815. }
  1816. break;
  1817. }
  1818. case COMMAND_LEVEL:{
  1819. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1820. int16 new_level = atoi(sep->arg[ndx]);
  1821. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1822. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1823. else {
  1824. if (new_level < 1)
  1825. new_level = 1;
  1826. if (new_level > 255)
  1827. new_level = 255;
  1828. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1829. client->GetPlayer()->SetXP(1);
  1830. client->GetPlayer()->SetNeededXP();
  1831. }
  1832. }else
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1834. break;
  1835. }
  1836. case COMMAND_SIT: {
  1837. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1838. if(client->GetPlayer()->GetHP() > 0){
  1839. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1841. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1842. }
  1843. break;
  1844. }
  1845. case COMMAND_STAND: {
  1846. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1847. if(client->GetPlayer()->GetHP() > 0){
  1848. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1850. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1851. }
  1852. break;
  1853. }
  1854. case COMMAND_CLASS:{
  1855. if(sep && sep->arg[ndx][0]){
  1856. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1857. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1858. }else
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1860. break;
  1861. }
  1862. case COMMAND_GENDER:{
  1863. if(sep && sep->arg[ndx][0]){
  1864. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1865. client->GetPlayer()->SetCharSheetChanged(true);
  1866. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1867. }else{
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1871. }
  1872. break;
  1873. }
  1874. case COMMAND_FLYMODE:{
  1875. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1876. PrintSep(sep, "COMMAND_FLYMODE");
  1877. int8 val = atoi(sep->arg[0]);
  1878. ClientPacketFunctions::SendFlyMode(client, val);
  1879. }
  1880. else{
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1883. }
  1884. break;
  1885. }
  1886. case COMMAND_LOOT_LIST:{
  1887. Spawn* spawn = cmdTarget;
  1888. if(spawn && spawn->IsEntity()){
  1889. if (sep && sep->arg[0]) {
  1890. if (!spawn->GetDatabaseID())
  1891. {
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1893. break;
  1894. }
  1895. else if (!spawn->IsNPC())
  1896. {
  1897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1898. break;
  1899. }
  1900. bool reloadLoot = false;
  1901. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1905. {
  1906. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1907. reloadLoot = true;
  1908. }
  1909. else
  1910. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1911. }
  1912. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1913. {
  1914. int32 loottable_id = atoul(sep->arg[1]);
  1915. if (loottable_id > 0)
  1916. {
  1917. database.AddLootTableToSpawn(spawn, loottable_id);
  1918. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1919. reloadLoot = true;
  1920. }
  1921. else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1923. }
  1924. else if (!stricmp(sep->arg[0], "clearall"))
  1925. {
  1926. if (database.RemoveSpawnLootTable(spawn, 0))
  1927. {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1929. reloadLoot = true;
  1930. }
  1931. else
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1933. }
  1934. else
  1935. {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1940. break;
  1941. }
  1942. if (reloadLoot)
  1943. {
  1944. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1945. if (spawn->IsNPC())
  1946. {
  1947. Entity* ent = (Entity*)spawn;
  1948. ent->SetLootCoins(0);
  1949. ent->ClearLootList();
  1950. spawn->GetZone()->AddLoot((NPC*)spawn);
  1951. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1952. }
  1953. }
  1954. break; // nothing further this is the end of these sub commands
  1955. }
  1956. else
  1957. {
  1958. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1959. if (loot_list.size() > 0) {
  1960. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1961. vector<int32>::iterator list_itr;
  1962. LootTable* table = 0;
  1963. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1964. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1965. if (table)
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1967. }
  1968. }
  1969. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  1970. vector<Item*>* items = spawn->GetLootItems();
  1971. if (items) {
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1973. vector<Item*>::iterator itr;
  1974. Item* item = 0;
  1975. for (itr = items->begin(); itr != items->end(); itr++) {
  1976. item = *itr;
  1977. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1978. }
  1979. }
  1980. else
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1982. }
  1983. }
  1984. break;
  1985. }
  1986. case COMMAND_LOOT_SETCOIN:{
  1987. Spawn* spawn = cmdTarget;
  1988. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1989. spawn->SetLootCoins(atoul(sep->arg[0]));
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1991. }
  1992. else
  1993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1994. break;
  1995. }
  1996. case COMMAND_LOOT_ADDITEM:{
  1997. Spawn* spawn = cmdTarget;
  1998. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1999. int16 charges = 1;
  2000. if(sep->arg[1] && sep->IsNumber(1))
  2001. charges = atoi(sep->arg[1]);
  2002. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2004. }
  2005. else
  2006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2007. break;
  2008. }
  2009. case COMMAND_LOOT_REMOVEITEM:{
  2010. Spawn* spawn = cmdTarget;
  2011. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2012. spawn->LootItem(atoul(sep->arg[0]));
  2013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2014. }
  2015. else
  2016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2017. break;
  2018. }
  2019. case COMMAND_LOOT_CORPSE:
  2020. case COMMAND_DISARM:
  2021. case COMMAND_LOOT:{
  2022. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2023. {
  2024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2025. break;
  2026. }
  2027. if(cmdTarget && cmdTarget->IsEntity()){
  2028. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2029. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2030. client->OpenChest(cmdTarget, true);
  2031. else
  2032. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2033. if (!(cmdTarget)->HasLoot()){
  2034. if (((Entity*)cmdTarget)->IsNPC())
  2035. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2036. }
  2037. }
  2038. else
  2039. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2040. }
  2041. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2043. break;
  2044. }
  2045. case COMMAND_RELOADSPAWNSCRIPTS:{
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2047. if (lua_interface)
  2048. lua_interface->SetSpawnScriptsReloading(true);
  2049. world.ResetSpawnScripts();
  2050. database.LoadSpawnScriptData();
  2051. if(lua_interface) {
  2052. lua_interface->DestroySpawnScripts();
  2053. lua_interface->SetSpawnScriptsReloading(false);
  2054. }
  2055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2056. break;
  2057. }
  2058. case COMMAND_RELOADLUASYSTEM:{
  2059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2060. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2061. safe_delete(lua_interface);
  2062. lua_interface = new LuaInterface();
  2063. if(lua_interface)
  2064. lua_interface->SetSpawnScriptsReloading(true);
  2065. if(lua_interface && debug_clients.size() > 0){
  2066. map<Client*, int32>::iterator itr;
  2067. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2068. if(lua_interface)
  2069. lua_interface->UpdateDebugClients(itr->first);
  2070. }
  2071. }
  2072. world.ResetSpawnScripts();
  2073. database.LoadSpawnScriptData();
  2074. world.ResetZoneScripts();
  2075. database.LoadZoneScriptData();
  2076. int32 quest_count = database.LoadQuests();
  2077. zone_list.DeleteSpellProcess();
  2078. master_spell_list.Reload();
  2079. int32 spell_count = 0;
  2080. if(lua_interface) {
  2081. lua_interface->DestroySpawnScripts();
  2082. lua_interface->DestroySpells();
  2083. spell_count = database.LoadSpellScriptData();
  2084. lua_interface->SetSpawnScriptsReloading(false);
  2085. }
  2086. zone_list.LoadSpellProcess();
  2087. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2088. break;
  2089. }
  2090. case COMMAND_DECLINE_QUEST:{
  2091. int32 quest_id = 0;
  2092. if(sep && sep->arg[0] && sep->IsNumber(0))
  2093. quest_id = atoul(sep->arg[0]);
  2094. if(quest_id > 0){
  2095. Quest* quest = client->GetPendingQuest(quest_id);
  2096. if(quest){
  2097. client->RemovePendingQuest(quest);
  2098. if(lua_interface)
  2099. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2100. safe_delete(quest);
  2101. client->GetCurrentZone()->SendQuestUpdates(client);
  2102. }
  2103. }
  2104. break;
  2105. }
  2106. case COMMAND_DELETE_QUEST:{
  2107. int32 quest_id = 0;
  2108. if(sep && sep->arg[0] && sep->IsNumber(0))
  2109. quest_id = atoul(sep->arg[0]);
  2110. if(quest_id > 0){
  2111. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2112. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2113. if (quest)
  2114. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2115. }
  2116. client->RemovePlayerQuest(quest_id);
  2117. client->GetCurrentZone()->SendQuestUpdates(client);
  2118. }
  2119. break;
  2120. }
  2121. case COMMAND_ACCEPT_QUEST:{
  2122. int32 quest_id = 0;
  2123. if(sep && sep->arg[0] && sep->IsNumber(0))
  2124. quest_id = atoul(sep->arg[0]);
  2125. if(quest_id > 0){
  2126. client->AcceptQuest(quest_id);
  2127. }
  2128. break;
  2129. }
  2130. case COMMAND_NAME:{
  2131. if(sep && sep->arg[ndx][0]){
  2132. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2133. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2134. client->GetPlayer()->SetCharSheetChanged(true);
  2135. }else
  2136. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2137. break;
  2138. }
  2139. case COMMAND_GROUPSAY:{
  2140. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2141. if(sep && sep->arg[0] && gmi)
  2142. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2143. break;
  2144. }
  2145. case COMMAND_GROUPINVITE: {
  2146. Entity* target = 0;
  2147. Client* target_client = 0;
  2148. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2149. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2150. return;
  2151. }
  2152. // name provided with command so it has to be a player, npc not supported here
  2153. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2154. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2155. if (target_client) {
  2156. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2157. target = 0;
  2158. else
  2159. target = target_client->GetPlayer();
  2160. }
  2161. }
  2162. // if name was not provided use the players target, npc or player supported here
  2163. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2164. target = (Entity*)client->GetPlayer()->GetTarget();
  2165. if (target->IsPlayer()) {
  2166. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2167. }
  2168. }
  2169. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2170. if (result == 0) {
  2171. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2172. if (target_client) {
  2173. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2174. if (packet) {
  2175. packet->setDataByName("type", 1);
  2176. packet->setDataByName("name", client->GetPlayer()->GetName());
  2177. packet->setDataByName("unknown2", 1);
  2178. target_client->QueuePacket(packet->serialize());
  2179. safe_delete(packet);
  2180. }
  2181. }
  2182. }
  2183. else if (result == 1)
  2184. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2185. else if (result == 2)
  2186. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2187. else if (result == 3)
  2188. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2189. else if (result == 4)
  2190. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2191. else if (result == 5)
  2192. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2193. else if (result == 6)
  2194. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2195. else
  2196. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2197. break;
  2198. }
  2199. case COMMAND_GROUPDISBAND: {
  2200. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2201. if (gmi) { // TODO: Leader check
  2202. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2203. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2204. }
  2205. break;
  2206. }
  2207. case COMMAND_GROUP_LEAVE: {
  2208. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2209. if (gmi) {
  2210. int32 group_id = gmi->group_id;
  2211. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2212. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2213. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2214. }
  2215. else {
  2216. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2217. }
  2218. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2219. }
  2220. break;
  2221. }
  2222. case COMMAND_FRIEND_ADD:{
  2223. string name = "";
  2224. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2225. name = database.GetPlayerName(sep->arg[0]);
  2226. else if(cmdTarget && cmdTarget->IsPlayer())
  2227. name = string(cmdTarget->GetName());
  2228. if(name.length() > 0){
  2229. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2230. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2231. client->GetPlayer()->RemoveIgnore(name.c_str());
  2232. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2233. client->SendChatRelationship(3, name.c_str());
  2234. }
  2235. client->GetPlayer()->AddFriend(name.c_str(), true);
  2236. client->SendChatRelationship(0, name.c_str());
  2237. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2238. if(zone_list.GetClientByCharName(name))
  2239. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2240. }
  2241. else
  2242. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2243. }
  2244. else
  2245. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2246. break;
  2247. }
  2248. case COMMAND_FRIEND_REMOVE:{
  2249. string name = "";
  2250. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2251. name = database.GetPlayerName(sep->arg[0]);
  2252. else if(cmdTarget && cmdTarget->IsPlayer())
  2253. name = string(cmdTarget->GetName());
  2254. if(name.length() > 0){
  2255. client->GetPlayer()->RemoveFriend(name.c_str());
  2256. client->SendChatRelationship(1, name.c_str());
  2257. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2258. }
  2259. else
  2260. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2261. break;
  2262. }
  2263. case COMMAND_FRIENDS:{
  2264. break;
  2265. }
  2266. case COMMAND_IGNORE_ADD:{
  2267. string name = "";
  2268. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2269. name = database.GetPlayerName(sep->arg[0]);
  2270. else if(cmdTarget && cmdTarget->IsPlayer())
  2271. name = string(cmdTarget->GetName());
  2272. if(name.length() > 0){
  2273. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2274. if(client->GetPlayer()->IsFriend(name.c_str())){
  2275. client->GetPlayer()->RemoveFriend(name.c_str());
  2276. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2277. client->SendChatRelationship(1, name.c_str());
  2278. }
  2279. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2280. client->SendChatRelationship(2, name.c_str());
  2281. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2282. }
  2283. else
  2284. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2285. }
  2286. else
  2287. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2288. break;
  2289. }
  2290. case COMMAND_IGNORE_REMOVE:{
  2291. string name = "";
  2292. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2293. name = database.GetPlayerName(sep->arg[0]);
  2294. else if(cmdTarget && cmdTarget->IsPlayer())
  2295. name = string(cmdTarget->GetName());
  2296. if(name.length() > 0){
  2297. client->GetPlayer()->RemoveIgnore(name.c_str());
  2298. client->SendChatRelationship(3, name.c_str());
  2299. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2300. }
  2301. break;
  2302. }
  2303. case COMMAND_IGNORES:{
  2304. break;
  2305. }
  2306. case COMMAND_GROUP_KICK:{
  2307. Entity* kicked = 0;
  2308. Client* kicked_client = 0;
  2309. int32 group_id = 0;
  2310. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2311. return;
  2312. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2313. if (sep && sep->arg[0]) {
  2314. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2315. if (kicked_client)
  2316. kicked = kicked_client->GetPlayer();
  2317. }
  2318. else if (cmdTarget && cmdTarget->IsEntity()) {
  2319. kicked = (Entity*)cmdTarget;
  2320. }
  2321. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2322. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2323. if (kicked)
  2324. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2325. if(send_kicked_message)
  2326. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2327. else
  2328. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2329. if (kicked_client)
  2330. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2331. break;
  2332. }
  2333. case COMMAND_GROUP_MAKE_LEADER:{
  2334. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2335. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2336. return;
  2337. }
  2338. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2339. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2340. if (new_leader) {
  2341. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2342. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2343. }
  2344. }
  2345. else
  2346. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2347. }
  2348. else if (cmdTarget && cmdTarget->IsPlayer())
  2349. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2350. else
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2352. break;
  2353. }
  2354. case COMMAND_GROUP_ACCEPT_INVITE: {
  2355. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2356. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2357. if (result == 0)
  2358. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2359. else if (result == 1)
  2360. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2361. else if (result == 2)
  2362. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2363. else
  2364. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2365. }
  2366. break;
  2367. }
  2368. case COMMAND_GROUP_DECLINE_INVITE: {
  2369. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2370. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2371. }
  2372. break;
  2373. }
  2374. case COMMAND_SUMMON:{
  2375. char* search_name = 0;
  2376. if(sep && sep->arg[0][0])
  2377. search_name = sep->arg[0];
  2378. if(!search_name && !cmdTarget){
  2379. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2380. 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.");
  2381. }
  2382. else{
  2383. if(!client->Summon(search_name))
  2384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_GOTO:{
  2389. const char* search_name = 0;
  2390. if(sep && sep->arg[0][0])
  2391. search_name = sep->argplus[0];
  2392. if(!search_name && !cmdTarget){
  2393. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2394. 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.");
  2395. }
  2396. else{
  2397. if(!client->GotoSpawn(search_name))
  2398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2399. }
  2400. break;
  2401. }
  2402. case COMMAND_MOVE:{
  2403. bool success = false;
  2404. try{
  2405. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2406. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2407. if(app){
  2408. client->QueuePacket(app);
  2409. success = true;
  2410. }
  2411. }
  2412. }
  2413. catch(...){}
  2414. if(!success){
  2415. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2416. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2417. }
  2418. break;
  2419. }
  2420. case COMMAND_SETTIME:{
  2421. if(sep && sep->arg[0]){
  2422. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2423. if(sep->arg[1] && sep->IsNumber(1))
  2424. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2425. if(sep->arg[2] && sep->IsNumber(2))
  2426. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2427. if(sep->arg[3] && sep->IsNumber(3))
  2428. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2429. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2430. }
  2431. else{
  2432. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2433. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2434. }
  2435. break;
  2436. }
  2437. case COMMAND_VERSION:{
  2438. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2439. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2440. break;
  2441. }
  2442. case COMMAND_ZONE:{
  2443. string* zonename = 0;
  2444. int32 instanceID = 0;
  2445. const char* zone = 0;
  2446. int32 zone_id = 0;
  2447. bool listSearch = false;
  2448. bool isInstance = false;
  2449. ZoneServer* zsZone = 0;
  2450. if(sep && sep->arg[0][0])
  2451. {
  2452. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2453. listSearch = true;
  2454. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2455. {
  2456. zone_list.SendZoneList(client);
  2457. break;
  2458. }
  2459. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2460. {
  2461. if(sep->IsNumber(1))
  2462. instanceID = atol(sep->arg[1]);
  2463. }
  2464. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2465. {
  2466. PrintSep(sep, "ZONE LOCK");
  2467. if(sep->IsNumber(1))
  2468. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2469. else
  2470. zsZone = zone_list.Get(sep->arg[1], false);
  2471. if( zsZone )
  2472. {
  2473. zsZone->SetZoneLockState(true);
  2474. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2475. }
  2476. else
  2477. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2478. break;
  2479. }
  2480. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2481. {
  2482. PrintSep(sep, "ZONE UNLOCK");
  2483. if(sep->IsNumber(1))
  2484. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2485. else
  2486. zsZone = zone_list.Get(sep->arg[1], false);
  2487. if( zsZone )
  2488. {
  2489. zsZone->SetZoneLockState(false);
  2490. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2491. }
  2492. else
  2493. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2494. break;
  2495. }
  2496. else
  2497. {
  2498. if(sep->IsNumber(0))
  2499. {
  2500. zone_id = atoul(sep->arg[0]);
  2501. zonename = database.GetZoneName(zone_id);
  2502. if(zonename)
  2503. zone = zonename->c_str();
  2504. }
  2505. else
  2506. zone = sep->arg[0];
  2507. }
  2508. if(instanceID > 0)
  2509. {
  2510. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2511. if(zsInstance != NULL)
  2512. {
  2513. instanceID = zsInstance->GetInstanceID();
  2514. zone = zsInstance->GetZoneName();
  2515. zone_id = zsInstance->GetZoneID();
  2516. isInstance = true;
  2517. }
  2518. }
  2519. }
  2520. if(!listSearch)
  2521. {
  2522. if(!zone)
  2523. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2524. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2525. zone_id != client->GetCurrentZone()->GetZoneID())
  2526. {
  2527. if(database.VerifyZone(zone))
  2528. {
  2529. if(client->CheckZoneAccess(zone))
  2530. {
  2531. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2532. if(isInstance)
  2533. client->Zone(instanceID,true,true);
  2534. else
  2535. client->Zone(zone);
  2536. }
  2537. }
  2538. else
  2539. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2540. }
  2541. else
  2542. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2543. }
  2544. else
  2545. {
  2546. const char* name = 0;
  2547. if(sep && sep->arg[1][0])
  2548. {
  2549. map<int32, string>* zone_names;
  2550. name = sep->argplus[1];
  2551. sint16 status = client->GetAdminStatus();
  2552. if( status > 0 )
  2553. {
  2554. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2555. zone_names = database.GetZoneList(name, true);
  2556. }
  2557. else
  2558. zone_names = database.GetZoneList(name);
  2559. if(!zone_names)
  2560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2561. else
  2562. {
  2563. map<int32, string>::iterator itr;
  2564. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2565. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2566. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2567. safe_delete(zone_names);
  2568. }
  2569. }
  2570. else
  2571. {
  2572. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2573. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2574. }
  2575. }
  2576. safe_delete(zonename);
  2577. break;
  2578. }
  2579. case COMMAND_USE: {
  2580. Spawn* target = cmdTarget;
  2581. if (target->IsWidget())
  2582. ((Widget*)target)->HandleUse(client, "use");
  2583. break;
  2584. }
  2585. case COMMAND_OPEN: {
  2586. Spawn* target = cmdTarget;
  2587. if (target->IsWidget())
  2588. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2589. break;
  2590. }
  2591. case COMMAND_CASTSPELL: {
  2592. if (sep && sep->arg[0] && sep->IsNumber(0))
  2593. {
  2594. int8 tier = 1;
  2595. if (sep->arg[1] && sep->IsNumber(1))
  2596. tier = atoul(sep->arg[1]);
  2597. int32 spellid = atoul(sep->arg[0]);
  2598. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2599. if (spell)
  2600. {
  2601. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2602. SpellProcess* spellProcess = 0;
  2603. // Get the current zones spell process
  2604. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2605. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2606. }
  2607. else
  2608. {
  2609. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2610. }
  2611. }
  2612. else if (sep && sep->arg[0])
  2613. {
  2614. database.FindSpell(client, (char*)sep->argplus[0]);
  2615. }
  2616. else
  2617. {
  2618. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2619. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2620. }
  2621. break;
  2622. }
  2623. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2624. if (client->GetVersion() <= 546)
  2625. break;
  2626. if (sep && sep->GetArgNumber() == 4)
  2627. {
  2628. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2629. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2630. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2631. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2632. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2633. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2634. ClientPacketFunctions::SendSkillSlotMappings(client);
  2635. }
  2636. else
  2637. {
  2638. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2639. }
  2640. break;
  2641. }
  2642. case COMMAND_MOVE_ITEM:
  2643. {
  2644. int32 id = 0;
  2645. if (sep->IsNumber(0))
  2646. id = atoul(sep->arg[0]);
  2647. Spawn* spawn = 0;
  2648. if (id == 0)
  2649. {
  2650. spawn = cmdTarget;
  2651. }
  2652. else
  2653. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2654. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2655. break;
  2656. client->SendMoveObjectMode(spawn, 0);
  2657. break;
  2658. }
  2659. case COMMAND_PICKUP:
  2660. {
  2661. int32 id = 0;
  2662. if (sep->IsNumber(0))
  2663. id = atoul(sep->arg[0]);
  2664. Spawn* spawn = 0;
  2665. if (id == 0)
  2666. {
  2667. spawn = cmdTarget;
  2668. }
  2669. else
  2670. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2671. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2672. break;
  2673. client->AddItem(spawn->GetPickupItemID(), 1);
  2674. Query query;
  2675. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  2676. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2677. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2678. }
  2679. // we had a UI Window displayed, update the house items
  2680. if ( id > 0 )
  2681. client->GetCurrentZone()->SendHouseItems(client);
  2682. break;
  2683. }
  2684. case COMMAND_HOUSE_DEPOSIT:
  2685. {
  2686. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2687. // arg0 = ??? (set to 3)
  2688. // arg1 = coin (in copper)
  2689. // arg2 = status? (not implemented yet)
  2690. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2691. if (ph && sep && sep->IsNumber(1))
  2692. {
  2693. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2694. if (client->GetPlayer()->RemoveCoins(outVal))
  2695. {
  2696. char query[256];
  2697. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2698. if (itr != ph->depositsMap.end())
  2699. {
  2700. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2701. }
  2702. else
  2703. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2704. if (database.RunQuery(query, strnlen(query, 256)))
  2705. {
  2706. ph->escrow_coins += outVal;
  2707. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2708. database.LoadDeposits(ph);
  2709. client->PlaySound("coin_cha_ching");
  2710. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2711. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2712. }
  2713. else
  2714. {
  2715. client->GetPlayer()->AddCoins(outVal);
  2716. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2717. }
  2718. }
  2719. }
  2720. break;
  2721. }
  2722. case COMMAND_HOUSE:
  2723. {
  2724. if (sep && sep->IsNumber(0))
  2725. {
  2726. int32 unique_id = atoi(sep->arg[0]);
  2727. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2728. HouseZone* hz = 0;
  2729. if (ph)
  2730. hz = world.GetHouseZone(ph->house_id);
  2731. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2732. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2733. }
  2734. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2735. {
  2736. // inside a house or something? Send the access window
  2737. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2738. HouseZone* hz = 0;
  2739. if ( ph )
  2740. hz = world.GetHouseZone(ph->house_id);
  2741. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2742. client->GetCurrentZone()->SendHouseItems(client);
  2743. }
  2744. break;
  2745. }
  2746. case COMMAND_HOUSE_UI:
  2747. {
  2748. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2749. {
  2750. int32 unique_id = atoi(sep->arg[0]);
  2751. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2752. HouseZone* hz = 0;
  2753. if ( ph )
  2754. hz = world.GetHouseZone(ph->house_id);
  2755. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2756. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2757. }
  2758. break;
  2759. }
  2760. case COMMAND_PLACE_HOUSE_ITEM: {
  2761. if (sep && sep->IsNumber(0))
  2762. {
  2763. int32 uniqueid = atoi(sep->arg[0]);
  2764. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2765. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2766. if (item && item->IsHouseItem())
  2767. {
  2768. if (!client->HasOwnerOrEditAccess())
  2769. {
  2770. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2771. break;
  2772. }
  2773. else if (!item->generic_info.appearance_id)
  2774. {
  2775. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  2776. break;
  2777. }
  2778. if (client->GetTempPlacementSpawn())
  2779. {
  2780. Spawn* tmp = client->GetTempPlacementSpawn();
  2781. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2782. delete tmp;
  2783. client->SetTempPlacementSpawn(nullptr);
  2784. }
  2785. Spawn* spawn = new Object();
  2786. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2787. spawn->SetID(Spawn::NextID());
  2788. spawn->SetX(client->GetPlayer()->GetX());
  2789. spawn->SetY(client->GetPlayer()->GetY());
  2790. spawn->SetZ(client->GetPlayer()->GetZ());
  2791. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2792. spawn->SetSpawnOrigX(spawn->GetX());
  2793. spawn->SetSpawnOrigY(spawn->GetY());
  2794. spawn->SetSpawnOrigZ(spawn->GetZ());
  2795. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2796. spawn->appearance.targetable = 1;
  2797. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2798. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2799. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2800. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2801. spawn->SetZone(client->GetCurrentZone());
  2802. client->GetCurrentZone()->SendSpawn(spawn, client);
  2803. client->SetTempPlacementSpawn(spawn);
  2804. client->SetPlacementUniqueItemID(uniqueid);
  2805. client->SendMoveObjectMode(spawn, 0);
  2806. }
  2807. }
  2808. break;
  2809. }
  2810. case COMMAND_GM:
  2811. {
  2812. if (sep->arg[0] && sep->arg[1])
  2813. {
  2814. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2815. if (strcmp(sep->arg[0], "vision") == 0)
  2816. {
  2817. client->GetPlayer()->SetGMVision(onOff);
  2818. #if defined(__GNUC__)
  2819. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2820. #else
  2821. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2822. #endif
  2823. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2824. if (onOff)
  2825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2826. else
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2828. }
  2829. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2830. {
  2831. client->SetLuaDebugClient(onOff);
  2832. #if defined(__GNUC__)
  2833. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2834. #else
  2835. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2836. #endif
  2837. if (onOff)
  2838. {
  2839. if (lua_interface)
  2840. lua_interface->UpdateDebugClients(client);
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2842. }
  2843. else
  2844. {
  2845. if (lua_interface)
  2846. lua_interface->RemoveDebugClients(client);
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2848. }
  2849. }
  2850. }
  2851. break;
  2852. }
  2853. case COMMAND_ATTACK:
  2854. case COMMAND_AUTO_ATTACK:{
  2855. int8 type = 1;
  2856. Player* player = client->GetPlayer();
  2857. if(!player)
  2858. break;
  2859. bool incombat = player->EngagedInCombat();
  2860. if(sep && sep->arg[0] && sep->IsNumber(0))
  2861. type = atoi(sep->arg[0]);
  2862. if(client->GetPlayer()->GetHP() == 0){
  2863. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2864. break;
  2865. }
  2866. if(type == 0){
  2867. if(incombat)
  2868. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2869. player->InCombat(false);
  2870. player->InCombat(false, true);
  2871. player->SetRangeAttack(false);
  2872. }
  2873. else {
  2874. if(type == 2){
  2875. player->InCombat(false);
  2876. if(incombat && player->GetRangeAttack()){
  2877. player->SetRangeAttack(false);
  2878. player->InCombat(false, true);
  2879. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2880. }
  2881. else{
  2882. player->SetRangeAttack(true);
  2883. player->InCombat(true, true);
  2884. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2885. }
  2886. }
  2887. else {
  2888. player->InCombat(false, true);
  2889. player->SetRangeAttack(false);
  2890. player->InCombat(true);
  2891. if(!incombat)
  2892. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2893. }
  2894. /*else
  2895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2896. }
  2897. player->SetCharSheetChanged(true);
  2898. break;
  2899. }
  2900. case COMMAND_DEPOP:{
  2901. bool allow_respawns = false;
  2902. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2903. if(atoi(sep->arg[0]) == 1)
  2904. allow_respawns = true;
  2905. }
  2906. client->GetCurrentZone()->Depop(allow_respawns);
  2907. break;
  2908. }
  2909. case COMMAND_REPOP:{
  2910. client->GetCurrentZone()->Depop(false, true);
  2911. break;
  2912. }
  2913. case COMMAND_BUYBACK:{
  2914. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2915. // 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
  2916. int64 id = atoi64(sep->arg[0]);
  2917. // get the first int32, the item id
  2918. //int32 item_id = (int32)id;
  2919. // get the second int32, the unique id
  2920. int32 unique_id = (int32)(id>>32);
  2921. int8 quantity = atoi(sep->arg[1]);
  2922. if(quantity == 255)
  2923. quantity = 1;
  2924. client->BuyBack(unique_id, quantity);
  2925. }
  2926. break;
  2927. }
  2928. case COMMAND_MERCHANT_BUY:{
  2929. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2930. int32 item_id = atoul(sep->arg[0]);
  2931. int8 quantity = atoi(sep->arg[1]);
  2932. client->BuyItem(item_id, quantity);
  2933. }
  2934. break;
  2935. }
  2936. case COMMAND_MERCHANT_SELL:{
  2937. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2938. // 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
  2939. int64 id = atoi64(sep->arg[0]);
  2940. // get the first int32, the item id
  2941. int32 item_id = (int32)id;
  2942. // get the second int32, the unique id
  2943. int32 unique_id = (int32)(id>>32);
  2944. int8 quantity = atoi(sep->arg[1]);
  2945. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2946. client->SellItem(item_id, quantity, unique_id);
  2947. }
  2948. break;
  2949. }
  2950. case COMMAND_MENDER_REPAIR: {
  2951. if (sep && sep->arg[0] && sep->IsNumber(0))
  2952. client->RepairItem(atoul(sep->arg[0]));
  2953. break;
  2954. }
  2955. case COMMAND_MENDER_REPAIR_ALL: {
  2956. client->RepairAllItems();
  2957. break;
  2958. }
  2959. case COMMAND_CANCEL_MERCHANT:{
  2960. client->SetMerchantTransaction(0);
  2961. break;
  2962. }
  2963. case COMMAND_START_MERCHANT:{
  2964. break;
  2965. }
  2966. case COMMAND_INVULNERABLE:{
  2967. sint8 val = -1;
  2968. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2969. val = atoi(sep->arg[0]);
  2970. //devn00b: Fix for linux builds
  2971. #if defined(__GNUC__)
  2972. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2973. #else
  2974. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2975. #endif
  2976. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2977. client->GetPlayer()->SetInvulnerable(val==1);
  2978. if(client->GetPlayer()->GetInvulnerable())
  2979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2980. else
  2981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2982. }
  2983. if(val == -1)
  2984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2985. break;
  2986. }
  2987. case COMMAND_REPAIR: {
  2988. Spawn* spawn = cmdTarget;
  2989. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2990. client->SendHailCommand(spawn);
  2991. client->SetMerchantTransaction(spawn);
  2992. client->SendRepairList();
  2993. }
  2994. break;
  2995. }
  2996. case COMMAND_LOTTO: {
  2997. Spawn* spawn = cmdTarget;
  2998. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2999. client->SetMerchantTransaction(spawn);
  3000. client->ShowLottoWindow();
  3001. }
  3002. break;
  3003. }
  3004. case COMMAND_ACCEPT_REWARD:{
  3005. int32 unknown = 0;
  3006. int32 selectable_item_id = 0;
  3007. //Quest *quest = 0;
  3008. Collection *collection = 0;
  3009. /* no idea what the first argument is for (faction maybe?)
  3010. if the reward has a selectable item reward, it's sent as the second argument
  3011. if neither of these are included in the reward, there is no sep
  3012. 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
  3013. only 1 quest or collection reward may be displayed at a time */
  3014. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3015. unknown = atoul(sep->arg[0]);
  3016. selectable_item_id = atoul(sep->arg[1]);
  3017. }
  3018. //if ((quest = player->GetPendingQuestReward()))
  3019. // client->AcceptQuestRewards(quest, selectable_item_id);
  3020. /* the below needs to go away eventually and be redone */
  3021. int32 item_id = 0;
  3022. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3023. item_id = atoul(sep->arg[0]);
  3024. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3025. if(quest){
  3026. client->AcceptQuestReward(quest, item_id);
  3027. break;
  3028. }
  3029. if (collection = player->GetPendingCollectionReward())
  3030. client->AcceptCollectionRewards(collection, selectable_item_id);
  3031. else
  3032. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3033. break;
  3034. }
  3035. case COMMAND_BUY_FROM_BROKER:{
  3036. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3037. int32 item_id = atoul(sep->arg[0]);
  3038. int16 quantity = atoul(sep->arg[1]);
  3039. client->AddItem(item_id, quantity);
  3040. }
  3041. break;
  3042. }
  3043. case COMMAND_SEARCH_STORES_PAGE:{
  3044. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3045. int32 page = atoul(sep->arg[0]);
  3046. client->SearchStore(page);
  3047. }
  3048. break;
  3049. }
  3050. case COMMAND_SEARCH_STORES:{
  3051. if(sep && sep->arg[0][0]){
  3052. const char* values = sep->argplus[0];
  3053. if(values){
  3054. map<string, string> str_values = TranslateBrokerRequest(values);
  3055. vector<Item*>* items = master_item_list.GetItems(str_values);
  3056. if(items){
  3057. client->SetItemSearch(items);
  3058. client->SearchStore(0);
  3059. }
  3060. }
  3061. }
  3062. break;
  3063. }
  3064. case COMMAND_LUADEBUG:{
  3065. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3066. client->SetLuaDebugClient(true);
  3067. if(lua_interface)
  3068. lua_interface->UpdateDebugClients(client);
  3069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3070. }
  3071. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3072. client->SetLuaDebugClient(false);
  3073. if(lua_interface)
  3074. lua_interface->RemoveDebugClients(client);
  3075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3076. }
  3077. else{
  3078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3080. }
  3081. break;
  3082. }
  3083. case COMMAND_SPAWN_GROUP:
  3084. {
  3085. Spawn* target = cmdTarget;
  3086. if(target && target->IsPlayer() == false)
  3087. {
  3088. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3089. {
  3090. if(target->GetSpawnLocationPlacementID() > 0)
  3091. {
  3092. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3093. {
  3094. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3095. if(id > 0)
  3096. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3097. else
  3098. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3099. target->SetSpawnGroupID(id);
  3100. target->AddSpawnToGroup(target);
  3101. }
  3102. else
  3103. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3104. }
  3105. else
  3106. 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.");
  3107. }
  3108. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3109. {
  3110. if(sep->arg[1] && sep->IsNumber(1))
  3111. {
  3112. int32 group_id = atoul(sep->arg[1]);
  3113. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3114. if(leader)
  3115. {
  3116. leader->AddSpawnToGroup(target);
  3117. target->SetSpawnGroupID(group_id);
  3118. if(database.SpawnGroupAddSpawn(target, group_id))
  3119. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3120. else
  3121. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3122. }
  3123. else
  3124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3125. }
  3126. else
  3127. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3128. }
  3129. else if(target->GetSpawnGroupID() == 0)
  3130. {
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3132. }
  3133. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3134. {
  3135. int32 group_id = target->GetSpawnGroupID();
  3136. target->RemoveSpawnFromGroup();
  3137. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3138. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3139. else
  3140. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3141. }
  3142. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3143. {
  3144. int32 group_id = target->GetSpawnGroupID();
  3145. if(sep->arg[1] && sep->IsNumber(1))
  3146. {
  3147. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3148. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3149. else
  3150. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3151. }
  3152. else
  3153. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3154. }
  3155. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3156. {
  3157. int32 group_id = target->GetSpawnGroupID();
  3158. if(sep->arg[1] && sep->IsNumber(1))
  3159. {
  3160. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3161. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3162. else
  3163. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3164. }
  3165. else
  3166. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3167. }
  3168. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3169. {
  3170. if(sep->arg[1] && sep->IsNumber(1))
  3171. {
  3172. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3173. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3174. else
  3175. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3176. }
  3177. else
  3178. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3179. }
  3180. else
  3181. {
  3182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3183. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3184. }
  3185. }
  3186. else
  3187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3188. break;
  3189. }
  3190. case COMMAND_SPAWN_COMBINE:{
  3191. Spawn* spawn = cmdTarget;
  3192. float radius = 0;
  3193. bool failed = true;
  3194. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3195. failed = false;
  3196. if(spawn->GetSpawnGroupID() > 0){
  3197. 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.");
  3198. }
  3199. else if(sep->IsNumber(0)){
  3200. radius = atof(sep->arg[0]);
  3201. client->CombineSpawns(radius, spawn);
  3202. }
  3203. else{
  3204. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3205. client->AddCombineSpawn(spawn);
  3206. }
  3207. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3208. client->RemoveCombineSpawn(spawn);
  3209. }
  3210. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3211. const char* name = 0;
  3212. if(sep->arg[1] && sep->arg[1][0])
  3213. name = sep->argplus[1];
  3214. client->SaveCombineSpawns(name);
  3215. }
  3216. else
  3217. failed = true;
  3218. }
  3219. }
  3220. if(failed){
  3221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3222. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3224. }
  3225. break;
  3226. }
  3227. case COMMAND_SPAWN_CREATE:{
  3228. Spawn* spawn = 0;
  3229. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3230. spawn = new Object();
  3231. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3232. }
  3233. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3234. spawn = new GroundSpawn();
  3235. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3236. }
  3237. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3238. spawn = new Sign();
  3239. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3240. }
  3241. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3242. spawn = new NPC();
  3243. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3244. spawn->appearance.pos.collision_radius = 32;
  3245. spawn->secondary_command_list_id = 0;
  3246. spawn->primary_command_list_id = 0;
  3247. spawn->appearance.display_name = 1;
  3248. spawn->appearance.show_level = 1;
  3249. spawn->appearance.attackable = 1;
  3250. }
  3251. else{
  3252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3255. break;
  3256. }
  3257. spawn->SetID(Spawn::NextID());
  3258. spawn->SetX(client->GetPlayer()->GetX());
  3259. spawn->SetY(client->GetPlayer()->GetY());
  3260. spawn->SetZ(client->GetPlayer()->GetZ());
  3261. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3262. spawn->SetSpawnOrigX(spawn->GetX());
  3263. spawn->SetSpawnOrigY(spawn->GetY());
  3264. spawn->SetSpawnOrigZ(spawn->GetZ());
  3265. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3266. spawn->appearance.targetable = 1;
  3267. spawn->appearance.race = 255;
  3268. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3269. spawn->SetModelType(atoi(sep->arg[1]));
  3270. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3271. spawn->SetLevel(atoi(sep->arg[3]));
  3272. spawn->SetName(sep->arg[4]);
  3273. if(sep->arg[5][0] && sep->IsNumber(5))
  3274. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3275. if(sep->arg[6][0] && sep->IsNumber(6))
  3276. spawn->size = atoi(sep->arg[6]);
  3277. if(spawn->GetTotalHP() == 0){
  3278. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3279. spawn->SetHP(25*spawn->GetLevel() + 1);
  3280. }
  3281. if(spawn->GetTotalPower() == 0){
  3282. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3283. spawn->SetPower(25*spawn->GetLevel() + 1);
  3284. }
  3285. client->GetCurrentZone()->AddSpawn(spawn);
  3286. break;
  3287. }
  3288. case COMMAND_SPAWN_EQUIPMENT:{
  3289. Spawn* spawn = cmdTarget;
  3290. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3291. int8 slot = atoi(sep->arg[0]);
  3292. int16 type = atoi(sep->arg[1]);
  3293. int8 red = 0;
  3294. int8 green = 0;
  3295. int8 blue = 0;
  3296. int8 h_red = 0;
  3297. int8 h_green = 0;
  3298. int8 h_blue = 0;
  3299. if(sep->arg[2])
  3300. red = atoi(sep->arg[2]);
  3301. if(sep->arg[3])
  3302. green = atoi(sep->arg[3]);
  3303. if(sep->arg[4])
  3304. blue = atoi(sep->arg[4]);
  3305. if(sep->arg[5])
  3306. h_red = atoi(sep->arg[5]);
  3307. if(sep->arg[6])
  3308. h_green = atoi(sep->arg[6]);
  3309. if(sep->arg[7])
  3310. h_blue = atoi(sep->arg[7]);
  3311. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3312. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3313. }
  3314. else{
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3318. }
  3319. break;
  3320. }
  3321. case COMMAND_SPAWN_DETAILS:{
  3322. Spawn* spawn = cmdTarget;
  3323. if (sep && sep->arg[0][0]) {
  3324. if (cmdTarget)
  3325. {
  3326. if (ToLower(string(sep->arg[0])) == "los")
  3327. {
  3328. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3329. if (hasLOS)
  3330. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3331. else
  3332. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3333. break;
  3334. }
  3335. else if (ToLower(string(sep->arg[0])) == "bestz")
  3336. {
  3337. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3338. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3339. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3340. break;
  3341. }
  3342. else if (ToLower(string(sep->arg[0])) == "pathto")
  3343. {
  3344. break;
  3345. }
  3346. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3347. {
  3348. break;
  3349. }
  3350. }
  3351. if (sep->IsNumber(0))
  3352. {
  3353. float radius = atof(sep->arg[0]);
  3354. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3356. break;
  3357. }
  3358. }
  3359. if(spawn){
  3360. const char* type = "NPC";
  3361. if(spawn->IsObject())
  3362. type = "Object";
  3363. else if(spawn->IsSign())
  3364. type = "Sign";
  3365. else if(spawn->IsWidget())
  3366. type = "Widget";
  3367. else if(spawn->IsGroundSpawn())
  3368. type = "GroundSpawn";
  3369. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3370. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3371. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3372. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3373. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3376. 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());
  3377. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3378. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3379. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3380. if(spawn->IsEntity()){
  3381. 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());
  3382. 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());
  3383. }
  3384. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3385. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3386. 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());
  3387. 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);
  3388. if (spawn->IsNPC())
  3389. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3390. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3391. if (packet) {
  3392. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3393. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3394. packet->setDataByName("book_title", title.c_str());
  3395. packet->setDataByName("book_type", "simple");
  3396. packet->setDataByName("unknown2", 1);
  3397. packet->setDataByName("unknown5", 1, 4);
  3398. packet->setArrayLengthByName("num_pages", 4);
  3399. string details;
  3400. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3401. details += "Type: " + string(type) + "\n";
  3402. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3403. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3404. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3405. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3406. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3407. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3408. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3409. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3410. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3411. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3412. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3413. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3414. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3415. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3416. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3417. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3418. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3419. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3420. char x[16];
  3421. sprintf(x, "%.2f", spawn->GetX());
  3422. char y[16];
  3423. sprintf(y, "%.2f", spawn->GetY());
  3424. char z[16];
  3425. sprintf(z, "%.2f", spawn->GetZ());
  3426. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3427. string details2;
  3428. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3429. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3430. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3431. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3432. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3433. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3434. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3435. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3436. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3437. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3438. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3439. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3440. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3441. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3442. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3443. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3444. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3445. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3446. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3447. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3448. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3449. string details3;
  3450. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3451. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3452. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3453. string details4;
  3454. if (spawn->IsEntity()) {
  3455. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3456. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3457. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3458. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3459. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3460. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3461. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3462. if (spawn->IsNPC()) {
  3463. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3464. }
  3465. }
  3466. //details2 += "" + to_string() + "\n";
  3467. packet->setArrayDataByName("page_text", details.c_str());
  3468. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3469. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3470. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3471. client->QueuePacket(packet->serialize());
  3472. safe_delete(packet);
  3473. }
  3474. }
  3475. else {
  3476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3477. 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.");
  3478. }
  3479. break;
  3480. }
  3481. case COMMAND_SPAWN_TARGET:{
  3482. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3483. int32 spawn_id = atoul(sep->arg[0]);
  3484. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3485. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3486. }
  3487. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3488. float distance = atof(sep->arg[1]);
  3489. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3490. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3491. }
  3492. else{
  3493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3495. }
  3496. break;
  3497. }
  3498. case COMMAND_SPAWN_SET:
  3499. {
  3500. Spawn* spawn = cmdTarget;
  3501. sint16 set_type = -1;
  3502. string type_str;
  3503. if (spawn)
  3504. {
  3505. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3506. 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)
  3507. {
  3508. // set the type, which will be 0 if location or list or invalid
  3509. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3510. }
  3511. if(set_type > 0)
  3512. {
  3513. // check if spawn set is NOT a char update, or not location, or isn't a number
  3514. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3515. {
  3516. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3517. }
  3518. else
  3519. {
  3520. string name = string(spawn->GetName());
  3521. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3522. {
  3523. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3524. {
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3526. }
  3527. else if(set_type == SPAWN_SET_VALUE_NAME)
  3528. {
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3530. }
  3531. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3532. {
  3533. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3534. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3535. }
  3536. else
  3537. {
  3538. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3539. }
  3540. switch (set_type)
  3541. {
  3542. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3543. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3544. case SPAWN_SET_VALUE_FACTION:
  3545. {
  3546. // not applicable
  3547. break;
  3548. }
  3549. default:
  3550. {
  3551. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3552. break;
  3553. }
  3554. }
  3555. 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))
  3556. {
  3557. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3558. {
  3559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3560. }
  3561. else if(spawn->GetSpawnLocationID() > 0)
  3562. {
  3563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3564. }
  3565. }
  3566. else
  3567. {
  3568. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3569. {
  3570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3571. }
  3572. else if(spawn->GetDatabaseID() > 0)
  3573. {
  3574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3575. }
  3576. }
  3577. }
  3578. }
  3579. }
  3580. else if(set_type == 0)
  3581. {
  3582. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3583. map<string, int8>::iterator itr;
  3584. int i=0;
  3585. string list;
  3586. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3587. {
  3588. if(i==10)
  3589. {
  3590. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3591. i = 0;
  3592. }
  3593. if(i>0)
  3594. {
  3595. list.append(", ").append(itr->first);
  3596. }
  3597. else
  3598. {
  3599. list = itr->first;
  3600. }
  3601. }
  3602. if(list.length() > 0)
  3603. {
  3604. // if 1 or more, display in client.
  3605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3606. }
  3607. }
  3608. else
  3609. {
  3610. // syntax fail
  3611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3615. }
  3616. }
  3617. break;
  3618. }
  3619. case COMMAND_SPAWN_REMOVE:{
  3620. Spawn* spawn = cmdTarget;
  3621. if(spawn && !spawn->IsPlayer()){
  3622. if(spawn->GetSpawnLocationID() > 0){
  3623. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3624. bool delete_spawn = false;
  3625. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3626. if(atoi(sep->arg[0]) == 1)
  3627. delete_spawn = true;
  3628. }
  3629. if(delete_spawn)
  3630. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3631. else
  3632. spawn->SetSpawnLocationID(0);
  3633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3634. }
  3635. else
  3636. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3637. }
  3638. else
  3639. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3640. }
  3641. else{
  3642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3644. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3645. }
  3646. break;
  3647. }
  3648. case COMMAND_SPAWN_LIST:{
  3649. if(sep && sep->arg[0][0]){
  3650. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3651. vector<string>::iterator itr;
  3652. if(results){
  3653. for(itr=results->begin();itr!=results->end();itr++){
  3654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3655. }
  3656. safe_delete(results);
  3657. }
  3658. else
  3659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3660. }
  3661. else{
  3662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3665. }
  3666. break;
  3667. }
  3668. case COMMAND_SPAWN_ADD:{
  3669. Spawn* spawn = cmdTarget;
  3670. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3671. if(spawn->GetSpawnLocationID() > 0){
  3672. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3673. break;
  3674. }
  3675. if(spawn->GetDatabaseID() == 0){
  3676. if(database.SaveSpawnInfo(spawn)) {
  3677. char spawn_type[32];
  3678. memset(spawn_type, 0, sizeof(spawn_type));
  3679. if (spawn->IsNPC())
  3680. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3681. else if (spawn->IsObject())
  3682. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3683. else if (spawn->IsSign())
  3684. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3685. else if (spawn->IsGroundSpawn())
  3686. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3687. else
  3688. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3689. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3690. }
  3691. else
  3692. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3693. }
  3694. int32 spawn_group_id = 0;
  3695. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3696. spawn_group_id = database.GetNextSpawnLocation();
  3697. else
  3698. spawn_group_id = atol(sep->arg[0]);
  3699. int8 percent = 100;
  3700. if(sep->arg[2] && sep->IsNumber(2))
  3701. percent = atoi(sep->arg[2]);
  3702. spawn->SetSpawnLocationID(spawn_group_id);
  3703. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3704. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3705. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3706. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3707. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3708. else
  3709. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3710. }
  3711. else{
  3712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_SPAWN:{
  3719. int32 id = 0;
  3720. Spawn* spawn = 0;
  3721. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3722. id = atol(sep->arg[0]);
  3723. spawn = client->GetCurrentZone()->GetSpawn(id);
  3724. }
  3725. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3726. id = 0;
  3727. if(!id || !spawn){
  3728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3731. safe_delete(sep);
  3732. return;
  3733. }
  3734. if(sep && sep->arg[1][0]){
  3735. float x = atof(sep->arg[1]);
  3736. spawn->appearance.pos.X = x;
  3737. }
  3738. else
  3739. spawn->SetX(client->GetPlayer()->GetX(), false);
  3740. if(sep && sep->arg[2][0]){
  3741. float y = atof(sep->arg[2]);
  3742. spawn->appearance.pos.Y = y;
  3743. }
  3744. else
  3745. spawn->SetY(client->GetPlayer()->GetY(), false);
  3746. if(sep && sep->arg[3][0]){
  3747. float z = atof(sep->arg[3]);
  3748. spawn->appearance.pos.Z = z;
  3749. }
  3750. else
  3751. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3752. if(sep && sep->arg[4][0]){
  3753. float heading = atof(sep->arg[4]);
  3754. spawn->SetHeading(heading);
  3755. }
  3756. else
  3757. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3758. spawn->SetSpawnOrigX(spawn->GetX());
  3759. spawn->SetSpawnOrigY(spawn->GetY());
  3760. spawn->SetSpawnOrigZ(spawn->GetZ());
  3761. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3762. if(sep && sep->arg[5][0])
  3763. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3764. else
  3765. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3766. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3767. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3768. spawn->SetHP(spawn->GetTotalHP());
  3769. }
  3770. if(spawn->GetTotalPower() == 0){
  3771. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3772. spawn->SetPower(spawn->GetTotalPower());
  3773. }
  3774. const char* script = world.GetSpawnScript(id);
  3775. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3776. spawn->SetSpawnScript(string(script));
  3777. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3778. client->GetCurrentZone()->AddSpawn(spawn);
  3779. if(spawn->IsNPC())
  3780. spawn->GetZone()->AddLoot((NPC*)spawn);
  3781. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3782. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3783. break;
  3784. }
  3785. case COMMAND_ADMINFLAG:
  3786. {
  3787. if(sep && sep->arg[0]){
  3788. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3789. sint16 new_status = atoi(sep->arg[1]);
  3790. if(tmp_status == -10)
  3791. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3792. else if(tmp_status >= client->GetAdminStatus())
  3793. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3794. else if (new_status > client->GetAdminStatus())
  3795. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3796. else{
  3797. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3798. if (!client2)
  3799. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3800. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3801. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3802. if (client2) {
  3803. client2->SetAdminStatus(new_status);
  3804. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3805. }
  3806. }
  3807. else
  3808. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3809. }
  3810. }else{
  3811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3812. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3813. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3814. }
  3815. break;
  3816. }
  3817. case COMMAND_CANNEDEMOTE:{
  3818. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3819. break;
  3820. }
  3821. case COMMAND_BROADCAST: {
  3822. if (sep && sep->arg[0])
  3823. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3824. else
  3825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3826. break;
  3827. }
  3828. case COMMAND_ANNOUNCE: {
  3829. if (sep && sep->arg[0])
  3830. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3831. else
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3833. break;
  3834. }
  3835. case COMMAND_RELOAD_ITEMS:{
  3836. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3838. database.ReloadItemList();
  3839. database.LoadMerchantInformation();
  3840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3841. break;
  3842. }
  3843. case COMMAND_ENABLE_ABILITY_QUE:{
  3844. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3845. if(app)
  3846. client->QueuePacket(app);
  3847. break;
  3848. }
  3849. case COMMAND_ITEMSEARCH:{
  3850. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3851. if (packet) {
  3852. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3853. //packet->setDataByName("unknown", 1);
  3854. packet->setDataByName("unknown2", 5, 0);
  3855. packet->setDataByName("unknown2", 20, 1);
  3856. packet->setDataByName("unknown2", 58, 3);
  3857. packet->setDataByName("unknown2", 40, 4);
  3858. client->QueuePacket(packet->serialize());
  3859. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3860. if (packet2) {
  3861. packet2->setDataByName("char_id", client->GetCharacterID());
  3862. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3863. safe_delete(packet2);
  3864. }
  3865. safe_delete(packet);
  3866. }
  3867. break;
  3868. }
  3869. case COMMAND_ANIMTEST:{
  3870. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3871. if(command_packet){
  3872. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3873. if (cmdTarget)
  3874. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3875. command_packet->setDataByName ( "spawn_id" , id);
  3876. int animID = 1;
  3877. if(sep && sep->arg[0] && sep->IsNumber(0))
  3878. animID = atoi(sep->arg[0]);
  3879. VisualState* vs = NULL;
  3880. if(animID == 0)
  3881. {
  3882. vs = visual_states.FindVisualState(sep->arg[0]);
  3883. }
  3884. char msg[128];
  3885. sprintf(msg,"Animation Test ID: %i",animID);
  3886. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3887. if(vs != NULL)
  3888. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3889. else
  3890. command_packet->setDataByName ( "anim_type", animID );
  3891. command_packet->setDataByName ( "unknown0", 0 );
  3892. EQ2Packet* outapp = command_packet->serialize();
  3893. client->QueuePacket(outapp);
  3894. safe_delete(command_packet);
  3895. }
  3896. break;
  3897. }
  3898. case COMMAND_KICK:
  3899. {
  3900. if( sep == 0 || sep->arg[0] == 0)
  3901. {
  3902. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3903. }
  3904. else
  3905. {
  3906. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3907. if ( kickClient == client )
  3908. {
  3909. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3910. break;
  3911. }
  3912. else if(kickClient != NULL)
  3913. {
  3914. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3915. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3916. {
  3917. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3918. break;
  3919. }
  3920. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3921. kickClient->Disconnect();
  3922. }
  3923. else
  3924. {
  3925. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3926. }
  3927. }
  3928. break;
  3929. }
  3930. case COMMAND_LOCK:
  3931. {
  3932. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3933. int worldLocked = atoi(sep->arg[0]);
  3934. net.world_locked = worldLocked;
  3935. if ( worldLocked )
  3936. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3937. else
  3938. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3939. }
  3940. else
  3941. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3942. break;
  3943. }
  3944. case COMMAND_BAN:{
  3945. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3946. {
  3947. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3948. }
  3949. else
  3950. {
  3951. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3952. if ( kickClient == client )
  3953. {
  3954. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3955. break;
  3956. }
  3957. else if(kickClient != NULL)
  3958. {
  3959. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3960. if ( maxStatus > client->GetAdminStatus( ) ||
  3961. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3962. {
  3963. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3964. break;
  3965. }
  3966. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3967. int perm = atol(sep->arg[1]);
  3968. if ( perm == 1 )
  3969. database.UpdateAdminStatus(sep->arg[0],-2);
  3970. else
  3971. database.UpdateAdminStatus(sep->arg[0],-1);
  3972. kickClient->Disconnect();
  3973. }
  3974. else
  3975. {
  3976. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3977. }
  3978. }
  3979. break;
  3980. }
  3981. case COMMAND_SET_COMBAT_VOICE:{
  3982. int32 value = 0;
  3983. if(sep && sep->arg[0] && sep->IsNumber(0))
  3984. value = atoi(sep->arg[0]);
  3985. client->GetPlayer()->SetCombatVoice(value);
  3986. break;
  3987. }
  3988. case COMMAND_SET_EMOTE_VOICE:{
  3989. int32 value = 0;
  3990. if(sep && sep->arg[0] && sep->IsNumber(0))
  3991. value = atoi(sep->arg[0]);
  3992. client->GetPlayer()->SetEmoteVoice(value);
  3993. break;
  3994. }
  3995. case COMMAND_GIVEITEM:{
  3996. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3997. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3998. if ( itemToClient == NULL )
  3999. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4000. else
  4001. {
  4002. int32 item_id = atol(sep->arg[1]);
  4003. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4004. itemToClient->AddItem(item_id);
  4005. }
  4006. }
  4007. else
  4008. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4009. break;
  4010. }
  4011. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4012. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4013. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4014. case COMMAND_SKILL :
  4015. case COMMAND_SKILL_ADD :
  4016. case COMMAND_SKILL_REMOVE :
  4017. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4018. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4019. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4020. case COMMAND_ENTITYCOMMAND :
  4021. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4022. case COMMAND_MERCHANT :
  4023. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4024. case COMMAND_APPEARANCE :
  4025. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4026. case COMMAND_TRACK : { Command_Track(client); break; }
  4027. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4028. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4029. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4030. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4031. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4032. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4033. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4034. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4035. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4036. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4037. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4038. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4039. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4040. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4041. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4042. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4043. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4044. case COMMAND_LOCATION : { Command_Location(client); break; }
  4045. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4046. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4047. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4048. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4049. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4050. case COMMAND_GRID : { Command_Grid(client); break; }
  4051. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4052. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4053. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4054. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4055. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4056. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4057. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4058. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4059. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4060. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4061. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4062. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4063. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4064. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4065. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4066. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4067. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4068. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4069. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4070. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4071. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4072. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4073. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4074. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4075. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4076. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4077. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4078. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4079. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4080. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4081. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4082. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4083. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4084. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4085. case COMMAND_TITLE : { Command_Title(client); break; }
  4086. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4087. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4088. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4089. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4090. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4091. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4092. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4093. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4094. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4095. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4096. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4097. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4098. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4099. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4100. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4101. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4102. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4103. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4104. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4105. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4106. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4107. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4108. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4109. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4110. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4111. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4112. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4113. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4114. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4115. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4116. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4117. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4118. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4119. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4120. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4121. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4122. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4123. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4124. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4125. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4126. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4127. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4128. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4129. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4130. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4131. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4132. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4133. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4134. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4135. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4136. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4137. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4138. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4139. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4140. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4141. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4142. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4143. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4144. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4145. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4146. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4147. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4148. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4149. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4150. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4151. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4152. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4153. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4154. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4155. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4156. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4157. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4158. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4159. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4160. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4161. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4162. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4163. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4164. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4165. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4166. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4167. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4168. case ADD_AA : { Add_AA(client, sep); break; }
  4169. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4170. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4171. case BACK_AA : { Back_AA(client, sep); break; }
  4172. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4173. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4174. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4175. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4176. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4177. default:
  4178. {
  4179. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4180. break;
  4181. }
  4182. }
  4183. safe_delete(sep);
  4184. }
  4185. /******************** New COMMAND Handler Functions ********************/
  4186. /*
  4187. Started breaking apart the huge switch() for commands into sepErate
  4188. functions so it is easier to locate the blocks of code by command
  4189. -- JA 2012.03.03
  4190. */
  4191. // sample function header
  4192. /*
  4193. Function:
  4194. Purpose :
  4195. Params :
  4196. Dev :
  4197. Example :
  4198. */
  4199. //void Commands::Command()
  4200. //{
  4201. //}
  4202. /*
  4203. Function: Command_AcceptAdvancement()
  4204. Purpose : Player accepts a new advancement option
  4205. Params : Spell ID
  4206. Dev : Jabantiz
  4207. */
  4208. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4209. {
  4210. Player *player = client->GetPlayer();
  4211. if (sep && sep->IsSet(0)) {
  4212. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4213. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4214. if (!player->HasSpell(trait->spellID, 0, true))
  4215. {
  4216. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4217. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4218. }
  4219. else
  4220. {
  4221. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4222. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4223. player->RemoveSpellBookEntry(spell->GetSpellID());
  4224. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4225. player->UnlockSpell(spell);
  4226. client->SendSpellUpdate(spell);
  4227. }
  4228. // Spell book update
  4229. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4230. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4231. }
  4232. }
  4233. /*
  4234. Function:
  4235. Purpose :
  4236. Params :
  4237. Dev :
  4238. Example :
  4239. */
  4240. void Commands::Command_AFK(Client* client, Seperator* sep)
  4241. {
  4242. Player* player = client->GetPlayer();
  4243. player->toggle_character_flag(CF_AFK);
  4244. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4245. if (player->get_character_flag(CF_AFK))
  4246. {
  4247. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4248. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4249. if (sep && sep->argplus[0])
  4250. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4251. else
  4252. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4253. string message = string(player->GetName()) + " is going afk.";
  4254. Spawn* target = player->GetTarget();
  4255. if (target && target != player)
  4256. {
  4257. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4258. player->GetGender() == 1 ? message += "he" : message += "she";
  4259. message += " is going afk.";
  4260. }
  4261. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4262. }
  4263. /*else
  4264. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4265. }
  4266. /*
  4267. Function: Command_Appearance()
  4268. Purpose : Handles /appearance commands
  4269. Params : list
  4270. Dev : Scatman
  4271. Example : /appearance list
  4272. */
  4273. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4274. {
  4275. if( handler == COMMAND_APPEARANCE )
  4276. {
  4277. // /appearance command by itself shows help (to be extended)
  4278. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4279. return;
  4280. }
  4281. else if( handler == COMMAND_APPEARANCE_LIST )
  4282. {
  4283. // /appearance list command expects "name" param
  4284. if (sep && sep->arg[0])
  4285. {
  4286. const char* appearance_name = sep->argplus[0];
  4287. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4288. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4289. if (appearances)
  4290. {
  4291. vector<int16>::iterator itr;
  4292. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4293. {
  4294. int16 id = *itr;
  4295. string name = database.GetAppearanceName(id);
  4296. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4297. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4298. }
  4299. safe_delete(appearances);
  4300. }
  4301. }
  4302. else // no param
  4303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4304. }
  4305. }
  4306. /*
  4307. Function: Command_Claim()
  4308. Purpose :
  4309. Params :
  4310. Dev :
  4311. Example :
  4312. */
  4313. void Commands::Command_Claim(Client* client, Seperator* sep)
  4314. {
  4315. if (sep && sep->arg[0] && sep->IsNumber(0))
  4316. {
  4317. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4319. }
  4320. else
  4321. client->ShowClaimWindow();
  4322. }
  4323. /*
  4324. Function: Command_ClearAllQueued()
  4325. Purpose :
  4326. Params :
  4327. Dev :
  4328. Example :
  4329. */
  4330. void Commands::Command_ClearAllQueued(Client* client)
  4331. {
  4332. ZoneServer* zone = client->GetPlayer()->GetZone();
  4333. if (zone && zone->GetSpellProcess())
  4334. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4335. }
  4336. /*
  4337. Function: Command_CancelMaintained()
  4338. Purpose : Cancels maintained spells
  4339. Params : Maintained Spell Index
  4340. Dev : Zcoretri
  4341. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4342. */
  4343. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4344. {
  4345. if (sep && sep->arg[0] && sep->IsNumber(0))
  4346. {
  4347. int32 spell_index = atoul(sep->arg[0]);
  4348. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4349. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4350. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4351. // just not spelleffects/dets - Foof
  4352. //{
  4353. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4354. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4355. // }
  4356. //else
  4357. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4358. }
  4359. }
  4360. /*
  4361. Function: Command_Create()
  4362. Purpose : Handler for starting Tradeskilling table
  4363. Params :
  4364. Dev : Zcoretri
  4365. Example :
  4366. */
  4367. void Commands::Command_Create(Client* client, Seperator* sep)
  4368. {
  4369. PrintSep(sep, "COMMAND_CREATE");
  4370. client->SendRecipeList();
  4371. client->ShowRecipeBook();
  4372. }
  4373. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4374. {
  4375. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4376. if (sep && sep->arg[0] && sep->IsNumber(0))
  4377. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4378. }
  4379. /*
  4380. Function: Command_Distance()
  4381. Purpose : Displays distance from targeted spawn
  4382. Params :
  4383. Dev : Scatman
  4384. Example : /distance
  4385. */
  4386. void Commands::Command_Distance(Client* client)
  4387. {
  4388. Spawn* target = client->GetPlayer()->GetTarget();
  4389. if (target)
  4390. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4391. else
  4392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4393. }
  4394. /*
  4395. Function: Command_Duel()
  4396. Purpose : Handle the /duel commands - not yet implemented
  4397. Params : unknown
  4398. Dev :
  4399. Example :
  4400. */
  4401. void Commands::Command_Duel(Client* client, Seperator* sep)
  4402. {
  4403. PrintSep(sep, "COMMAND_DUEL");
  4404. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4405. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4406. }
  4407. /*
  4408. Function: Command_DuelBet()
  4409. Purpose : Handle the /duel commands - not yet implemented
  4410. Params : unknown
  4411. Dev :
  4412. Example :
  4413. */
  4414. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4415. {
  4416. PrintSep(sep, "COMMAND_DUELBET");
  4417. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4418. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4419. }
  4420. /*
  4421. Function: Command_DuelAccept()
  4422. Purpose : Handle the /duel commands - not yet implemented
  4423. Params : unknown
  4424. Dev :
  4425. Example :
  4426. */
  4427. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4428. {
  4429. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4430. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4431. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4432. }
  4433. /*
  4434. Function: Command_DuelDecline()
  4435. Purpose : Handle the /duel commands - not yet implemented
  4436. Params : unknown
  4437. Dev :
  4438. Example :
  4439. */
  4440. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4441. {
  4442. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4443. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4444. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4445. }
  4446. /*
  4447. Function: Command_DuelSurrender()
  4448. Purpose : Handle the /duel commands - not yet implemented
  4449. Params : unknown
  4450. Dev :
  4451. Example :
  4452. */
  4453. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4454. {
  4455. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4456. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4457. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4458. // JA, just messin around ;)
  4459. char surrender[64];
  4460. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4461. zone_list.HandleGlobalAnnouncement(surrender);
  4462. }
  4463. /*
  4464. Function: Command_DuelToggle()
  4465. Purpose : Handle the /duel commands - not yet implemented
  4466. Params : unknown
  4467. Dev :
  4468. Example :
  4469. */
  4470. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4471. {
  4472. PrintSep(sep, "COMMAND_DUEL");
  4473. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4474. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4475. }
  4476. /*
  4477. Function:
  4478. Purpose :
  4479. Params :
  4480. Dev :
  4481. Example :
  4482. */
  4483. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4484. {
  4485. if( handler == COMMAND_ENTITYCOMMAND )
  4486. {
  4487. // /entitycommand command by itself shows help (to be extended)
  4488. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4489. return;
  4490. }
  4491. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4492. {
  4493. // /entitycommand list command expects "name" param
  4494. if (sep && sep->arg[0])
  4495. {
  4496. const char* entity_command_name = sep->argplus[0];
  4497. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4498. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4499. map<int32, vector<EntityCommand*>*>::iterator itr;
  4500. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4501. {
  4502. vector<EntityCommand*>* entity_command_list = itr->second;
  4503. vector<EntityCommand*>::iterator itr2;
  4504. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4505. {
  4506. EntityCommand* entity_command = *itr2;
  4507. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4508. 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);
  4509. }
  4510. }
  4511. }
  4512. else // no command name
  4513. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4514. }
  4515. }
  4516. /*
  4517. Function: Command_Follow()
  4518. Purpose : Handle the /follow command - not yet implemented
  4519. Params :
  4520. Dev :
  4521. Example :
  4522. */
  4523. void Commands::Command_Follow(Client* client, Seperator* sep)
  4524. {
  4525. PrintSep(sep, "COMMAND_FOLLOW");
  4526. // flag to toggle if the players target is in the players group
  4527. bool targetInGroup = false;
  4528. // get a pointer to the players group
  4529. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4530. // If the player has a group and has a target
  4531. if (gmi && client->GetPlayer()->GetTarget()) {
  4532. deque<GroupMemberInfo*>::iterator itr;
  4533. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4534. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4535. // Loop through the group members
  4536. for (itr = members->begin(); itr != members->end(); itr++) {
  4537. // If a group member matches a target
  4538. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4539. // toggle the flag and break the loop
  4540. targetInGroup = true;
  4541. break;
  4542. }
  4543. }
  4544. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4545. }
  4546. if (targetInGroup) {
  4547. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4548. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4549. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4550. client->GetPlayer()->info_changed = true;
  4551. client->GetPlayer()->changed = true;
  4552. }
  4553. else
  4554. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4555. }
  4556. /*
  4557. Function: Command_StopFollow()
  4558. Purpose : Handle the /stop_follow command - not yet implemented
  4559. Params :
  4560. Dev :
  4561. Example :
  4562. */
  4563. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4564. {
  4565. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4566. if (client->GetPlayer()->GetFollowTarget()) {
  4567. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4568. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4569. client->GetPlayer()->SetFollowTarget(0);
  4570. client->GetPlayer()->info_changed = true;
  4571. client->GetPlayer()->changed = true;
  4572. }
  4573. }
  4574. #include "../Zone/SPGrid.h"
  4575. /*
  4576. Function: Command_Grid()
  4577. Purpose : Show player's current Grid ID
  4578. Params :
  4579. Dev : Scatman
  4580. Example : /grid
  4581. */
  4582. void Commands::Command_Grid(Client* client)
  4583. {
  4584. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4585. if (client->GetCurrentZone()->Grid != nullptr) {
  4586. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4587. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4588. }
  4589. }
  4590. /*
  4591. Function: Command_Guild()
  4592. Purpose : Handler for all UI-related guild commands
  4593. Dev : Scatman
  4594. */
  4595. void Commands::Command_Guild(Client* client, Seperator* sep)
  4596. {
  4597. Guild* guild = client->GetPlayer()->GetGuild();
  4598. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4599. {
  4600. const char* command = sep->arg[0];
  4601. int32 length = strlen(command);
  4602. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4603. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4604. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4605. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4606. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4607. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4608. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4609. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4610. guild->KickGuildMember(client, sep->arg[1]);
  4611. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4612. guild->DemoteGuildMember(client, sep->arg[1]);
  4613. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4614. guild->PromoteGuildMember(client, sep->arg[1]);
  4615. else if (strncmp(command, "points", length) == 0 && guild)
  4616. {
  4617. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4618. {
  4619. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4620. {
  4621. float points = atof(sep->arg[2]);
  4622. const char* option = sep->arg[3];
  4623. const char* comment = sep->argplus[4];
  4624. if (strncmp(option, "all", strlen(option)) == 0)
  4625. guild->AddPointsToAll(client, points, comment);
  4626. else if (strncmp(option, "online", strlen(option)) == 0)
  4627. guild->AddPointsToAllOnline(client, points, comment);
  4628. else if (strncmp(option, "group", strlen(option)) == 0)
  4629. guild->AddPointsToGroup(client, points, comment);
  4630. else if (strncmp(option, "raid", strlen(option)) == 0)
  4631. guild->AddPointsToRaid(client, points, comment);
  4632. else
  4633. guild->AddPointsToGuildMember(client, points, option, comment);
  4634. }
  4635. }
  4636. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4637. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4638. else
  4639. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4640. }
  4641. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4642. guild->SetMOTD(sep->argplus[1]);
  4643. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4644. {
  4645. if (sep->arg[1])
  4646. {
  4647. const char* option = sep->arg[1];
  4648. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4649. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4650. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4651. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4652. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4653. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4654. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4655. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4656. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4657. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4658. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4659. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4660. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4661. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4662. else
  4663. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4664. }
  4665. else
  4666. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4667. }
  4668. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4669. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4670. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4671. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4672. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4673. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4674. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4675. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4676. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4677. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4678. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4679. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4680. else if (strncmp(command, "invite", length) == 0 && guild)
  4681. {
  4682. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4683. guild->InvitePlayer(client, sep->arg[1]);
  4684. else
  4685. {
  4686. Spawn* target = client->GetPlayer()->GetTarget();
  4687. if (target)
  4688. {
  4689. if (target->IsPlayer())
  4690. guild->InvitePlayer(client, target->GetName());
  4691. else
  4692. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4693. }
  4694. }
  4695. }
  4696. else if (strncmp(command, "accept", length) == 0)
  4697. {
  4698. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4699. if (pgi && pgi->guild && pgi->invited_by)
  4700. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4701. client->SetPendingGuildInvite(0);
  4702. }
  4703. else if (strncmp(command, "decline", length) == 0)
  4704. {
  4705. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4706. if (pgi && pgi->guild && pgi->invited_by)
  4707. {
  4708. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4709. if (client_inviter)
  4710. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4711. }
  4712. client->SetPendingGuildInvite(0);
  4713. }
  4714. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4715. {
  4716. const char* guild_name = sep->argplus[1];
  4717. if (!guild_list.GetGuild(guild_name))
  4718. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4719. else
  4720. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4721. }
  4722. else if (strncmp(command, "search", length) == 0)
  4723. client->ShowGuildSearchWindow();
  4724. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4725. {
  4726. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4727. if (to_guild)
  4728. to_guild->SendGuildRecruitingDetails(client);
  4729. }
  4730. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4731. {
  4732. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4733. if (to_guild)
  4734. to_guild->SendGuildRecruitingImages(client);
  4735. }
  4736. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4737. {
  4738. if (sep->arg[1])
  4739. {
  4740. const char* option = sep->arg[1];
  4741. if (strncmp(option, "toggle", strlen(option)) == 0)
  4742. guild->ToggleGuildRecruiterAdventureClass(client);
  4743. }
  4744. else
  4745. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4746. }
  4747. else if (strncmp(command, "display_heraldry", length) == 0)
  4748. {
  4749. // JA: not sure this is right...
  4750. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4751. client->GetPlayer()->SetCharSheetChanged(true);
  4752. }
  4753. else
  4754. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4755. }
  4756. }
  4757. /*
  4758. Function: Command_GuildCreate()
  4759. Purpose : Display's in-game Guild Creation window
  4760. Dev : Scatman
  4761. */
  4762. void Commands::Command_CreateGuild(Client* client)
  4763. {
  4764. client->SendGuildCreateWindow();
  4765. }
  4766. /*
  4767. Function: Command_SetGuildOfficerNote()
  4768. Purpose :
  4769. Dev : Scatman
  4770. */
  4771. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4772. {
  4773. if (sep && sep->arg[0] && sep->arg[1])
  4774. {
  4775. Guild* guild = client->GetPlayer()->GetGuild();
  4776. if (guild)
  4777. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4778. }
  4779. }
  4780. /*
  4781. Function: Command_SetGuildMemberNote()
  4782. Purpose :
  4783. Dev : Scatman
  4784. */
  4785. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4786. {
  4787. if (sep && sep->arg[0] && sep->arg[1])
  4788. {
  4789. Guild* guild = client->GetPlayer()->GetGuild();
  4790. if (guild)
  4791. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4792. }
  4793. }
  4794. /*
  4795. Function: Command_GuildSay()
  4796. Purpose :
  4797. Dev : Scatman
  4798. */
  4799. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4800. {
  4801. Guild* guild = client->GetPlayer()->GetGuild();
  4802. if (guild)
  4803. {
  4804. if (sep && sep->arg[0])
  4805. guild->HandleGuildSay(client, sep->argplus[0]);
  4806. }
  4807. else
  4808. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4809. }
  4810. /*
  4811. Function: Command_OfficerSay()
  4812. Purpose :
  4813. Dev : Scatman
  4814. */
  4815. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4816. {
  4817. Guild* guild = client->GetPlayer()->GetGuild();
  4818. if (guild)
  4819. {
  4820. if (sep && sep->arg[0])
  4821. guild->HandleOfficerSay(client, sep->argplus[0]);
  4822. }
  4823. else
  4824. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4825. }
  4826. /*
  4827. Function: Command_Guilds()
  4828. Purpose : Shows help for /guild command
  4829. Params :
  4830. Dev : Scatman
  4831. Example :
  4832. */
  4833. void Commands::Command_Guilds(Client* client)
  4834. {
  4835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4836. }
  4837. /*
  4838. Function: Command_GuildsAdd()
  4839. Purpose : Add's players to a guild
  4840. Params : guild_name|guild_id, player name
  4841. Dev : Scatman
  4842. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4843. */
  4844. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4845. {
  4846. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4847. {
  4848. Guild* guild = 0;
  4849. bool found = true;
  4850. if (sep->IsNumber(0))
  4851. {
  4852. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4853. if (!guild)
  4854. {
  4855. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4856. found = false;
  4857. }
  4858. }
  4859. else
  4860. {
  4861. guild = guild_list.GetGuild(sep->arg[0]);
  4862. if (!guild)
  4863. {
  4864. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4865. found = false;
  4866. }
  4867. }
  4868. if (found)
  4869. {
  4870. Client* to_client = 0;
  4871. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4872. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4873. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4874. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4875. if (to_client)
  4876. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4877. else
  4878. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4879. }
  4880. }
  4881. else
  4882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4883. }
  4884. /*
  4885. Function: Command_GuildsCreate()
  4886. Purpose : Creates a guild
  4887. Params : guild_name, player_name (optional)
  4888. Dev : Scatman
  4889. Example : /guilds create [guild name] (player name)
  4890. */
  4891. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4892. {
  4893. if (sep && sep->arg[0])
  4894. {
  4895. const char* guild_name = sep->arg[0];
  4896. if (!guild_list.GetGuild(guild_name))
  4897. {
  4898. bool ret = false;
  4899. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4900. {
  4901. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4902. if (to_client)
  4903. {
  4904. world.CreateGuild(guild_name, to_client);
  4905. ret = true;
  4906. }
  4907. else
  4908. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4909. }
  4910. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4911. {
  4912. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4913. if (to_client)
  4914. {
  4915. world.CreateGuild(guild_name, to_client);
  4916. ret = true;
  4917. }
  4918. }
  4919. else
  4920. {
  4921. world.CreateGuild(guild_name);
  4922. ret = true;
  4923. }
  4924. if (ret)
  4925. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4926. else
  4927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4928. }
  4929. else
  4930. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4931. }
  4932. else
  4933. 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.");
  4934. }
  4935. /*
  4936. Function: Command_GuildsDelete()
  4937. Purpose : Delete's a guild
  4938. Params : guild name
  4939. Dev : Scatman
  4940. Example : /guilds delete Test
  4941. */
  4942. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4943. {
  4944. if (sep && sep->arg[0])
  4945. {
  4946. Guild* guild = 0;
  4947. bool found = true;
  4948. if (sep->IsNumber(0))
  4949. {
  4950. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4951. if (!guild)
  4952. {
  4953. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4954. found = false;
  4955. }
  4956. }
  4957. else
  4958. {
  4959. guild = guild_list.GetGuild(sep->arg[0]);
  4960. if (!guild)
  4961. {
  4962. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4963. found = false;
  4964. }
  4965. }
  4966. if (found)
  4967. {
  4968. guild->RemoveAllGuildMembers();
  4969. database.DeleteGuild(guild);
  4970. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4971. guild_list.RemoveGuild(guild, true);
  4972. }
  4973. }
  4974. else
  4975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4976. }
  4977. /*
  4978. Function: Command_GuildsList()
  4979. Purpose : Lists current guilds on server
  4980. Params :
  4981. Dev : Scatman
  4982. Example : /guilds list
  4983. */
  4984. void Commands::Command_GuildsList(Client* client)
  4985. {
  4986. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4987. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4989. if (guilds->size() == 0)
  4990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4991. else {
  4992. while (itr.Next()) {
  4993. Guild* guild = itr.second;
  4994. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4995. }
  4996. }
  4997. }
  4998. /*
  4999. Function: Command_GuildsRemove()
  5000. Purpose : Removes a player from a guild
  5001. Params : guild name|guild id, player name
  5002. Dev : Scatman
  5003. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5004. */
  5005. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5006. {
  5007. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5008. {
  5009. Guild* guild = 0;
  5010. bool found = true;
  5011. if (sep->IsNumber(0))
  5012. {
  5013. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5014. if (!guild)
  5015. {
  5016. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5017. found = false;
  5018. }
  5019. }
  5020. else
  5021. {
  5022. guild = guild_list.GetGuild(sep->arg[0]);
  5023. if (!guild)
  5024. {
  5025. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5026. found = false;
  5027. }
  5028. }
  5029. if (found)
  5030. {
  5031. Client* to_client = 0;
  5032. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5033. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5034. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5035. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5036. if (to_client)
  5037. {
  5038. Player* to_player = to_client->GetPlayer();
  5039. if (to_player->GetGuild())
  5040. {
  5041. if (to_player->GetGuild() == guild)
  5042. {
  5043. guild->KickGuildMember(client, to_player->GetName());
  5044. }
  5045. else
  5046. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5047. }
  5048. else
  5049. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5050. }
  5051. else
  5052. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5053. }
  5054. }
  5055. else
  5056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5057. }
  5058. /*
  5059. Function: Command_InspectPlayer()
  5060. Purpose : Handle the Inspect functions
  5061. Params : Client to inspect
  5062. Dev : Scatman
  5063. Example : /inspect Scatman
  5064. */
  5065. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5066. {
  5067. if (sep && sep->arg[0])
  5068. {
  5069. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5070. if (inspect_client)
  5071. client->InspectPlayer(inspect_client->GetPlayer());
  5072. }
  5073. else
  5074. {
  5075. Spawn* target = client->GetPlayer()->GetTarget();
  5076. if (target && target->IsPlayer())
  5077. client->InspectPlayer((Player*)target);
  5078. }
  5079. }
  5080. /*
  5081. Function: Command_Inventory()
  5082. Purpose : Handle changes in player inventory
  5083. Params : <TBD>
  5084. Dev : All
  5085. Example : /inventory delete item_id
  5086. */
  5087. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5088. {
  5089. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5090. Player* player = client->GetPlayer();
  5091. if(sep && sep->arg[0][0])
  5092. {
  5093. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5094. if(client->GetPlayer()->GetHP() == 0)
  5095. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5096. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5097. {
  5098. int16 index = atoi(sep->arg[1]);
  5099. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5100. if(item)
  5101. {
  5102. if(item->GetItemScript() && lua_interface)
  5103. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5104. int32 bag_id = item->details.inv_slot_id;
  5105. database.DeleteItem(client->GetCharacterID(), item, 0);
  5106. client->GetPlayer()->item_list.DestroyItem(index);
  5107. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5108. client->QueuePacket(outapp);
  5109. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5110. if (outapp)
  5111. client->QueuePacket(outapp);
  5112. }
  5113. }
  5114. 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))
  5115. {
  5116. int16 from_index = atoi(sep->arg[1]);
  5117. sint16 to_slot = atoi(sep->arg[2]);
  5118. sint32 bag_id = atol(sep->arg[3]);
  5119. int8 charges = atoi(sep->arg[4]);
  5120. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5121. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5122. {
  5123. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5124. return;
  5125. }
  5126. sint32 old_inventory_id = 0;
  5127. if(item)
  5128. old_inventory_id = item->details.inv_slot_id;
  5129. //autobank
  5130. if (bag_id == -3 && to_slot == -1)
  5131. {
  5132. if (player->HasFreeBankSlot())
  5133. to_slot = player->FindFreeBankSlot();
  5134. else
  5135. {
  5136. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5137. return;
  5138. }
  5139. }
  5140. //auto inventory
  5141. if (bag_id == 0 && to_slot == -1)
  5142. {
  5143. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5144. {
  5145. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5146. return;
  5147. }
  5148. }
  5149. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5150. client->QueuePacket(outapp);
  5151. //removed from bag send update
  5152. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5153. {
  5154. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5155. if(outapp)
  5156. client->QueuePacket(outapp);
  5157. }
  5158. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5159. {
  5160. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5161. if(outapp)
  5162. client->QueuePacket(outapp);
  5163. }
  5164. }
  5165. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5166. {
  5167. if(client->GetPlayer()->EngagedInCombat())
  5168. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5169. else
  5170. {
  5171. int16 index = atoi(sep->arg[1]);
  5172. int8 slot_id = 255;
  5173. if(sep->arg[2][0] && sep->IsNumber(2))
  5174. slot_id = atoi(sep->arg[2]);
  5175. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5176. EQ2Packet* outapp = 0;
  5177. for(int32 i=0;i<packets.size();i++)
  5178. {
  5179. outapp = packets[i];
  5180. if(outapp)
  5181. client->QueuePacket(outapp);
  5182. }
  5183. client->GetPlayer()->ChangePrimaryWeapon();
  5184. client->GetPlayer()->ChangeSecondaryWeapon();
  5185. client->GetPlayer()->ChangeRangedWeapon();
  5186. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5187. client->QueuePacket(characterSheetPackets);
  5188. }
  5189. }
  5190. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5191. {
  5192. if (client->GetPlayer()->EngagedInCombat())
  5193. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5194. else {
  5195. int16 index = atoi(sep->arg[1]);
  5196. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5197. if (item) {
  5198. // client->GetPlayer()->item_list.DestroyItem(index);
  5199. if (item->item_sets.size() > 0) {
  5200. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5201. ItemSet* set = item->item_sets[i];
  5202. if (set->item_stack_size == 0)
  5203. set->item_stack_size += 1;
  5204. client->AddItem(set->item_id, set->item_stack_size);
  5205. }
  5206. }
  5207. }
  5208. client->RemoveItem(item, 1);
  5209. }
  5210. }
  5211. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5212. {
  5213. if(client->GetPlayer()->EngagedInCombat())
  5214. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5215. else
  5216. {
  5217. int16 index = atoi(sep->arg[1]);
  5218. sint32 bag_id = -999;
  5219. int8 to_slot = 255;
  5220. if(sep->arg[3][0])
  5221. {
  5222. if(sep->IsNumber(2))
  5223. bag_id = atol(sep->arg[2]);
  5224. if(sep->IsNumber(3))
  5225. to_slot = atoi(sep->arg[3]);
  5226. }
  5227. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5228. EQ2Packet* outapp = 0;
  5229. for(int32 i=0;i<packets.size();i++)
  5230. {
  5231. outapp = packets[i];
  5232. if(outapp)
  5233. client->QueuePacket(outapp);
  5234. }
  5235. client->GetPlayer()->ChangePrimaryWeapon();
  5236. client->GetPlayer()->ChangeSecondaryWeapon();
  5237. client->GetPlayer()->ChangeRangedWeapon();
  5238. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5239. client->QueuePacket(characterSheetPackets);
  5240. }
  5241. }
  5242. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5243. {
  5244. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5245. int16 index1 = atoi(sep->arg[1]);
  5246. int16 index2 = atoi(sep->arg[2]);
  5247. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5248. if(outapp)
  5249. client->QueuePacket(outapp);
  5250. else
  5251. {
  5252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5253. return;
  5254. }
  5255. }
  5256. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5257. {
  5258. sint16 to_slot = atoi(sep->arg[1]);
  5259. sint32 bag_id = atoi(sep->arg[2]);
  5260. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5261. if (item) {
  5262. //auto inventory
  5263. if (bag_id == 0 && to_slot == -1)
  5264. {
  5265. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5266. {
  5267. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5268. return;
  5269. }
  5270. // Set the slot for the item
  5271. item->details.inv_slot_id = bag_id;
  5272. item->details.slot_id = to_slot;
  5273. // Flag the item so it gets saved in its new location
  5274. item->save_needed = true;
  5275. // Add the item to its new location
  5276. player->item_list.AddItem(item);
  5277. // Remove the item from the overflow list
  5278. player->item_list.RemoveOverflowItem(item);
  5279. // Send the inventory update packet
  5280. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5281. return;
  5282. }
  5283. else if (bag_id == -3 && to_slot == -1) {
  5284. // Auto Bank
  5285. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5286. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5287. return;
  5288. }
  5289. item->details.inv_slot_id = bag_id;
  5290. item->details.slot_id = to_slot;
  5291. item->save_needed = true;
  5292. player->item_list.AddItem(item);
  5293. player->item_list.RemoveOverflowItem(item);
  5294. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5295. }
  5296. else if (bag_id == -4) {
  5297. // Shared Bank
  5298. if (!player->item_list.SharedBankAddAllowed(item)) {
  5299. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5300. return;
  5301. }
  5302. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5303. if (tmp_item) {
  5304. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5305. return;
  5306. }
  5307. else {
  5308. item->details.inv_slot_id = bag_id;
  5309. item->details.slot_id = to_slot;
  5310. item->save_needed = true;
  5311. player->item_list.AddItem(item);
  5312. player->item_list.RemoveOverflowItem(item);
  5313. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5314. return;
  5315. }
  5316. }
  5317. else {
  5318. // Try to get an item from the given bag id and slot id
  5319. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5320. // Check to see if we got an item, if we do send an error,
  5321. // if we don't put the overflow item into this slot
  5322. if (tmp_item) {
  5323. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5324. }
  5325. else {
  5326. item->details.inv_slot_id = bag_id;
  5327. item->details.slot_id = to_slot;
  5328. item->save_needed = true;
  5329. player->item_list.AddItem(item);
  5330. player->item_list.RemoveOverflowItem(item);
  5331. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5332. return;
  5333. }
  5334. }
  5335. }
  5336. }
  5337. }
  5338. else
  5339. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5340. }
  5341. /*
  5342. Function: Command_IRC()
  5343. Purpose : Handle the IRC functions
  5344. Params : IRC Commands
  5345. Dev : Scatman
  5346. Example : /irc say #Channel Hello World!
  5347. */
  5348. void Commands::Command_IRC(Client* client, Seperator* sep)
  5349. {
  5350. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5351. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5352. return;
  5353. }
  5354. if (sep && sep->arg[0][0]) {
  5355. if (strcasecmp(sep->arg[0], "say") == 0) {
  5356. if (sep->arg[1][0] && sep->arg[2][0]) {
  5357. if (sep->IsNumber(sep->arg[1]))
  5358. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5359. else
  5360. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5361. }
  5362. else
  5363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5364. }
  5365. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5366. if (sep->arg[1][0])
  5367. irc.JoinChannel(client, sep->arg[1]);
  5368. else
  5369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5370. }
  5371. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5372. if (sep->arg[1][0])
  5373. irc.LeaveChannel(client, sep->arg[1]);
  5374. else
  5375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5376. }
  5377. else if (strcasecmp(sep->arg[0], "list") == 0)
  5378. irc.ListChannels(client);
  5379. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5380. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5381. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5382. else
  5383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5384. }
  5385. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5386. irc.DisconnectFromServer(client);
  5387. else
  5388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5389. }
  5390. else
  5391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5392. }
  5393. /*
  5394. Function: Command_Languages()
  5395. Purpose : Show's languages the player knows
  5396. Params :
  5397. Dev : Zcoretri
  5398. Example :
  5399. */
  5400. void Commands::Command_Languages(Client* client, Seperator* sep)
  5401. {
  5402. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5403. list<Language*>::iterator itr;
  5404. Language* language;
  5405. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5406. for(itr = languages->begin(); itr != languages->end(); itr++)
  5407. {
  5408. language = *itr;
  5409. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5410. }
  5411. }
  5412. /*
  5413. Function: Command_SetLanguage()
  5414. Purpose : Handles language commands
  5415. Params : Language ID
  5416. Dev : Zcoretri
  5417. Example :
  5418. */
  5419. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5420. {
  5421. Player* player = client->GetPlayer();
  5422. if (sep && sep->arg[0])
  5423. {
  5424. if(!sep->IsNumber(0))
  5425. {
  5426. //String passed in
  5427. const char* value = sep->arg[0];
  5428. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5429. {
  5430. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5431. client->SendLanguagesUpdate(0);
  5432. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5433. }
  5434. else
  5435. {
  5436. if(player->HasLanguage(value))
  5437. {
  5438. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5439. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5440. client->SendLanguagesUpdate(language->GetID());
  5441. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5442. }
  5443. else
  5444. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5445. }
  5446. }
  5447. else
  5448. {
  5449. //Number passed in
  5450. int32 id = atoul(sep->arg[0]);
  5451. if(player->HasLanguage(id))
  5452. {
  5453. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5454. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5455. client->SendLanguagesUpdate(id);
  5456. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5457. }
  5458. else
  5459. {
  5460. Language* language = master_languages_list.GetLanguage(id);
  5461. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5462. }
  5463. }
  5464. }
  5465. else
  5466. {
  5467. //No value was passed in
  5468. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5469. if(id > 0)
  5470. {
  5471. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5472. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5473. }
  5474. else
  5475. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5476. }
  5477. }
  5478. /*
  5479. Function: Command_LastName()
  5480. Purpose : Sets player surname
  5481. Params : Name text
  5482. Dev : theFoof
  5483. Example :
  5484. */
  5485. void Commands::Command_LastName(Client* client, Seperator* sep)
  5486. {
  5487. if (!client)
  5488. return;
  5489. if (sep && sep->arg[0])
  5490. {
  5491. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5492. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5493. return;
  5494. }
  5495. client->RemovePendingLastName();
  5496. uchar* checkname = (uchar*)sep->arg[0];
  5497. bool valid_name = true;
  5498. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5499. if (!alpha_check(checkname[i])) {
  5500. valid_name = false;
  5501. break;
  5502. }
  5503. }
  5504. if (!valid_name) {
  5505. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5506. return;
  5507. }
  5508. string last_name = (string)sep->arg[0];
  5509. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5510. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5511. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5512. client->SetPendingLastName(last_name);
  5513. client->SendLastNameConfirmation();
  5514. }
  5515. else
  5516. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5517. }
  5518. }
  5519. /*
  5520. Function: Command_ConfirmLastName()
  5521. Purpose : Confirms setting of player surname
  5522. Params : Name text
  5523. Dev : theFoof
  5524. Example :
  5525. */
  5526. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5527. {
  5528. if (!client)
  5529. return;
  5530. string* name = client->GetPendingLastName();
  5531. if (name){
  5532. Player* player = client->GetPlayer();
  5533. player->SetLastName(name->c_str(), false);
  5534. client->SendTitleUpdate();
  5535. player->SetCharSheetChanged(true);
  5536. client->RemovePendingLastName();
  5537. }
  5538. }
  5539. /*
  5540. Function: Command_Location()
  5541. Purpose : Display's Help for /location commands
  5542. Params :
  5543. Dev : Scatman
  5544. Example : /location = show's help for command
  5545. */
  5546. void Commands::Command_Location(Client* client)
  5547. {
  5548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5550. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5554. }
  5555. /*
  5556. Function: Command_LocationAdd()
  5557. Purpose : Add's a location to an existing location config
  5558. Params : location_id
  5559. Dev : Scatman
  5560. Example : /location add {location_id}
  5561. */
  5562. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5563. {
  5564. if (sep && sep->arg[0] && sep->IsNumber(0))
  5565. {
  5566. int32 location_id = atoul(sep->arg[0]);
  5567. float x = client->GetPlayer()->GetX();
  5568. float y = client->GetPlayer()->GetY();
  5569. float z = client->GetPlayer()->GetZ();
  5570. if (database.AddLocationPoint(location_id, x, y, z))
  5571. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5572. else
  5573. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5574. }
  5575. else
  5576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5577. }
  5578. /*
  5579. Function: Command_LocationCreate()
  5580. Purpose : Creates a new location config
  5581. Params : location name, 0/1 for include_y (optional)
  5582. Dev : Scatman
  5583. Example : /location create Test 1 = creates a new location named Test with include_y True
  5584. */
  5585. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5586. {
  5587. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5588. {
  5589. const char* name = sep->arg[0];
  5590. bool include_y = false;
  5591. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5592. include_y = true;
  5593. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5594. if (location_id > 0)
  5595. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5596. else
  5597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5598. }
  5599. else
  5600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5601. }
  5602. /*
  5603. Function: Command_LocationDelete()
  5604. Purpose : Delete's a location config and all it's location points
  5605. Params : location_id
  5606. Dev : Scatman
  5607. Example : /location delete {location_id}
  5608. */
  5609. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5610. {
  5611. if (sep && sep->arg[0] && sep->IsNumber(0))
  5612. {
  5613. int32 location_id = atoul(sep->arg[0]);
  5614. if (database.DeleteLocation(location_id))
  5615. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5616. else
  5617. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5618. }
  5619. else
  5620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5621. }
  5622. /*
  5623. Function: Command_LocationList()
  5624. Purpose : Display's a list of location points
  5625. Params : location_id
  5626. Dev : Scatman
  5627. Example : /location list {location_id}
  5628. */
  5629. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5630. {
  5631. if (sep && sep->arg[0])
  5632. {
  5633. const char* option = sep->arg[0];
  5634. if (strncmp(option, "locations", strlen(option)) == 0)
  5635. database.ListLocations(client);
  5636. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5637. {
  5638. int32 location_id = atoul(sep->arg[1]);
  5639. database.ListLocationPoints(client, location_id);
  5640. }
  5641. else
  5642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5643. }
  5644. else
  5645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5646. }
  5647. /*
  5648. Function: Command_LocationRemove()
  5649. Purpose : Removes a single location point from a location config
  5650. Params : location_point_id (gotten from /location list {id})
  5651. Dev : Scatman
  5652. Example : /location remove 1 = will remove location_point_id 1
  5653. */
  5654. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5655. {
  5656. if (sep && sep->arg[0] && sep->IsNumber(0))
  5657. {
  5658. int32 location_point_id = atoul(sep->arg[0]);
  5659. if (database.DeleteLocationPoint(location_point_id))
  5660. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5661. else
  5662. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5663. }
  5664. else
  5665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5666. }
  5667. /*
  5668. Function: Command_Merchant()
  5669. Purpose : Handles Merchant commands
  5670. Params : list
  5671. Dev : Scatman
  5672. Example : /merchant list
  5673. */
  5674. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5675. {
  5676. if( handler == COMMAND_MERCHANT )
  5677. {
  5678. // /merchant command by itself shows help (to be extended)
  5679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5680. return;
  5681. }
  5682. else if( handler == COMMAND_MERCHANT_LIST )
  5683. {
  5684. // /merchant list command expects "description" param
  5685. if (sep && sep->arg[0])
  5686. {
  5687. const char* merchant_description = sep->argplus[0];
  5688. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5689. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5690. map<int32, MerchantInfo*>::iterator itr;
  5691. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5692. {
  5693. string description = database.GetMerchantDescription(itr->first);
  5694. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5695. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5696. }
  5697. }
  5698. else // no description
  5699. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5700. }
  5701. }
  5702. /*
  5703. Function: Command_Modify()
  5704. Purpose : to replace our other "set" commands
  5705. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5706. Dev : John Adams
  5707. Example : /modify spell set name "Aegolism III"
  5708. */
  5709. void Commands::Command_Modify(Client* client)
  5710. {
  5711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5716. }
  5717. /*
  5718. Function: Command_ModifySpawn()
  5719. Purpose : replace "spawn set" commands
  5720. Params : Action : the action to perform (or special handler)
  5721. : Field : the DB field to change
  5722. : Value : what to set the value to
  5723. : Target : what object to change (my target, or spawn_id)
  5724. Dev : John Adams
  5725. Example : /modify spawn set name "Lady Vox"
  5726. :
  5727. Note : Special Handlers, like "zoneto" for Signs
  5728. : /modify spawn zoneto
  5729. : Will set a sign's zone x/y/z to my current coords
  5730. */
  5731. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5732. {
  5733. PrintSep(sep, "COMMAND_MODIFY");
  5734. // need at least 2 args for a valid command
  5735. if( sep && sep->arg[1] )
  5736. {
  5737. // JA: just a quick implementation because I need it :)
  5738. if (strcmp(sep->arg[0], "zoneto") == 0)
  5739. {
  5740. if( sep->IsNumber(1) )
  5741. {
  5742. int32 spawn_id = atoul(sep->arg[1]);
  5743. float x_coord = client->GetPlayer()->GetX();
  5744. float y_coord = client->GetPlayer()->GetY();
  5745. float z_coord = client->GetPlayer()->GetZ();
  5746. float h_coord = client->GetPlayer()->GetHeading();
  5747. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5748. }
  5749. else
  5750. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5751. }
  5752. }
  5753. else
  5754. Command_Modify(client);
  5755. }
  5756. /*
  5757. Function: Command_ModifyCharacter()
  5758. Purpose : to replace our other "set" commands
  5759. Params : Action : Add, Remove
  5760. : Field : copper, silver, gold, plat
  5761. : Value : min 1, max unlimited
  5762. : Target : Self, Player
  5763. Dev : Cynnar
  5764. Example : /modify character add gold 50
  5765. : /modify character remove silver 25
  5766. */
  5767. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5768. {
  5769. PrintSep(sep, "COMMAND_MODIFY");
  5770. int64 value = 0;
  5771. Player* player = client->GetPlayer();
  5772. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5773. player = (Player*)player->GetTarget();
  5774. // need at least 2 args for a valid command
  5775. if( sep && sep->arg[1] )
  5776. {
  5777. if (strcmp(sep->arg[0], "add") == 0)
  5778. {
  5779. if (strcmp(sep->arg[1], "copper") == 0)
  5780. {
  5781. value = atoi64(sep->arg[2]);
  5782. player->AddCoins(value);
  5783. if (client->GetPlayer() == player)
  5784. {
  5785. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5786. }
  5787. else {
  5788. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5789. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5790. }
  5791. }
  5792. else if (strcmp(sep->arg[1], "silver") == 0)
  5793. {
  5794. value = atoi64(sep->arg[2]) * 100;
  5795. player->AddCoins(value);
  5796. if (client->GetPlayer() == player)
  5797. {
  5798. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5799. }
  5800. else {
  5801. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5802. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5803. }
  5804. }
  5805. else if (strcmp(sep->arg[1], "gold") == 0)
  5806. {
  5807. value = atoi64(sep->arg[2]) * 10000;
  5808. player->AddCoins(value);
  5809. if (client->GetPlayer() == player)
  5810. {
  5811. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5812. }
  5813. else {
  5814. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5815. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5816. }
  5817. }
  5818. else if (strcmp(sep->arg[1], "plat") == 0)
  5819. {
  5820. value = atoi64(sep->arg[2]) * 1000000;
  5821. player->AddCoins(value);
  5822. if (client->GetPlayer() == player)
  5823. {
  5824. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5825. }
  5826. else {
  5827. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5828. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5829. }
  5830. }
  5831. else
  5832. {
  5833. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5834. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5835. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5836. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5837. }
  5838. }
  5839. else if (strcmp(sep->arg[0], "remove") == 0)
  5840. {
  5841. if (strcmp(sep->arg[1], "copper") == 0)
  5842. {
  5843. value = atoi64(sep->arg[2]);
  5844. player->RemoveCoins(value);
  5845. if (client->GetPlayer() == player)
  5846. {
  5847. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5848. }
  5849. else {
  5850. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5851. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5852. }
  5853. }
  5854. else if (strcmp(sep->arg[1], "silver") == 0)
  5855. {
  5856. value = atoi64(sep->arg[2]) * 100;
  5857. player->RemoveCoins(value);
  5858. if (client->GetPlayer() == player)
  5859. {
  5860. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5861. }
  5862. else {
  5863. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5864. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5865. }
  5866. }
  5867. else if (strcmp(sep->arg[1], "gold") == 0)
  5868. {
  5869. value = atoi64(sep->arg[2]) * 10000;
  5870. player->RemoveCoins(value);
  5871. if (client->GetPlayer() == player)
  5872. {
  5873. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5874. }
  5875. else {
  5876. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5877. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5878. }
  5879. }
  5880. else if (strcmp(sep->arg[1], "plat") == 0)
  5881. {
  5882. value = atoi64(sep->arg[2]) * 1000000;
  5883. player->RemoveCoins(value);
  5884. if (client->GetPlayer() == player)
  5885. {
  5886. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5887. }
  5888. else {
  5889. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5890. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5891. }
  5892. }
  5893. else
  5894. {
  5895. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5896. }
  5897. }
  5898. else if (strcmp(sep->arg[0], "set") == 0) {
  5899. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5900. int8 level = atoi(sep->arg[2]);
  5901. if (level > 0 && level < 256) {
  5902. if (player) {
  5903. if (client->GetPlayer() == player)
  5904. client->ChangeTSLevel(player->GetTSLevel(), level);
  5905. else
  5906. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5907. }
  5908. }
  5909. else
  5910. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5911. }
  5912. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5913. int8 tsclass = atoi(sep->arg[2]);
  5914. player->SetTradeskillClass(tsclass);
  5915. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5916. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5917. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5918. player->SetCharSheetChanged(true);
  5919. }
  5920. }
  5921. }
  5922. else
  5923. {
  5924. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5925. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5926. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5927. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5928. }
  5929. }
  5930. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5931. {
  5932. PrintSep(sep, "COMMAND_MODIFY");
  5933. // need at least 2 args for a valid command
  5934. if( sep && sep->arg[1] )
  5935. {
  5936. }
  5937. else
  5938. Command_Modify(client);
  5939. }
  5940. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5941. {
  5942. PrintSep(sep, "COMMAND_MODIFY");
  5943. // need at least 2 args for a valid command
  5944. if( sep && sep->arg[1] )
  5945. {
  5946. }
  5947. else
  5948. Command_Modify(client);
  5949. }
  5950. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5951. {
  5952. PrintSep(sep, "COMMAND_MODIFY");
  5953. // need at least 2 args for a valid command
  5954. if( sep && sep->arg[1] )
  5955. {
  5956. }
  5957. else
  5958. Command_Modify(client);
  5959. }
  5960. /*
  5961. Function: Command_ModifyQuest()
  5962. Purpose : to list players quest and completed quests
  5963. Params : Action : list, completed
  5964. : Target : Self, Player
  5965. Dev : Cynnar
  5966. Example : /modify quest list
  5967. : /modify quest completed
  5968. */
  5969. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5970. {
  5971. PrintSep(sep, "COMMAND_MODIFY");
  5972. int64 value = 0;
  5973. Player* player = client->GetPlayer();
  5974. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5975. player = (Player*)player->GetTarget();
  5976. // need at least 2 args for a valid command
  5977. if (sep && sep->arg[1])
  5978. {
  5979. if (strcmp(sep->arg[0], "list") == 0)
  5980. {
  5981. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5982. map<int32, Quest*>::iterator itr;
  5983. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5984. if (quests->size() == 0)
  5985. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5986. else
  5987. {
  5988. for (itr = quests->begin(); itr != quests->end(); itr++)
  5989. {
  5990. Quest* quest = itr->second;
  5991. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5992. }
  5993. }
  5994. }
  5995. else if (strcmp(sep->arg[0], "completed") == 0)
  5996. {
  5997. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5998. map<int32, Quest*>::iterator itr;
  5999. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6000. if (quests->size() == 0)
  6001. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6002. else
  6003. {
  6004. for (itr = quests->begin(); itr != quests->end(); itr++)
  6005. {
  6006. Quest* quest = itr->second;
  6007. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6008. }
  6009. }
  6010. }
  6011. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6012. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6013. else if (strcmp(sep->arg[0], "remove") == 0)
  6014. {
  6015. int32 quest_id = 0;
  6016. if (sep && sep->arg[1] && sep->IsNumber(1))
  6017. quest_id = atoul(sep->arg[1]);
  6018. if (quest_id > 0)
  6019. {
  6020. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6021. {
  6022. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6023. if (quest)
  6024. if (client->GetPlayer() == player)
  6025. {
  6026. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6027. }
  6028. else
  6029. {
  6030. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6031. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6032. }
  6033. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6034. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6035. }
  6036. client->RemovePlayerQuest(quest_id);
  6037. client->GetCurrentZone()->SendQuestUpdates(client);
  6038. }
  6039. }
  6040. else if (strcmp(sep->arg[0], "advance") == 0)
  6041. {
  6042. int32 quest_id = 0;
  6043. int32 step = 0;
  6044. if (sep && sep->arg[1] && sep->IsNumber(1))
  6045. {
  6046. quest_id = atoul(sep->arg[1]);
  6047. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6048. if (sep && sep->arg[2] && sep->IsNumber(1))
  6049. {
  6050. step = atoul(sep->arg[2]);
  6051. if (quest_id > 0 && step > 0)
  6052. {
  6053. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6054. {
  6055. if (client)
  6056. {
  6057. client->AddPendingQuestUpdate(quest_id, step);
  6058. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6059. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6060. }
  6061. }
  6062. }
  6063. else
  6064. {
  6065. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6066. }
  6067. }
  6068. else
  6069. {
  6070. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6071. }
  6072. }
  6073. else
  6074. {
  6075. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6076. }
  6077. }
  6078. else
  6079. {
  6080. Command_Modify(client);
  6081. }
  6082. }
  6083. else
  6084. {
  6085. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6086. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6087. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6088. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6089. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6090. }
  6091. }
  6092. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6093. {
  6094. PrintSep(sep, "COMMAND_MODIFY");
  6095. // need at least 2 args for a valid command
  6096. if( sep && sep->arg[1] )
  6097. {
  6098. if (strcmp(sep->arg[0], "add") == 0) {
  6099. const char* skill_name = sep->argplus[1];
  6100. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6101. if (skill) {
  6102. Player* player = 0;
  6103. Client* to_client = 0;
  6104. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6105. player = (Player*)client->GetPlayer()->GetTarget();
  6106. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6107. }
  6108. else {
  6109. player = client->GetPlayer();
  6110. to_client = client;
  6111. }
  6112. if (player)
  6113. {
  6114. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6115. {
  6116. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6117. if (to_client == client) {
  6118. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6119. }
  6120. else {
  6121. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6122. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6123. }
  6124. }
  6125. else
  6126. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6127. }
  6128. }
  6129. else
  6130. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6131. }
  6132. else if (strcmp(sep->arg[0], "remove") == 0) {
  6133. const char* skill_name = sep->argplus[1];
  6134. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6135. if (skill) {
  6136. Player* player = 0;
  6137. Client* to_client = 0;
  6138. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6139. player = (Player*)client->GetPlayer()->GetTarget();
  6140. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6141. }
  6142. else {
  6143. player = client->GetPlayer();
  6144. to_client = client;
  6145. }
  6146. if (player)
  6147. {
  6148. if (player->GetSkills()->HasSkill(skill->skill_id))
  6149. {
  6150. player->RemoveSkillFromDB(skill, true);
  6151. if (client == to_client) {
  6152. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6153. }
  6154. else {
  6155. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6156. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6157. }
  6158. }
  6159. else {
  6160. if (client == to_client)
  6161. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6162. else
  6163. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6164. }
  6165. }
  6166. }
  6167. else
  6168. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6169. }
  6170. else if (strcmp(sep->arg[0], "set") == 0) {
  6171. if (!sep->IsNumber(2)) {
  6172. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6173. return;
  6174. }
  6175. const char* skill_name = sep->arg[1];
  6176. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6177. if (skill) {
  6178. int16 val = atoi(sep->arg[2]);
  6179. Player* player = 0;
  6180. Client* to_client = 0;
  6181. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6182. player = (Player*)client->GetPlayer()->GetTarget();
  6183. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6184. }
  6185. else {
  6186. player = client->GetPlayer();
  6187. to_client = client;
  6188. }
  6189. if (player)
  6190. {
  6191. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6192. player->GetSkills()->SetSkill(skill->skill_id, val);
  6193. if (client != to_client)
  6194. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6195. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6196. }
  6197. else {
  6198. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6199. }
  6200. }
  6201. }
  6202. else {
  6203. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6204. }
  6205. }
  6206. else {
  6207. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6208. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6209. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6210. }
  6211. }
  6212. else {
  6213. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6214. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6215. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6216. }
  6217. }
  6218. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6219. {
  6220. PrintSep(sep, "COMMAND_MODIFY");
  6221. // need at least 2 args for a valid command
  6222. if( sep && sep->arg[1] )
  6223. {
  6224. }
  6225. else
  6226. Command_Modify(client);
  6227. }
  6228. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6229. {
  6230. PrintSep(sep, "COMMAND_MODIFY");
  6231. // need at least 2 args for a valid command
  6232. if( sep && sep->arg[1] )
  6233. {
  6234. }
  6235. else
  6236. Command_Modify(client);
  6237. }
  6238. /*
  6239. Function: Command_MOTD()
  6240. Purpose : Displays server MOTD
  6241. Params :
  6242. Dev : LethalEncounter
  6243. Example : /motd
  6244. */
  6245. void Commands::Command_MOTD(Client* client)
  6246. {
  6247. if (client)
  6248. ClientPacketFunctions::SendMOTD(client);
  6249. }
  6250. /*
  6251. Function: Command_Pet()
  6252. Purpose : Handle Pet {Command} commands
  6253. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6254. Dev :
  6255. Example : /pet preserve_master
  6256. */
  6257. void Commands::Command_Pet(Client* client, Seperator* sep)
  6258. {
  6259. PrintSep(sep, "COMMAND_PET");
  6260. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6261. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6262. if (strcmp(sep->arg[0], "hide") == 0) {
  6263. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6264. Entity* pet = client->GetPlayer()->GetDeityPet();
  6265. if (pet) {
  6266. if (pet->IsPrivateSpawn())
  6267. client->GetPlayer()->HideDeityPet(false);
  6268. else
  6269. client->GetPlayer()->HideDeityPet(true);
  6270. }
  6271. pet = client->GetPlayer()->GetCosmeticPet();
  6272. if (pet) {
  6273. if (pet->IsPrivateSpawn())
  6274. client->GetPlayer()->HideCosmeticPet(false);
  6275. else
  6276. client->GetPlayer()->HideCosmeticPet(true);
  6277. }
  6278. return;
  6279. }
  6280. // below is for all combat pets
  6281. if (!client->GetPlayer()->HasPet()) {
  6282. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6283. return;
  6284. }
  6285. if (strcmp(sep->arg[0], "stay") == 0) {
  6286. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6287. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6288. client->GetPlayer()->SetCharSheetChanged(true);
  6289. if (client->GetPlayer()->GetPet())
  6290. client->GetPlayer()->GetPet()->following = false;
  6291. if (client->GetPlayer()->GetCharmedPet())
  6292. client->GetPlayer()->GetCharmedPet()->following = false;
  6293. }
  6294. else if (strcmp(sep->arg[0], "follow") == 0) {
  6295. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6296. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6297. client->GetPlayer()->SetCharSheetChanged(true);
  6298. }
  6299. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6300. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6301. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6302. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6303. }
  6304. else {
  6305. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6306. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6307. }
  6308. client->GetPlayer()->SetCharSheetChanged(true);
  6309. }
  6310. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6311. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6312. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6313. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6314. }
  6315. else {
  6316. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6317. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6318. }
  6319. client->GetPlayer()->SetCharSheetChanged(true);
  6320. }
  6321. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6322. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6323. if (client->GetPlayer()->GetPet())
  6324. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6325. if (client->GetPlayer()->GetCharmedPet())
  6326. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6327. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6328. client->GetPlayer()->SetCharSheetChanged(true);
  6329. }
  6330. else if (strcmp(sep->arg[0], "attack") == 0) {
  6331. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6332. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6333. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6334. if (client->GetPlayer()->GetPet())
  6335. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6336. if (client->GetPlayer()->GetCharmedPet())
  6337. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6338. }
  6339. else
  6340. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6341. }
  6342. else
  6343. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6344. }
  6345. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6346. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6347. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6348. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6349. }
  6350. else
  6351. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6352. }
  6353. /*
  6354. Function: Command_PetName()
  6355. Purpose : Pet your name (???)
  6356. Params :
  6357. Dev :
  6358. Example :
  6359. */
  6360. void Commands::Command_PetName(Client* client, Seperator* sep)
  6361. {
  6362. PrintSep(sep, "COMMAND_PETNAME");
  6363. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6364. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6365. }
  6366. /*
  6367. Function: Command_NamePet()
  6368. Purpose : Name your pet
  6369. Params :
  6370. Dev :
  6371. Example :
  6372. */
  6373. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6374. {
  6375. PrintSep(sep, "COMMAND_NAME_PET");
  6376. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6377. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6378. }
  6379. /*
  6380. Function: Command_Rename()
  6381. Purpose : Renames existing pet
  6382. Params :
  6383. Dev :
  6384. Example :
  6385. */
  6386. void Commands::Command_Rename(Client* client, Seperator* sep)
  6387. {
  6388. PrintSep(sep, "COMMAND_RENAME");
  6389. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6390. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6391. }
  6392. /*
  6393. Function: Command_ConfirmRename()
  6394. Purpose : Confirms renaming your pet
  6395. Params :
  6396. Dev :
  6397. Example :
  6398. */
  6399. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6400. {
  6401. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6402. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6403. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6404. }
  6405. /*
  6406. Function: Command_PetOptions()
  6407. Purpose : Sets various pet options
  6408. Params :
  6409. Dev :
  6410. Example :
  6411. */
  6412. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6413. {
  6414. PrintSep(sep, "COMMAND_PETOPTIONS");
  6415. Player* player = client->GetPlayer();
  6416. Spawn* target = player->GetTarget();
  6417. if (!target)
  6418. return;
  6419. if (target == player->GetPet())
  6420. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6421. else if (target == player->GetCharmedPet())
  6422. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6423. else if (target == player->GetCosmeticPet())
  6424. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6425. else if (target == player->GetDeityPet())
  6426. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6427. }
  6428. /*
  6429. Function: Command_Random()
  6430. Purpose : Handles /random dice roll in-game
  6431. Params : 1-100
  6432. Dev : Scatman
  6433. Example : /randon 1 100
  6434. */
  6435. void Commands::Command_Random(Client* client, Seperator* sep)
  6436. {
  6437. char message[256] = {0};
  6438. if (sep)
  6439. {
  6440. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6441. 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])));
  6442. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6443. 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])));
  6444. else
  6445. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6446. }
  6447. else
  6448. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6449. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6450. }
  6451. /*
  6452. Function: Command_Randomize()
  6453. Purpose : Sets randomize (appearance) values for NPCs
  6454. Params : Attrib Name
  6455. Dev : Scatman
  6456. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6457. */
  6458. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6459. {
  6460. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6461. if (target)
  6462. {
  6463. if (target->IsNPC())
  6464. {
  6465. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6466. {
  6467. const char* value = sep->arg[0];
  6468. if (strncasecmp(value, "show", strlen(value)) == 0)
  6469. {
  6470. client->DisplayRandomizeFeatures(target->GetRandomize());
  6471. }
  6472. else
  6473. {
  6474. if (sep->arg[1] && sep->IsNumber(1))
  6475. {
  6476. int8 option = atoi(sep->arg[1]);
  6477. if (option == 0 || option == 1)
  6478. {
  6479. int32 feature = 0;
  6480. char feature_text[32] = {0};
  6481. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6482. feature = RANDOMIZE_GENDER;
  6483. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6484. }
  6485. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6486. feature = RANDOMIZE_RACE;
  6487. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6488. }
  6489. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6490. feature = RANDOMIZE_MODEL_TYPE;
  6491. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6492. }
  6493. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6494. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6495. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6496. }
  6497. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6498. feature = RANDOMIZE_HAIR_TYPE;
  6499. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6500. }
  6501. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6502. feature = RANDOMIZE_WING_TYPE;
  6503. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6504. }
  6505. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6506. feature = RANDOMIZE_CHEEK_TYPE;
  6507. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6508. }
  6509. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6510. feature = RANDOMIZE_CHIN_TYPE;
  6511. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6512. }
  6513. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6514. feature = RANDOMIZE_EAR_TYPE;
  6515. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6516. }
  6517. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6518. feature = RANDOMIZE_EYE_BROW_TYPE;
  6519. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6520. }
  6521. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6522. feature = RANDOMIZE_EYE_TYPE;
  6523. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6524. }
  6525. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6526. feature = RANDOMIZE_LIP_TYPE;
  6527. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6528. }
  6529. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6530. feature = RANDOMIZE_NOSE_TYPE;
  6531. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6532. }
  6533. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6534. feature = RANDOMIZE_EYE_COLOR;
  6535. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6536. }
  6537. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6538. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6539. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6540. }
  6541. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6542. feature = RANDOMIZE_HAIR_COLOR1;
  6543. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6544. }
  6545. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6546. feature = RANDOMIZE_HAIR_COLOR2;
  6547. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6548. }
  6549. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6550. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6551. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6552. }
  6553. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6554. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6555. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6556. }
  6557. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6558. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6559. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6560. }
  6561. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6562. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6563. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6564. }
  6565. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6566. feature = RANDOMIZE_SKIN_COLOR;
  6567. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6568. }
  6569. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6570. feature = RANDOMIZE_WING_COLOR1;
  6571. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6572. }
  6573. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6574. feature = RANDOMIZE_WING_COLOR2;
  6575. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6576. }
  6577. else {
  6578. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6579. 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'.");
  6580. }
  6581. if (feature > 0) {
  6582. if (option == 1) {
  6583. if (target->GetRandomize() & feature)
  6584. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6585. else {
  6586. target->AddRandomize(feature);
  6587. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6588. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6589. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6590. }
  6591. }
  6592. else {
  6593. if (target->GetRandomize() & feature) {
  6594. target->AddRandomize(-feature);
  6595. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6596. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6597. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6598. }
  6599. else
  6600. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6601. }
  6602. }
  6603. }
  6604. else
  6605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6606. }
  6607. else
  6608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6609. }
  6610. }
  6611. else {
  6612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6614. 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'.");
  6615. }
  6616. }
  6617. else
  6618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6619. }
  6620. else
  6621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6622. }
  6623. /*
  6624. Function: Command_ShowCloak()
  6625. Purpose : Character Settings combo box for Show Cloak
  6626. Params : true/false
  6627. Dev : John Adams
  6628. Example :
  6629. */
  6630. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6631. {
  6632. Player* player = client->GetPlayer();
  6633. if (sep && sep->arg[0])
  6634. {
  6635. const char* value = sep->arg[0];
  6636. if (strncasecmp(value, "true", strlen(value)) == 0)
  6637. {
  6638. player->set_character_flag(CF_SHOW_CLOAK);
  6639. player->reset_character_flag(CF2_SHOW_RANGED);
  6640. }
  6641. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6642. player->reset_character_flag(CF_SHOW_CLOAK);
  6643. else
  6644. {
  6645. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6646. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6647. }
  6648. }
  6649. }
  6650. /*
  6651. Function: Command_ShowHelm()
  6652. Purpose : Character Settings combo box for Show Helm
  6653. Params : true/false
  6654. Dev : John Adams
  6655. Example :
  6656. */
  6657. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6658. {
  6659. Player* player = client->GetPlayer();
  6660. if (sep && sep->arg[0])
  6661. {
  6662. const char* value = sep->arg[0];
  6663. if (strncasecmp(value, "true", strlen(value)) == 0)
  6664. {
  6665. player->reset_character_flag(CF_HIDE_HELM);
  6666. player->set_character_flag(CF_HIDE_HOOD);
  6667. }
  6668. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6669. player->set_character_flag(CF_HIDE_HELM);
  6670. else
  6671. {
  6672. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6673. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6674. }
  6675. }
  6676. }
  6677. /*
  6678. Function: Command_ShowHood()
  6679. Purpose : Character Settings combo box for Show Hood
  6680. Params : true/false
  6681. Dev : John Adams
  6682. Example :
  6683. */
  6684. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6685. {
  6686. Player* player = client->GetPlayer();
  6687. if (sep && sep->arg[0])
  6688. {
  6689. const char* value = sep->arg[0];
  6690. if (strncasecmp(value, "true", strlen(value)) == 0)
  6691. {
  6692. player->reset_character_flag(CF_HIDE_HOOD);
  6693. player->set_character_flag(CF_HIDE_HELM);
  6694. }
  6695. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6696. player->set_character_flag(CF_HIDE_HOOD);
  6697. else
  6698. {
  6699. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6700. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6701. }
  6702. }
  6703. }
  6704. /*
  6705. Function: Command_ShowHoodHelm()
  6706. Purpose : Character Settings combo box for Show Helm or Hood
  6707. Params : true/false
  6708. Dev : John Adams
  6709. Example :
  6710. */
  6711. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6712. {
  6713. Player* player = client->GetPlayer();
  6714. if (sep && sep->arg[0])
  6715. {
  6716. const char* value = sep->arg[0];
  6717. if (strncasecmp(value, "true", strlen(value)) == 0)
  6718. {
  6719. player->reset_character_flag(CF_HIDE_HOOD);
  6720. player->reset_character_flag(CF_HIDE_HELM);
  6721. }
  6722. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6723. {
  6724. // don't think we ever wind up in here...
  6725. player->set_character_flag(CF_HIDE_HOOD);
  6726. player->set_character_flag(CF_HIDE_HELM);
  6727. }
  6728. else
  6729. {
  6730. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6731. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6732. }
  6733. }
  6734. }
  6735. /*
  6736. Function: Command_ShowRanged()
  6737. Purpose : Character Settings combo box for Show Ranged weapon
  6738. Params : true/false
  6739. Dev : John Adams
  6740. Example :
  6741. */
  6742. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6743. {
  6744. Player* player = client->GetPlayer();
  6745. if (sep && sep->arg[0])
  6746. {
  6747. const char* value = sep->arg[0];
  6748. if (strncasecmp(value, "true", strlen(value)) == 0)
  6749. {
  6750. player->set_character_flag(CF2_SHOW_RANGED);
  6751. player->reset_character_flag(CF_SHOW_CLOAK);
  6752. }
  6753. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6754. player->reset_character_flag(CF2_SHOW_RANGED);
  6755. else
  6756. {
  6757. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6758. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6759. }
  6760. }
  6761. }
  6762. /*
  6763. Function:
  6764. Purpose :
  6765. Params :
  6766. Dev :
  6767. Example :
  6768. */
  6769. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6770. {
  6771. Player* player = 0;
  6772. Client* to_client = 0;
  6773. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6774. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6775. switch(handler)
  6776. {
  6777. case COMMAND_SKILL:
  6778. {
  6779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6781. break;
  6782. }
  6783. case COMMAND_SKILL_ADD:
  6784. {
  6785. if (sep && sep->arg[0])
  6786. {
  6787. const char* skill_name = sep->argplus[0];
  6788. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6789. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6790. {
  6791. player = to_client->GetPlayer();
  6792. if (player)
  6793. {
  6794. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6795. {
  6796. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6797. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6798. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6799. }
  6800. else
  6801. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6802. }
  6803. }
  6804. else if (skill) // add skill to yourself
  6805. {
  6806. player = client->GetPlayer();
  6807. if (player)
  6808. {
  6809. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6810. {
  6811. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6813. }
  6814. else
  6815. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6816. }
  6817. }
  6818. else
  6819. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6820. }
  6821. else
  6822. {
  6823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6825. }
  6826. break;
  6827. }
  6828. case COMMAND_SKILL_REMOVE:
  6829. {
  6830. if (sep && sep->arg[0])
  6831. {
  6832. const char* skill_name = sep->argplus[0];
  6833. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6834. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6835. {
  6836. player = to_client->GetPlayer();
  6837. if (player)
  6838. {
  6839. if (player->GetSkills()->HasSkill(skill->skill_id))
  6840. {
  6841. player->RemoveSkillFromDB(skill, true);
  6842. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6843. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6844. }
  6845. else
  6846. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6847. }
  6848. }
  6849. else if(skill) // remove skill from yourself
  6850. {
  6851. Player* player = client->GetPlayer();
  6852. if (player)
  6853. {
  6854. if (player->GetSkills()->HasSkill(skill->skill_id))
  6855. {
  6856. player->RemoveSkillFromDB(skill, true);
  6857. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6858. }
  6859. else
  6860. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6861. }
  6862. }
  6863. else
  6864. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6865. }
  6866. else
  6867. {
  6868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6870. }
  6871. break;
  6872. }
  6873. case COMMAND_SKILL_LIST:
  6874. {
  6875. if (sep && sep->arg[0])
  6876. {
  6877. const char* skill_name = sep->argplus[0];
  6878. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6879. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6880. map<int32, Skill*>::iterator itr;
  6881. if (skills && skills->size() > 0)
  6882. {
  6883. for (itr = skills->begin(); itr != skills->end(); itr++)
  6884. {
  6885. Skill* skill = itr->second;
  6886. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6887. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6888. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6889. }
  6890. }
  6891. }
  6892. else
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6894. break;
  6895. }
  6896. }
  6897. }
  6898. /*
  6899. Function: Command_SpawnTemplate()
  6900. Purpose : Create or Use defined Spawn Templates
  6901. Params : create, save, rempve, list
  6902. Dev : John Adams
  6903. Example : /spawn template create "Test"
  6904. */
  6905. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6906. {
  6907. if (sep == NULL || sep->arg[0] == NULL)
  6908. {
  6909. 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.");
  6910. return;
  6911. }
  6912. // got params, continue
  6913. const char * template_cmd = sep->arg[0];
  6914. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6915. {
  6916. if (!sep->IsSet(1))
  6917. {
  6918. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6919. 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.");
  6920. return;
  6921. }
  6922. map<int32, string>* template_names = 0;
  6923. if (sep->IsNumber(1))
  6924. {
  6925. int32 location_id = 0;
  6926. location_id = atoi(sep->arg[1]);
  6927. template_names = database.GetSpawnTemplateListByID(location_id);
  6928. }
  6929. else
  6930. {
  6931. const char* name = 0;
  6932. name = sep->argplus[1];
  6933. template_names = database.GetSpawnTemplateListByName(name);
  6934. }
  6935. if(!template_names)
  6936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6937. else
  6938. {
  6939. map<int32, string>::iterator itr;
  6940. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6941. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6942. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6943. safe_delete(template_names);
  6944. }
  6945. }
  6946. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6947. {
  6948. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6949. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6950. {
  6951. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6952. {
  6953. // first, lookup to see if template name already exists
  6954. const char* name = 0;
  6955. name = sep->argplus[1];
  6956. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6957. if(!template_names)
  6958. {
  6959. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6960. if( new_template_id > 0 )
  6961. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6962. else
  6963. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6964. }
  6965. else
  6966. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6967. }
  6968. else
  6969. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6970. }
  6971. else
  6972. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6973. }
  6974. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6975. {
  6976. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6977. {
  6978. int32 template_id = 0;
  6979. template_id = atoi(sep->arg[1]);
  6980. if (database.RemoveSpawnTemplate(template_id))
  6981. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6982. else
  6983. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6984. }
  6985. else
  6986. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6987. }
  6988. // Renamed create to spawn
  6989. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6990. {
  6991. if (sep && sep->arg[1][0])
  6992. {
  6993. int32 new_location = 0;
  6994. if (sep->IsNumber(1))
  6995. {
  6996. int32 template_id = 0;
  6997. template_id = atoi(sep->arg[1]);
  6998. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6999. if( new_location > 0 )
  7000. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7001. else
  7002. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7003. }
  7004. else
  7005. {
  7006. const char* name = 0;
  7007. name = sep->argplus[1];
  7008. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7009. if( new_location > 0 )
  7010. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7011. else
  7012. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7013. }
  7014. }
  7015. else
  7016. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7017. }
  7018. else
  7019. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7020. }
  7021. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7022. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7023. float new_speed = atof(sep->arg[0]);
  7024. if (new_speed > 0.0f)
  7025. {
  7026. client->GetPlayer()->SetSpeed(new_speed, true);
  7027. client->GetPlayer()->SetCharSheetChanged(true);
  7028. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7029. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7030. }
  7031. else
  7032. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7033. }
  7034. else{
  7035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7036. }
  7037. }
  7038. /*
  7039. Function: Command_StationMarketPlace()
  7040. Purpose : just trying to eat the console spam for now
  7041. Params :
  7042. Dev : John
  7043. */
  7044. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7045. {
  7046. PrintSep(sep, "COMMAND_SMP");
  7047. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7048. // can't seem to reduce it any more get rid of it completely...
  7049. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7050. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7051. if (packet) {
  7052. packet->setDataByName("account_id", client->GetAccountID());
  7053. packet->setDataByName("character_id", client->GetCharacterID());
  7054. packet->setDataByName("unknown1", 1, 5);
  7055. packet->setDataByName("unknown1", 26, 6);
  7056. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7057. packet->setDataByName("unknown3", 248, 1);
  7058. client->QueuePacket(packet->serialize());
  7059. }
  7060. safe_delete(packet);
  7061. }
  7062. }
  7063. /*
  7064. Function: Command_StopDrinking()
  7065. Purpose : Stops player from auto-consuming drink
  7066. Params :
  7067. Dev : Zcoretri
  7068. Example : /stopdrinking
  7069. */
  7070. void Commands::Command_StopDrinking(Client* client)
  7071. {
  7072. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7073. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7074. }
  7075. /*
  7076. Function: Command_StopEating()
  7077. Purpose : Stops player from auto-consuming food
  7078. Params :
  7079. Dev : Zcoretri
  7080. Example : /stopeating
  7081. */
  7082. void Commands::Command_StopEating(Client* client)
  7083. {
  7084. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7085. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7086. }
  7087. /*
  7088. Function: Command_Title()
  7089. Purpose : Help for /title command
  7090. Params : n/a
  7091. Dev : Zcoretri
  7092. Example : /title
  7093. */
  7094. void Commands::Command_Title(Client* client)
  7095. {
  7096. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7097. }
  7098. /*
  7099. Function: Command_TitleList()
  7100. Purpose : List available titles for player
  7101. Params : n/a
  7102. Dev : Zcoretri
  7103. Example : /title list
  7104. */
  7105. void Commands::Command_TitleList(Client* client)
  7106. {
  7107. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7108. list<Title*>::iterator itr;
  7109. Title* title;
  7110. int16 i = 0;
  7111. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7112. for(itr = titles->begin(); itr != titles->end(); itr++)
  7113. {
  7114. title = *itr;
  7115. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7116. i++;
  7117. }
  7118. }
  7119. /*
  7120. Function: Command_TitleSetPrefix()
  7121. Purpose : Set Prefix title for player
  7122. Params : Title ID
  7123. Dev : Zcoretri
  7124. Example : /title setprefix 1
  7125. */
  7126. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7127. {
  7128. if (sep && sep->arg[0] && sep->IsNumber(0))
  7129. {
  7130. int32 index = atoul(sep->arg[0]);
  7131. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7132. client->SendTitleUpdate();
  7133. }
  7134. }
  7135. /*
  7136. Function: Command_TitleSetSuffix()
  7137. Purpose : Set Suffix title for player
  7138. Params : Title ID
  7139. Dev : Zcoretri
  7140. Example : /title setsuffix 1
  7141. */
  7142. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7143. {
  7144. if (sep && sep->arg[0] && sep->IsNumber(0))
  7145. {
  7146. int32 index = atoul(sep->arg[0]);
  7147. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7148. client->SendTitleUpdate();
  7149. }
  7150. }
  7151. /*
  7152. Function: Command_TitleFix()
  7153. Purpose : Fix title for player (???)
  7154. Params :
  7155. Dev : Zcoretri
  7156. Example :
  7157. */
  7158. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7159. {
  7160. PrintSep(sep, "COMMAND_TITLE_FIX");
  7161. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7162. }
  7163. /*
  7164. Function: Command_Toggle_Anonymous()
  7165. Purpose : Toggles player Anonymous
  7166. Params :
  7167. Dev : paulgh
  7168. Example : /anon
  7169. */
  7170. void Commands::Command_Toggle_Anonymous(Client* client)
  7171. {
  7172. Player* player = client->GetPlayer();
  7173. player->toggle_character_flag(CF_ANONYMOUS);
  7174. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7175. if (player->get_character_flag(CF_ANONYMOUS))
  7176. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7177. else
  7178. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7179. }
  7180. /*
  7181. Function: Command_Toggle_AutoConsume()
  7182. Purpose : Toggles player food/drink auto consume
  7183. Params : unknown
  7184. Dev : paulgh
  7185. Example : /set_auto_consume
  7186. */
  7187. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7188. {
  7189. Player* player = client->GetPlayer();
  7190. if (sep && sep->arg[0])
  7191. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7192. if (sep && sep->arg[0] && sep->IsNumber(0))
  7193. {
  7194. int8 slot = atoi(sep->arg[0]);
  7195. int8 flag = atoi(sep->arg[1]);
  7196. if (slot == EQ2_FOOD_SLOT)
  7197. {
  7198. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7199. player->SetCharSheetChanged(true);
  7200. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7201. if (flag == 1)
  7202. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7203. else
  7204. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7205. }
  7206. else
  7207. {
  7208. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7209. player->SetCharSheetChanged(true);
  7210. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7211. if (flag == 1)
  7212. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7213. else
  7214. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7215. }
  7216. }
  7217. }
  7218. /*
  7219. Function: Command_Toggle_BonusXP()
  7220. Purpose : Toggles player Bonus XP
  7221. Params :
  7222. Dev : John Adams
  7223. Example : /disable_char_bonus_exp
  7224. */
  7225. void Commands::Command_Toggle_BonusXP(Client* client)
  7226. {
  7227. Player* player = client->GetPlayer();
  7228. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7229. player->SetCharSheetChanged(true);
  7230. }
  7231. /*
  7232. Function: Command_Toggle_CombatXP()
  7233. Purpose : Toggles player Adventure XP
  7234. Params :
  7235. Dev : John Adams
  7236. Example : /disable_combat_exp
  7237. */
  7238. void Commands::Command_Toggle_CombatXP(Client* client)
  7239. {
  7240. Player* player = client->GetPlayer();
  7241. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7242. player->SetCharSheetChanged(true);
  7243. }
  7244. /*
  7245. Function: Command_Toggle_GMHide()
  7246. Purpose : Toggles hiding player GM status
  7247. Params :
  7248. Dev : Scatman
  7249. Example : /gm_hide
  7250. */
  7251. void Commands::Command_Toggle_GMHide(Client* client)
  7252. {
  7253. Player* player = client->GetPlayer();
  7254. player->toggle_character_flag(CF_HIDE_STATUS);
  7255. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7256. }
  7257. /*
  7258. Function: Command_Toggle_GMVanish()
  7259. Purpose : Toggles hiding GM players from /who searches
  7260. Params :
  7261. Dev : Scatman
  7262. Example : /gm_vanish
  7263. */
  7264. void Commands::Command_Toggle_GMVanish(Client* client)
  7265. {
  7266. Player* player = client->GetPlayer();
  7267. player->toggle_character_flag(CF_GM_HIDDEN);
  7268. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7269. }
  7270. /*
  7271. Function: Command_Toggle_Illusions()
  7272. Purpose : Toggles player illusion form
  7273. Params : not sure sep is needed, testing
  7274. Dev : paulgh
  7275. Example : /hide_illusions
  7276. */
  7277. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7278. {
  7279. if (sep && sep->arg[0])
  7280. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7281. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7282. }
  7283. /*
  7284. Function: Command_Toggle_LFG()
  7285. Purpose : Toggles player LFG Flag
  7286. Params :
  7287. Dev : paulgh
  7288. Example : /lfg
  7289. */
  7290. void Commands::Command_Toggle_LFG(Client* client)
  7291. {
  7292. Player* player = client->GetPlayer();
  7293. player->toggle_character_flag(CF_LFG);
  7294. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7295. if (player->get_character_flag(CF_LFG))
  7296. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7297. else
  7298. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7299. }
  7300. /*
  7301. Function: Command_Toggle_LFW()
  7302. Purpose : Toggles player LFW Flag
  7303. Params :
  7304. Dev : paulgh
  7305. Example : /lfw
  7306. */
  7307. void Commands::Command_Toggle_LFW(Client* client)
  7308. {
  7309. Player* player = client->GetPlayer();
  7310. player->toggle_character_flag(CF_LFW);
  7311. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7312. if (player->get_character_flag(CF_LFW))
  7313. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7314. else
  7315. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7316. }
  7317. /*
  7318. Function: Command_Toggle_QuestXP()
  7319. Purpose : Toggles player Quest XP
  7320. Params :
  7321. Dev : John Adams
  7322. Example : /disable_quest_exp
  7323. */
  7324. void Commands::Command_Toggle_QuestXP(Client* client)
  7325. {
  7326. Player* player = client->GetPlayer();
  7327. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7328. player->SetCharSheetChanged(true);
  7329. }
  7330. /*
  7331. Function: Command_Toggle_Roleplaying()
  7332. Purpose : Toggles player Roleplaying flag
  7333. Params :
  7334. Dev : paulgh
  7335. Example : /role
  7336. */
  7337. void Commands::Command_Toggle_Roleplaying(Client* client)
  7338. {
  7339. Player* player = client->GetPlayer();
  7340. player->toggle_character_flag(CF_ROLEPLAYING);
  7341. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7342. if (player->get_character_flag(CF_ROLEPLAYING))
  7343. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7344. else
  7345. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7346. }
  7347. void Commands::Command_Toggle_Duels(Client* client)
  7348. {
  7349. Player* player = client->GetPlayer();
  7350. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7351. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7352. }
  7353. void Commands::Command_Toggle_Trades(Client* client)
  7354. {
  7355. Player* player = client->GetPlayer();
  7356. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7357. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7358. }
  7359. void Commands::Command_Toggle_Guilds(Client* client)
  7360. {
  7361. Player* player = client->GetPlayer();
  7362. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7363. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7364. }
  7365. void Commands::Command_Toggle_Groups(Client* client)
  7366. {
  7367. Player* player = client->GetPlayer();
  7368. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7369. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7370. }
  7371. void Commands::Command_Toggle_Raids(Client* client)
  7372. {
  7373. Player* player = client->GetPlayer();
  7374. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7375. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7376. }
  7377. void Commands::Command_Toggle_LON(Client* client)
  7378. {
  7379. Player* player = client->GetPlayer();
  7380. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7381. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7382. }
  7383. void Commands::Command_Toggle_VoiceChat(Client* client)
  7384. {
  7385. Player* player = client->GetPlayer();
  7386. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7387. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7388. }
  7389. /*
  7390. Function: Command_TradeStart()
  7391. Purpose : Starts item/coin trade between players
  7392. Params :
  7393. Dev :
  7394. Example :
  7395. */
  7396. #include "../Trade.h"
  7397. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7398. {
  7399. PrintSep(sep, "COMMAND_START_TRADE");
  7400. Entity* trader = client->GetPlayer();
  7401. Entity* trader2 = 0;
  7402. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7403. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7404. if (spawn) {
  7405. if (spawn->IsEntity())
  7406. trader2 = (Entity*)spawn;
  7407. }
  7408. }
  7409. else if (client->GetPlayer()->GetTarget()) {
  7410. if (client->GetPlayer()->GetTarget()->IsEntity())
  7411. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7412. }
  7413. // can only trade with player or bots
  7414. if (trader && trader2) {
  7415. if (trader == trader2) {
  7416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7417. }
  7418. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7419. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7420. if (trader->trade)
  7421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7422. else if (trader2->trade)
  7423. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7424. else {
  7425. Trade* trade = new Trade(trader, trader2);
  7426. trader->trade = trade;
  7427. trader2->trade = trade;
  7428. }
  7429. }
  7430. else {
  7431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7432. }
  7433. }
  7434. else
  7435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7436. }
  7437. /*
  7438. Function: Command_Track()
  7439. Purpose : Starts/Stops Tracking for a player
  7440. Params :
  7441. Dev : Scatman
  7442. Example : /track
  7443. */
  7444. void Commands::Command_Track(Client* client)
  7445. {
  7446. if (!client->GetPlayer()->GetIsTracking())
  7447. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7448. else
  7449. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7450. }
  7451. /*
  7452. Function: Command_TradeAccept()
  7453. Purpose : Accepts item/coin trade between players
  7454. Params :
  7455. Dev :
  7456. Example :
  7457. */
  7458. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7459. {
  7460. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7461. Trade* trade = client->GetPlayer()->trade;
  7462. if (trade) {
  7463. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7464. if (trade_complete)
  7465. safe_delete(trade);
  7466. }
  7467. else
  7468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7469. }
  7470. /*
  7471. Function: Command_TradeReject()
  7472. Purpose : Rejects item/coin trade between players
  7473. Params :
  7474. Dev :
  7475. Example :
  7476. */
  7477. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7478. {
  7479. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7480. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7481. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7482. }
  7483. /*
  7484. Function: Command_TradeCancel()
  7485. Purpose : Cancels item/coin trade between players
  7486. Params :
  7487. Dev :
  7488. Example :
  7489. */
  7490. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7491. {
  7492. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7493. Trade* trade = client->GetPlayer()->trade;
  7494. if (trade) {
  7495. trade->CancelTrade(client->GetPlayer());
  7496. safe_delete(trade);
  7497. }
  7498. else
  7499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7500. }
  7501. /*
  7502. Function: Command_TradeSetCoin()
  7503. Purpose : Sets coin trade between players
  7504. Params :
  7505. Dev :
  7506. Example :
  7507. */
  7508. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7509. {
  7510. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7511. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7512. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7513. }
  7514. /*
  7515. Function: Command_TradeAddCoin()
  7516. Purpose : Adds coin to trade between players
  7517. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7518. Dev :
  7519. Example :
  7520. */
  7521. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7522. {
  7523. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7524. Trade* trade = client->GetPlayer()->trade;
  7525. if (trade) {
  7526. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7527. int32 amount = atoi(sep->arg[0]);
  7528. int64 val = 0;
  7529. switch (handler) {
  7530. case COMMAND_ADD_TRADE_COPPER:
  7531. {
  7532. val = amount;
  7533. trade->AddCoinToTrade(client->GetPlayer(), val);
  7534. break;
  7535. }
  7536. case COMMAND_ADD_TRADE_SILVER:
  7537. {
  7538. val = amount * 100;
  7539. trade->AddCoinToTrade(client->GetPlayer(), val);
  7540. break;
  7541. }
  7542. case COMMAND_ADD_TRADE_GOLD:
  7543. {
  7544. val = amount * 10000;
  7545. trade->AddCoinToTrade(client->GetPlayer(), val);
  7546. break;
  7547. }
  7548. case COMMAND_ADD_TRADE_PLAT:
  7549. {
  7550. val = amount * 1000000;
  7551. trade->AddCoinToTrade(client->GetPlayer(), val);
  7552. break;
  7553. }
  7554. default:
  7555. {
  7556. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7557. break;
  7558. }
  7559. }
  7560. }
  7561. else
  7562. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7563. }
  7564. else
  7565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7566. }
  7567. /*
  7568. Function: Command_TradeRemoveCoin()
  7569. Purpose : Removes coin from trade between players
  7570. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7571. Dev :
  7572. Example :
  7573. */
  7574. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7575. {
  7576. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7577. Trade* trade = client->GetPlayer()->trade;
  7578. if (trade) {
  7579. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7580. int32 amount = atoi(sep->arg[0]);
  7581. int64 val = 0;
  7582. switch (handler) {
  7583. case COMMAND_REMOVE_TRADE_COPPER:
  7584. {
  7585. val = amount;
  7586. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7587. break;
  7588. }
  7589. case COMMAND_REMOVE_TRADE_SILVER:
  7590. {
  7591. val = amount * 100;
  7592. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7593. break;
  7594. }
  7595. case COMMAND_REMOVE_TRADE_GOLD:
  7596. {
  7597. val = amount * 10000;
  7598. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7599. break;
  7600. }
  7601. case COMMAND_REMOVE_TRADE_PLAT:
  7602. {
  7603. val = amount * 1000000;
  7604. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7605. break;
  7606. }
  7607. default:
  7608. {
  7609. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7610. break;
  7611. }
  7612. }
  7613. }
  7614. else
  7615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7616. }
  7617. else
  7618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7619. }
  7620. /*
  7621. Function: Command_TradeAddItem()
  7622. Purpose : Adds item to trade between players
  7623. Params :
  7624. Dev :
  7625. Example :
  7626. */
  7627. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7628. {
  7629. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7630. /*
  7631. arg[0] = item index
  7632. arg[1] = slot
  7633. arg[2] = quantity
  7634. */
  7635. if (!client->GetPlayer()->trade) {
  7636. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7638. return;
  7639. }
  7640. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7641. Item* item = 0;
  7642. int32 index = atoi(sep->arg[0]);
  7643. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7644. if (item) {
  7645. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7646. if (result == 1)
  7647. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7648. else if (result == 2)
  7649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7650. else if (result == 3)
  7651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7652. else if (result == 255)
  7653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7654. }
  7655. else {
  7656. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7657. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7658. }
  7659. }
  7660. else
  7661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7662. }
  7663. /*
  7664. Function: Command_TradeRemoveItem()
  7665. Purpose : Removes item from trade between players
  7666. Params :
  7667. Dev :
  7668. Example :
  7669. */
  7670. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7671. {
  7672. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7673. /*
  7674. arg[0] = trade window slot
  7675. */
  7676. Trade* trade = client->GetPlayer()->trade;
  7677. if (trade) {
  7678. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7679. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7680. }
  7681. else
  7682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7683. }
  7684. else
  7685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7686. }
  7687. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7688. {
  7689. Item *item = 0;
  7690. sint32 crc;
  7691. if (sep) {
  7692. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7693. if (client->GetVersion() < 1096) {
  7694. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7695. {
  7696. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7697. crc = atol(sep->arg[2]);
  7698. }
  7699. }
  7700. else {
  7701. // From the broker and links in chat
  7702. if (strcmp(sep->arg[0], "crc") == 0) {
  7703. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7704. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7705. crc = atol(sep->arg[3]);
  7706. }
  7707. }
  7708. // From inventory
  7709. if (strcmp(sep->arg[0], "dbid") == 0) {
  7710. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7711. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7712. crc = atol(sep->arg[4]);
  7713. }
  7714. }
  7715. }
  7716. if (item)
  7717. client->ShowDressingRoom(item, crc);
  7718. }
  7719. }
  7720. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7721. const char *channel_name, *password = NULL;
  7722. if (sep == NULL || !sep->IsSet(0)) {
  7723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7724. return;
  7725. }
  7726. channel_name = sep->arg[0];
  7727. if (sep->IsSet(1))
  7728. password = sep->arg[1];
  7729. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7730. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7731. return;
  7732. }
  7733. if (chat.IsInChannel(client, channel_name)) {
  7734. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7735. return;
  7736. }
  7737. if (chat.HasPassword(channel_name)) {
  7738. if (password == NULL) {
  7739. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7740. return;
  7741. }
  7742. if (!chat.PasswordMatches(channel_name, password)) {
  7743. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7744. return;
  7745. }
  7746. }
  7747. if (!chat.JoinChannel(client, channel_name))
  7748. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7749. }
  7750. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7751. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7752. Command_JoinChannel(client, sep);
  7753. }
  7754. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7755. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7757. PrintSep(sep, "tellchannel");
  7758. return;
  7759. }
  7760. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7761. }
  7762. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7763. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7764. if (sep->IsSet(0)) {
  7765. if (atoi(sep->arg[0]) == 1) {
  7766. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7767. if (packet2) {
  7768. packet2->setDataByName("spell_type", 2);
  7769. packet2->setDataByName("spell_id", 8308);
  7770. packet2->setDataByName("spell_name", "Sprint");
  7771. packet2->setDataByName("add_silently", 0);
  7772. packet2->setDataByName("tier", 1);
  7773. packet2->setDataByName("blah1", 1);
  7774. packet2->setDataByName("blah2", 1);
  7775. EQ2Packet* outapp = packet2->serialize();
  7776. DumpPacket(outapp);
  7777. client->QueuePacket(outapp);
  7778. safe_delete(packet2);
  7779. }
  7780. }
  7781. else if (atoi(sep->arg[0]) == 2) {
  7782. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7783. if (packet2) {
  7784. packet2->setDataByName("guild_name", "Test");
  7785. packet2->setDataByName("guild_motd", "Test MOTD");
  7786. packet2->setDataByName("guild_id", 1234);
  7787. packet2->setDataByName("guild_level", 1);
  7788. packet2->setDataByName("unknown", 2);
  7789. packet2->setDataByName("unknown2", 3);
  7790. packet2->setDataByName("exp_current", 1);
  7791. packet2->setDataByName("exp_to_next_level", 4);
  7792. EQ2Packet* outapp = packet2->serialize();
  7793. DumpPacket(outapp);
  7794. client->QueuePacket(outapp);
  7795. safe_delete(packet2);
  7796. }
  7797. }
  7798. else if (atoi(sep->arg[0]) == 3) {
  7799. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7800. if (packet2) {
  7801. packet2->setDataByName("guild_id", 1234);
  7802. packet2->setDataByName("character_id", 1);
  7803. packet2->setDataByName("account_id", 2);
  7804. packet2->setDataByName("guild_level", 1);
  7805. packet2->setDataByName("name", "Test");
  7806. packet2->setDataByName("unknown2", 0);
  7807. packet2->setDataByName("unknown3", 1);
  7808. packet2->setDataByName("adventure_class", 6);
  7809. packet2->setDataByName("adventure_level", 7);
  7810. packet2->setDataByName("tradeskill_class", 4);
  7811. packet2->setDataByName("tradeskill_level", 5);
  7812. packet2->setDataByName("rank", 0);
  7813. packet2->setDataByName("member_flags", 2);
  7814. packet2->setDataByName("join_date", 1591112273);
  7815. packet2->setDataByName("guild_status", 2);
  7816. packet2->setDataByName("last_login", 1591132273);
  7817. packet2->setDataByName("recruiter_id", 1);
  7818. packet2->setDataByName("points", 2345);
  7819. packet2->setDataByName("note", "note");
  7820. packet2->setMediumStringByName("officer_note", "O note");
  7821. packet2->setMediumStringByName("zone", "Blah");
  7822. EQ2Packet* outapp = packet2->serialize();
  7823. DumpPacket(outapp);
  7824. client->QueuePacket(outapp);
  7825. safe_delete(packet2);
  7826. }
  7827. }
  7828. else if (atoi(sep->arg[0]) == 5) {
  7829. client->GetPlayer()->GetTarget();
  7830. int16 offset = atoi(sep->arg[2]);
  7831. int32 value1 = atol(sep->arg[4]);
  7832. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7833. client->QueuePacket(outapp);
  7834. }
  7835. else if (atoi(sep->arg[0]) == 6) {
  7836. Spawn* spawn = client->GetPlayer()->GetTarget();
  7837. if (!spawn)
  7838. spawn = client->GetPlayer();
  7839. else if (spawn->IsEntity())
  7840. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7841. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7842. }
  7843. else if (atoi(sep->arg[0]) == 7) {
  7844. int32 id = 0;
  7845. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7846. if (spawn) {
  7847. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7848. spawn->SetY(client->GetPlayer()->GetY(), false);
  7849. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7850. float heading = client->GetPlayer()->GetHeading() + 180;
  7851. if (heading > 360)
  7852. heading -= 360;
  7853. spawn->SetLevel(5);
  7854. spawn->SetAdventureClass(4);
  7855. spawn->SetHeading(heading, false);
  7856. spawn->SetSpawnOrigX(spawn->GetX());
  7857. spawn->SetSpawnOrigY(spawn->GetY());
  7858. spawn->SetSpawnOrigZ(spawn->GetZ());
  7859. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7860. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7861. spawn->appearance.targetable = 1;
  7862. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7863. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7864. spawn->SetHP(spawn->GetTotalHP());
  7865. }
  7866. if (spawn->GetTotalPower() == 0) {
  7867. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7868. spawn->SetPower(spawn->GetTotalPower());
  7869. }
  7870. int16 offset = atoi(sep->arg[1]);
  7871. int32 value1 = atol(sep->arg[2]);
  7872. sprintf(spawn->appearance.name, "Offset %i", offset);
  7873. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7874. DumpPacket(ret);
  7875. client->QueuePacket(ret);
  7876. }
  7877. }
  7878. else if (atoi(sep->arg[0]) == 8) {
  7879. int32 id = atoi(sep->arg[1]);
  7880. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7881. if (spawn) {
  7882. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7883. spawn->SetY(client->GetPlayer()->GetY(), false);
  7884. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7885. float heading = client->GetPlayer()->GetHeading() + 180;
  7886. if (heading > 360)
  7887. heading -= 360;
  7888. spawn->SetLevel(5);
  7889. spawn->SetAdventureClass(4);
  7890. spawn->SetHeading(heading, false);
  7891. spawn->SetSpawnOrigX(spawn->GetX());
  7892. spawn->SetSpawnOrigY(spawn->GetY());
  7893. spawn->SetSpawnOrigZ(spawn->GetZ());
  7894. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7895. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7896. spawn->appearance.targetable = 1;
  7897. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7898. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7899. spawn->SetHP(spawn->GetTotalHP());
  7900. }
  7901. if (spawn->GetTotalPower() == 0) {
  7902. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7903. spawn->SetPower(spawn->GetTotalPower());
  7904. }
  7905. int16 offset = atoi(sep->arg[2]);
  7906. int16 offset2 = atoi(sep->arg[3]);
  7907. int32 value1 = atol(sep->arg[4]);
  7908. int16 offset3 = 0;
  7909. int16 offset4 = 0;
  7910. int32 value2 = 0;
  7911. if (sep->IsSet(7)) {
  7912. offset3 = atoi(sep->arg[5]);
  7913. offset4 = atoi(sep->arg[6]);
  7914. value2 = atol(sep->arg[7]);
  7915. }
  7916. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7917. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7918. DumpPacket(ret);
  7919. client->QueuePacket(ret);
  7920. }
  7921. }
  7922. else if (atoi(sep->arg[0]) == 9) {
  7923. Item* item = master_item_list.GetItem(70007);
  7924. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7925. if (sep->IsSet(2)) {
  7926. int8 offset = atoi(sep->arg[1]);
  7927. uchar* ptr2 = app->pBuffer;
  7928. ptr2 += offset;
  7929. if (sep->IsNumber(2)) {
  7930. int32 value1 = atol(sep->arg[2]);
  7931. if (value1 > 0xFFFF)
  7932. memcpy(ptr2, (uchar*)&value1, 4);
  7933. else if (value1 > 0xFF)
  7934. memcpy(ptr2, (uchar*)&value1, 2);
  7935. else
  7936. memcpy(ptr2, (uchar*)&value1, 1);
  7937. }
  7938. else {
  7939. int8 len = strlen(sep->arg[2]);
  7940. memcpy(ptr2, (uchar*)&len, 1);
  7941. ptr2 += 1;
  7942. memcpy(ptr2, sep->arg[2], len);
  7943. }
  7944. }
  7945. if (sep->IsSet(4)) {
  7946. int8 offset = atoi(sep->arg[3]);
  7947. uchar* ptr2 = app->pBuffer;
  7948. ptr2 += offset;
  7949. if (sep->IsNumber(4)) {
  7950. int32 value1 = atol(sep->arg[4]);
  7951. if (value1 > 0xFFFF)
  7952. memcpy(ptr2, (uchar*)&value1, 4);
  7953. else if (value1 > 0xFF)
  7954. memcpy(ptr2, (uchar*)&value1, 2);
  7955. else
  7956. memcpy(ptr2, (uchar*)&value1, 1);
  7957. }
  7958. else {
  7959. int8 len = strlen(sep->arg[4]);
  7960. memcpy(ptr2, (uchar*)&len, 1);
  7961. ptr2 += 1;
  7962. memcpy(ptr2, sep->arg[4], len);
  7963. }
  7964. }
  7965. DumpPacket(app);
  7966. client->QueuePacket(app);
  7967. }
  7968. else if (atoi(sep->arg[0]) == 10) {
  7969. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7970. if (packet2) {
  7971. packet2->setArrayLengthByName("num_quests", 1);
  7972. packet2->setArrayDataByName("active", 1);
  7973. packet2->setArrayDataByName("name", "Archetype Selection");
  7974. packet2->setArrayDataByName("quest_type", "Hallmark");
  7975. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7976. packet2->setArrayDataByName("journal_updated", 1);
  7977. packet2->setArrayDataByName("quest_id", 5);
  7978. packet2->setArrayDataByName("day", 19);
  7979. packet2->setArrayDataByName("month", 6);
  7980. packet2->setArrayDataByName("year", 20);
  7981. packet2->setArrayDataByName("level", 2);
  7982. packet2->setArrayDataByName("encounter_level", 4);
  7983. packet2->setArrayDataByName("difficulty", 3);
  7984. packet2->setArrayDataByName("visible", 1);
  7985. packet2->setDataByName("visible_quest_id", 5);
  7986. packet2->setDataByName("player_crc", 2900677088);
  7987. packet2->setDataByName("player_name", "LethalEncounter");
  7988. EQ2Packet* app = packet2->serialize();
  7989. if (sep->IsSet(2)) {
  7990. int8 offset = atoi(sep->arg[1]);
  7991. uchar* ptr2 = app->pBuffer;
  7992. ptr2 += offset;
  7993. if (sep->IsNumber(2)) {
  7994. int32 value1 = atol(sep->arg[2]);
  7995. if (value1 > 0xFFFF)
  7996. memcpy(ptr2, (uchar*)&value1, 4);
  7997. else if (value1 > 0xFF)
  7998. memcpy(ptr2, (uchar*)&value1, 2);
  7999. else
  8000. memcpy(ptr2, (uchar*)&value1, 1);
  8001. }
  8002. else {
  8003. int8 len = strlen(sep->arg[2]);
  8004. memcpy(ptr2, (uchar*)&len, 1);
  8005. ptr2 += 1;
  8006. memcpy(ptr2, sep->arg[2], len);
  8007. }
  8008. }
  8009. DumpPacket(app);
  8010. client->QueuePacket(app);
  8011. safe_delete(packet2);
  8012. }
  8013. }
  8014. else if (atoi(sep->arg[0]) == 11) {
  8015. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8016. if (packet2) {
  8017. packet2->setDataByName("quest_id", 5);
  8018. packet2->setDataByName("player_crc", 2900677088);
  8019. packet2->setDataByName("name", "Archetype Selection");
  8020. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  8021. packet2->setDataByName("type", "Hallmark");
  8022. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8023. packet2->setDataByName("day", 19);
  8024. packet2->setDataByName("month", 6);
  8025. packet2->setDataByName("year", 20);
  8026. packet2->setDataByName("level", 2);
  8027. packet2->setDataByName("encounter_level", 4);
  8028. packet2->setDataByName("difficulty", 3);
  8029. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8030. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8031. packet2->setDataByName("timer_duration", 300);
  8032. packet2->setDataByName("timer_running", 1);
  8033. packet2->setArrayLengthByName("task_groups_completed", 0);
  8034. packet2->setArrayLengthByName("num_task_groups", 1);
  8035. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8036. packet2->setSubArrayLengthByName("num_tasks", 1);
  8037. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8038. packet2->setSubArrayLengthByName("num_updates", 1);
  8039. packet2->setSubArrayDataByName("update_currentval", 0);
  8040. packet2->setSubArrayDataByName("update_maxval", 1);
  8041. packet2->setSubArrayDataByName("icon", 11);
  8042. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8043. packet2->setDataByName("journal_updated", 1);
  8044. EQ2Packet* app = packet2->serialize();
  8045. if (sep->IsSet(2)) {
  8046. int16 offset = atoi(sep->arg[1]);
  8047. uchar* ptr2 = app->pBuffer;
  8048. ptr2 += offset;
  8049. if (sep->IsNumber(2)) {
  8050. int32 value1 = atol(sep->arg[2]);
  8051. if (value1 > 0xFFFF)
  8052. memcpy(ptr2, (uchar*)&value1, 4);
  8053. else if (value1 > 0xFF)
  8054. memcpy(ptr2, (uchar*)&value1, 2);
  8055. else
  8056. memcpy(ptr2, (uchar*)&value1, 1);
  8057. }
  8058. else {
  8059. int16 len = strlen(sep->arg[2]);
  8060. memcpy(ptr2, (uchar*)&len, 2);
  8061. ptr2 += 2;
  8062. memcpy(ptr2, sep->arg[2], len);
  8063. }
  8064. }
  8065. DumpPacket(app);
  8066. client->QueuePacket(app);
  8067. safe_delete(packet2);
  8068. }
  8069. }
  8070. else if (atoi(sep->arg[0]) == 12) {
  8071. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8072. if (packet2) {
  8073. packet2->setDataByName("quest_id", 5);
  8074. packet2->setDataByName("player_crc", 2900677088);
  8075. packet2->setDataByName("name", "Archetype Selection");
  8076. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8077. packet2->setDataByName("type", "Hallmark");
  8078. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8079. packet2->setDataByName("day", 19);
  8080. packet2->setDataByName("month", 6);
  8081. packet2->setDataByName("year", 20);
  8082. packet2->setDataByName("level", 2);
  8083. packet2->setDataByName("encounter_level", 4);
  8084. packet2->setDataByName("difficulty", 3);
  8085. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8086. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8087. packet2->setDataByName("timer_duration", 300);
  8088. packet2->setDataByName("timer_running", 1);
  8089. packet2->setArrayLengthByName("task_groups_completed", 0);
  8090. packet2->setArrayLengthByName("num_task_groups", 1);
  8091. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8092. packet2->setSubArrayLengthByName("num_tasks", 1);
  8093. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8094. packet2->setSubArrayLengthByName("num_updates", 1);
  8095. packet2->setSubArrayDataByName("update_currentval", 0);
  8096. packet2->setSubArrayDataByName("update_maxval", 1);
  8097. packet2->setSubArrayDataByName("icon", 11);
  8098. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8099. packet2->setDataByName("journal_updated", 1);
  8100. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8101. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8102. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8103. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8104. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8105. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8106. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8107. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8108. Item* item = master_item_list.GetItem(152755);
  8109. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8110. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8111. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8112. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8113. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8114. packet2->setSubstructDataByName("item", "tier", 4);
  8115. packet2->setSubstructDataByName("item", "flags", 0x60);
  8116. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8117. packet2->setSubstructDataByName("item", "stat_type", 1);
  8118. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8119. packet2->setSubstructDataByName("item", "value", 3);
  8120. packet2->setSubstructDataByName("item", "condition", 100);
  8121. packet2->setSubstructDataByName("item", "weight", 1);
  8122. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8123. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8124. packet2->setSubstructDataByName("item", "skill_min", 1);
  8125. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8126. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8127. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8128. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8129. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8130. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8131. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8132. packet2->setSubstructDataByName("item", "level", 0x1e);
  8133. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8134. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8135. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8136. //packet2->PrintPacket();
  8137. EQ2Packet* app = packet2->serialize();
  8138. if (sep->IsSet(2)) {
  8139. int16 offset = atoi(sep->arg[1]);
  8140. uchar* ptr2 = app->pBuffer;
  8141. ptr2 += offset;
  8142. if (sep->IsNumber(2)) {
  8143. int32 value1 = atol(sep->arg[2]);
  8144. if (value1 > 0xFFFF)
  8145. memcpy(ptr2, (uchar*)&value1, 4);
  8146. else if (value1 > 0xFF)
  8147. memcpy(ptr2, (uchar*)&value1, 2);
  8148. else
  8149. memcpy(ptr2, (uchar*)&value1, 1);
  8150. }
  8151. else {
  8152. int16 len = strlen(sep->arg[2]);
  8153. memcpy(ptr2, (uchar*)&len, 2);
  8154. ptr2 += 2;
  8155. memcpy(ptr2, sep->arg[2], len);
  8156. }
  8157. }
  8158. DumpPacket(app);
  8159. client->QueuePacket(app);
  8160. safe_delete(packet2);
  8161. }
  8162. }
  8163. else if (atoi(sep->arg[0]) == 13) {
  8164. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8165. if (packet2 && sep->IsSet(7)) {
  8166. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8167. char blah[128];
  8168. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8169. packet2->setDataByName("text", blah);
  8170. packet2->setDataByName("message_type", sep->arg[3]);
  8171. packet2->setDataByName("size", atof(sep->arg[4]));
  8172. packet2->setDataByName("red", atoi(sep->arg[5]));
  8173. packet2->setDataByName("green", atoi(sep->arg[6]));
  8174. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8175. EQ2Packet* app = packet2->serialize();
  8176. DumpPacket(app);
  8177. client->QueuePacket(app);
  8178. safe_delete(packet2);
  8179. }
  8180. }
  8181. else if (atoi(sep->arg[0]) == 14) {
  8182. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8183. if (packet2 && sep->IsSet(3)) {
  8184. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8185. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8186. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8187. packet2->setDataByName("text", "Welcome to Norrath, the world of EverQuest II. Left click on the help button at any time for more detailed help and information.");
  8188. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8189. packet2->setArrayLengthByName("num_goals", 1);
  8190. //packet2->setArrayDataByName("goal_text", )
  8191. packet2->setSubArrayLengthByName("num_tasks", 1);
  8192. packet2->setSubArrayDataByName("task_text", "continue");
  8193. packet2->setDataByName("complete_sound", "click");
  8194. packet2->setDataByName("signal", "introduction");
  8195. packet2->setDataByName("voice_key1", 0xcda65173);
  8196. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8197. EQ2Packet* app = packet2->serialize();
  8198. DumpPacket(app);
  8199. client->QueuePacket(app);
  8200. safe_delete(packet2);
  8201. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8202. packet2->setDataByName("window", "MainHUD.StartMenu");
  8203. packet2->setDataByName("show", 1);
  8204. app = packet2->serialize();
  8205. DumpPacket(app);
  8206. client->QueuePacket(app);
  8207. safe_delete(packet2);
  8208. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8209. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8210. packet2->setDataByName("flash_seconds", 10);
  8211. app = packet2->serialize();
  8212. DumpPacket(app);
  8213. client->QueuePacket(app);
  8214. safe_delete(packet2);
  8215. }
  8216. }
  8217. else if (atoi(sep->arg[0]) == 15) {
  8218. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8219. if (packet2) {
  8220. packet2->setArrayLengthByName("loot_count", 1);
  8221. packet2->setArrayDataByName("name", "Test");
  8222. packet2->setArrayDataByName("item_id", 1234);
  8223. packet2->setArrayDataByName("count", 1);
  8224. packet2->setArrayDataByName("icon", 258);
  8225. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8226. Spawn* spawn = client->GetPlayer()->GetTarget();
  8227. if (spawn)
  8228. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8229. packet2->setDataByName("unknown3", 1);
  8230. packet2->setDataByName("unknown4", 1);
  8231. packet2->setDataByName("unknown5", 60);
  8232. EQ2Packet* app = packet2->serialize();
  8233. DumpPacket(app);
  8234. client->QueuePacket(app);
  8235. safe_delete(packet2);
  8236. }
  8237. }
  8238. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8239. char blah[32];
  8240. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8241. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8242. }
  8243. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8244. if (sep->IsSet(2)) {
  8245. int16 offset = atoi(sep->arg[1]);
  8246. if (sep->IsNumber(2)) {
  8247. int32 value1 = atol(sep->arg[2]);
  8248. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8249. cout << "Sent" << endl;
  8250. }
  8251. }
  8252. }
  8253. else if (atoi(sep->arg[0]) == 18) {
  8254. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8255. if (packet2) {
  8256. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8257. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8258. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8259. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8260. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8261. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8262. Item* item = new Item(master_item_list.GetItem(36212));
  8263. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8264. item->stack_count = 20;
  8265. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8266. safe_delete(item);
  8267. item = new Item(master_item_list.GetItem(36685));
  8268. item->stack_count = 20;
  8269. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8270. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8271. safe_delete(item);
  8272. item = master_item_list.GetItem(1414);
  8273. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8274. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8275. item = master_item_list.GetItem(75057);
  8276. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8277. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8278. EQ2Packet* app = packet2->serialize();
  8279. if (sep->IsSet(2)) {
  8280. int16 offset = atoi(sep->arg[1]);
  8281. uchar* ptr2 = app->pBuffer;
  8282. ptr2 += offset;
  8283. if (sep->IsNumber(2)) {
  8284. int32 value1 = atol(sep->arg[2]);
  8285. if (value1 > 0xFFFF)
  8286. memcpy(ptr2, (uchar*)&value1, 4);
  8287. else if (value1 > 0xFF)
  8288. memcpy(ptr2, (uchar*)&value1, 2);
  8289. else
  8290. memcpy(ptr2, (uchar*)&value1, 1);
  8291. }
  8292. else {
  8293. int16 len = strlen(sep->arg[2]);
  8294. memcpy(ptr2, (uchar*)&len, 2);
  8295. ptr2 += 2;
  8296. memcpy(ptr2, sep->arg[2], len);
  8297. }
  8298. }
  8299. DumpPacket(app);
  8300. client->QueuePacket(app);
  8301. safe_delete(packet2);
  8302. }
  8303. }
  8304. else if (atoi(sep->arg[0]) == 19) {
  8305. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8306. Spawn* spawn = client->GetPlayer()->GetTarget();
  8307. if (packet2 && spawn) {
  8308. Item* item = master_item_list.GetItem(130053);
  8309. packet2->setArrayLengthByName("loot_count", 1);
  8310. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8311. packet2->setArrayDataByName("unknown2", 1);
  8312. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8313. packet2->setDataByName("display", 1);
  8314. packet2->setDataByName("unknown2b", 1);
  8315. packet2->setDataByName("unknown3", 0x3c);
  8316. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8317. packet2->PrintPacket();
  8318. EQ2Packet* app = packet2->serialize();
  8319. if (sep->IsSet(2)) {
  8320. int16 offset = atoi(sep->arg[1]);
  8321. int16 offset2 = 0;
  8322. int32 value1 = 0;
  8323. if (sep->IsSet(3)) {
  8324. offset2 = atoi(sep->arg[2]);
  8325. value1 = atol(sep->arg[3]);
  8326. }
  8327. else
  8328. value1 = atol(sep->arg[2]);
  8329. int16 offset3 = 0;
  8330. int16 offset4 = 0;
  8331. int32 value2 = 0;
  8332. if (sep->IsSet(6)) {
  8333. offset3 = atoi(sep->arg[4]);
  8334. offset4 = atoi(sep->arg[5]);
  8335. value2 = atol(sep->arg[6]);
  8336. }
  8337. offset--;
  8338. if (offset2 > 0 && offset2 >= offset) {
  8339. offset2--;
  8340. uchar* ptr2 = app->pBuffer;
  8341. ptr2 += offset;
  8342. for (int i = offset; i <= offset2; i++) {
  8343. if (value1 > 0xFFFF) {
  8344. memcpy(ptr2, (uchar*)&value1, 4);
  8345. i += 3;
  8346. ptr2 += 3;
  8347. }
  8348. else if (value1 > 0xFF) {
  8349. memcpy(ptr2, (uchar*)&value1, 2);
  8350. i++;
  8351. ptr2++;
  8352. }
  8353. else
  8354. memcpy(ptr2, (uchar*)&value1, 1);
  8355. ptr2++;
  8356. }
  8357. }
  8358. if (offset4 > 0 && offset4 >= offset3) {
  8359. offset3--;
  8360. offset4--;
  8361. uchar* ptr2 = app->pBuffer;
  8362. ptr2 += offset3;
  8363. for (int i = offset3; i <= offset4; i++) {
  8364. if (value2 > 0xFFFF) {
  8365. memcpy(ptr2, (uchar*)&value2, 4);
  8366. i += 3;
  8367. ptr2 += 3;
  8368. }
  8369. else if (value2 > 0xFF) {
  8370. memcpy(ptr2, (uchar*)&value2, 2);
  8371. i++;
  8372. ptr2++;
  8373. }
  8374. else
  8375. memcpy(ptr2, (uchar*)&value2, 1);
  8376. ptr2++;
  8377. }
  8378. }
  8379. }
  8380. DumpPacket(app);
  8381. client->QueuePacket(app);
  8382. safe_delete(packet2);
  8383. }
  8384. }
  8385. else if (atoi(sep->arg[0]) == 20) {
  8386. uchar blah[] = { 0x09,0x01,0x00,0x00,0xff,0xc9,0x01,0x03,0x00,0x4d,0xf0,0x00,0x00,0x01
  8387. ,0x00,0x00,0x00,0x4d,0xf0,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7
  8388. ,0x05,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8389. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x0a,0x8c,0x5a,0xf1,0xd2,0x8c,0x5a,0xf1
  8390. ,0xd2,0x01,0x01,0x00,0xff,0x1e,0x00,0x01,0x03,0x03,0x00,0x00,0x00,0x03,0x07
  8391. ,0x07,0x00,0x10,0x74,0x68,0x72,0x65,0x61,0x64,0x62,0x61,0x72,0x65,0x20,0x74,0x75
  8392. ,0x6e,0x69,0x63,0x00,0x00,0x4e,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4e,0xf0,0x00
  8393. ,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0a,0x00,0x01,0x60,0x00,0x00,0x00
  8394. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8395. ,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03
  8396. ,0x00,0x00,0x00,0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x09,0x73,0x6d,0x61,0x6c,0x6c
  8397. ,0x20,0x62,0x61,0x67,0x00,0x00,0x4f,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4f,0xf0
  8398. ,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x01,0x01,0x60,0x01,0x00
  8399. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8400. ,0x00,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00
  8401. ,0x03,0x00,0x00,0x00,0x00,0x00,0x0c,0x57,0x61,0x75,0x6c,0x6f,0x6e,0x27,0x73,0x20
  8402. ,0x48,0x61,0x74,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x0d,0x00
  8403. ,0x00,0x00 };
  8404. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, blah, sizeof(blah));
  8405. if (sep->IsSet(2)) {
  8406. int16 offset = atoi(sep->arg[1]);
  8407. uchar* ptr2 = app->pBuffer;
  8408. ptr2 += offset;
  8409. if (sep->IsNumber(2)) {
  8410. int32 value1 = atol(sep->arg[2]);
  8411. if (value1 > 0xFFFF)
  8412. memcpy(ptr2, (uchar*)&value1, 4);
  8413. else if (value1 > 0xFF)
  8414. memcpy(ptr2, (uchar*)&value1, 2);
  8415. else
  8416. memcpy(ptr2, (uchar*)&value1, 1);
  8417. }
  8418. else {
  8419. int16 len = strlen(sep->arg[2]);
  8420. memcpy(ptr2, (uchar*)&len, 2);
  8421. ptr2 += 2;
  8422. memcpy(ptr2, sep->arg[2], len);
  8423. }
  8424. }
  8425. DumpPacket(app);
  8426. client->QueuePacket(app);
  8427. }
  8428. }
  8429. else if (atoi(sep->arg[0]) == 21) {
  8430. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8431. if (packet2) {
  8432. packet2->setDataByName("unknown0", 255);
  8433. packet2->setDataByName("reward", "New Quest");
  8434. packet2->setDataByName("title", "Title");
  8435. packet2->setDataByName("description", "description");
  8436. packet2->setDataByName("quest_difficulty", 3);
  8437. packet2->setDataByName("unknown1", 5);
  8438. packet2->setDataByName("level", 3);
  8439. packet2->setDataByName("coin", 150);
  8440. packet2->setDataByName("status_points", 5);
  8441. packet2->setDataByName("exp_bonus", 10);
  8442. packet2->setArrayLengthByName("num_rewards", 1);
  8443. Item* item = new Item(master_item_list.GetItem(36212));
  8444. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8445. item->stack_count = 20;
  8446. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8447. safe_delete(item);
  8448. char accept[35] = { 0 };
  8449. char decline[35] = { 0 };
  8450. sprintf(accept, "q_accept_pending_quest %u", 0);
  8451. sprintf(decline, "q_deny_pending_quest %u", 0);
  8452. packet2->setDataByName("accept_command", accept);
  8453. packet2->setDataByName("decline_command", decline);
  8454. EQ2Packet* app = packet2->serialize();
  8455. if (sep->IsSet(2)) {
  8456. int16 offset = atoi(sep->arg[1]);
  8457. uchar* ptr2 = app->pBuffer;
  8458. ptr2 += offset;
  8459. if (sep->IsNumber(2)) {
  8460. int32 value1 = atol(sep->arg[2]);
  8461. if (value1 > 0xFFFF)
  8462. memcpy(ptr2, (uchar*)&value1, 4);
  8463. else if (value1 > 0xFF)
  8464. memcpy(ptr2, (uchar*)&value1, 2);
  8465. else
  8466. memcpy(ptr2, (uchar*)&value1, 1);
  8467. }
  8468. else {
  8469. int16 len = strlen(sep->arg[2]);
  8470. memcpy(ptr2, (uchar*)&len, 2);
  8471. ptr2 += 2;
  8472. memcpy(ptr2, sep->arg[2], len);
  8473. }
  8474. }
  8475. DumpPacket(app);
  8476. client->QueuePacket(app);
  8477. safe_delete(packet2);
  8478. }
  8479. }
  8480. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8481. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8482. if (packet2) {
  8483. packet2->setDataByName("unknown0", 255);
  8484. packet2->setDataByName("reward", "New Quest");
  8485. packet2->setDataByName("title", "Title");
  8486. packet2->setDataByName("description", "description");
  8487. packet2->setDataByName("quest_difficulty", 3);
  8488. packet2->setDataByName("unknown1", 5);
  8489. packet2->setDataByName("level", 3);
  8490. packet2->setDataByName("coin", 150);
  8491. packet2->setDataByName("status_points", 5);
  8492. packet2->setDataByName("exp_bonus", 10);
  8493. packet2->setArrayLengthByName("num_rewards", 1);
  8494. Item* item = new Item(master_item_list.GetItem(36212));
  8495. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8496. item->stack_count = 20;
  8497. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8498. safe_delete(item);
  8499. char accept[35] = { 0 };
  8500. char decline[35] = { 0 };
  8501. sprintf(accept, "q_accept_pending_quest %u", 0);
  8502. sprintf(decline, "q_deny_pending_quest %u", 0);
  8503. packet2->setDataByName("accept_command", accept);
  8504. packet2->setDataByName("decline_command", decline);
  8505. EQ2Packet* app = packet2->serialize();
  8506. if (sep->IsSet(2)) {
  8507. int16 offset = atoi(sep->arg[1]);
  8508. uchar* ptr2 = app->pBuffer;
  8509. ptr2 += offset;
  8510. if (sep->IsNumber(2)) {
  8511. int32 value1 = atol(sep->arg[2]);
  8512. if (value1 > 0xFFFF)
  8513. memcpy(ptr2, (uchar*)&value1, 4);
  8514. else if (value1 > 0xFF)
  8515. memcpy(ptr2, (uchar*)&value1, 2);
  8516. else
  8517. memcpy(ptr2, (uchar*)&value1, 1);
  8518. }
  8519. else {
  8520. int8 len = strlen(sep->arg[2]);
  8521. memcpy(ptr2, (uchar*)&len, 1);
  8522. ptr2 += 1;
  8523. memcpy(ptr2, sep->arg[2], len);
  8524. }
  8525. }
  8526. DumpPacket(app);
  8527. client->QueuePacket(app);
  8528. safe_delete(packet2);
  8529. }
  8530. }
  8531. else {
  8532. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8533. if (packet2) {
  8534. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8535. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8536. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8537. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8538. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8539. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8540. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8541. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8542. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8543. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8544. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8545. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8546. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8547. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8548. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8549. packet2->setSubstructDataByName("spell_info", "level", 19);
  8550. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8551. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8552. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8553. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8554. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8555. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8556. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8557. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8558. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8559. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8560. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8561. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8562. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8563. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8564. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8565. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8566. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8567. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8568. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8569. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8570. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8571. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8572. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8573. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8574. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8575. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8576. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8577. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8578. packet2->setArrayDataByName("reagent", "Alcohol");
  8579. packet2->setArrayDataByName("consumed", "123");
  8580. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8581. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8582. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8583. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8584. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8585. packet2->setSubstructDataByName("spell_info", "type", 2);
  8586. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8587. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8588. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8589. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8590. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8591. EQ2Packet* outapp = packet2->serialize();
  8592. DumpPacket(outapp);
  8593. client->QueuePacket(outapp);
  8594. safe_delete(packet2);
  8595. }
  8596. }
  8597. return;
  8598. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8599. if (!p) return;
  8600. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8601. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8602. //}
  8603. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8604. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8605. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8606. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8607. if (packet) {
  8608. client->QueuePacket(packet->serialize());
  8609. safe_delete(packet);
  8610. }
  8611. }*/
  8612. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8613. int32 numFaces = 0;
  8614. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8615. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8616. map<int32, vector<Face*> >::iterator itr;
  8617. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8618. numFaces += (*itr).second.size();
  8619. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8620. }*/
  8621. //uchar blah[] = {
  8622. // 1208 - OP_EQUpdateStoreCmd
  8623. // /*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
  8624. // /*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
  8625. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8626. // /*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
  8627. /*};
  8628. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8629. int8 val = 0;
  8630. int16 pos = 0;
  8631. int idx = 0;
  8632. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8633. pos = atoi(sep2->arg[idx]);
  8634. val = atoi(sep2->arg[idx+1]);
  8635. memset(blah+pos, val, 1);
  8636. idx+=2;
  8637. }
  8638. DumpPacket(blah, sizeof(blah));
  8639. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8640. if (client->GetPlayer()->GetTarget()) {
  8641. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8642. if (packet) {
  8643. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8644. packet->setDataByName("size", 0);
  8645. packet->setDataByName("unknown2", 0);
  8646. EQ2Packet* app = packet->serialize();
  8647. client->QueuePacket(app);
  8648. safe_delete(packet);
  8649. }
  8650. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8651. if (set_pov) {
  8652. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8653. EQ2Packet* app_pov = set_pov->serialize();
  8654. client->QueuePacket(app_pov);
  8655. safe_delete(set_pov);
  8656. }
  8657. }
  8658. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8659. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8660. if (packet) {
  8661. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8662. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8663. else
  8664. packet->setDataByName("Type", 2);
  8665. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8666. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8667. else
  8668. packet->setDataByName("race_id", 0);
  8669. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8670. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8671. else
  8672. packet->setDataByName("gender", 2);
  8673. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8674. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8675. else
  8676. packet->setDataByName("unknown", 0, 0);
  8677. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8678. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8679. else
  8680. packet->setDataByName("unknown", 0, 1);
  8681. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8682. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8683. else
  8684. packet->setDataByName("unknown", 0, 2);
  8685. client->QueuePacket(packet->serialize());
  8686. }
  8687. safe_delete(packet);
  8688. safe_delete(sep2);
  8689. }
  8690. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8691. const char *channel_name;
  8692. if (sep == NULL || !sep->IsSet(0)) {
  8693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8694. PrintSep(sep);
  8695. return;
  8696. }
  8697. channel_name = sep->arg[0];
  8698. if (!chat.IsInChannel(client, channel_name))
  8699. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8700. else if (!chat.LeaveChannel(client, channel_name))
  8701. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8702. }
  8703. /*
  8704. Function:
  8705. Purpose :
  8706. Params :
  8707. Dev :
  8708. Example :
  8709. */
  8710. void Commands::Command_WeaponStats(Client* client)
  8711. {
  8712. Player* player = client->GetPlayer();
  8713. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8714. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8715. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8716. client->SimpleMessage(0, "Primary:");
  8717. if (primary) {
  8718. client->Message(0, "Name: %s", primary->name.c_str());
  8719. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8720. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8721. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8722. client->Message(0, "Proc Percent: %d%%", 0);
  8723. client->Message(0, "Procs Per Minute: %d", 0);
  8724. }
  8725. else {
  8726. client->SimpleMessage(0, "Name: fist");
  8727. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8728. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8729. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8730. client->Message(0, "Proc Percent: %d%%", 0);
  8731. client->Message(0, "Procs Per Minute: %d", 0);
  8732. }
  8733. client->SimpleMessage(0, " ");
  8734. client->SimpleMessage(0, " ");
  8735. if (secondary) {
  8736. client->SimpleMessage(0, "Secondary:");
  8737. client->Message(0, "Name: %s", secondary->name.c_str());
  8738. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8739. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8740. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8741. client->Message(0, "Proc Percent: %d%%", 0);
  8742. client->Message(0, "Procs Per Minute: %d", 0);
  8743. client->SimpleMessage(0, " ");
  8744. client->SimpleMessage(0, " ");
  8745. }
  8746. client->SimpleMessage(0, "Ranged:");
  8747. if (ranged) {
  8748. client->Message(0, "Name: %s", ranged->name.c_str());
  8749. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8750. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8751. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8752. client->Message(0, "Proc Percent: %d%%", 0);
  8753. client->Message(0, "Procs Per Minute: %d", 0);
  8754. }
  8755. else
  8756. client->SimpleMessage(0, "None");
  8757. }
  8758. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8759. const char *channel_name;
  8760. if (sep == NULL || !sep->IsSet(0)) {
  8761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8762. return;
  8763. }
  8764. channel_name = sep->arg[0];
  8765. if (!chat.ChannelExists(channel_name))
  8766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8767. else
  8768. chat.SendChannelUserList(client, channel_name);
  8769. }
  8770. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8771. {
  8772. ZoneServer* zone = 0;
  8773. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8774. if (zone_id > 0)
  8775. {
  8776. zone = zone_list.Get(zone_id, false);
  8777. if (zone)
  8778. {
  8779. zone->SetSafeX(client->GetPlayer()->GetX());
  8780. zone->SetSafeY(client->GetPlayer()->GetY());
  8781. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8782. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8783. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8785. else
  8786. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8787. }
  8788. }
  8789. }
  8790. /*
  8791. Function:
  8792. Purpose :
  8793. Params :
  8794. Dev :
  8795. Example :
  8796. */
  8797. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8798. {
  8799. ZoneInfo* zone_info = new ZoneInfo;
  8800. if (sep && sep->arg[0])
  8801. {
  8802. if (sep->IsNumber(0))
  8803. zone_info->id = atoi(sep->arg[0]);
  8804. else
  8805. zone_info->id = database.GetZoneID(sep->arg[0]);
  8806. if (zone_info->id > 0)
  8807. {
  8808. database.LoadZoneInfo(zone_info);
  8809. 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);
  8810. 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);
  8811. 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);
  8812. 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);
  8813. 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);
  8814. 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);
  8815. 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);
  8816. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8817. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8818. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8819. }
  8820. else
  8821. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8822. }
  8823. else
  8824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8825. safe_delete(zone_info);
  8826. }
  8827. /*
  8828. Function:
  8829. Purpose :
  8830. Params :
  8831. Dev :
  8832. Example :
  8833. */
  8834. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8835. {
  8836. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8837. {
  8838. ZoneServer* zone = 0;
  8839. int32 zone_id = 0;
  8840. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8841. {
  8842. zone_id = atoi(sep->arg[0]);
  8843. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8844. }
  8845. else
  8846. {
  8847. zone_id = database.GetZoneID(sep->arg[0]);
  8848. if (zone_id > 0)
  8849. zone = zone_list.Get(sep->arg[0], false);
  8850. }
  8851. if (zone_id > 0)
  8852. {
  8853. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8854. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8855. else
  8856. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8857. }
  8858. else
  8859. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8860. }
  8861. else
  8862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8863. }
  8864. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8865. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8867. return;
  8868. }
  8869. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8870. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8871. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8872. }
  8873. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8874. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8876. return;
  8877. }
  8878. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8879. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8880. }
  8881. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8882. Spawn* spawn = client->GetPlayer()->GetTarget();
  8883. if(spawn) {
  8884. client->SetMerchantTransaction(spawn);
  8885. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8886. client->SendHailCommand(spawn);
  8887. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8888. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8889. client->SendBuyMerchantList(sell);
  8890. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8891. client->SendSellMerchantList(sell);
  8892. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8893. client->SendBuyBackList(sell);
  8894. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8895. if (packet) {
  8896. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8897. packet->setDataByName("type", 16);
  8898. EQ2Packet* outapp = packet->serialize();
  8899. if (outapp)
  8900. client->QueuePacket(outapp);
  8901. safe_delete(packet);
  8902. }
  8903. }
  8904. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8905. client->SendRepairList();
  8906. }
  8907. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8908. }
  8909. void Commands::Command_Weather(Client* client, Seperator* sep)
  8910. {
  8911. //PrintSep(sep, "Weather");
  8912. if( sep && sep->arg[0] )
  8913. {
  8914. ZoneServer* zsZone = client->GetCurrentZone();
  8915. const char* value = sep->arg[0];
  8916. // process single-param commands first
  8917. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8918. {
  8919. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8920. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8921. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8922. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  8923. }
  8924. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  8925. {
  8926. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8927. zsZone->ProcessWeather();
  8928. }
  8929. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  8930. {
  8931. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  8932. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  8933. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  8934. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  8935. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  8936. zsZone->SetWeatherPattern(1);
  8937. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  8938. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  8939. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  8940. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8941. zsZone->ProcessWeather();
  8942. }
  8943. // process commands with params
  8944. if( sep->arg[1] )
  8945. {
  8946. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  8947. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  8948. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  8949. zsZone->SetWeatherType(atoi(sep->arg[1]));
  8950. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  8951. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  8952. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  8953. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  8954. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  8955. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  8956. }
  8957. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  8958. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  8959. zsZone->SetRain(zsZone->GetCurrentWeather());
  8960. }
  8961. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  8962. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  8963. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  8964. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  8965. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8966. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  8967. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8968. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  8969. }
  8970. }
  8971. else
  8972. {
  8973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  8974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  8975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  8976. return;
  8977. }
  8978. }
  8979. void Commands::Command_Select(Client* client, Seperator* sep) {
  8980. if (sep && sep->arg[1]) {
  8981. Spawn* spawn = client->GetPlayer()->GetTarget();
  8982. if (spawn && strlen(sep->arg[1]) > 0)
  8983. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  8984. }
  8985. }
  8986. /*
  8987. Function: Command_ConsumeFood()
  8988. Purpose : Consume Food/Drink and apply mods
  8989. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  8990. Dev : Zcoretri
  8991. Example : /consume_food 22
  8992. */
  8993. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  8994. if (sep && sep->arg[0] && sep->IsNumber(0))
  8995. {
  8996. Player* player = client->GetPlayer();
  8997. int8 slot = atoi(sep->arg[0]);
  8998. Item* item = player->GetEquipmentList()->GetItem(slot);
  8999. if(item) {
  9000. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9001. if(item->GetItemScript() && lua_interface){
  9002. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9003. if (slot == 22)
  9004. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9005. else
  9006. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9007. }
  9008. }
  9009. if (item->details.count > 1) {
  9010. item->details.count -= 1;
  9011. item->save_needed = true;
  9012. }
  9013. else {
  9014. player->GetEquipmentList()->RemoveItem(slot, true);
  9015. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9016. }
  9017. client->GetPlayer()->SetCharSheetChanged(true);
  9018. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9019. }
  9020. }
  9021. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9022. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9023. if (atoi(sep->arg[0]) == 1) {
  9024. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9025. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9026. client->GetPlayer()->SetCharSheetChanged(true);
  9027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9028. }
  9029. else {
  9030. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9031. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9032. client->GetPlayer()->SetCharSheetChanged(true);
  9033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9034. }
  9035. }
  9036. else
  9037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9038. }
  9039. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9040. {
  9041. if(sep)
  9042. {
  9043. string data;
  9044. if(sep->arg[0]){
  9045. data = string(sep->arg[0]);
  9046. }
  9047. for(int i=1;i<sep->GetMaxArgNum();i++){
  9048. if(sep->arg[i])
  9049. data.append(" ").append(sep->arg[i]);
  9050. }
  9051. const char* target_name = 0;
  9052. int32 spawn_id = 0;
  9053. if(client->GetPlayer()->GetTarget())
  9054. {
  9055. target_name = client->GetPlayer()->GetTarget()->GetName();
  9056. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9057. }
  9058. else
  9059. target_name = "N/A";
  9060. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9061. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9063. else
  9064. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9065. }
  9066. }
  9067. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9068. PrintSep(sep, "Command_Attune_Inv");
  9069. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9070. // Get the item index from the first parameter
  9071. int16 index = atoi(sep->arg[0]);
  9072. // Check to see if this is a valid item index for the player, if not exit out of the function
  9073. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9074. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9075. return;
  9076. }
  9077. // Get the item
  9078. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9079. if(item) {
  9080. // Valid item lets check to make sure this item is attunable, if not return out
  9081. if (!item->CheckFlag(ATTUNEABLE)) {
  9082. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9083. return;
  9084. }
  9085. // Remove the attunable flag
  9086. item->generic_info.item_flags -= ATTUNEABLE;
  9087. // Set the attuned flag
  9088. item->generic_info.item_flags += ATTUNED;
  9089. // Flag this item for saving
  9090. item->save_needed = true;
  9091. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9092. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9093. EQ2Packet* outapp = 0;
  9094. for (int32 i=0;i<packets.size();i++) {
  9095. outapp = packets[i];
  9096. if(outapp)
  9097. client->QueuePacket(outapp);
  9098. }
  9099. }
  9100. }
  9101. }
  9102. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9103. PrintSep(sep, "Command_Reset_Zone_Timer");
  9104. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9105. int32 db_id = atoul(sep->arg[0]);
  9106. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9107. if (data) {
  9108. // TODO: add a check to timers to ensure it can be reset
  9109. // Delete the character from the instance
  9110. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9111. data->instance_id = 0;
  9112. // Update the success time and set to 0 so the player can enter it again
  9113. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9114. data->last_success_timestamp = 0;
  9115. }
  9116. }*/
  9117. }
  9118. void Commands::Command_Player(Client* client, Seperator* sep) {
  9119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9121. }
  9122. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9123. // /player coins add 10
  9124. // /player coins add plat 10
  9125. Player* player = client->GetPlayer();
  9126. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9127. player = (Player*)player->GetTarget();
  9128. if (sep && sep->arg[0] && sep->arg[1]) {
  9129. const char* action = sep->arg[0];
  9130. int64 value = 0;
  9131. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9132. if (sep->IsNumber(1)) {
  9133. value = atoi64(sep->arg[1]);
  9134. player->AddCoins(value);
  9135. if (client->GetPlayer() == player)
  9136. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9137. else {
  9138. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9139. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9140. }
  9141. return;
  9142. }
  9143. else if (sep->arg[2] && sep->IsNumber(2)) {
  9144. const char* type = sep->arg[1];
  9145. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9146. value = atoi64(sep->arg[2]);
  9147. }
  9148. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9149. value = atoi64(sep->arg[2]) * 100;
  9150. }
  9151. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9152. value = atoi64(sep->arg[2]) * 10000;
  9153. }
  9154. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9155. value = atoi64(sep->arg[2]) * 1000000;
  9156. }
  9157. player->AddCoins(value);
  9158. if (client->GetPlayer() == player)
  9159. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9160. else {
  9161. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9162. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9163. }
  9164. return;
  9165. }
  9166. }
  9167. }
  9168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9174. }
  9175. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9176. PrintSep(sep, "ACHIEVEMENT_ADD");
  9177. if (sep && sep->IsSet(0)) {
  9178. int32 spell_id = atoul(sep->arg[1]);
  9179. int8 spell_tier = 0;
  9180. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9181. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9182. // addspellbookentry here
  9183. if (spell_tier >= data->maxRank) {
  9184. return;
  9185. }
  9186. if (!spell_tier) {
  9187. spell_tier = 1;
  9188. }
  9189. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9190. {
  9191. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9192. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9193. client->GetPlayer()->UnlockSpell(spell);
  9194. client->SendSpellUpdate(spell);
  9195. }
  9196. else
  9197. {
  9198. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9199. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9200. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9201. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9202. client->GetPlayer()->UnlockSpell(spell);
  9203. client->SendSpellUpdate(spell);
  9204. }
  9205. // cast spell here
  9206. if (!spell_tier)
  9207. spell_tier = 1;
  9208. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9209. if (spell) {
  9210. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9211. }
  9212. }
  9213. else {
  9214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9215. }
  9216. master_aa_list.DisplayAA(client, 0, 0);
  9217. }
  9218. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9219. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9220. if (packet) {
  9221. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9222. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9223. char command[255];
  9224. url = "browser " + url;
  9225. int32 spawn_id = 0;
  9226. int32 zone_id = 0;
  9227. string type;
  9228. if (client->GetCurrentZone())
  9229. zone_id = client->GetCurrentZone()->GetZoneID();
  9230. if (client->GetPlayer()->GetTarget()) {
  9231. Spawn* target = client->GetPlayer()->GetTarget();
  9232. if (target->IsWidget())
  9233. type = "widgets";
  9234. else if (target->IsSign())
  9235. type = "signs";
  9236. else if (target->IsObject())
  9237. type = "objects";
  9238. else if (target->IsNPC())
  9239. type = "npcs";
  9240. else if (target->IsGroundSpawn())
  9241. type = "ground";
  9242. else
  9243. type = "spawn";
  9244. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9245. }
  9246. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9247. packet->setDataByName("accept_command", command);
  9248. }
  9249. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9250. char command[255];
  9251. url = "browser " + url;
  9252. if (client->GetPlayer()->GetTarget())
  9253. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9254. packet->setDataByName("accept_command", command);
  9255. }
  9256. else {
  9257. string command = "browser " + url;
  9258. packet->setDataByName("accept_command", command.c_str());
  9259. }
  9260. packet->setDataByName("text", "Open the web editor?");
  9261. packet->setDataByName("accept_text", "Open");
  9262. packet->setDataByName("cancel_text", "Cancel");
  9263. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9264. packet->setDataByName("unknown2", 50);
  9265. packet->setDataByName("unknown4", 1);
  9266. client->QueuePacket(packet->serialize());
  9267. safe_delete(packet);
  9268. }
  9269. }
  9270. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9271. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9272. return;
  9273. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9274. if(client->GetCurrentRez()->active)
  9275. client->AcceptResurrection();
  9276. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9277. }
  9278. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9279. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9280. return;
  9281. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9282. if(client->GetCurrentRez()->active)
  9283. client->GetCurrentRez()->should_delete = true;
  9284. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9285. }
  9286. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9287. PrintSep(sep, "Switch_AA_Profile");
  9288. if (sep && sep->IsSet(0)) {
  9289. string type = sep->arg[0];
  9290. int8 newtemplate = atoul(sep->arg[1]);
  9291. master_aa_list.DisplayAA(client, newtemplate, 1);
  9292. }
  9293. }
  9294. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9295. PrintSep(sep, "Get_AA_Xml");
  9296. if (sep && sep->IsSet(0)) {
  9297. string tabnum = sep->arg[0];
  9298. string spellid = sep->arg[1];
  9299. }
  9300. }
  9301. void Commands::Add_AA(Client* client, Seperator* sep) {
  9302. PrintSep(sep, "Add_AA");
  9303. if (sep && sep->IsSet(0)) {
  9304. int32 spell_id = atoul(sep->arg[1]);
  9305. int8 spell_tier = 0;
  9306. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9307. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9308. // addspellbookentry here
  9309. if (spell_tier >= data->maxRank) {
  9310. return;
  9311. }
  9312. if (!spell_tier) {
  9313. spell_tier = 1;
  9314. }
  9315. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9316. {
  9317. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9318. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9319. client->GetPlayer()->UnlockSpell(spell);
  9320. client->SendSpellUpdate(spell);
  9321. }
  9322. else
  9323. {
  9324. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9325. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9326. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9327. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9328. client->GetPlayer()->UnlockSpell(spell);
  9329. client->SendSpellUpdate(spell);
  9330. }
  9331. // cast spell here
  9332. if (!spell_tier)
  9333. spell_tier = 1;
  9334. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9335. if (spell) {
  9336. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9337. }
  9338. }
  9339. else {
  9340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9341. }
  9342. master_aa_list.DisplayAA(client, 0, 0);
  9343. }
  9344. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9345. PrintSep(sep, "Commit_AA_Profile");
  9346. if (sep && sep->IsSet(0)) {
  9347. }
  9348. }
  9349. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9350. PrintSep(sep, "Begin_AA_Profile");
  9351. if (sep && sep->IsSet(0)) {
  9352. master_aa_list.DisplayAA(client, 100, 2);
  9353. }
  9354. }
  9355. void Commands::Back_AA(Client* client, Seperator* sep) {
  9356. if (sep && sep->IsSet(0)) {
  9357. PrintSep(sep, "Back_AA");
  9358. }
  9359. }
  9360. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9361. if (sep && sep->IsSet(0)) {
  9362. PrintSep(sep, "Remove_AA");
  9363. }
  9364. }
  9365. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9366. MasterAAList master_aa_list;
  9367. PrintSep(sep, "Cancel_AA_Profile");
  9368. master_aa_list.DisplayAA(client, 0, 0);
  9369. }
  9370. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9371. if (sep && sep->IsSet(0)) {
  9372. PrintSep(sep, "Save_AA_Profile");
  9373. }
  9374. }
  9375. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9376. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9377. if (!sep->IsNumber(0)) return;
  9378. int32 request_id = atoul(sep->arg[0]);
  9379. if (!sep->IsNumber(1)) return;
  9380. sint32 item_id = atoi(sep->arg[1]);
  9381. if (client->IsCurrentTransmuteID(request_id)) {
  9382. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9383. }
  9384. else if (client->IsCurrentTransmuteID(item_id)) {
  9385. if (!sep->IsSet(2)) return;
  9386. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9387. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9388. }
  9389. }
  9390. }