Commands.cpp 322 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  146. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  147. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  148. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  149. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  150. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  151. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  152. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  153. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  154. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  155. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  156. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  157. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  158. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  159. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  160. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  161. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  162. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  163. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  164. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  165. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  166. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  167. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  168. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  169. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  170. }
  171. Commands::~Commands() {
  172. safe_delete(remote_commands);
  173. }
  174. int32 Commands::GetSpawnSetType(string val){
  175. if(spawn_set_values.count(val) > 0)
  176. return spawn_set_values[val];
  177. return 0xFFFFFFFF;
  178. }
  179. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  180. if(!target)
  181. return false;
  182. int32 val = 0;
  183. try{
  184. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG))
  185. val = atoul(value);
  186. }
  187. catch(...){
  188. if(client)
  189. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  190. return false;
  191. }
  192. if(temporary && temp_value){
  193. char tmp[128] = {0};
  194. switch(type){
  195. case SPAWN_SET_VALUE_NAME:{
  196. sprintf(tmp, "%s", target->GetName());
  197. target->SetName(value);
  198. client->GetCurrentZone()->SendUpdateTitles(target);
  199. break;
  200. }
  201. case SPAWN_SET_VALUE_X_OFFSET:
  202. {
  203. sprintf(tmp, "%f", target->GetXOffset());
  204. target->SetXOffset(float(val));
  205. break;
  206. }
  207. case SPAWN_SET_VALUE_Y_OFFSET:
  208. {
  209. sprintf(tmp, "%f", target->GetYOffset());
  210. target->SetYOffset(float(val));
  211. break;
  212. }
  213. case SPAWN_SET_VALUE_Z_OFFSET:
  214. {
  215. sprintf(tmp, "%f", target->GetZOffset());
  216. target->SetZOffset(float(val));
  217. break;
  218. }
  219. case SPAWN_SET_VALUE_EXPIRE: {
  220. sprintf(tmp, "%u", target->GetExpireTime());
  221. target->SetExpireTime(val);
  222. break;
  223. }
  224. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  225. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  226. target->SetExpireOffsetTime(val);
  227. break;
  228. }
  229. case SPAWN_SET_VALUE_SUB_TITLE: {
  230. sprintf(tmp, "%s", target->GetSubTitle());
  231. target->SetSubTitle(value);
  232. client->GetCurrentZone()->SendUpdateTitles(target);
  233. break;
  234. }
  235. case SPAWN_SET_VALUE_LEVEL:{
  236. sprintf(tmp, "%i", target->GetLevel());
  237. target->SetLevel(val, send_update);
  238. break;
  239. }
  240. case SPAWN_SET_VALUE_DIFFICULTY:{
  241. sprintf(tmp, "%i", target->GetEncounterLevel());
  242. target->SetEncounterLevel(val, send_update);
  243. break;
  244. }
  245. case SPAWN_SET_VALUE_MODEL_TYPE:{
  246. sprintf(tmp, "%i", target->GetModelType());
  247. target->SetModelType(val, send_update);
  248. break;
  249. }
  250. case SPAWN_SET_VALUE_CLASS:{
  251. sprintf(tmp, "%i", target->GetAdventureClass());
  252. target->SetAdventureClass(val, send_update);
  253. break;
  254. }
  255. case SPAWN_SET_VALUE_GENDER:{
  256. sprintf(tmp, "%i", target->GetGender());
  257. target->SetGender(val, send_update);
  258. break;
  259. }
  260. case SPAWN_SET_VALUE_SHOW_NAME:{
  261. sprintf(tmp, "%i", target->GetShowName());
  262. target->SetShowName(val, send_update);
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_ATTACKABLE:{
  266. sprintf(tmp, "%i", target->GetAttackable());
  267. target->SetAttackable(val, send_update);
  268. break;
  269. }
  270. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  271. sprintf(tmp, "%i", target->GetShowLevel());
  272. target->SetShowLevel(val, send_update);
  273. break;
  274. }
  275. case SPAWN_SET_VALUE_TARGETABLE:{
  276. sprintf(tmp, "%i", target->GetTargetable());
  277. target->SetTargetable(val, send_update);
  278. break;
  279. }
  280. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  281. sprintf(tmp, "%i", target->GetShowCommandIcon());
  282. target->SetShowCommandIcon(val, send_update);
  283. break;
  284. }
  285. case SPAWN_SET_VALUE_HAND_ICON:{
  286. sprintf(tmp, "%i", target->GetShowHandIcon());
  287. target->SetShowHandIcon(val, send_update);
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_HAIR_TYPE:{
  291. if(target->IsEntity()){
  292. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  293. ((Entity*)target)->SetHairType(val, send_update);
  294. }
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  298. if(target->IsEntity()){
  299. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  300. ((Entity*)target)->SetHairType(val, send_update);
  301. }
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_WING_TYPE:{
  305. if(target->IsEntity()){
  306. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  307. ((Entity*)target)->SetWingType(val, send_update);
  308. }
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_CHEST_TYPE:{
  312. if(target->IsEntity()){
  313. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  314. ((Entity*)target)->SetChestType(val, send_update);
  315. }
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_LEGS_TYPE:{
  319. if(target->IsEntity()){
  320. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  321. ((Entity*)target)->SetLegsType(val, send_update);
  322. }
  323. break;
  324. }
  325. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  326. if(target->IsEntity()){
  327. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  328. ((Entity*)target)->SetSogaHairType(val, send_update);
  329. }
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  333. if(target->IsEntity()){
  334. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  335. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  336. }
  337. break;
  338. }
  339. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  340. sprintf(tmp, "%i", target->GetSogaModelType());
  341. target->SetSogaModelType(val, send_update);
  342. break;
  343. }
  344. case SPAWN_SET_VALUE_SIZE:{
  345. sprintf(tmp, "%i", target->GetSize());
  346. target->SetSize(val, send_update);
  347. break;
  348. }
  349. case SPAWN_SET_VALUE_HP:{
  350. sprintf(tmp, "%i", target->GetHP());
  351. target->SetHP(val, send_update);
  352. break;
  353. }
  354. case SPAWN_SET_VALUE_POWER:{
  355. sprintf(tmp, "%i", target->GetPower());
  356. target->SetPower(val, send_update);
  357. break;
  358. }
  359. case SPAWN_SET_VALUE_HEROIC:{
  360. sprintf(tmp, "%i", target->GetHeroic());
  361. target->SetHeroic(val, send_update);
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_RESPAWN:{
  365. sprintf(tmp, "%u", target->GetRespawnTime());
  366. target->SetRespawnTime(val);
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_X:{
  370. sprintf(tmp, "%f", target->GetX());
  371. target->SetX(atof(value), send_update);
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_Y:{
  375. sprintf(tmp, "%f", target->GetY());
  376. target->SetY(atof(value), send_update);
  377. break;
  378. }
  379. case SPAWN_SET_VALUE_Z:{
  380. sprintf(tmp, "%f", target->GetZ());
  381. target->SetZ(atof(value), send_update);
  382. break;
  383. }
  384. case SPAWN_SET_VALUE_HEADING:{
  385. sprintf(tmp, "%f", target->GetHeading());
  386. target->SetHeading(atof(value) + 360, send_update);
  387. break;
  388. }
  389. case SPAWN_SET_VALUE_VISUAL_STATE:{
  390. sprintf(tmp, "%i", target->GetVisualState());
  391. target->SetVisualState(val, send_update);
  392. break;
  393. }
  394. case SPAWN_SET_VALUE_ACTION_STATE:{
  395. sprintf(tmp, "%i", target->GetActionState());
  396. target->SetActionState(val, send_update);
  397. break;
  398. }
  399. case SPAWN_SET_VALUE_MOOD_STATE:{
  400. sprintf(tmp, "%i", target->GetMoodState());
  401. target->SetMoodState(val, send_update);
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_INITIAL_STATE:{
  405. sprintf(tmp, "%i", target->GetInitialState());
  406. target->SetInitialState(val, send_update);
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  410. sprintf(tmp, "%i", target->GetActivityStatus());
  411. target->SetActivityStatus(val, send_update);
  412. break;
  413. }
  414. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  415. sprintf(tmp, "%i", target->GetCollisionRadius());
  416. target->SetCollisionRadius(val, send_update);
  417. break;
  418. }
  419. case SPAWN_SET_VALUE_DEVICE_ID: {
  420. if (target->IsObject()) {
  421. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  422. ((Object*)target)->SetDeviceID(val);
  423. }
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_PITCH: {
  427. sprintf(tmp, "%f", target->GetPitch());
  428. target->SetPitch(atof(value), send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_ROLL: {
  432. sprintf(tmp, "%f", target->GetRoll());
  433. target->SetRoll(atof(value), send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HIDE_HOOD: {
  437. sprintf(tmp, "%i", target->appearance.hide_hood);
  438. target->SetHideHood(val);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_EMOTE_STATE: {
  442. sprintf(tmp, "%i", target->appearance.emote_state);
  443. target->SetEmoteState(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_ICON: {
  447. sprintf(tmp, "%i", target->GetIconValue());
  448. target->SetIcon(val);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_PREFIX: {
  452. sprintf(tmp, "%s", target->GetPrefixTitle());
  453. target->SetPrefixTitle(value);
  454. client->GetCurrentZone()->SendUpdateTitles(target);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_SUFFIX: {
  458. sprintf(tmp, "%s", target->GetSuffixTitle());
  459. target->SetSuffixTitle(value);
  460. client->GetCurrentZone()->SendUpdateTitles(target);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_LASTNAME: {
  464. sprintf(tmp, "%s", target->GetLastName());
  465. target->SetLastName(value);
  466. client->GetCurrentZone()->SendUpdateTitles(target);
  467. break;
  468. }
  469. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  470. // nothing to do must reload spawns
  471. break;
  472. }
  473. *temp_value = string(tmp);
  474. }
  475. }
  476. else{
  477. switch(type){
  478. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  479. if (target->GetDatabaseID() > 0)
  480. {
  481. char query[256];
  482. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  483. if (database.RunQuery(query, strnlen(query, 256)))
  484. {
  485. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  486. }
  487. }
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_NAME:{
  491. target->SetName(value);
  492. client->GetCurrentZone()->SendUpdateTitles(target);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_SUB_TITLE: {
  496. target->SetSubTitle(value);
  497. client->GetCurrentZone()->SendUpdateTitles(target);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_X_OFFSET:
  501. {
  502. target->SetXOffset(atof(value));
  503. break;
  504. }
  505. case SPAWN_SET_VALUE_Y_OFFSET:
  506. {
  507. target->SetYOffset(atof(value));
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_Z_OFFSET:
  511. {
  512. target->SetZOffset(atof(value));
  513. break;
  514. }
  515. case SPAWN_SET_VALUE_EXPIRE: {
  516. target->SetExpireTime(val);
  517. break;
  518. }
  519. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  520. target->SetExpireOffsetTime(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_LEVEL:{
  524. target->SetLevel(val, send_update);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_DIFFICULTY:{
  528. target->SetEncounterLevel(val, send_update);
  529. break;
  530. }
  531. case SPAWN_SET_VALUE_MODEL_TYPE:{
  532. target->SetModelType(val, send_update);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_CLASS:{
  536. target->SetAdventureClass(val, send_update);
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_GENDER:{
  540. target->SetGender(val, send_update);
  541. break;
  542. }
  543. case SPAWN_SET_VALUE_SHOW_NAME:{
  544. target->SetShowName(val, send_update);
  545. break;
  546. }
  547. case SPAWN_SET_VALUE_ATTACKABLE:{
  548. target->SetAttackable(val, send_update);
  549. break;
  550. }
  551. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  552. target->SetShowLevel(val, send_update);
  553. break;
  554. }
  555. case SPAWN_SET_VALUE_TARGETABLE:{
  556. target->SetTargetable(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  560. target->SetShowCommandIcon(val, send_update);
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_HAND_ICON:{
  564. target->SetShowHandIcon(val, send_update);
  565. break;
  566. }
  567. case SPAWN_SET_VALUE_HAIR_TYPE:{
  568. if(target->IsEntity())
  569. ((Entity*)target)->SetHairType(val, send_update);
  570. break;
  571. }
  572. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  573. if(target->IsEntity())
  574. ((Entity*)target)->SetHairType(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_WING_TYPE:{
  578. if(target->IsEntity())
  579. ((Entity*)target)->SetWingType(val, send_update);
  580. break;
  581. }
  582. case SPAWN_SET_VALUE_CHEST_TYPE:{
  583. if(target->IsEntity())
  584. ((Entity*)target)->SetChestType(val, send_update);
  585. break;
  586. }
  587. case SPAWN_SET_VALUE_LEGS_TYPE:{
  588. if(target->IsEntity())
  589. ((Entity*)target)->SetLegsType(val, send_update);
  590. break;
  591. }
  592. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  593. if(target->IsEntity())
  594. ((Entity*)target)->SetSogaHairType(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  598. if(target->IsEntity())
  599. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  600. break;
  601. }
  602. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  603. target->SetSogaModelType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_SIZE:{
  607. target->SetSize(val, send_update);
  608. break;
  609. }
  610. case SPAWN_SET_VALUE_HP:{
  611. target->SetHP(val, send_update);
  612. break;
  613. }
  614. case SPAWN_SET_VALUE_POWER:{
  615. target->SetPower(val, send_update);
  616. break;
  617. }
  618. case SPAWN_SET_VALUE_HEROIC:{
  619. target->SetHeroic(val, send_update);
  620. break;
  621. }
  622. case SPAWN_SET_VALUE_RESPAWN:{
  623. target->SetRespawnTime(val);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_X:{
  627. target->SetX(atof(value), send_update);
  628. target->SetSpawnOrigX(target->GetX());
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_Y:{
  632. target->SetY(atof(value), send_update);
  633. target->SetSpawnOrigY(target->GetY());
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_Z:{
  637. target->SetZ(atof(value), send_update);
  638. target->SetSpawnOrigZ(target->GetZ());
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_HEADING:{
  642. target->SetHeading(atof(value), send_update);
  643. target->SetSpawnOrigHeading(target->GetHeading());
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  647. ZoneServer* zone = target->GetZone();
  648. if (!zone)
  649. zone = client->GetCurrentZone();
  650. if(zone->GetEntityCommandList(val))
  651. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  652. target->primary_command_list_id = val;
  653. break;
  654. }
  655. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  656. ZoneServer* zone = target->GetZone();
  657. if (!zone)
  658. zone = client->GetCurrentZone();
  659. if (zone->GetEntityCommandList(val))
  660. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  661. target->secondary_command_list_id = val;
  662. break;
  663. }
  664. case SPAWN_SET_VALUE_VISUAL_STATE:{
  665. target->SetVisualState(val, send_update);
  666. break;
  667. }
  668. case SPAWN_SET_VALUE_ACTION_STATE:{
  669. target->SetActionState(val, send_update);
  670. break;
  671. }
  672. case SPAWN_SET_VALUE_MOOD_STATE:{
  673. target->SetMoodState(val, send_update);
  674. break;
  675. }
  676. case SPAWN_SET_VALUE_INITIAL_STATE:{
  677. target->SetInitialState(val, send_update);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  681. target->SetActivityStatus(val, send_update);
  682. break;
  683. }
  684. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  685. target->SetCollisionRadius(val, send_update);
  686. break;
  687. }
  688. case SPAWN_SET_VALUE_FACTION:{
  689. ZoneServer* zone = target->GetZone();
  690. if (!zone)
  691. zone = client->GetCurrentZone();
  692. target->faction_id = val;
  693. zone->RemoveDeadEnemyList(target);
  694. if(target->IsNPC())
  695. zone->AddEnemyList((NPC*)target);
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_DEVICE_ID:{
  699. if (target->IsObject())
  700. ((Object*)target)->SetDeviceID(val);
  701. break;
  702. }
  703. case SPAWN_SET_VALUE_PITCH: {
  704. target->SetPitch(atof(value), send_update);
  705. target->SetSpawnOrigPitch(atof(value));
  706. break;
  707. }
  708. case SPAWN_SET_VALUE_ROLL: {
  709. target->SetRoll(atof(value), send_update);
  710. target->SetSpawnOrigRoll(atof(value));
  711. break;
  712. }
  713. case SPAWN_SET_VALUE_HIDE_HOOD: {
  714. target->SetHideHood(val);
  715. break;
  716. }
  717. case SPAWN_SET_VALUE_EMOTE_STATE: {
  718. target->SetEmoteState(val);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_ICON: {
  722. target->SetIcon(val);
  723. break;
  724. }
  725. case SPAWN_SET_VALUE_PREFIX: {
  726. target->SetPrefixTitle(value);
  727. client->GetCurrentZone()->SendUpdateTitles(target);
  728. break;
  729. }
  730. case SPAWN_SET_VALUE_SUFFIX: {
  731. target->SetSuffixTitle(value);
  732. client->GetCurrentZone()->SendUpdateTitles(target);
  733. break;
  734. }
  735. case SPAWN_SET_VALUE_LASTNAME: {
  736. target->SetLastName(value);
  737. client->GetCurrentZone()->SendUpdateTitles(target);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  741. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  742. if(client){
  743. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  744. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  745. }
  746. return false;
  747. }
  748. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  749. return false;
  750. else{
  751. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  752. target->SetSpawnScript(value);
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  757. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  758. if(client){
  759. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  760. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  761. }
  762. return false;
  763. }
  764. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  765. return false;
  766. else{
  767. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  768. target->SetSpawnScript(value);
  769. }
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  773. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  774. if(client){
  775. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  776. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  777. }
  778. return false;
  779. }
  780. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  781. return false;
  782. else
  783. target->SetSpawnScript(value);
  784. break;
  785. }
  786. }
  787. }
  788. return true;
  789. }
  790. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  791. the database fields always and also update the zone in memory if it's running. */
  792. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  793. if (client && zone_id > 0 && type > 0 && value) {
  794. sint32 int_value = 0;
  795. float float_value = 0;
  796. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  797. try {
  798. float_value = atof(value);
  799. }
  800. catch (...) {
  801. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  802. return false;
  803. }
  804. }
  805. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  806. try {
  807. int_value = atoi(value);
  808. }
  809. catch (...) {
  810. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  811. return false;
  812. }
  813. }
  814. switch (type) {
  815. case ZONE_SET_VALUE_EXPANSION_ID: {
  816. break;
  817. }
  818. case ZONE_SET_VALUE_NAME: {
  819. if (zone)
  820. zone->SetZoneName(const_cast<char*>(value));
  821. database.SaveZoneInfo(zone_id, "name", value);
  822. break;
  823. }
  824. case ZONE_SET_VALUE_FILE: {
  825. if (zone)
  826. zone->SetZoneFile(const_cast<char*>(value));
  827. database.SaveZoneInfo(zone_id, "file", value);
  828. break;
  829. }
  830. case ZONE_SET_VALUE_DESCRIPTION: {
  831. if (zone)
  832. zone->SetZoneDescription(const_cast<char*>(value));
  833. database.SaveZoneInfo(zone_id, "description", value);
  834. break;
  835. }
  836. case ZONE_SET_VALUE_SAFE_X: {
  837. if (zone)
  838. zone->SetSafeX(float_value);
  839. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  840. break;
  841. }
  842. case ZONE_SET_VALUE_SAFE_Y: {
  843. if (zone)
  844. zone->SetSafeY(float_value);
  845. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  846. break;
  847. }
  848. case ZONE_SET_VALUE_SAFE_Z: {
  849. if (zone)
  850. zone->SetSafeZ(float_value);
  851. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  852. break;
  853. }
  854. case ZONE_SET_VALUE_UNDERWORLD: {
  855. if (zone)
  856. zone->SetUnderWorld(float_value);
  857. database.SaveZoneInfo(zone_id, "underworld", float_value);
  858. break;
  859. }
  860. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  861. break;
  862. }
  863. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  864. break;
  865. }
  866. case ZONE_SET_VALUE_ZONE_TYPE: {
  867. break;
  868. }
  869. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  870. if (zone)
  871. zone->SetAlwaysLoaded(int_value == 1);
  872. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  873. break;
  874. }
  875. case ZONE_SET_VALUE_CITY_ZONE: {
  876. if (zone)
  877. zone->SetCityZone(int_value == 1);
  878. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  879. break;
  880. }
  881. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  882. if (zone)
  883. zone->SetWeatherAllowed(int_value == 1);
  884. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  885. break;
  886. }
  887. case ZONE_SET_VALUE_MIN_STATUS: {
  888. if (zone)
  889. zone->SetMinimumStatus(int_value);
  890. database.SaveZoneInfo(zone_id, "min_status", int_value);
  891. break;
  892. }
  893. case ZONE_SET_VALUE_MIN_LEVEL: {
  894. if (zone)
  895. zone->SetMinimumLevel(int_value);
  896. database.SaveZoneInfo(zone_id, "min_level", int_value);
  897. break;
  898. }
  899. case ZONE_SET_VALUE_MAX_LEVEL: {
  900. if (zone)
  901. zone->SetMaximumLevel(int_value);
  902. database.SaveZoneInfo(zone_id, "max_level", int_value);
  903. break;
  904. }
  905. case ZONE_SET_VALUE_START_ZONE: {
  906. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  910. if (zone)
  911. zone->SetInstanceType(int_value);
  912. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  916. if (zone)
  917. zone->SetDefaultReenterTime(int_value);
  918. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  922. if (zone)
  923. zone->SetDefaultResetTime(int_value);
  924. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  928. if (zone)
  929. zone->SetDefaultLockoutTime(int_value);
  930. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  934. if (zone)
  935. zone->SetForceGroupZoneOption(int_value);
  936. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_LUA_SCRIPT: {
  940. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  941. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  942. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  943. return false;
  944. }
  945. else {
  946. world.AddZoneScript(zone_id, const_cast<char*>(value));
  947. database.SaveZoneInfo(zone_id, "lua_script", value);
  948. }
  949. break;
  950. }
  951. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  952. if (zone)
  953. zone->SetShutdownTimer(int_value);
  954. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  955. break;
  956. }
  957. case ZONE_SET_VALUE_ZONE_MOTD: {
  958. if (zone)
  959. zone->SetZoneMOTD(string(value));
  960. database.SaveZoneInfo(zone_id, "zone_motd", value);
  961. break;
  962. }
  963. default: {
  964. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  965. return false;
  966. }
  967. }
  968. }
  969. else {
  970. if (client)
  971. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  972. return false;
  973. }
  974. return true;
  975. }
  976. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  977. if (index >= remote_commands->commands.size()) {
  978. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  979. return;
  980. }
  981. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  982. EQ2_RemoteCommandString* parent_command = 0;
  983. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  984. Seperator* sep = 0;
  985. if (command_parms->size > 0) {
  986. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  987. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  988. parent_command = command;
  989. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  990. safe_delete(sep);
  991. if (command_parms->data.length() > (command->command.data.length() + 1))
  992. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  993. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  994. }
  995. else
  996. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  997. }
  998. int ndx = 0;
  999. if (command->required_status > client->GetAdminStatus())
  1000. {
  1001. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1002. safe_delete(sep);
  1003. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1004. return;
  1005. }
  1006. Player* player = client->GetPlayer();
  1007. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1008. switch (command->handler) {
  1009. case COMMAND_RELOAD: {
  1010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1012. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1025. break;
  1026. }
  1027. case COMMAND_RELOADSTRUCTS: {
  1028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1029. configReader.ReloadStructs();
  1030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1031. break;
  1032. }
  1033. case COMMAND_RELOAD_QUESTS: {
  1034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1035. master_quest_list.Reload();
  1036. client_list.ReloadQuests();
  1037. zone_list.ReloadClientQuests();
  1038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1039. break;
  1040. }
  1041. case COMMAND_RELOAD_SPAWNS: {
  1042. client->GetCurrentZone()->ReloadSpawns();
  1043. break;
  1044. }
  1045. case COMMAND_RELOAD_SPELLS: {
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1047. zone_list.DeleteSpellProcess();
  1048. master_spell_list.Reload();
  1049. if (lua_interface)
  1050. lua_interface->ReloadSpells();
  1051. zone_list.LoadSpellProcess();
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1053. break;
  1054. }
  1055. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1057. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1058. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1060. break;
  1061. }
  1062. case COMMAND_RELOAD_ZONESCRIPTS: {
  1063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1064. world.ResetZoneScripts();
  1065. database.LoadZoneScriptData();
  1066. if (lua_interface)
  1067. lua_interface->DestroyZoneScripts();
  1068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1069. break;
  1070. }
  1071. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1073. client->GetCurrentZone()->ClearEntityCommands();
  1074. database.LoadEntityCommands(client->GetCurrentZone());
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1076. break;
  1077. }
  1078. case COMMAND_RELOAD_FACTIONS: {
  1079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1080. master_faction_list.Clear();
  1081. database.LoadFactionList();
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1083. break;
  1084. }
  1085. case COMMAND_RELOAD_MAIL: {
  1086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1087. zone_list.ReloadMail();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GUILDS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1093. world.ReloadGuilds();
  1094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1095. break;
  1096. }
  1097. case COMMAND_RELOAD_LOCATIONS: {
  1098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1099. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1100. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1102. break;
  1103. }
  1104. case COMMAND_READ: {
  1105. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1106. if (strcmp(sep->arg[0], "read") == 0) {
  1107. int32 item_index = atol(sep->arg[1]);
  1108. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1109. if (item) {
  1110. Spawn* spawn = cmdTarget;
  1111. int8 numpages = item->book_pages.size();
  1112. string page1 = string(item->book_pages[0]->page_text.data);
  1113. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1114. string title = item->name;
  1115. if (packet) {
  1116. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1117. packet->setDataByName("book_title", title.c_str());
  1118. packet->setDataByName("book_type", "simple");
  1119. packet->setDataByName("unknown2", 1);
  1120. packet->setDataByName("unknown5", 1, 4);
  1121. packet->setArrayLengthByName("num_pages", numpages);
  1122. for (int8 pages = 1; pages <= numpages; pages++) {
  1123. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1124. string page = string(item->book_pages[pages-1]->page_text.data);
  1125. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1126. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1127. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1128. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1129. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1130. // Need to add support for images
  1131. }
  1132. client->QueuePacket(packet->serialize());
  1133. safe_delete(packet);
  1134. }
  1135. break;
  1136. }
  1137. }
  1138. }
  1139. }
  1140. case COMMAND_USEABILITY:{
  1141. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1142. if (client->GetPlayer()->GetHP() == 0) {
  1143. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1144. }
  1145. else {
  1146. int32 spell_id = atoul(sep->arg[0]);
  1147. int8 spell_tier = 0;
  1148. if (sep->arg[1][0] && sep->IsNumber(1))
  1149. spell_tier = atoi(sep->arg[1]);
  1150. else
  1151. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1152. if (!spell_tier)
  1153. spell_tier = 1;
  1154. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1155. if (spell) {
  1156. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1157. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1158. else
  1159. {
  1160. if (cmdTarget)
  1161. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1162. else
  1163. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1164. }
  1165. }
  1166. }
  1167. }
  1168. else if (cmdTarget && cmdTarget->IsWidget())
  1169. {
  1170. Widget* widget = (Widget*)cmdTarget;
  1171. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1172. }
  1173. else
  1174. {
  1175. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1176. }
  1177. break;
  1178. }
  1179. case COMMAND_INFO:{
  1180. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1181. if(strcmp(sep->arg[0], "inventory") == 0){
  1182. int32 item_index = atol(sep->arg[1]);
  1183. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1184. if(item){
  1185. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1186. break;
  1187. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1188. //DumpPacket(app);
  1189. client->QueuePacket(app);
  1190. if(item->GetItemScript() && lua_interface)
  1191. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1192. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1193. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1194. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1195. client->AddPendingQuest(quest);
  1196. }
  1197. }
  1198. else
  1199. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1200. }
  1201. else if(strcmp(sep->arg[0], "equipment") == 0){
  1202. int32 item_index = atol(sep->arg[1]);
  1203. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1204. if(item){
  1205. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1206. client->QueuePacket(app);
  1207. if(item->GetItemScript() && lua_interface)
  1208. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1209. }
  1210. else
  1211. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1212. }
  1213. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1214. int32 item_id = atoul(sep->arg[1]);
  1215. Item* item = master_item_list.GetItem(item_id);
  1216. if(item){
  1217. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1218. client->QueuePacket(app);
  1219. }
  1220. else
  1221. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1222. }
  1223. else if (strcmp(sep->arg[0], "spell") == 0) {
  1224. sint32 spell_id = atol(sep->arg[1]);
  1225. int8 tier = atoi(sep->arg[3]);
  1226. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1227. if (outapp)
  1228. client->QueuePacket(outapp);
  1229. else
  1230. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1231. }
  1232. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1233. sint32 spell_id = atol(sep->arg[2]);
  1234. int8 group = atoi(sep->arg[1]);
  1235. AltAdvanceData* data = 0;
  1236. SpellBookEntry* spellentry = 0;
  1237. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1238. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1239. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1240. if (outapp)
  1241. client->QueuePacket(outapp);
  1242. else
  1243. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1244. }
  1245. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1246. sint32 spell_id = atol(sep->arg[1]);
  1247. int8 tier = atoi(sep->arg[2]);
  1248. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1249. if (outapp)
  1250. client->QueuePacket(outapp);
  1251. else
  1252. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1253. }
  1254. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1255. sint32 recipe_id = atol(sep->arg[1]);
  1256. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1257. if(outapp)
  1258. client->QueuePacket(outapp);
  1259. else
  1260. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1261. }
  1262. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1263. int32 slot = atol(sep->arg[1]);
  1264. int32 spell_id = atol(sep->arg[2]);
  1265. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1266. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1267. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1268. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1269. if(outapp)
  1270. client->QueuePacket(outapp);
  1271. else
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1273. }
  1274. else if (strcmp(sep->arg[0], "effect") == 0) {
  1275. int32 spell_id = atol(sep->arg[1]);
  1276. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1277. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1278. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1279. if (outapp){
  1280. client->QueuePacket(outapp);
  1281. }
  1282. else
  1283. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1284. }
  1285. }
  1286. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1287. Item* item = player->item_list.GetOverflowItem();
  1288. if(item) {
  1289. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1290. client->QueuePacket(app);
  1291. }
  1292. else
  1293. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1294. }
  1295. else
  1296. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1297. break;
  1298. }
  1299. case COMMAND_USE_EQUIPPED_ITEM:{
  1300. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1301. int32 slot_id = atoul(sep->arg[0]);
  1302. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1303. if (item && item->generic_info.usable && item->GetItemScript())
  1304. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1305. }
  1306. break;
  1307. }
  1308. case COMMAND_USE_ITEM: {
  1309. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1310. int32 item_index = atoul(sep->arg[0]);
  1311. Item* item = player->item_list.GetItemFromIndex(item_index);
  1312. if (item && item->GetItemScript()) {
  1313. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1314. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1315. else {
  1316. if (item->generic_info.display_charges > 0) {
  1317. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1318. item->generic_info.display_charges -= 1;
  1319. item->save_needed = true;
  1320. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1321. }
  1322. }
  1323. }
  1324. }
  1325. break;
  1326. }
  1327. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1328. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1329. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1330. if (item) {
  1331. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1332. if(item->generic_info.item_type == 6) {
  1333. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1334. int8 old_slot = 0;
  1335. if (spell) {
  1336. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1337. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1338. player->RemoveSpellBookEntry(spell->GetSpellID());
  1339. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1340. player->UnlockSpell(spell);
  1341. client->SendSpellUpdate(spell);
  1342. database.DeleteItem(client->GetCharacterID(), item, 0);
  1343. player->item_list.RemoveItem(item, true);
  1344. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1345. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1346. }
  1347. }
  1348. else
  1349. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1350. }
  1351. else if(item->generic_info.item_type == 7){
  1352. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1353. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1354. // if valid recipe book and the player doesn't have it
  1355. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1356. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1357. safe_delete(recipe_book);
  1358. }
  1359. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1360. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1361. // Add recipe book to the players list
  1362. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1363. // Get a list of all recipes this book contains
  1364. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1365. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1366. // Create the packet to send to update the players recipe list
  1367. PacketStruct* packet = 0;
  1368. if (client->GetRecipeListSent()) {
  1369. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1370. if (packet)
  1371. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1372. }
  1373. // loop through the list
  1374. vector<Recipe*>::iterator itr;
  1375. int16 i = 0;
  1376. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1377. // check to see if the player already has this recipe some how
  1378. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1379. // Player doesn't already have this recipe so lets add it
  1380. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1381. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1382. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1383. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1384. if (packet && client->GetRecipeListSent()) {
  1385. packet->setArrayDataByName("id", recipe->GetID(), i);
  1386. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1387. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1388. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1389. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1390. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1391. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1392. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1393. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1394. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1395. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1396. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1397. i++;
  1398. }
  1399. }
  1400. }
  1401. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1402. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1403. database.DeleteItem(client->GetCharacterID(), item, 0);
  1404. client->GetPlayer()->item_list.RemoveItem(item, true);
  1405. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1406. if (packet && client->GetRecipeListSent())
  1407. client->QueuePacket(packet->serialize());
  1408. safe_delete(packet);
  1409. }
  1410. else {
  1411. if (recipe_book)
  1412. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1413. safe_delete(recipe_book);
  1414. }
  1415. }
  1416. }
  1417. else
  1418. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1419. }
  1420. break;
  1421. }
  1422. case COMMAND_SUMMONITEM: {
  1423. if (sep && sep->IsNumber(0)) {
  1424. int32 item_id = atol(sep->arg[0]);
  1425. int32 quantity = 1;
  1426. if (sep->arg[1] && sep->IsNumber(1))
  1427. quantity = atoi(sep->arg[1]);
  1428. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1429. client->AddItemToBank(item_id,quantity);
  1430. }
  1431. else {
  1432. client->AddItem(item_id, quantity);
  1433. }
  1434. }
  1435. else {
  1436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1438. }
  1439. break;
  1440. }
  1441. case COMMAND_COLLECTION_ADDITEM: {
  1442. // takes 2 params: collection_id, slot
  1443. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1444. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1445. if (item)
  1446. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1447. else
  1448. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1449. }
  1450. else
  1451. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1452. break;
  1453. }
  1454. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1455. // takes 1 param: slot
  1456. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1457. int i = 0;
  1458. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1459. printf("\t%u: %s\n", i, sep->arg[i]);
  1460. i++;
  1461. }
  1462. break;
  1463. }
  1464. case COMMAND_WHO:{
  1465. const char* who = 0;
  1466. if(sep && sep->arg[0]){
  1467. //cout << "Who query: \n";
  1468. who = sep->argplus[0];
  1469. //cout << who << endl;
  1470. }
  1471. zone_list.ProcessWhoQuery(who, client);
  1472. break;
  1473. }
  1474. case COMMAND_SELECT_JUNCTION:{
  1475. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1476. int32 choice = 0;
  1477. if(sep && sep->arg[0] && sep->IsNumber(0))
  1478. choice = atoul(sep->arg[0]);
  1479. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1480. client->HandlePlayerRevive(choice);
  1481. }
  1482. break;
  1483. }
  1484. case COMMAND_SPAWN_MOVE: {
  1485. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1486. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1487. if (packet) {
  1488. float unknown2_3 = 0;
  1489. int8 placement_mode = 0;
  1490. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1491. if (sep && sep->arg[0][0]) {
  1492. if (strcmp(sep->arg[0], "wall") == 0) {
  1493. placement_mode = 2;
  1494. unknown2_3 = 150;
  1495. }
  1496. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1497. placement_mode = 1;
  1498. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1499. {
  1500. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1501. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1502. }
  1503. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1504. {
  1505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1506. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1507. }
  1508. else if (strcmp(sep->arg[0], "myloc") == 0)
  1509. {
  1510. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1511. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1512. safe_delete(packet);
  1513. break;
  1514. }
  1515. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1516. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1517. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1518. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1519. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1520. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1521. safe_delete(packet);
  1522. break;
  1523. }
  1524. }
  1525. packet->setDataByName("placement_mode", placement_mode);
  1526. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1527. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1528. packet->setDataByName("unknown", 1); //size
  1529. packet->setDataByName("unknown2", 1); //size 2
  1530. packet->setDataByName("unknown2", .5, 1); //size 3
  1531. packet->setDataByName("unknown2", 3, 2);
  1532. packet->setDataByName("unknown2", unknown2_3, 3);
  1533. packet->setDataByName("max_distance", 500);
  1534. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1535. client->QueuePacket(packet->serialize());
  1536. safe_delete(packet);
  1537. }
  1538. }
  1539. else {
  1540. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1542. }
  1543. break;
  1544. }
  1545. case COMMAND_HAIL:{
  1546. Spawn* spawn = cmdTarget;
  1547. if(spawn && spawn->GetTargetable())
  1548. {
  1549. char tmp[75] = {0};
  1550. sprintf(tmp, "Hail, %s", spawn->GetName());
  1551. bool show_bubble = true;
  1552. if (spawn->IsNPC())
  1553. show_bubble = false;
  1554. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1555. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1556. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1557. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1558. else
  1559. spawn->ProcessMovement();
  1560. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1561. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1562. }
  1563. }
  1564. else {
  1565. string tmp = "Hail";
  1566. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1567. }
  1568. break;
  1569. }
  1570. case COMMAND_SAY:{
  1571. if (sep && sep->arg[0][0]) {
  1572. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1573. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1574. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1575. }
  1576. else
  1577. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1578. break;
  1579. }
  1580. case COMMAND_TELL:{
  1581. if(sep && sep->arg[0] && sep->argplus[1]){
  1582. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1583. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1584. }else
  1585. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1586. break;
  1587. }
  1588. case COMMAND_SHOUT:{
  1589. if(sep && sep->arg[0][0])
  1590. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1591. else
  1592. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1593. break;
  1594. }
  1595. case COMMAND_AUCTION:{
  1596. if(sep && sep->arg[0][0])
  1597. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1598. else
  1599. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1600. break;
  1601. }
  1602. case COMMAND_OOC:{
  1603. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1604. if(sep && sep->arg[0][0])
  1605. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1606. else
  1607. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1608. break;
  1609. }
  1610. case COMMAND_EMOTE:{
  1611. if(sep && sep->arg[0][0])
  1612. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1613. else
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1615. break;
  1616. }
  1617. case COMMAND_RACE:{
  1618. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1619. if(sep->arg[1][0] && sep->IsNumber(1)){
  1620. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1621. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1622. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1623. client->GetPlayer()->SetCharSheetChanged(true);
  1624. }
  1625. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1626. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1627. //client->QueuePacket(outapp);
  1628. }
  1629. else{
  1630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1631. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1632. }
  1633. break;
  1634. }
  1635. case COMMAND_BANK_DEPOSIT:{
  1636. if(client->GetBanker() && sep && sep->arg[0]){
  1637. int64 amount = 0;
  1638. string deposit = string(sep->arg[0]);
  1639. amount = atoi64(deposit.c_str());
  1640. client->BankDeposit(amount);
  1641. }
  1642. break;
  1643. }
  1644. case COMMAND_BANK_WITHDRAWAL:{
  1645. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1646. int64 amount = 0;
  1647. string deposit = string(sep->arg[0]);
  1648. amount = atoi64(deposit.c_str());
  1649. client->BankWithdrawal(amount);
  1650. }
  1651. break;
  1652. }
  1653. case COMMAND_BANK_CANCEL:{
  1654. Spawn* banker = cmdTarget;
  1655. client->Bank(banker, true);
  1656. break;
  1657. }
  1658. case COMMAND_BANK:{
  1659. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1660. Spawn* banker = cmdTarget;
  1661. client->Bank(banker);
  1662. break;
  1663. }
  1664. case COMMAND_GUILD_BANK:{
  1665. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1666. //Spawn* banker = client->GetPlayer()->GetTarget();
  1667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1668. break;
  1669. }
  1670. case COMMAND_START_MAIL: {
  1671. client->SetMailTransaction(cmdTarget);
  1672. client->SendMailList();
  1673. break;
  1674. }
  1675. case COMMAND_CANCEL_MAIL: {
  1676. client->SetMailTransaction(0);
  1677. break;
  1678. }
  1679. case COMMAND_GET_MAIL_MESSAGE: {
  1680. if (sep && sep->arg[0] && sep->IsNumber(0))
  1681. client->DisplayMailMessage(atoul(sep->arg[0]));
  1682. break;
  1683. }
  1684. case COMMAND_ADD_MAIL_PLAT: {
  1685. if (sep && sep->arg[0] && sep->IsNumber(0))
  1686. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1687. break;
  1688. }
  1689. case COMMAND_ADD_MAIL_GOLD: {
  1690. if (sep && sep->arg[0] && sep->IsNumber(0))
  1691. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1692. break;
  1693. }
  1694. case COMMAND_ADD_MAIL_SILVER: {
  1695. if (sep && sep->arg[0] && sep->IsNumber(0))
  1696. client->AddMailCoin(0, atoul(sep->arg[0]));
  1697. break;
  1698. }
  1699. case COMMAND_ADD_MAIL_COPPER: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0))
  1701. client->AddMailCoin(atoul(sep->arg[0]));
  1702. break;
  1703. }
  1704. case COMMAND_SET_MAIL_ITEM: {
  1705. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1706. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1707. break;
  1708. }
  1709. case COMMAND_REMOVE_MAIL_PLAT: {
  1710. if (sep && sep->arg[0] && sep->IsNumber(0))
  1711. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1712. break;
  1713. }
  1714. case COMMAND_REMOVE_MAIL_GOLD: {
  1715. if (sep && sep->arg[0] && sep->IsNumber(0))
  1716. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1717. break;
  1718. }
  1719. case COMMAND_REMOVE_MAIL_SILVER: {
  1720. if (sep && sep->arg[0] && sep->IsNumber(0))
  1721. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1722. break;
  1723. }
  1724. case COMMAND_REMOVE_MAIL_COPPER: {
  1725. if (sep && sep->arg[0] && sep->IsNumber(0))
  1726. client->RemoveMailCoin(atoul(sep->arg[0]));
  1727. break;
  1728. }
  1729. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1730. if (sep && sep->arg[0] && sep->IsNumber(0))
  1731. client->TakeMailAttachments(atoul(sep->arg[0]));
  1732. break;
  1733. }
  1734. case COMMAND_CANCEL_SEND_MAIL: {
  1735. client->CancelSendMail();
  1736. break;
  1737. }
  1738. case COMMAND_DELETE_MAIL_MESSAGE: {
  1739. if (sep && sep->arg[0] && sep->IsNumber(0))
  1740. client->DeleteMail(atoul(sep->arg[0]), true);
  1741. break;
  1742. }
  1743. case COMMAND_REPORT_SPAM: {
  1744. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1745. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1746. break;
  1747. }
  1748. case COMMAND_KILL:{
  1749. Spawn* dead = 0;
  1750. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1751. dead=client->GetPlayer();
  1752. client->GetPlayer()->SetHP(0);
  1753. client->GetPlayer()->KillSpawn(dead);
  1754. }else{
  1755. dead= cmdTarget;
  1756. if(dead && dead->IsPlayer() == false){
  1757. dead->SetHP(0);
  1758. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1759. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1760. else
  1761. client->GetPlayer()->KillSpawn(dead);
  1762. }else{
  1763. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1764. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1765. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1766. }
  1767. }
  1768. break;
  1769. }
  1770. case COMMAND_LEVEL:{
  1771. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1772. int16 new_level = atoi(sep->arg[ndx]);
  1773. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1774. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1775. else {
  1776. if (new_level < 1)
  1777. new_level = 1;
  1778. if (new_level > 255)
  1779. new_level = 255;
  1780. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1781. client->GetPlayer()->SetXP(1);
  1782. client->GetPlayer()->SetNeededXP();
  1783. }
  1784. }else
  1785. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1786. break;
  1787. }
  1788. case COMMAND_SIT: {
  1789. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1790. if(client->GetPlayer()->GetHP() > 0){
  1791. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1792. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1793. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1794. }
  1795. break;
  1796. }
  1797. case COMMAND_STAND: {
  1798. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1799. if(client->GetPlayer()->GetHP() > 0){
  1800. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1801. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1802. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1803. }
  1804. break;
  1805. }
  1806. case COMMAND_CLASS:{
  1807. if(sep && sep->arg[ndx][0]){
  1808. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1809. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1810. }else
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1812. break;
  1813. }
  1814. case COMMAND_GENDER:{
  1815. if(sep && sep->arg[ndx][0]){
  1816. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1817. client->GetPlayer()->SetCharSheetChanged(true);
  1818. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1819. }else{
  1820. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1821. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1823. }
  1824. break;
  1825. }
  1826. case COMMAND_FLYMODE:{
  1827. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1828. PrintSep(sep, "COMMAND_FLYMODE");
  1829. int8 val = atoi(sep->arg[0]);
  1830. ClientPacketFunctions::SendFlyMode(client, val);
  1831. }
  1832. else{
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1835. }
  1836. break;
  1837. }
  1838. case COMMAND_LOOT_LIST:{
  1839. Spawn* spawn = cmdTarget;
  1840. if(spawn && spawn->IsEntity()){
  1841. if (sep && sep->arg[0]) {
  1842. if (!spawn->GetDatabaseID())
  1843. {
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1845. break;
  1846. }
  1847. else if (!spawn->IsNPC())
  1848. {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1850. break;
  1851. }
  1852. bool reloadLoot = false;
  1853. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1854. {
  1855. int32 loottable_id = atoul(sep->arg[1]);
  1856. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1857. {
  1858. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1859. reloadLoot = true;
  1860. }
  1861. else
  1862. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1863. }
  1864. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1865. {
  1866. int32 loottable_id = atoul(sep->arg[1]);
  1867. if (loottable_id > 0)
  1868. {
  1869. database.AddLootTableToSpawn(spawn, loottable_id);
  1870. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1871. reloadLoot = true;
  1872. }
  1873. else
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1875. }
  1876. else if (!stricmp(sep->arg[0], "clearall"))
  1877. {
  1878. if (database.RemoveSpawnLootTable(spawn, 0))
  1879. {
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1881. reloadLoot = true;
  1882. }
  1883. else
  1884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1885. }
  1886. else
  1887. {
  1888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1892. break;
  1893. }
  1894. if (reloadLoot)
  1895. {
  1896. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1897. if (spawn->IsNPC())
  1898. {
  1899. Entity* ent = (Entity*)spawn;
  1900. ent->SetLootCoins(0);
  1901. ent->ClearLootList();
  1902. spawn->GetZone()->AddLoot((NPC*)spawn);
  1903. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1904. }
  1905. }
  1906. break; // nothing further this is the end of these sub commands
  1907. }
  1908. else
  1909. {
  1910. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1911. if (loot_list.size() > 0) {
  1912. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1913. vector<int32>::iterator list_itr;
  1914. LootTable* table = 0;
  1915. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1916. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1917. if (table)
  1918. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1919. }
  1920. }
  1921. Entity* target = (Entity*)spawn;
  1922. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1923. vector<Item*>* items = target->GetLootItems();
  1924. if (items) {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1926. vector<Item*>::iterator itr;
  1927. Item* item = 0;
  1928. for (itr = items->begin(); itr != items->end(); itr++) {
  1929. item = *itr;
  1930. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1931. }
  1932. }
  1933. else
  1934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1935. }
  1936. }
  1937. break;
  1938. }
  1939. case COMMAND_LOOT_SETCOIN:{
  1940. Spawn* spawn = cmdTarget;
  1941. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1942. Entity* target = (Entity*)spawn;
  1943. target->SetLootCoins(atoul(sep->arg[0]));
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1945. }
  1946. else
  1947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1948. break;
  1949. }
  1950. case COMMAND_LOOT_ADDITEM:{
  1951. Spawn* spawn = cmdTarget;
  1952. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1953. Entity* target = (Entity*)spawn;
  1954. int16 charges = 1;
  1955. if(sep->arg[1] && sep->IsNumber(1))
  1956. charges = atoi(sep->arg[1]);
  1957. target->AddLootItem(atoul(sep->arg[0]), charges);
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1959. }
  1960. else
  1961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1962. break;
  1963. }
  1964. case COMMAND_LOOT_REMOVEITEM:{
  1965. Spawn* spawn = cmdTarget;
  1966. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1967. Entity* target = (Entity*)spawn;
  1968. target->LootItem(atoul(sep->arg[0]));
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1970. }
  1971. else
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1973. break;
  1974. }
  1975. case COMMAND_LOOT_CORPSE:
  1976. case COMMAND_DISARM:
  1977. case COMMAND_LOOT:{
  1978. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1979. {
  1980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1981. break;
  1982. }
  1983. if(cmdTarget && cmdTarget->IsEntity()){
  1984. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  1985. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  1986. client->OpenChest((Entity*)cmdTarget, true);
  1987. else
  1988. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  1989. if (!((Entity*)cmdTarget)->HasLoot()){
  1990. if (((Entity*)cmdTarget)->IsNPC())
  1991. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1992. }
  1993. }
  1994. else
  1995. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1996. }
  1997. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1999. break;
  2000. }
  2001. case COMMAND_RELOADSPAWNSCRIPTS:{
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2003. if (lua_interface)
  2004. lua_interface->SetSpawnScriptsReloading(true);
  2005. world.ResetSpawnScripts();
  2006. database.LoadSpawnScriptData();
  2007. if(lua_interface) {
  2008. lua_interface->DestroySpawnScripts();
  2009. lua_interface->SetSpawnScriptsReloading(false);
  2010. }
  2011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2012. break;
  2013. }
  2014. case COMMAND_RELOADLUASYSTEM:{
  2015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2016. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2017. safe_delete(lua_interface);
  2018. lua_interface = new LuaInterface();
  2019. if(lua_interface)
  2020. lua_interface->SetSpawnScriptsReloading(true);
  2021. if(lua_interface && debug_clients.size() > 0){
  2022. map<Client*, int32>::iterator itr;
  2023. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2024. if(lua_interface)
  2025. lua_interface->UpdateDebugClients(itr->first);
  2026. }
  2027. }
  2028. world.ResetSpawnScripts();
  2029. database.LoadSpawnScriptData();
  2030. world.ResetZoneScripts();
  2031. database.LoadZoneScriptData();
  2032. int32 quest_count = database.LoadQuests();
  2033. zone_list.DeleteSpellProcess();
  2034. master_spell_list.Reload();
  2035. int32 spell_count = 0;
  2036. if(lua_interface) {
  2037. lua_interface->DestroySpawnScripts();
  2038. lua_interface->DestroySpells();
  2039. spell_count = database.LoadSpellScriptData();
  2040. lua_interface->SetSpawnScriptsReloading(false);
  2041. }
  2042. zone_list.LoadSpellProcess();
  2043. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2044. break;
  2045. }
  2046. case COMMAND_DECLINE_QUEST:{
  2047. int32 quest_id = 0;
  2048. if(sep && sep->arg[0] && sep->IsNumber(0))
  2049. quest_id = atoul(sep->arg[0]);
  2050. if(quest_id > 0){
  2051. Quest* quest = client->GetPendingQuest(quest_id);
  2052. if(quest){
  2053. client->RemovePendingQuest(quest);
  2054. if(lua_interface)
  2055. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2056. safe_delete(quest);
  2057. client->GetCurrentZone()->SendQuestUpdates(client);
  2058. }
  2059. }
  2060. break;
  2061. }
  2062. case COMMAND_DELETE_QUEST:{
  2063. int32 quest_id = 0;
  2064. if(sep && sep->arg[0] && sep->IsNumber(0))
  2065. quest_id = atoul(sep->arg[0]);
  2066. if(quest_id > 0){
  2067. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2068. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2069. if (quest)
  2070. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2071. }
  2072. client->RemovePlayerQuest(quest_id);
  2073. client->GetCurrentZone()->SendQuestUpdates(client);
  2074. }
  2075. break;
  2076. }
  2077. case COMMAND_ACCEPT_QUEST:{
  2078. int32 quest_id = 0;
  2079. if(sep && sep->arg[0] && sep->IsNumber(0))
  2080. quest_id = atoul(sep->arg[0]);
  2081. if(quest_id > 0){
  2082. Quest* quest = client->GetPendingQuest(quest_id);
  2083. if(quest){
  2084. client->RemovePendingQuest(quest);
  2085. client->AddPlayerQuest(quest);
  2086. client->GetCurrentZone()->SendQuestUpdates(client);
  2087. // If character has already completed this quest once update the given date in the database
  2088. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2089. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2090. if (quest2)
  2091. quest->SetCompleteCount(quest2->GetCompleteCount());
  2092. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2093. }
  2094. }
  2095. }
  2096. break;
  2097. }
  2098. case COMMAND_NAME:{
  2099. if(sep && sep->arg[ndx][0]){
  2100. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2101. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2102. client->GetPlayer()->SetCharSheetChanged(true);
  2103. }else
  2104. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2105. break;
  2106. }
  2107. case COMMAND_GROUPSAY:{
  2108. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2109. if(sep && sep->arg[0] && gmi)
  2110. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2111. break;
  2112. }
  2113. case COMMAND_GROUPINVITE: {
  2114. Entity* target = 0;
  2115. Client* target_client = 0;
  2116. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2117. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2118. return;
  2119. }
  2120. // name provided with command so it has to be a player, npc not supported here
  2121. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2122. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2123. if (target_client) {
  2124. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2125. target = 0;
  2126. else
  2127. target = target_client->GetPlayer();
  2128. }
  2129. }
  2130. // if name was not provided use the players target, npc or player supported here
  2131. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2132. target = (Entity*)client->GetPlayer()->GetTarget();
  2133. if (target->IsPlayer()) {
  2134. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2135. }
  2136. }
  2137. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2138. if (result == 0) {
  2139. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2140. if (target_client) {
  2141. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2142. if (packet) {
  2143. packet->setDataByName("type", 1);
  2144. packet->setDataByName("name", client->GetPlayer()->GetName());
  2145. packet->setDataByName("unknown2", 1);
  2146. target_client->QueuePacket(packet->serialize());
  2147. safe_delete(packet);
  2148. }
  2149. }
  2150. }
  2151. else if (result == 1)
  2152. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2153. else if (result == 2)
  2154. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2155. else if (result == 3)
  2156. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2157. else if (result == 4)
  2158. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2159. else if (result == 5)
  2160. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2161. else if (result == 6)
  2162. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2163. else
  2164. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2165. break;
  2166. }
  2167. case COMMAND_GROUPDISBAND: {
  2168. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2169. if (gmi) { // TODO: Leader check
  2170. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2171. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2172. }
  2173. break;
  2174. }
  2175. case COMMAND_GROUP_LEAVE: {
  2176. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2177. if (gmi) {
  2178. int32 group_id = gmi->group_id;
  2179. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2180. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2181. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2182. }
  2183. else {
  2184. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2185. }
  2186. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2187. }
  2188. break;
  2189. }
  2190. case COMMAND_FRIEND_ADD:{
  2191. string name = "";
  2192. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2193. name = database.GetPlayerName(sep->arg[0]);
  2194. else if(cmdTarget && cmdTarget->IsPlayer())
  2195. name = string(cmdTarget->GetName());
  2196. if(name.length() > 0){
  2197. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2198. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2199. client->GetPlayer()->RemoveIgnore(name.c_str());
  2200. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2201. client->SendChatRelationship(3, name.c_str());
  2202. }
  2203. client->GetPlayer()->AddFriend(name.c_str(), true);
  2204. client->SendChatRelationship(0, name.c_str());
  2205. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2206. if(zone_list.GetClientByCharName(name))
  2207. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2208. }
  2209. else
  2210. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2211. }
  2212. else
  2213. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2214. break;
  2215. }
  2216. case COMMAND_FRIEND_REMOVE:{
  2217. string name = "";
  2218. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2219. name = database.GetPlayerName(sep->arg[0]);
  2220. else if(cmdTarget && cmdTarget->IsPlayer())
  2221. name = string(cmdTarget->GetName());
  2222. if(name.length() > 0){
  2223. client->GetPlayer()->RemoveFriend(name.c_str());
  2224. client->SendChatRelationship(1, name.c_str());
  2225. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2226. }
  2227. else
  2228. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2229. break;
  2230. }
  2231. case COMMAND_FRIENDS:{
  2232. break;
  2233. }
  2234. case COMMAND_IGNORE_ADD:{
  2235. string name = "";
  2236. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2237. name = database.GetPlayerName(sep->arg[0]);
  2238. else if(cmdTarget && cmdTarget->IsPlayer())
  2239. name = string(cmdTarget->GetName());
  2240. if(name.length() > 0){
  2241. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2242. if(client->GetPlayer()->IsFriend(name.c_str())){
  2243. client->GetPlayer()->RemoveFriend(name.c_str());
  2244. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2245. client->SendChatRelationship(1, name.c_str());
  2246. }
  2247. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2248. client->SendChatRelationship(2, name.c_str());
  2249. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2250. }
  2251. else
  2252. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2253. }
  2254. else
  2255. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2256. break;
  2257. }
  2258. case COMMAND_IGNORE_REMOVE:{
  2259. string name = "";
  2260. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2261. name = database.GetPlayerName(sep->arg[0]);
  2262. else if(cmdTarget && cmdTarget->IsPlayer())
  2263. name = string(cmdTarget->GetName());
  2264. if(name.length() > 0){
  2265. client->GetPlayer()->RemoveIgnore(name.c_str());
  2266. client->SendChatRelationship(3, name.c_str());
  2267. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2268. }
  2269. break;
  2270. }
  2271. case COMMAND_IGNORES:{
  2272. break;
  2273. }
  2274. case COMMAND_GROUP_KICK:{
  2275. Entity* kicked = 0;
  2276. Client* kicked_client = 0;
  2277. int32 group_id = 0;
  2278. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2279. return;
  2280. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2281. if (sep && sep->arg[0]) {
  2282. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2283. if (kicked_client)
  2284. kicked = kicked_client->GetPlayer();
  2285. }
  2286. else if (cmdTarget && cmdTarget->IsEntity()) {
  2287. kicked = (Entity*)cmdTarget;
  2288. }
  2289. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2290. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2291. if (kicked)
  2292. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2293. if(send_kicked_message)
  2294. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2295. else
  2296. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2297. if (kicked_client)
  2298. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2299. break;
  2300. }
  2301. case COMMAND_GROUP_MAKE_LEADER:{
  2302. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2303. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2304. return;
  2305. }
  2306. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2307. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2308. if (new_leader) {
  2309. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2310. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2311. }
  2312. }
  2313. else
  2314. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2315. }
  2316. else if (cmdTarget && cmdTarget->IsPlayer())
  2317. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2318. else
  2319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2320. break;
  2321. }
  2322. case COMMAND_GROUP_ACCEPT_INVITE: {
  2323. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2324. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2325. if (result == 0)
  2326. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2327. else if (result == 1)
  2328. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2329. else if (result == 2)
  2330. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2331. else
  2332. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2333. }
  2334. break;
  2335. }
  2336. case COMMAND_GROUP_DECLINE_INVITE: {
  2337. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2338. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2339. }
  2340. break;
  2341. }
  2342. case COMMAND_SUMMON:{
  2343. char* search_name = 0;
  2344. if(sep && sep->arg[0][0])
  2345. search_name = sep->arg[0];
  2346. if(!search_name && !cmdTarget){
  2347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2348. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Summons a targeted spawn or a spawn by name to you. If more than one spawn matches name, it will summon closest.");
  2349. }
  2350. else{
  2351. if(!client->Summon(search_name))
  2352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2353. }
  2354. break;
  2355. }
  2356. case COMMAND_GOTO:{
  2357. const char* search_name = 0;
  2358. if(sep && sep->arg[0][0])
  2359. search_name = sep->argplus[0];
  2360. if(!search_name && !cmdTarget){
  2361. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2362. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves to targeted spawn or to a spawn by name. If more than one spawn matches name, you will move to closest.");
  2363. }
  2364. else{
  2365. if(!client->GotoSpawn(search_name))
  2366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2367. }
  2368. break;
  2369. }
  2370. case COMMAND_MOVE:{
  2371. bool success = false;
  2372. try{
  2373. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2374. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2375. if(app){
  2376. client->QueuePacket(app);
  2377. success = true;
  2378. }
  2379. }
  2380. }
  2381. catch(...){}
  2382. if(!success){
  2383. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2384. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_SETTIME:{
  2389. if(sep && sep->arg[0]){
  2390. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2391. if(sep->arg[1] && sep->IsNumber(1))
  2392. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2393. if(sep->arg[2] && sep->IsNumber(2))
  2394. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2395. if(sep->arg[3] && sep->IsNumber(3))
  2396. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2397. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2398. }
  2399. else{
  2400. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2401. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2402. }
  2403. break;
  2404. }
  2405. case COMMAND_VERSION:{
  2406. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2407. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2408. break;
  2409. }
  2410. case COMMAND_ZONE:{
  2411. string* zonename = 0;
  2412. int32 instanceID = 0;
  2413. const char* zone = 0;
  2414. int32 zone_id = 0;
  2415. bool listSearch = false;
  2416. bool isInstance = false;
  2417. ZoneServer* zsZone = 0;
  2418. if(sep && sep->arg[0][0])
  2419. {
  2420. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2421. listSearch = true;
  2422. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2423. {
  2424. zone_list.SendZoneList(client);
  2425. break;
  2426. }
  2427. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2428. {
  2429. if(sep->IsNumber(1))
  2430. instanceID = atol(sep->arg[1]);
  2431. }
  2432. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2433. {
  2434. PrintSep(sep, "ZONE LOCK");
  2435. if(sep->IsNumber(1))
  2436. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2437. else
  2438. zsZone = zone_list.Get(sep->arg[1], false);
  2439. if( zsZone )
  2440. {
  2441. zsZone->SetZoneLockState(true);
  2442. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2443. }
  2444. else
  2445. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2446. break;
  2447. }
  2448. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2449. {
  2450. PrintSep(sep, "ZONE UNLOCK");
  2451. if(sep->IsNumber(1))
  2452. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2453. else
  2454. zsZone = zone_list.Get(sep->arg[1], false);
  2455. if( zsZone )
  2456. {
  2457. zsZone->SetZoneLockState(false);
  2458. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2459. }
  2460. else
  2461. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2462. break;
  2463. }
  2464. else
  2465. {
  2466. if(sep->IsNumber(0))
  2467. {
  2468. zone_id = atoul(sep->arg[0]);
  2469. zonename = database.GetZoneName(zone_id);
  2470. if(zonename)
  2471. zone = zonename->c_str();
  2472. }
  2473. else
  2474. zone = sep->arg[0];
  2475. }
  2476. if(instanceID > 0)
  2477. {
  2478. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2479. if(zsInstance != NULL)
  2480. {
  2481. instanceID = zsInstance->GetInstanceID();
  2482. zone = zsInstance->GetZoneName();
  2483. zone_id = zsInstance->GetZoneID();
  2484. isInstance = true;
  2485. }
  2486. }
  2487. }
  2488. if(!listSearch)
  2489. {
  2490. if(!zone)
  2491. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2492. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2493. zone_id != client->GetCurrentZone()->GetZoneID())
  2494. {
  2495. if(database.VerifyZone(zone))
  2496. {
  2497. if(client->CheckZoneAccess(zone))
  2498. {
  2499. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2500. if(isInstance)
  2501. client->Zone(instanceID,true,true);
  2502. else
  2503. client->Zone(zone);
  2504. }
  2505. }
  2506. else
  2507. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2508. }
  2509. else
  2510. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2511. }
  2512. else
  2513. {
  2514. const char* name = 0;
  2515. if(sep && sep->arg[1][0])
  2516. {
  2517. map<int32, string>* zone_names;
  2518. name = sep->argplus[1];
  2519. sint16 status = client->GetAdminStatus();
  2520. if( status > 0 )
  2521. {
  2522. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2523. zone_names = database.GetZoneList(name, true);
  2524. }
  2525. else
  2526. zone_names = database.GetZoneList(name);
  2527. if(!zone_names)
  2528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2529. else
  2530. {
  2531. map<int32, string>::iterator itr;
  2532. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2533. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2534. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2535. safe_delete(zone_names);
  2536. }
  2537. }
  2538. else
  2539. {
  2540. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2542. }
  2543. }
  2544. safe_delete(zonename);
  2545. break;
  2546. }
  2547. case COMMAND_USE: {
  2548. Spawn* target = cmdTarget;
  2549. if (target->IsWidget())
  2550. ((Widget*)target)->HandleUse(client, "use");
  2551. break;
  2552. }
  2553. case COMMAND_OPEN: {
  2554. Spawn* target = cmdTarget;
  2555. if (target->IsWidget())
  2556. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2557. break;
  2558. }
  2559. case COMMAND_CASTSPELL: {
  2560. if (sep && sep->arg[0] && sep->IsNumber(0))
  2561. {
  2562. int8 tier = 1;
  2563. if (sep->arg[1] && sep->IsNumber(1))
  2564. tier = atoul(sep->arg[1]);
  2565. int32 spellid = atoul(sep->arg[0]);
  2566. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2567. if (spell)
  2568. {
  2569. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2570. SpellProcess* spellProcess = 0;
  2571. // Get the current zones spell process
  2572. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2573. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2574. }
  2575. else
  2576. {
  2577. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2578. }
  2579. }
  2580. else if (sep && sep->arg[0])
  2581. {
  2582. database.FindSpell(client, (char*)sep->argplus[0]);
  2583. }
  2584. else
  2585. {
  2586. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2587. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2588. }
  2589. break;
  2590. }
  2591. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2592. if (sep && sep->GetArgNumber() == 4)
  2593. {
  2594. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2595. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2596. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2597. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2598. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2599. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2600. ClientPacketFunctions::SendSkillSlotMappings(client);
  2601. }
  2602. else
  2603. {
  2604. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2605. }
  2606. break;
  2607. }
  2608. case COMMAND_HOUSE_UI:
  2609. {
  2610. PrintSep(sep, "COMMAND_HOUSEUI");
  2611. if (sep && sep->IsNumber(0))
  2612. {
  2613. int32 unique_id = atoi(sep->arg[0]);
  2614. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2615. HouseZone* hz = 0;
  2616. if ( ph )
  2617. hz = world.GetHouseZone(ph->house_id);
  2618. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2619. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, cmdTarget ? cmdTarget->GetID() : 0);
  2620. }
  2621. break;
  2622. }
  2623. case COMMAND_PLACE_HOUSE_ITEM: {
  2624. if (sep && sep->IsNumber(0))
  2625. {
  2626. int32 uniqueid = atoi(sep->arg[0]);
  2627. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2628. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2629. if (item && item->IsHouseItem())
  2630. {
  2631. if (!client->HasOwnerOrEditAccess())
  2632. {
  2633. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2634. break;
  2635. }
  2636. else if (!item->generic_info.appearance_id)
  2637. {
  2638. 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);
  2639. break;
  2640. }
  2641. if (client->GetTempPlacementSpawn())
  2642. {
  2643. Spawn* tmp = client->GetTempPlacementSpawn();
  2644. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2645. delete tmp;
  2646. client->SetTempPlacementSpawn(nullptr);
  2647. }
  2648. Spawn* spawn = new Object();
  2649. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2650. spawn->SetID(Spawn::NextID());
  2651. spawn->SetX(client->GetPlayer()->GetX());
  2652. spawn->SetY(client->GetPlayer()->GetY());
  2653. spawn->SetZ(client->GetPlayer()->GetZ());
  2654. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2655. spawn->SetSpawnOrigX(spawn->GetX());
  2656. spawn->SetSpawnOrigY(spawn->GetY());
  2657. spawn->SetSpawnOrigZ(spawn->GetZ());
  2658. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2659. spawn->appearance.targetable = 1;
  2660. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2661. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2662. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2663. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2664. spawn->SetZone(client->GetCurrentZone());
  2665. client->GetCurrentZone()->SendSpawn(spawn, client);
  2666. client->SetTempPlacementSpawn(spawn);
  2667. client->SetPlacementUniqueItemID(uniqueid);
  2668. client->SendMoveObjectMode(spawn, 0);
  2669. }
  2670. }
  2671. break;
  2672. }
  2673. case COMMAND_GM:
  2674. {
  2675. if (sep->arg[0] && sep->arg[1])
  2676. {
  2677. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2678. if (strcmp(sep->arg[0], "vision") == 0)
  2679. {
  2680. client->GetPlayer()->SetGMVision(onOff);
  2681. #if defined(__GNUC__)
  2682. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2683. #else
  2684. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2685. #endif
  2686. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2687. if (onOff)
  2688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2689. else
  2690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2691. }
  2692. }
  2693. break;
  2694. }
  2695. case COMMAND_ATTACK:
  2696. case COMMAND_AUTO_ATTACK:{
  2697. int8 type = 1;
  2698. Player* player = client->GetPlayer();
  2699. if(!player)
  2700. break;
  2701. bool incombat = player->EngagedInCombat();
  2702. if(sep && sep->arg[0] && sep->IsNumber(0))
  2703. type = atoi(sep->arg[0]);
  2704. if(client->GetPlayer()->GetHP() == 0){
  2705. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2706. break;
  2707. }
  2708. if(type == 0){
  2709. if(incombat)
  2710. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2711. player->InCombat(false);
  2712. player->InCombat(false, true);
  2713. player->SetRangeAttack(false);
  2714. }
  2715. else {
  2716. if(type == 2){
  2717. player->InCombat(false);
  2718. if(incombat && player->GetRangeAttack()){
  2719. player->SetRangeAttack(false);
  2720. player->InCombat(false, true);
  2721. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2722. }
  2723. else{
  2724. player->SetRangeAttack(true);
  2725. player->InCombat(true, true);
  2726. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2727. }
  2728. }
  2729. else {
  2730. player->InCombat(false, true);
  2731. player->SetRangeAttack(false);
  2732. player->InCombat(true);
  2733. if(!incombat)
  2734. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2735. }
  2736. /*else
  2737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2738. }
  2739. player->SetCharSheetChanged(true);
  2740. break;
  2741. }
  2742. case COMMAND_DEPOP:{
  2743. bool allow_respawns = false;
  2744. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2745. if(atoi(sep->arg[0]) == 1)
  2746. allow_respawns = true;
  2747. }
  2748. client->GetCurrentZone()->Depop(allow_respawns);
  2749. break;
  2750. }
  2751. case COMMAND_REPOP:{
  2752. client->GetCurrentZone()->Depop(false, true);
  2753. break;
  2754. }
  2755. case COMMAND_BUYBACK:{
  2756. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2757. // 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
  2758. int64 id = atoi64(sep->arg[0]);
  2759. // get the first int32, the item id
  2760. //int32 item_id = (int32)id;
  2761. // get the second int32, the unique id
  2762. int32 unique_id = (int32)(id>>32);
  2763. int8 quantity = atoi(sep->arg[1]);
  2764. if(quantity == 255)
  2765. quantity = 1;
  2766. client->BuyBack(unique_id, quantity);
  2767. }
  2768. break;
  2769. }
  2770. case COMMAND_MERCHANT_BUY:{
  2771. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2772. int32 item_id = atoul(sep->arg[0]);
  2773. int8 quantity = atoi(sep->arg[1]);
  2774. client->BuyItem(item_id, quantity);
  2775. }
  2776. break;
  2777. }
  2778. case COMMAND_MERCHANT_SELL:{
  2779. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2780. // 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
  2781. int64 id = atoi64(sep->arg[0]);
  2782. // get the first int32, the item id
  2783. int32 item_id = (int32)id;
  2784. // get the second int32, the unique id
  2785. int32 unique_id = (int32)(id>>32);
  2786. int8 quantity = atoi(sep->arg[1]);
  2787. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2788. client->SellItem(item_id, quantity, unique_id);
  2789. }
  2790. break;
  2791. }
  2792. case COMMAND_MENDER_REPAIR: {
  2793. if (sep && sep->arg[0] && sep->IsNumber(0))
  2794. client->RepairItem(atoul(sep->arg[0]));
  2795. break;
  2796. }
  2797. case COMMAND_MENDER_REPAIR_ALL: {
  2798. client->RepairAllItems();
  2799. break;
  2800. }
  2801. case COMMAND_CANCEL_MERCHANT:{
  2802. client->SetMerchantTransaction(0);
  2803. break;
  2804. }
  2805. case COMMAND_START_MERCHANT:{
  2806. break;
  2807. }
  2808. case COMMAND_INVULNERABLE:{
  2809. sint8 val = -1;
  2810. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2811. val = atoi(sep->arg[0]);
  2812. //devn00b: Fix for linux builds
  2813. #if defined(__GNUC__)
  2814. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2815. #else
  2816. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2817. #endif
  2818. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2819. client->GetPlayer()->SetInvulnerable(val==1);
  2820. if(client->GetPlayer()->GetInvulnerable())
  2821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2822. else
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2824. }
  2825. if(val == -1)
  2826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2827. break;
  2828. }
  2829. case COMMAND_REPAIR: {
  2830. Spawn* spawn = cmdTarget;
  2831. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2832. client->SendHailCommand(spawn);
  2833. client->SetMerchantTransaction(spawn);
  2834. client->SendRepairList();
  2835. }
  2836. break;
  2837. }
  2838. case COMMAND_LOTTO: {
  2839. Spawn* spawn = cmdTarget;
  2840. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2841. client->SetMerchantTransaction(spawn);
  2842. client->ShowLottoWindow();
  2843. }
  2844. break;
  2845. }
  2846. case COMMAND_ACCEPT_REWARD:{
  2847. int32 unknown = 0;
  2848. int32 selectable_item_id = 0;
  2849. //Quest *quest = 0;
  2850. Collection *collection = 0;
  2851. /* no idea what the first argument is for (faction maybe?)
  2852. if the reward has a selectable item reward, it's sent as the second argument
  2853. if neither of these are included in the reward, there is no sep
  2854. 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
  2855. only 1 quest or collection reward may be displayed at a time */
  2856. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2857. unknown = atoul(sep->arg[0]);
  2858. selectable_item_id = atoul(sep->arg[1]);
  2859. }
  2860. //if ((quest = player->GetPendingQuestReward()))
  2861. // client->AcceptQuestRewards(quest, selectable_item_id);
  2862. /* the below needs to go away eventually and be redone */
  2863. int32 item_id = 0;
  2864. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2865. item_id = atoul(sep->arg[0]);
  2866. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2867. if(quest){
  2868. client->AcceptQuestReward(quest, item_id);
  2869. break;
  2870. }
  2871. if (collection = player->GetPendingCollectionReward())
  2872. client->AcceptCollectionRewards(collection, selectable_item_id);
  2873. else
  2874. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2875. break;
  2876. }
  2877. case COMMAND_BUY_FROM_BROKER:{
  2878. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2879. int32 item_id = atoul(sep->arg[0]);
  2880. int16 quantity = atoul(sep->arg[1]);
  2881. client->AddItem(item_id, quantity);
  2882. }
  2883. break;
  2884. }
  2885. case COMMAND_SEARCH_STORES_PAGE:{
  2886. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2887. int32 page = atoul(sep->arg[0]);
  2888. client->SearchStore(page);
  2889. }
  2890. break;
  2891. }
  2892. case COMMAND_SEARCH_STORES:{
  2893. if(sep && sep->arg[0][0]){
  2894. const char* values = sep->argplus[0];
  2895. if(values){
  2896. map<string, string> str_values = TranslateBrokerRequest(values);
  2897. vector<Item*>* items = master_item_list.GetItems(str_values);
  2898. if(items){
  2899. client->SetItemSearch(items);
  2900. client->SearchStore(0);
  2901. }
  2902. }
  2903. }
  2904. break;
  2905. }
  2906. case COMMAND_LUADEBUG:{
  2907. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2908. client->SetLuaDebugClient(true);
  2909. if(lua_interface)
  2910. lua_interface->UpdateDebugClients(client);
  2911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2912. }
  2913. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2914. client->SetLuaDebugClient(false);
  2915. if(lua_interface)
  2916. lua_interface->RemoveDebugClients(client);
  2917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2918. }
  2919. else{
  2920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2922. }
  2923. break;
  2924. }
  2925. case COMMAND_SPAWN_GROUP:
  2926. {
  2927. Spawn* target = cmdTarget;
  2928. if(target && target->IsPlayer() == false)
  2929. {
  2930. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2931. {
  2932. if(target->GetSpawnLocationPlacementID() > 0)
  2933. {
  2934. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2935. {
  2936. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2937. if(id > 0)
  2938. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2939. else
  2940. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2941. target->SetSpawnGroupID(id);
  2942. target->AddSpawnToGroup(target);
  2943. }
  2944. else
  2945. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2946. }
  2947. else
  2948. 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.");
  2949. }
  2950. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2951. {
  2952. if(sep->arg[1] && sep->IsNumber(1))
  2953. {
  2954. int32 group_id = atoul(sep->arg[1]);
  2955. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2956. if(leader)
  2957. {
  2958. leader->AddSpawnToGroup(target);
  2959. target->SetSpawnGroupID(group_id);
  2960. if(database.SpawnGroupAddSpawn(target, group_id))
  2961. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2962. else
  2963. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2964. }
  2965. else
  2966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2967. }
  2968. else
  2969. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2970. }
  2971. else if(target->GetSpawnGroupID() == 0)
  2972. {
  2973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2974. }
  2975. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2976. {
  2977. int32 group_id = target->GetSpawnGroupID();
  2978. target->RemoveSpawnFromGroup();
  2979. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2980. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2981. else
  2982. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2983. }
  2984. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2985. {
  2986. int32 group_id = target->GetSpawnGroupID();
  2987. if(sep->arg[1] && sep->IsNumber(1))
  2988. {
  2989. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2990. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2991. else
  2992. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2993. }
  2994. else
  2995. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2996. }
  2997. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2998. {
  2999. int32 group_id = target->GetSpawnGroupID();
  3000. if(sep->arg[1] && sep->IsNumber(1))
  3001. {
  3002. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3003. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3004. else
  3005. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3006. }
  3007. else
  3008. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3009. }
  3010. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3011. {
  3012. if(sep->arg[1] && sep->IsNumber(1))
  3013. {
  3014. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3015. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3016. else
  3017. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3018. }
  3019. else
  3020. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3021. }
  3022. else
  3023. {
  3024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3025. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3026. }
  3027. }
  3028. else
  3029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3030. break;
  3031. }
  3032. case COMMAND_SPAWN_COMBINE:{
  3033. Spawn* spawn = cmdTarget;
  3034. float radius = 0;
  3035. bool failed = true;
  3036. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3037. failed = false;
  3038. if(spawn->GetSpawnGroupID() > 0){
  3039. 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.");
  3040. }
  3041. else if(sep->IsNumber(0)){
  3042. radius = atof(sep->arg[0]);
  3043. client->CombineSpawns(radius, spawn);
  3044. }
  3045. else{
  3046. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3047. client->AddCombineSpawn(spawn);
  3048. }
  3049. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3050. client->RemoveCombineSpawn(spawn);
  3051. }
  3052. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3053. const char* name = 0;
  3054. if(sep->arg[1] && sep->arg[1][0])
  3055. name = sep->argplus[1];
  3056. client->SaveCombineSpawns(name);
  3057. }
  3058. else
  3059. failed = true;
  3060. }
  3061. }
  3062. if(failed){
  3063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3064. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3065. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3066. }
  3067. break;
  3068. }
  3069. case COMMAND_SPAWN_CREATE:{
  3070. Spawn* spawn = 0;
  3071. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3072. spawn = new Object();
  3073. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3074. }
  3075. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3076. spawn = new GroundSpawn();
  3077. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3078. }
  3079. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3080. spawn = new Sign();
  3081. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3082. }
  3083. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3084. spawn = new NPC();
  3085. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3086. spawn->appearance.pos.collision_radius = 32;
  3087. spawn->secondary_command_list_id = 0;
  3088. spawn->primary_command_list_id = 0;
  3089. spawn->appearance.display_name = 1;
  3090. spawn->appearance.show_level = 1;
  3091. spawn->appearance.attackable = 1;
  3092. }
  3093. else{
  3094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3097. break;
  3098. }
  3099. spawn->SetID(Spawn::NextID());
  3100. spawn->SetX(client->GetPlayer()->GetX());
  3101. spawn->SetY(client->GetPlayer()->GetY());
  3102. spawn->SetZ(client->GetPlayer()->GetZ());
  3103. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3104. spawn->SetSpawnOrigX(spawn->GetX());
  3105. spawn->SetSpawnOrigY(spawn->GetY());
  3106. spawn->SetSpawnOrigZ(spawn->GetZ());
  3107. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3108. spawn->appearance.targetable = 1;
  3109. spawn->appearance.race = 255;
  3110. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3111. spawn->SetModelType(atoi(sep->arg[1]));
  3112. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3113. spawn->SetLevel(atoi(sep->arg[3]));
  3114. spawn->SetName(sep->arg[4]);
  3115. if(sep->arg[5][0] && sep->IsNumber(5))
  3116. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3117. if(sep->arg[6][0] && sep->IsNumber(6))
  3118. spawn->size = atoi(sep->arg[6]);
  3119. if(spawn->GetTotalHP() == 0){
  3120. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3121. spawn->SetHP(25*spawn->GetLevel() + 1);
  3122. }
  3123. if(spawn->GetTotalPower() == 0){
  3124. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3125. spawn->SetPower(25*spawn->GetLevel() + 1);
  3126. }
  3127. client->GetCurrentZone()->AddSpawn(spawn);
  3128. break;
  3129. }
  3130. case COMMAND_SPAWN_EQUIPMENT:{
  3131. Spawn* spawn = cmdTarget;
  3132. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3133. int8 slot = atoi(sep->arg[0]);
  3134. int16 type = atoi(sep->arg[1]);
  3135. int8 red = 0;
  3136. int8 green = 0;
  3137. int8 blue = 0;
  3138. int8 h_red = 0;
  3139. int8 h_green = 0;
  3140. int8 h_blue = 0;
  3141. if(sep->arg[2])
  3142. red = atoi(sep->arg[2]);
  3143. if(sep->arg[3])
  3144. green = atoi(sep->arg[3]);
  3145. if(sep->arg[4])
  3146. blue = atoi(sep->arg[4]);
  3147. if(sep->arg[5])
  3148. h_red = atoi(sep->arg[5]);
  3149. if(sep->arg[6])
  3150. h_green = atoi(sep->arg[6]);
  3151. if(sep->arg[7])
  3152. h_blue = atoi(sep->arg[7]);
  3153. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3154. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3155. }
  3156. else{
  3157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3159. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3160. }
  3161. break;
  3162. }
  3163. case COMMAND_SPAWN_DETAILS:{
  3164. Spawn* spawn = cmdTarget;
  3165. if (sep && sep->arg[0][0]) {
  3166. if (cmdTarget)
  3167. {
  3168. if (ToLower(string(sep->arg[0])) == "los")
  3169. {
  3170. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3171. if (hasLOS)
  3172. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3173. else
  3174. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3175. break;
  3176. }
  3177. else if (ToLower(string(sep->arg[0])) == "bestz")
  3178. {
  3179. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3180. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3181. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3182. break;
  3183. }
  3184. else if (ToLower(string(sep->arg[0])) == "pathto")
  3185. {
  3186. break;
  3187. }
  3188. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3189. {
  3190. break;
  3191. }
  3192. }
  3193. if (sep->IsNumber(0))
  3194. {
  3195. float radius = atof(sep->arg[0]);
  3196. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3198. break;
  3199. }
  3200. }
  3201. if(spawn){
  3202. const char* type = "NPC";
  3203. if(spawn->IsObject())
  3204. type = "Object";
  3205. else if(spawn->IsSign())
  3206. type = "Sign";
  3207. else if(spawn->IsWidget())
  3208. type = "Widget";
  3209. else if(spawn->IsGroundSpawn())
  3210. type = "GroundSpawn";
  3211. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3212. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3213. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3214. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3215. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3216. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3217. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3218. 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());
  3219. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3220. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3221. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3222. if(spawn->IsEntity()){
  3223. 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());
  3224. 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());
  3225. }
  3226. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3227. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3228. 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());
  3229. 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);
  3230. if (spawn->IsNPC())
  3231. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3232. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3233. if (packet) {
  3234. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3235. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3236. packet->setDataByName("book_title", title.c_str());
  3237. packet->setDataByName("book_type", "simple");
  3238. packet->setDataByName("unknown2", 1);
  3239. packet->setDataByName("unknown5", 1, 4);
  3240. packet->setArrayLengthByName("num_pages", 4);
  3241. string details;
  3242. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3243. details += "Type: " + string(type) + "\n";
  3244. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3245. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3246. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3247. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3248. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3249. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3250. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3251. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3252. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3253. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3254. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3255. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3256. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3257. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3258. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3259. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3260. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3261. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3262. char x[16];
  3263. sprintf(x, "%.2f", spawn->GetX());
  3264. char y[16];
  3265. sprintf(y, "%.2f", spawn->GetY());
  3266. char z[16];
  3267. sprintf(z, "%.2f", spawn->GetZ());
  3268. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3269. string details2;
  3270. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3271. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3272. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3273. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3274. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3275. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3276. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3277. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3278. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3279. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3280. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3281. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3282. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3283. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3284. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3285. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3286. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3287. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3288. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3289. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3290. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3291. string details3;
  3292. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3293. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3294. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3295. string details4;
  3296. if (spawn->IsEntity()) {
  3297. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3298. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3299. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3300. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3301. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3302. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3303. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3304. if (spawn->IsNPC()) {
  3305. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3306. }
  3307. }
  3308. //details2 += "" + to_string() + "\n";
  3309. packet->setArrayDataByName("page_text", details.c_str());
  3310. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3311. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3312. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3313. client->QueuePacket(packet->serialize());
  3314. safe_delete(packet);
  3315. }
  3316. }
  3317. else {
  3318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3319. 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.");
  3320. }
  3321. break;
  3322. }
  3323. case COMMAND_SPAWN_TARGET:{
  3324. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3325. int32 spawn_id = atoul(sep->arg[0]);
  3326. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3327. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3328. }
  3329. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3330. float distance = atof(sep->arg[1]);
  3331. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3332. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3333. }
  3334. else{
  3335. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3337. }
  3338. break;
  3339. }
  3340. case COMMAND_SPAWN_SET:
  3341. {
  3342. Spawn* spawn = cmdTarget;
  3343. sint16 set_type = -1;
  3344. string type_str;
  3345. if (spawn)
  3346. {
  3347. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3348. 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)
  3349. {
  3350. // set the type, which will be 0 if location or list or invalid
  3351. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3352. }
  3353. if(set_type > 0)
  3354. {
  3355. // check if spawn set is NOT a char update, or not location, or isn't a number
  3356. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_EXPANSION_FLAG) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3357. {
  3358. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3359. }
  3360. else
  3361. {
  3362. string name = string(spawn->GetName());
  3363. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3364. {
  3365. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG)
  3366. {
  3367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack flag.");
  3368. }
  3369. else if(set_type == SPAWN_SET_VALUE_NAME)
  3370. {
  3371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3372. }
  3373. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3374. {
  3375. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3376. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3377. }
  3378. else
  3379. {
  3380. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3381. }
  3382. if(set_type != SPAWN_SET_VALUE_FACTION && set_type != SPAWN_SET_VALUE_EXPANSION_FLAG)
  3383. {
  3384. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3385. }
  3386. 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))
  3387. {
  3388. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3389. {
  3390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3391. }
  3392. else if(spawn->GetSpawnLocationID() > 0)
  3393. {
  3394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3395. }
  3396. }
  3397. else
  3398. {
  3399. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3400. {
  3401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3402. }
  3403. else if(spawn->GetDatabaseID() > 0)
  3404. {
  3405. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3406. }
  3407. }
  3408. }
  3409. }
  3410. }
  3411. else if(set_type == 0)
  3412. {
  3413. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3414. map<string, int8>::iterator itr;
  3415. int i=0;
  3416. string list;
  3417. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3418. {
  3419. if(i==10)
  3420. {
  3421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3422. i = 0;
  3423. }
  3424. if(i>0)
  3425. {
  3426. list.append(", ").append(itr->first);
  3427. }
  3428. else
  3429. {
  3430. list = itr->first;
  3431. }
  3432. }
  3433. if(list.length() > 0)
  3434. {
  3435. // if 1 or more, display in client.
  3436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3437. }
  3438. }
  3439. else
  3440. {
  3441. // syntax fail
  3442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3446. }
  3447. }
  3448. break;
  3449. }
  3450. case COMMAND_SPAWN_REMOVE:{
  3451. Spawn* spawn = cmdTarget;
  3452. if(spawn && !spawn->IsPlayer()){
  3453. if(spawn->GetSpawnLocationID() > 0){
  3454. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3455. bool delete_spawn = false;
  3456. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3457. if(atoi(sep->arg[0]) == 1)
  3458. delete_spawn = true;
  3459. }
  3460. if(delete_spawn)
  3461. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3462. else
  3463. spawn->SetSpawnLocationID(0);
  3464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3465. }
  3466. else
  3467. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3468. }
  3469. else
  3470. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3471. }
  3472. else{
  3473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3475. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3476. }
  3477. break;
  3478. }
  3479. case COMMAND_SPAWN_LIST:{
  3480. if(sep && sep->arg[0][0]){
  3481. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3482. vector<string>::iterator itr;
  3483. if(results){
  3484. for(itr=results->begin();itr!=results->end();itr++){
  3485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3486. }
  3487. safe_delete(results);
  3488. }
  3489. else
  3490. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3491. }
  3492. else{
  3493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3495. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3496. }
  3497. break;
  3498. }
  3499. case COMMAND_SPAWN_ADD:{
  3500. Spawn* spawn = cmdTarget;
  3501. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3502. if(spawn->GetSpawnLocationID() > 0){
  3503. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3504. break;
  3505. }
  3506. if(spawn->GetDatabaseID() == 0){
  3507. if(database.SaveSpawnInfo(spawn)) {
  3508. char spawn_type[32];
  3509. memset(spawn_type, 0, sizeof(spawn_type));
  3510. if (spawn->IsNPC())
  3511. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3512. else if (spawn->IsObject())
  3513. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3514. else if (spawn->IsSign())
  3515. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3516. else if (spawn->IsGroundSpawn())
  3517. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3518. else
  3519. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3520. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3521. }
  3522. else
  3523. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3524. }
  3525. int32 spawn_group_id = 0;
  3526. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3527. spawn_group_id = database.GetNextSpawnLocation();
  3528. else
  3529. spawn_group_id = atol(sep->arg[0]);
  3530. int8 percent = 100;
  3531. if(sep->arg[2] && sep->IsNumber(2))
  3532. percent = atoi(sep->arg[2]);
  3533. spawn->SetSpawnLocationID(spawn_group_id);
  3534. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3535. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3536. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3537. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3538. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3539. else
  3540. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3541. }
  3542. else{
  3543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3546. }
  3547. break;
  3548. }
  3549. case COMMAND_SPAWN:{
  3550. int32 id = 0;
  3551. Spawn* spawn = 0;
  3552. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3553. id = atol(sep->arg[0]);
  3554. spawn = client->GetCurrentZone()->GetSpawn(id);
  3555. }
  3556. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3557. id = 0;
  3558. if(!id || !spawn){
  3559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3561. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3562. safe_delete(sep);
  3563. return;
  3564. }
  3565. if(sep && sep->arg[1][0]){
  3566. float x = atof(sep->arg[1]);
  3567. spawn->appearance.pos.X = x;
  3568. }
  3569. else
  3570. spawn->SetX(client->GetPlayer()->GetX(), false);
  3571. if(sep && sep->arg[2][0]){
  3572. float y = atof(sep->arg[2]);
  3573. spawn->appearance.pos.Y = y;
  3574. }
  3575. else
  3576. spawn->SetY(client->GetPlayer()->GetY(), false);
  3577. if(sep && sep->arg[3][0]){
  3578. float z = atof(sep->arg[3]);
  3579. spawn->appearance.pos.Z = z;
  3580. }
  3581. else
  3582. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3583. if(sep && sep->arg[4][0]){
  3584. float heading = atof(sep->arg[4]);
  3585. spawn->SetHeading(heading);
  3586. }
  3587. else
  3588. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3589. spawn->SetSpawnOrigX(spawn->GetX());
  3590. spawn->SetSpawnOrigY(spawn->GetY());
  3591. spawn->SetSpawnOrigZ(spawn->GetZ());
  3592. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3593. if(sep && sep->arg[5][0])
  3594. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3595. else
  3596. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3597. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3598. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3599. spawn->SetHP(spawn->GetTotalHP());
  3600. }
  3601. if(spawn->GetTotalPower() == 0){
  3602. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3603. spawn->SetPower(spawn->GetTotalPower());
  3604. }
  3605. const char* script = world.GetSpawnScript(id);
  3606. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3607. spawn->SetSpawnScript(string(script));
  3608. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3609. client->GetCurrentZone()->AddSpawn(spawn);
  3610. if(spawn->IsNPC())
  3611. spawn->GetZone()->AddLoot((NPC*)spawn);
  3612. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3613. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3614. break;
  3615. }
  3616. case COMMAND_ADMINFLAG:
  3617. {
  3618. if(sep && sep->arg[0]){
  3619. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3620. sint16 new_status = atoi(sep->arg[1]);
  3621. if(tmp_status == -10)
  3622. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3623. else if(tmp_status >= client->GetAdminStatus())
  3624. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3625. else if (new_status > client->GetAdminStatus())
  3626. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3627. else{
  3628. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3629. if (!client2)
  3630. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3631. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3632. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3633. if (client2) {
  3634. client2->SetAdminStatus(new_status);
  3635. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3636. }
  3637. }
  3638. else
  3639. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3640. }
  3641. }else{
  3642. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3643. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3644. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3645. }
  3646. break;
  3647. }
  3648. case COMMAND_CANNEDEMOTE:{
  3649. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3650. break;
  3651. }
  3652. case COMMAND_BROADCAST: {
  3653. if (sep && sep->arg[0])
  3654. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3655. else
  3656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3657. break;
  3658. }
  3659. case COMMAND_ANNOUNCE: {
  3660. if (sep && sep->arg[0])
  3661. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3662. else
  3663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3664. break;
  3665. }
  3666. case COMMAND_RELOAD_ITEMS:{
  3667. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3669. database.ReloadItemList();
  3670. database.LoadMerchantInformation();
  3671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3672. break;
  3673. }
  3674. case COMMAND_ENABLE_ABILITY_QUE:{
  3675. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3676. if(app)
  3677. client->QueuePacket(app);
  3678. break;
  3679. }
  3680. case COMMAND_ITEMSEARCH:{
  3681. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3682. if (packet) {
  3683. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3684. //packet->setDataByName("unknown", 1);
  3685. packet->setDataByName("unknown2", 5, 0);
  3686. packet->setDataByName("unknown2", 20, 1);
  3687. packet->setDataByName("unknown2", 58, 3);
  3688. packet->setDataByName("unknown2", 40, 4);
  3689. client->QueuePacket(packet->serialize());
  3690. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3691. if (packet2) {
  3692. packet2->setDataByName("char_id", client->GetCharacterID());
  3693. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3694. safe_delete(packet2);
  3695. }
  3696. safe_delete(packet);
  3697. }
  3698. break;
  3699. }
  3700. case COMMAND_ANIMTEST:{
  3701. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3702. if(command_packet){
  3703. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3704. if (cmdTarget)
  3705. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3706. command_packet->setDataByName ( "spawn_id" , id);
  3707. int animID = 1;
  3708. if(sep && sep->arg[0] && sep->IsNumber(0))
  3709. animID = atoi(sep->arg[0]);
  3710. VisualState* vs = NULL;
  3711. if(animID == 0)
  3712. {
  3713. vs = visual_states.FindVisualState(sep->arg[0]);
  3714. }
  3715. char msg[128];
  3716. sprintf(msg,"Animation Test ID: %i",animID);
  3717. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3718. if(vs != NULL)
  3719. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3720. else
  3721. command_packet->setDataByName ( "anim_type", animID );
  3722. command_packet->setDataByName ( "unknown0", 0 );
  3723. EQ2Packet* outapp = command_packet->serialize();
  3724. client->QueuePacket(outapp);
  3725. safe_delete(command_packet);
  3726. }
  3727. break;
  3728. }
  3729. case COMMAND_KICK:
  3730. {
  3731. if( sep == 0 || sep->arg[0] == 0)
  3732. {
  3733. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3734. }
  3735. else
  3736. {
  3737. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3738. if ( kickClient == client )
  3739. {
  3740. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3741. break;
  3742. }
  3743. else if(kickClient != NULL)
  3744. {
  3745. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3746. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3747. {
  3748. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3749. break;
  3750. }
  3751. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3752. kickClient->Disconnect();
  3753. }
  3754. else
  3755. {
  3756. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3757. }
  3758. }
  3759. break;
  3760. }
  3761. case COMMAND_LOCK:
  3762. {
  3763. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3764. int worldLocked = atoi(sep->arg[0]);
  3765. net.world_locked = worldLocked;
  3766. if ( worldLocked )
  3767. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3768. else
  3769. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3770. }
  3771. else
  3772. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3773. break;
  3774. }
  3775. case COMMAND_BAN:{
  3776. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3777. {
  3778. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3779. }
  3780. else
  3781. {
  3782. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3783. if ( kickClient == client )
  3784. {
  3785. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3786. break;
  3787. }
  3788. else if(kickClient != NULL)
  3789. {
  3790. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3791. if ( maxStatus > client->GetAdminStatus( ) ||
  3792. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3793. {
  3794. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3795. break;
  3796. }
  3797. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3798. int perm = atol(sep->arg[1]);
  3799. if ( perm == 1 )
  3800. database.UpdateAdminStatus(sep->arg[0],-2);
  3801. else
  3802. database.UpdateAdminStatus(sep->arg[0],-1);
  3803. kickClient->Disconnect();
  3804. }
  3805. else
  3806. {
  3807. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3808. }
  3809. }
  3810. break;
  3811. }
  3812. case COMMAND_SET_COMBAT_VOICE:{
  3813. int32 value = 0;
  3814. if(sep && sep->arg[0] && sep->IsNumber(0))
  3815. value = atoi(sep->arg[0]);
  3816. client->GetPlayer()->SetCombatVoice(value);
  3817. break;
  3818. }
  3819. case COMMAND_SET_EMOTE_VOICE:{
  3820. int32 value = 0;
  3821. if(sep && sep->arg[0] && sep->IsNumber(0))
  3822. value = atoi(sep->arg[0]);
  3823. client->GetPlayer()->SetEmoteVoice(value);
  3824. break;
  3825. }
  3826. case COMMAND_GIVEITEM:{
  3827. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3828. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3829. if ( itemToClient == NULL )
  3830. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3831. else
  3832. {
  3833. int32 item_id = atol(sep->arg[1]);
  3834. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3835. itemToClient->AddItem(item_id);
  3836. }
  3837. }
  3838. else
  3839. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3840. break;
  3841. }
  3842. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3843. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3844. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3845. case COMMAND_SKILL :
  3846. case COMMAND_SKILL_ADD :
  3847. case COMMAND_SKILL_REMOVE :
  3848. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3849. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3850. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3851. case COMMAND_ENTITYCOMMAND :
  3852. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3853. case COMMAND_MERCHANT :
  3854. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3855. case COMMAND_APPEARANCE :
  3856. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3857. case COMMAND_TRACK : { Command_Track(client); break; }
  3858. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3859. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3860. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3861. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3862. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3863. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3864. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3865. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3866. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3867. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3868. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3869. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3870. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3871. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3872. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3873. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3874. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3875. case COMMAND_LOCATION : { Command_Location(client); break; }
  3876. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3877. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3878. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3879. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3880. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3881. case COMMAND_GRID : { Command_Grid(client); break; }
  3882. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3883. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3884. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3885. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3886. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3887. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3888. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3889. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3890. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3891. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3892. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3893. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3894. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3895. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3896. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3897. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3898. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3899. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3900. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3901. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3902. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3903. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3904. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3905. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3906. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3907. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3908. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3909. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3910. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3911. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3912. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3913. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3914. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3915. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3916. case COMMAND_TITLE : { Command_Title(client); break; }
  3917. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3918. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3919. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3920. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3921. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3922. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3923. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3924. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3925. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3926. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3927. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3928. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3929. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3930. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3931. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3932. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3933. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3934. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3935. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3936. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3937. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3938. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3939. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3940. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3941. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3942. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3943. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3944. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3945. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3946. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3947. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3948. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3949. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3950. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3951. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3952. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3953. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3954. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3955. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3956. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3957. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3958. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3959. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3960. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3961. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3962. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3963. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3964. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3965. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3966. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3967. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3968. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3969. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3970. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3971. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3972. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3973. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3974. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3975. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3976. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3977. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3978. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3979. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3980. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3981. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3982. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3983. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3984. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3985. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3986. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3987. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3988. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3989. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3990. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3991. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3992. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3993. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3994. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3995. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3996. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3997. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3998. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3999. case ADD_AA : { Add_AA(client, sep); break; }
  4000. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4001. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4002. case BACK_AA : { Back_AA(client, sep); break; }
  4003. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4004. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4005. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4006. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4007. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4008. default:
  4009. {
  4010. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4011. break;
  4012. }
  4013. }
  4014. safe_delete(sep);
  4015. }
  4016. /******************** New COMMAND Handler Functions ********************/
  4017. /*
  4018. Started breaking apart the huge switch() for commands into sepErate
  4019. functions so it is easier to locate the blocks of code by command
  4020. -- JA 2012.03.03
  4021. */
  4022. // sample function header
  4023. /*
  4024. Function:
  4025. Purpose :
  4026. Params :
  4027. Dev :
  4028. Example :
  4029. */
  4030. //void Commands::Command()
  4031. //{
  4032. //}
  4033. /*
  4034. Function: Command_AcceptAdvancement()
  4035. Purpose : Player accepts a new advancement option
  4036. Params : Spell ID
  4037. Dev : Jabantiz
  4038. */
  4039. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4040. {
  4041. Player *player = client->GetPlayer();
  4042. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4043. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4044. if (!player->HasSpell(trait->spellID, 0, true))
  4045. {
  4046. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4047. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4048. }
  4049. else
  4050. {
  4051. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4052. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4053. player->RemoveSpellBookEntry(spell->GetSpellID());
  4054. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4055. player->UnlockSpell(spell);
  4056. client->SendSpellUpdate(spell);
  4057. }
  4058. // Spell book update
  4059. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4060. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4061. }
  4062. /*
  4063. Function:
  4064. Purpose :
  4065. Params :
  4066. Dev :
  4067. Example :
  4068. */
  4069. void Commands::Command_AFK(Client* client, Seperator* sep)
  4070. {
  4071. Player* player = client->GetPlayer();
  4072. player->toggle_character_flag(CF_AFK);
  4073. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4074. if (player->get_character_flag(CF_AFK))
  4075. {
  4076. //LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4077. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  4078. if (sep && sep->argplus[0])
  4079. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4080. else
  4081. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4082. string message = string(player->GetName()) + " is going afk.";
  4083. Spawn* target = player->GetTarget();
  4084. if (target && target != player)
  4085. {
  4086. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4087. player->GetGender() == 1 ? message += "he" : message += "she";
  4088. message += " is going afk.";
  4089. }
  4090. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4091. }
  4092. else
  4093. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  4094. }
  4095. /*
  4096. Function: Command_Appearance()
  4097. Purpose : Handles /appearance commands
  4098. Params : list
  4099. Dev : Scatman
  4100. Example : /appearance list
  4101. */
  4102. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4103. {
  4104. if( handler == COMMAND_APPEARANCE )
  4105. {
  4106. // /appearance command by itself shows help (to be extended)
  4107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4108. return;
  4109. }
  4110. else if( handler == COMMAND_APPEARANCE_LIST )
  4111. {
  4112. // /appearance list command expects "name" param
  4113. if (sep && sep->arg[0])
  4114. {
  4115. const char* appearance_name = sep->argplus[0];
  4116. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4117. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4118. if (appearances)
  4119. {
  4120. vector<int16>::iterator itr;
  4121. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4122. {
  4123. int16 id = *itr;
  4124. string name = database.GetAppearanceName(id);
  4125. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4126. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4127. }
  4128. safe_delete(appearances);
  4129. }
  4130. }
  4131. else // no param
  4132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4133. }
  4134. }
  4135. /*
  4136. Function: Command_Claim()
  4137. Purpose :
  4138. Params :
  4139. Dev :
  4140. Example :
  4141. */
  4142. void Commands::Command_Claim(Client* client, Seperator* sep)
  4143. {
  4144. if (sep && sep->arg[0] && sep->IsNumber(0))
  4145. {
  4146. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4148. }
  4149. else
  4150. client->ShowClaimWindow();
  4151. }
  4152. /*
  4153. Function: Command_ClearAllQueued()
  4154. Purpose :
  4155. Params :
  4156. Dev :
  4157. Example :
  4158. */
  4159. void Commands::Command_ClearAllQueued(Client* client)
  4160. {
  4161. ZoneServer* zone = client->GetPlayer()->GetZone();
  4162. if (zone && zone->GetSpellProcess())
  4163. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4164. }
  4165. /*
  4166. Function: Command_CancelMaintained()
  4167. Purpose : Cancels maintained spells
  4168. Params : Maintained Spell Index
  4169. Dev : Zcoretri
  4170. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4171. */
  4172. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4173. {
  4174. if (sep && sep->arg[0] && sep->IsNumber(0))
  4175. {
  4176. int32 spell_index = atoul(sep->arg[0]);
  4177. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4178. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4179. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4180. // just not spelleffects/dets - Foof
  4181. //{
  4182. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4183. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4184. // }
  4185. //else
  4186. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4187. }
  4188. }
  4189. /*
  4190. Function: Command_Create()
  4191. Purpose : Handler for starting Tradeskilling table
  4192. Params :
  4193. Dev : Zcoretri
  4194. Example :
  4195. */
  4196. void Commands::Command_Create(Client* client, Seperator* sep)
  4197. {
  4198. PrintSep(sep, "COMMAND_CREATE");
  4199. client->SendRecipeList();
  4200. client->ShowRecipeBook();
  4201. }
  4202. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4203. {
  4204. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4205. if (sep && sep->arg[0] && sep->IsNumber(0))
  4206. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4207. }
  4208. /*
  4209. Function: Command_Distance()
  4210. Purpose : Displays distance from targeted spawn
  4211. Params :
  4212. Dev : Scatman
  4213. Example : /distance
  4214. */
  4215. void Commands::Command_Distance(Client* client)
  4216. {
  4217. Spawn* target = client->GetPlayer()->GetTarget();
  4218. if (target)
  4219. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4220. else
  4221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4222. }
  4223. /*
  4224. Function: Command_Duel()
  4225. Purpose : Handle the /duel commands - not yet implemented
  4226. Params : unknown
  4227. Dev :
  4228. Example :
  4229. */
  4230. void Commands::Command_Duel(Client* client, Seperator* sep)
  4231. {
  4232. PrintSep(sep, "COMMAND_DUEL");
  4233. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4234. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4235. }
  4236. /*
  4237. Function: Command_DuelBet()
  4238. Purpose : Handle the /duel commands - not yet implemented
  4239. Params : unknown
  4240. Dev :
  4241. Example :
  4242. */
  4243. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4244. {
  4245. PrintSep(sep, "COMMAND_DUELBET");
  4246. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4247. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4248. }
  4249. /*
  4250. Function: Command_DuelAccept()
  4251. Purpose : Handle the /duel commands - not yet implemented
  4252. Params : unknown
  4253. Dev :
  4254. Example :
  4255. */
  4256. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4257. {
  4258. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4259. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4260. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4261. }
  4262. /*
  4263. Function: Command_DuelDecline()
  4264. Purpose : Handle the /duel commands - not yet implemented
  4265. Params : unknown
  4266. Dev :
  4267. Example :
  4268. */
  4269. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4270. {
  4271. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4272. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4273. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4274. }
  4275. /*
  4276. Function: Command_DuelSurrender()
  4277. Purpose : Handle the /duel commands - not yet implemented
  4278. Params : unknown
  4279. Dev :
  4280. Example :
  4281. */
  4282. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4283. {
  4284. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4285. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4286. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4287. // JA, just messin around ;)
  4288. char surrender[64];
  4289. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4290. zone_list.HandleGlobalAnnouncement(surrender);
  4291. }
  4292. /*
  4293. Function: Command_DuelToggle()
  4294. Purpose : Handle the /duel commands - not yet implemented
  4295. Params : unknown
  4296. Dev :
  4297. Example :
  4298. */
  4299. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4300. {
  4301. PrintSep(sep, "COMMAND_DUEL");
  4302. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4303. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4304. }
  4305. /*
  4306. Function:
  4307. Purpose :
  4308. Params :
  4309. Dev :
  4310. Example :
  4311. */
  4312. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4313. {
  4314. if( handler == COMMAND_ENTITYCOMMAND )
  4315. {
  4316. // /entitycommand command by itself shows help (to be extended)
  4317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4318. return;
  4319. }
  4320. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4321. {
  4322. // /entitycommand list command expects "name" param
  4323. if (sep && sep->arg[0])
  4324. {
  4325. const char* entity_command_name = sep->argplus[0];
  4326. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4327. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4328. map<int32, vector<EntityCommand*>*>::iterator itr;
  4329. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4330. {
  4331. vector<EntityCommand*>* entity_command_list = itr->second;
  4332. vector<EntityCommand*>::iterator itr2;
  4333. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4334. {
  4335. EntityCommand* entity_command = *itr2;
  4336. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4337. 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);
  4338. }
  4339. }
  4340. }
  4341. else // no command name
  4342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4343. }
  4344. }
  4345. /*
  4346. Function: Command_Follow()
  4347. Purpose : Handle the /follow command - not yet implemented
  4348. Params :
  4349. Dev :
  4350. Example :
  4351. */
  4352. void Commands::Command_Follow(Client* client, Seperator* sep)
  4353. {
  4354. PrintSep(sep, "COMMAND_FOLLOW");
  4355. // flag to toggle if the players target is in the players group
  4356. bool targetInGroup = false;
  4357. // get a pointer to the players group
  4358. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4359. // If the player has a group and has a target
  4360. if (gmi && client->GetPlayer()->GetTarget()) {
  4361. deque<GroupMemberInfo*>::iterator itr;
  4362. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4363. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4364. // Loop through the group members
  4365. for (itr = members->begin(); itr != members->end(); itr++) {
  4366. // If a group member matches a target
  4367. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4368. // toggle the flag and break the loop
  4369. targetInGroup = true;
  4370. break;
  4371. }
  4372. }
  4373. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4374. }
  4375. if (targetInGroup) {
  4376. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4377. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4378. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4379. client->GetPlayer()->info_changed = true;
  4380. client->GetPlayer()->changed = true;
  4381. }
  4382. else
  4383. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4384. }
  4385. /*
  4386. Function: Command_StopFollow()
  4387. Purpose : Handle the /stop_follow command - not yet implemented
  4388. Params :
  4389. Dev :
  4390. Example :
  4391. */
  4392. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4393. {
  4394. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4395. if (client->GetPlayer()->GetFollowTarget()) {
  4396. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4397. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4398. client->GetPlayer()->SetFollowTarget(0);
  4399. client->GetPlayer()->info_changed = true;
  4400. client->GetPlayer()->changed = true;
  4401. }
  4402. }
  4403. #include "../Zone/SPGrid.h"
  4404. /*
  4405. Function: Command_Grid()
  4406. Purpose : Show player's current Grid ID
  4407. Params :
  4408. Dev : Scatman
  4409. Example : /grid
  4410. */
  4411. void Commands::Command_Grid(Client* client)
  4412. {
  4413. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4414. if (client->GetCurrentZone()->Grid != nullptr) {
  4415. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4416. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4417. }
  4418. }
  4419. /*
  4420. Function: Command_Guild()
  4421. Purpose : Handler for all UI-related guild commands
  4422. Dev : Scatman
  4423. */
  4424. void Commands::Command_Guild(Client* client, Seperator* sep)
  4425. {
  4426. Guild* guild = client->GetPlayer()->GetGuild();
  4427. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4428. {
  4429. const char* command = sep->arg[0];
  4430. int32 length = strlen(command);
  4431. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4432. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4433. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4434. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4435. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4436. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4437. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4438. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4439. guild->KickGuildMember(client, sep->arg[1]);
  4440. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4441. guild->DemoteGuildMember(client, sep->arg[1]);
  4442. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4443. guild->PromoteGuildMember(client, sep->arg[1]);
  4444. else if (strncmp(command, "points", length) == 0 && guild)
  4445. {
  4446. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4447. {
  4448. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4449. {
  4450. float points = atof(sep->arg[2]);
  4451. const char* option = sep->arg[3];
  4452. const char* comment = sep->argplus[4];
  4453. if (strncmp(option, "all", strlen(option)) == 0)
  4454. guild->AddPointsToAll(client, points, comment);
  4455. else if (strncmp(option, "online", strlen(option)) == 0)
  4456. guild->AddPointsToAllOnline(client, points, comment);
  4457. else if (strncmp(option, "group", strlen(option)) == 0)
  4458. guild->AddPointsToGroup(client, points, comment);
  4459. else if (strncmp(option, "raid", strlen(option)) == 0)
  4460. guild->AddPointsToRaid(client, points, comment);
  4461. else
  4462. guild->AddPointsToGuildMember(client, points, option, comment);
  4463. }
  4464. }
  4465. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4466. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4467. else
  4468. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4469. }
  4470. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4471. guild->SetMOTD(sep->argplus[1]);
  4472. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4473. {
  4474. if (sep->arg[1])
  4475. {
  4476. const char* option = sep->arg[1];
  4477. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4478. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4479. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4480. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4481. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4482. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4483. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4484. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4485. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4486. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4487. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4488. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4489. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4490. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4491. else
  4492. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4493. }
  4494. else
  4495. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4496. }
  4497. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4498. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4499. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4500. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4501. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4502. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4503. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4504. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4505. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4506. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4507. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4508. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4509. else if (strncmp(command, "invite", length) == 0 && guild)
  4510. {
  4511. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4512. guild->InvitePlayer(client, sep->arg[1]);
  4513. else
  4514. {
  4515. Spawn* target = client->GetPlayer()->GetTarget();
  4516. if (target)
  4517. {
  4518. if (target->IsPlayer())
  4519. guild->InvitePlayer(client, target->GetName());
  4520. else
  4521. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4522. }
  4523. }
  4524. }
  4525. else if (strncmp(command, "accept", length) == 0)
  4526. {
  4527. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4528. if (pgi && pgi->guild && pgi->invited_by)
  4529. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4530. client->SetPendingGuildInvite(0);
  4531. }
  4532. else if (strncmp(command, "decline", length) == 0)
  4533. {
  4534. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4535. if (pgi && pgi->guild && pgi->invited_by)
  4536. {
  4537. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4538. if (client_inviter)
  4539. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4540. }
  4541. client->SetPendingGuildInvite(0);
  4542. }
  4543. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4544. {
  4545. const char* guild_name = sep->argplus[1];
  4546. if (!guild_list.GetGuild(guild_name))
  4547. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4548. else
  4549. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4550. }
  4551. else if (strncmp(command, "search", length) == 0)
  4552. client->ShowGuildSearchWindow();
  4553. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4554. {
  4555. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4556. if (to_guild)
  4557. to_guild->SendGuildRecruitingDetails(client);
  4558. }
  4559. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4560. {
  4561. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4562. if (to_guild)
  4563. to_guild->SendGuildRecruitingImages(client);
  4564. }
  4565. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4566. {
  4567. if (sep->arg[1])
  4568. {
  4569. const char* option = sep->arg[1];
  4570. if (strncmp(option, "toggle", strlen(option)) == 0)
  4571. guild->ToggleGuildRecruiterAdventureClass(client);
  4572. }
  4573. else
  4574. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4575. }
  4576. else if (strncmp(command, "display_heraldry", length) == 0)
  4577. {
  4578. // JA: not sure this is right...
  4579. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4580. client->GetPlayer()->SetCharSheetChanged(true);
  4581. }
  4582. else
  4583. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4584. }
  4585. }
  4586. /*
  4587. Function: Command_GuildCreate()
  4588. Purpose : Display's in-game Guild Creation window
  4589. Dev : Scatman
  4590. */
  4591. void Commands::Command_CreateGuild(Client* client)
  4592. {
  4593. client->SendGuildCreateWindow();
  4594. }
  4595. /*
  4596. Function: Command_SetGuildOfficerNote()
  4597. Purpose :
  4598. Dev : Scatman
  4599. */
  4600. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4601. {
  4602. if (sep && sep->arg[0] && sep->arg[1])
  4603. {
  4604. Guild* guild = client->GetPlayer()->GetGuild();
  4605. if (guild)
  4606. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4607. }
  4608. }
  4609. /*
  4610. Function: Command_SetGuildMemberNote()
  4611. Purpose :
  4612. Dev : Scatman
  4613. */
  4614. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4615. {
  4616. if (sep && sep->arg[0] && sep->arg[1])
  4617. {
  4618. Guild* guild = client->GetPlayer()->GetGuild();
  4619. if (guild)
  4620. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4621. }
  4622. }
  4623. /*
  4624. Function: Command_GuildSay()
  4625. Purpose :
  4626. Dev : Scatman
  4627. */
  4628. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4629. {
  4630. Guild* guild = client->GetPlayer()->GetGuild();
  4631. if (guild)
  4632. {
  4633. if (sep && sep->arg[0])
  4634. guild->HandleGuildSay(client, sep->argplus[0]);
  4635. }
  4636. else
  4637. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4638. }
  4639. /*
  4640. Function: Command_OfficerSay()
  4641. Purpose :
  4642. Dev : Scatman
  4643. */
  4644. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4645. {
  4646. Guild* guild = client->GetPlayer()->GetGuild();
  4647. if (guild)
  4648. {
  4649. if (sep && sep->arg[0])
  4650. guild->HandleOfficerSay(client, sep->argplus[0]);
  4651. }
  4652. else
  4653. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4654. }
  4655. /*
  4656. Function: Command_Guilds()
  4657. Purpose : Shows help for /guild command
  4658. Params :
  4659. Dev : Scatman
  4660. Example :
  4661. */
  4662. void Commands::Command_Guilds(Client* client)
  4663. {
  4664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4665. }
  4666. /*
  4667. Function: Command_GuildsAdd()
  4668. Purpose : Add's players to a guild
  4669. Params : guild_name|guild_id, player name
  4670. Dev : Scatman
  4671. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4672. */
  4673. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4674. {
  4675. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4676. {
  4677. Guild* guild = 0;
  4678. bool found = true;
  4679. if (sep->IsNumber(0))
  4680. {
  4681. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4682. if (!guild)
  4683. {
  4684. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4685. found = false;
  4686. }
  4687. }
  4688. else
  4689. {
  4690. guild = guild_list.GetGuild(sep->arg[0]);
  4691. if (!guild)
  4692. {
  4693. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4694. found = false;
  4695. }
  4696. }
  4697. if (found)
  4698. {
  4699. Client* to_client = 0;
  4700. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4701. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4702. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4703. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4704. if (to_client)
  4705. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4706. else
  4707. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4708. }
  4709. }
  4710. else
  4711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4712. }
  4713. /*
  4714. Function: Command_GuildsCreate()
  4715. Purpose : Creates a guild
  4716. Params : guild_name, player_name (optional)
  4717. Dev : Scatman
  4718. Example : /guilds create [guild name] (player name)
  4719. */
  4720. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4721. {
  4722. if (sep && sep->arg[0])
  4723. {
  4724. const char* guild_name = sep->arg[0];
  4725. if (!guild_list.GetGuild(guild_name))
  4726. {
  4727. bool ret = false;
  4728. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4729. {
  4730. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4731. if (to_client)
  4732. {
  4733. world.CreateGuild(guild_name, to_client);
  4734. ret = true;
  4735. }
  4736. else
  4737. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4738. }
  4739. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4740. {
  4741. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4742. if (to_client)
  4743. {
  4744. world.CreateGuild(guild_name, to_client);
  4745. ret = true;
  4746. }
  4747. }
  4748. else
  4749. {
  4750. world.CreateGuild(guild_name);
  4751. ret = true;
  4752. }
  4753. if (ret)
  4754. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4755. else
  4756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4757. }
  4758. else
  4759. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4760. }
  4761. else
  4762. 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.");
  4763. }
  4764. /*
  4765. Function: Command_GuildsDelete()
  4766. Purpose : Delete's a guild
  4767. Params : guild name
  4768. Dev : Scatman
  4769. Example : /guilds delete Test
  4770. */
  4771. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4772. {
  4773. if (sep && sep->arg[0])
  4774. {
  4775. Guild* guild = 0;
  4776. bool found = true;
  4777. if (sep->IsNumber(0))
  4778. {
  4779. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4780. if (!guild)
  4781. {
  4782. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4783. found = false;
  4784. }
  4785. }
  4786. else
  4787. {
  4788. guild = guild_list.GetGuild(sep->arg[0]);
  4789. if (!guild)
  4790. {
  4791. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4792. found = false;
  4793. }
  4794. }
  4795. if (found)
  4796. {
  4797. guild->RemoveAllGuildMembers();
  4798. database.DeleteGuild(guild);
  4799. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4800. guild_list.RemoveGuild(guild, true);
  4801. }
  4802. }
  4803. else
  4804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4805. }
  4806. /*
  4807. Function: Command_GuildsList()
  4808. Purpose : Lists current guilds on server
  4809. Params :
  4810. Dev : Scatman
  4811. Example : /guilds list
  4812. */
  4813. void Commands::Command_GuildsList(Client* client)
  4814. {
  4815. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4816. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4818. if (guilds->size() == 0)
  4819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4820. else {
  4821. while (itr.Next()) {
  4822. Guild* guild = itr.second;
  4823. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4824. }
  4825. }
  4826. }
  4827. /*
  4828. Function: Command_GuildsRemove()
  4829. Purpose : Removes a player from a guild
  4830. Params : guild name|guild id, player name
  4831. Dev : Scatman
  4832. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4833. */
  4834. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4835. {
  4836. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4837. {
  4838. Guild* guild = 0;
  4839. bool found = true;
  4840. if (sep->IsNumber(0))
  4841. {
  4842. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4843. if (!guild)
  4844. {
  4845. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4846. found = false;
  4847. }
  4848. }
  4849. else
  4850. {
  4851. guild = guild_list.GetGuild(sep->arg[0]);
  4852. if (!guild)
  4853. {
  4854. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4855. found = false;
  4856. }
  4857. }
  4858. if (found)
  4859. {
  4860. Client* to_client = 0;
  4861. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4862. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4863. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4864. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4865. if (to_client)
  4866. {
  4867. Player* to_player = to_client->GetPlayer();
  4868. if (to_player->GetGuild())
  4869. {
  4870. if (to_player->GetGuild() == guild)
  4871. {
  4872. guild->KickGuildMember(client, to_player->GetName());
  4873. }
  4874. else
  4875. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4876. }
  4877. else
  4878. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4879. }
  4880. else
  4881. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4882. }
  4883. }
  4884. else
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4886. }
  4887. /*
  4888. Function: Command_InspectPlayer()
  4889. Purpose : Handle the Inspect functions
  4890. Params : Client to inspect
  4891. Dev : Scatman
  4892. Example : /inspect Scatman
  4893. */
  4894. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4895. {
  4896. if (sep && sep->arg[0])
  4897. {
  4898. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4899. if (inspect_client)
  4900. client->InspectPlayer(inspect_client->GetPlayer());
  4901. }
  4902. else
  4903. {
  4904. Spawn* target = client->GetPlayer()->GetTarget();
  4905. if (target && target->IsPlayer())
  4906. client->InspectPlayer((Player*)target);
  4907. }
  4908. }
  4909. /*
  4910. Function: Command_Inventory()
  4911. Purpose : Handle changes in player inventory
  4912. Params : <TBD>
  4913. Dev : All
  4914. Example : /inventory delete item_id
  4915. */
  4916. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4917. {
  4918. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4919. Player* player = client->GetPlayer();
  4920. if(sep && sep->arg[0][0])
  4921. {
  4922. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4923. if(client->GetPlayer()->GetHP() == 0)
  4924. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4925. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4926. {
  4927. int16 index = atoi(sep->arg[1]);
  4928. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4929. if(item)
  4930. {
  4931. if(item->GetItemScript() && lua_interface)
  4932. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4933. int32 bag_id = item->details.inv_slot_id;
  4934. database.DeleteItem(client->GetCharacterID(), item, 0);
  4935. client->GetPlayer()->item_list.DestroyItem(index);
  4936. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4937. client->QueuePacket(outapp);
  4938. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4939. if (outapp)
  4940. client->QueuePacket(outapp);
  4941. }
  4942. }
  4943. 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))
  4944. {
  4945. int16 from_index = atoi(sep->arg[1]);
  4946. sint16 to_slot = atoi(sep->arg[2]);
  4947. sint32 bag_id = atol(sep->arg[3]);
  4948. int8 charges = atoi(sep->arg[4]);
  4949. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4950. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4951. {
  4952. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4953. return;
  4954. }
  4955. sint32 old_inventory_id = 0;
  4956. if(item)
  4957. old_inventory_id = item->details.inv_slot_id;
  4958. //autobank
  4959. if (bag_id == -3 && to_slot == -1)
  4960. {
  4961. if (player->HasFreeBankSlot())
  4962. to_slot = player->FindFreeBankSlot();
  4963. else
  4964. {
  4965. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4966. return;
  4967. }
  4968. }
  4969. //auto inventory
  4970. if (bag_id == 0 && to_slot == -1)
  4971. {
  4972. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4973. {
  4974. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4975. return;
  4976. }
  4977. }
  4978. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4979. client->QueuePacket(outapp);
  4980. //removed from bag send update
  4981. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4982. {
  4983. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4984. if(outapp)
  4985. client->QueuePacket(outapp);
  4986. }
  4987. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4988. {
  4989. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4990. if(outapp)
  4991. client->QueuePacket(outapp);
  4992. }
  4993. }
  4994. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4995. {
  4996. if(client->GetPlayer()->EngagedInCombat())
  4997. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4998. else
  4999. {
  5000. int16 index = atoi(sep->arg[1]);
  5001. int8 slot_id = 255;
  5002. if(sep->arg[2][0] && sep->IsNumber(2))
  5003. slot_id = atoi(sep->arg[2]);
  5004. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5005. EQ2Packet* outapp = 0;
  5006. for(int32 i=0;i<packets.size();i++)
  5007. {
  5008. outapp = packets[i];
  5009. if(outapp)
  5010. client->QueuePacket(outapp);
  5011. }
  5012. client->GetPlayer()->ChangePrimaryWeapon();
  5013. client->GetPlayer()->ChangeSecondaryWeapon();
  5014. client->GetPlayer()->ChangeRangedWeapon();
  5015. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5016. client->QueuePacket(characterSheetPackets);
  5017. }
  5018. }
  5019. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5020. {
  5021. if (client->GetPlayer()->EngagedInCombat())
  5022. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5023. else {
  5024. int16 index = atoi(sep->arg[1]);
  5025. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5026. if (item) {
  5027. // client->GetPlayer()->item_list.DestroyItem(index);
  5028. if (item->item_sets.size() > 0) {
  5029. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5030. ItemSet* set = item->item_sets[i];
  5031. if (set->item_stack_size == 0)
  5032. set->item_stack_size += 1;
  5033. client->AddItem(set->item_id, set->item_stack_size);
  5034. }
  5035. }
  5036. }
  5037. client->RemoveItem(item, 1);
  5038. }
  5039. }
  5040. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5041. {
  5042. if(client->GetPlayer()->EngagedInCombat())
  5043. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5044. else
  5045. {
  5046. int16 index = atoi(sep->arg[1]);
  5047. sint32 bag_id = -999;
  5048. int8 to_slot = 255;
  5049. if(sep->arg[3][0])
  5050. {
  5051. if(sep->IsNumber(2))
  5052. bag_id = atol(sep->arg[2]);
  5053. if(sep->IsNumber(3))
  5054. to_slot = atoi(sep->arg[3]);
  5055. }
  5056. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5057. EQ2Packet* outapp = 0;
  5058. for(int32 i=0;i<packets.size();i++)
  5059. {
  5060. outapp = packets[i];
  5061. if(outapp)
  5062. client->QueuePacket(outapp);
  5063. }
  5064. client->GetPlayer()->ChangePrimaryWeapon();
  5065. client->GetPlayer()->ChangeSecondaryWeapon();
  5066. client->GetPlayer()->ChangeRangedWeapon();
  5067. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5068. client->QueuePacket(characterSheetPackets);
  5069. }
  5070. }
  5071. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5072. {
  5073. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5074. int16 index1 = atoi(sep->arg[1]);
  5075. int16 index2 = atoi(sep->arg[2]);
  5076. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5077. if(outapp)
  5078. client->QueuePacket(outapp);
  5079. else
  5080. {
  5081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5082. return;
  5083. }
  5084. }
  5085. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5086. {
  5087. sint16 to_slot = atoi(sep->arg[1]);
  5088. sint32 bag_id = atoi(sep->arg[2]);
  5089. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5090. if (item) {
  5091. //auto inventory
  5092. if (bag_id == 0 && to_slot == -1)
  5093. {
  5094. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5095. {
  5096. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5097. return;
  5098. }
  5099. // Set the slot for the item
  5100. item->details.inv_slot_id = bag_id;
  5101. item->details.slot_id = to_slot;
  5102. // Flag the item so it gets saved in its new location
  5103. item->save_needed = true;
  5104. // Add the item to its new location
  5105. player->item_list.AddItem(item);
  5106. // Remove the item from the overflow list
  5107. player->item_list.RemoveOverflowItem(item);
  5108. // Send the inventory update packet
  5109. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5110. return;
  5111. }
  5112. else if (bag_id == -3 && to_slot == -1) {
  5113. // Auto Bank
  5114. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5115. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5116. return;
  5117. }
  5118. item->details.inv_slot_id = bag_id;
  5119. item->details.slot_id = to_slot;
  5120. item->save_needed = true;
  5121. player->item_list.AddItem(item);
  5122. player->item_list.RemoveOverflowItem(item);
  5123. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5124. }
  5125. else if (bag_id == -4) {
  5126. // Shared Bank
  5127. if (!player->item_list.SharedBankAddAllowed(item)) {
  5128. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5129. return;
  5130. }
  5131. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5132. if (tmp_item) {
  5133. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5134. return;
  5135. }
  5136. else {
  5137. item->details.inv_slot_id = bag_id;
  5138. item->details.slot_id = to_slot;
  5139. item->save_needed = true;
  5140. player->item_list.AddItem(item);
  5141. player->item_list.RemoveOverflowItem(item);
  5142. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5143. return;
  5144. }
  5145. }
  5146. else {
  5147. // Try to get an item from the given bag id and slot id
  5148. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5149. // Check to see if we got an item, if we do send an error,
  5150. // if we don't put the overflow item into this slot
  5151. if (tmp_item) {
  5152. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5153. }
  5154. else {
  5155. item->details.inv_slot_id = bag_id;
  5156. item->details.slot_id = to_slot;
  5157. item->save_needed = true;
  5158. player->item_list.AddItem(item);
  5159. player->item_list.RemoveOverflowItem(item);
  5160. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5161. return;
  5162. }
  5163. }
  5164. }
  5165. }
  5166. }
  5167. else
  5168. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5169. }
  5170. /*
  5171. Function: Command_IRC()
  5172. Purpose : Handle the IRC functions
  5173. Params : IRC Commands
  5174. Dev : Scatman
  5175. Example : /irc say #Channel Hello World!
  5176. */
  5177. void Commands::Command_IRC(Client* client, Seperator* sep)
  5178. {
  5179. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5180. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5181. return;
  5182. }
  5183. if (sep && sep->arg[0][0]) {
  5184. if (strcasecmp(sep->arg[0], "say") == 0) {
  5185. if (sep->arg[1][0] && sep->arg[2][0]) {
  5186. if (sep->IsNumber(sep->arg[1]))
  5187. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5188. else
  5189. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5190. }
  5191. else
  5192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5193. }
  5194. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5195. if (sep->arg[1][0])
  5196. irc.JoinChannel(client, sep->arg[1]);
  5197. else
  5198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5199. }
  5200. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5201. if (sep->arg[1][0])
  5202. irc.LeaveChannel(client, sep->arg[1]);
  5203. else
  5204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5205. }
  5206. else if (strcasecmp(sep->arg[0], "list") == 0)
  5207. irc.ListChannels(client);
  5208. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5209. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5210. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5211. else
  5212. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5213. }
  5214. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5215. irc.DisconnectFromServer(client);
  5216. else
  5217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5218. }
  5219. else
  5220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5221. }
  5222. /*
  5223. Function: Command_Languages()
  5224. Purpose : Show's languages the player knows
  5225. Params :
  5226. Dev : Zcoretri
  5227. Example :
  5228. */
  5229. void Commands::Command_Languages(Client* client, Seperator* sep)
  5230. {
  5231. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5232. list<Language*>::iterator itr;
  5233. Language* language;
  5234. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5235. for(itr = languages->begin(); itr != languages->end(); itr++)
  5236. {
  5237. language = *itr;
  5238. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5239. }
  5240. }
  5241. /*
  5242. Function: Command_SetLanguage()
  5243. Purpose : Handles language commands
  5244. Params : Language ID
  5245. Dev : Zcoretri
  5246. Example :
  5247. */
  5248. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5249. {
  5250. Player* player = client->GetPlayer();
  5251. if (sep && sep->arg[0])
  5252. {
  5253. if(!sep->IsNumber(0))
  5254. {
  5255. //String passed in
  5256. const char* value = sep->arg[0];
  5257. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5258. {
  5259. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5260. client->SendLanguagesUpdate(0);
  5261. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5262. }
  5263. else
  5264. {
  5265. if(player->HasLanguage(value))
  5266. {
  5267. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5268. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5269. client->SendLanguagesUpdate(language->GetID());
  5270. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5271. }
  5272. else
  5273. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5274. }
  5275. }
  5276. else
  5277. {
  5278. //Number passed in
  5279. int32 id = atoul(sep->arg[0]);
  5280. if(player->HasLanguage(id))
  5281. {
  5282. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5283. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5284. client->SendLanguagesUpdate(id);
  5285. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5286. }
  5287. else
  5288. {
  5289. Language* language = master_languages_list.GetLanguage(id);
  5290. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5291. }
  5292. }
  5293. }
  5294. else
  5295. {
  5296. //No value was passed in
  5297. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5298. if(id > 0)
  5299. {
  5300. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5301. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5302. }
  5303. else
  5304. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5305. }
  5306. }
  5307. /*
  5308. Function: Command_LastName()
  5309. Purpose : Sets player surname
  5310. Params : Name text
  5311. Dev : theFoof
  5312. Example :
  5313. */
  5314. void Commands::Command_LastName(Client* client, Seperator* sep)
  5315. {
  5316. if (!client)
  5317. return;
  5318. if (sep && sep->arg[0])
  5319. {
  5320. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5321. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5322. return;
  5323. }
  5324. client->RemovePendingLastName();
  5325. uchar* checkname = (uchar*)sep->arg[0];
  5326. bool valid_name = true;
  5327. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5328. if (!alpha_check(checkname[i])) {
  5329. valid_name = false;
  5330. break;
  5331. }
  5332. }
  5333. if (!valid_name) {
  5334. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5335. return;
  5336. }
  5337. string last_name = (string)sep->arg[0];
  5338. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5339. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5340. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5341. client->SetPendingLastName(last_name);
  5342. client->SendLastNameConfirmation();
  5343. }
  5344. else
  5345. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5346. }
  5347. }
  5348. /*
  5349. Function: Command_ConfirmLastName()
  5350. Purpose : Confirms setting of player surname
  5351. Params : Name text
  5352. Dev : theFoof
  5353. Example :
  5354. */
  5355. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5356. {
  5357. if (!client)
  5358. return;
  5359. string* name = client->GetPendingLastName();
  5360. if (name){
  5361. Player* player = client->GetPlayer();
  5362. player->SetLastName(name->c_str(), false);
  5363. client->SendTitleUpdate();
  5364. player->SetCharSheetChanged(true);
  5365. client->RemovePendingLastName();
  5366. }
  5367. }
  5368. /*
  5369. Function: Command_Location()
  5370. Purpose : Display's Help for /location commands
  5371. Params :
  5372. Dev : Scatman
  5373. Example : /location = show's help for command
  5374. */
  5375. void Commands::Command_Location(Client* client)
  5376. {
  5377. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5378. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5380. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5382. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5383. }
  5384. /*
  5385. Function: Command_LocationAdd()
  5386. Purpose : Add's a location to an existing location config
  5387. Params : location_id
  5388. Dev : Scatman
  5389. Example : /location add {location_id}
  5390. */
  5391. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5392. {
  5393. if (sep && sep->arg[0] && sep->IsNumber(0))
  5394. {
  5395. int32 location_id = atoul(sep->arg[0]);
  5396. float x = client->GetPlayer()->GetX();
  5397. float y = client->GetPlayer()->GetY();
  5398. float z = client->GetPlayer()->GetZ();
  5399. if (database.AddLocationPoint(location_id, x, y, z))
  5400. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5401. else
  5402. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5403. }
  5404. else
  5405. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5406. }
  5407. /*
  5408. Function: Command_LocationCreate()
  5409. Purpose : Creates a new location config
  5410. Params : location name, 0/1 for include_y (optional)
  5411. Dev : Scatman
  5412. Example : /location create Test 1 = creates a new location named Test with include_y True
  5413. */
  5414. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5415. {
  5416. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5417. {
  5418. const char* name = sep->arg[0];
  5419. bool include_y = false;
  5420. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5421. include_y = true;
  5422. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5423. if (location_id > 0)
  5424. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5425. else
  5426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5427. }
  5428. else
  5429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5430. }
  5431. /*
  5432. Function: Command_LocationDelete()
  5433. Purpose : Delete's a location config and all it's location points
  5434. Params : location_id
  5435. Dev : Scatman
  5436. Example : /location delete {location_id}
  5437. */
  5438. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5439. {
  5440. if (sep && sep->arg[0] && sep->IsNumber(0))
  5441. {
  5442. int32 location_id = atoul(sep->arg[0]);
  5443. if (database.DeleteLocation(location_id))
  5444. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5445. else
  5446. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5447. }
  5448. else
  5449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5450. }
  5451. /*
  5452. Function: Command_LocationList()
  5453. Purpose : Display's a list of location points
  5454. Params : location_id
  5455. Dev : Scatman
  5456. Example : /location list {location_id}
  5457. */
  5458. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5459. {
  5460. if (sep && sep->arg[0])
  5461. {
  5462. const char* option = sep->arg[0];
  5463. if (strncmp(option, "locations", strlen(option)) == 0)
  5464. database.ListLocations(client);
  5465. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5466. {
  5467. int32 location_id = atoul(sep->arg[1]);
  5468. database.ListLocationPoints(client, location_id);
  5469. }
  5470. else
  5471. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5472. }
  5473. else
  5474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5475. }
  5476. /*
  5477. Function: Command_LocationRemove()
  5478. Purpose : Removes a single location point from a location config
  5479. Params : location_point_id (gotten from /location list {id})
  5480. Dev : Scatman
  5481. Example : /location remove 1 = will remove location_point_id 1
  5482. */
  5483. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5484. {
  5485. if (sep && sep->arg[0] && sep->IsNumber(0))
  5486. {
  5487. int32 location_point_id = atoul(sep->arg[0]);
  5488. if (database.DeleteLocationPoint(location_point_id))
  5489. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5490. else
  5491. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5492. }
  5493. else
  5494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5495. }
  5496. /*
  5497. Function: Command_Merchant()
  5498. Purpose : Handles Merchant commands
  5499. Params : list
  5500. Dev : Scatman
  5501. Example : /merchant list
  5502. */
  5503. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5504. {
  5505. if( handler == COMMAND_MERCHANT )
  5506. {
  5507. // /merchant command by itself shows help (to be extended)
  5508. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5509. return;
  5510. }
  5511. else if( handler == COMMAND_MERCHANT_LIST )
  5512. {
  5513. // /merchant list command expects "description" param
  5514. if (sep && sep->arg[0])
  5515. {
  5516. const char* merchant_description = sep->argplus[0];
  5517. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5518. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5519. map<int32, MerchantInfo*>::iterator itr;
  5520. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5521. {
  5522. string description = database.GetMerchantDescription(itr->first);
  5523. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5524. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5525. }
  5526. }
  5527. else // no description
  5528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5529. }
  5530. }
  5531. /*
  5532. Function: Command_Modify()
  5533. Purpose : to replace our other "set" commands
  5534. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5535. Dev : John Adams
  5536. Example : /modify spell set name "Aegolism III"
  5537. */
  5538. void Commands::Command_Modify(Client* client)
  5539. {
  5540. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5545. }
  5546. /*
  5547. Function: Command_ModifySpawn()
  5548. Purpose : replace "spawn set" commands
  5549. Params : Action : the action to perform (or special handler)
  5550. : Field : the DB field to change
  5551. : Value : what to set the value to
  5552. : Target : what object to change (my target, or spawn_id)
  5553. Dev : John Adams
  5554. Example : /modify spawn set name "Lady Vox"
  5555. :
  5556. Note : Special Handlers, like "zoneto" for Signs
  5557. : /modify spawn zoneto
  5558. : Will set a sign's zone x/y/z to my current coords
  5559. */
  5560. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5561. {
  5562. PrintSep(sep, "COMMAND_MODIFY");
  5563. // need at least 2 args for a valid command
  5564. if( sep && sep->arg[1] )
  5565. {
  5566. // JA: just a quick implementation because I need it :)
  5567. if (strcmp(sep->arg[0], "zoneto") == 0)
  5568. {
  5569. if( sep->IsNumber(1) )
  5570. {
  5571. int32 spawn_id = atoul(sep->arg[1]);
  5572. float x_coord = client->GetPlayer()->GetX();
  5573. float y_coord = client->GetPlayer()->GetY();
  5574. float z_coord = client->GetPlayer()->GetZ();
  5575. float h_coord = client->GetPlayer()->GetHeading();
  5576. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5577. }
  5578. else
  5579. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5580. }
  5581. }
  5582. else
  5583. Command_Modify(client);
  5584. }
  5585. /*
  5586. Function: Command_ModifyCharacter()
  5587. Purpose : to replace our other "set" commands
  5588. Params : Action : Add, Remove
  5589. : Field : copper, silver, gold, plat
  5590. : Value : min 1, max unlimited
  5591. : Target : Self, Player
  5592. Dev : Cynnar
  5593. Example : /modify character add gold 50
  5594. : /modify character remove silver 25
  5595. */
  5596. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5597. {
  5598. PrintSep(sep, "COMMAND_MODIFY");
  5599. int64 value = 0;
  5600. Player* player = client->GetPlayer();
  5601. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5602. player = (Player*)player->GetTarget();
  5603. // need at least 2 args for a valid command
  5604. if( sep && sep->arg[1] )
  5605. {
  5606. if (strcmp(sep->arg[0], "add") == 0)
  5607. {
  5608. if (strcmp(sep->arg[1], "copper") == 0)
  5609. {
  5610. value = atoi64(sep->arg[2]);
  5611. player->AddCoins(value);
  5612. if (client->GetPlayer() == player)
  5613. {
  5614. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5615. }
  5616. else {
  5617. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5618. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5619. }
  5620. }
  5621. else if (strcmp(sep->arg[1], "silver") == 0)
  5622. {
  5623. value = atoi64(sep->arg[2]) * 100;
  5624. player->AddCoins(value);
  5625. if (client->GetPlayer() == player)
  5626. {
  5627. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5628. }
  5629. else {
  5630. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5631. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5632. }
  5633. }
  5634. else if (strcmp(sep->arg[1], "gold") == 0)
  5635. {
  5636. value = atoi64(sep->arg[2]) * 10000;
  5637. player->AddCoins(value);
  5638. if (client->GetPlayer() == player)
  5639. {
  5640. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5641. }
  5642. else {
  5643. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5644. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5645. }
  5646. }
  5647. else if (strcmp(sep->arg[1], "plat") == 0)
  5648. {
  5649. value = atoi64(sep->arg[2]) * 1000000;
  5650. player->AddCoins(value);
  5651. if (client->GetPlayer() == player)
  5652. {
  5653. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5654. }
  5655. else {
  5656. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5657. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5658. }
  5659. }
  5660. else
  5661. {
  5662. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5663. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5664. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5665. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5666. }
  5667. }
  5668. else if (strcmp(sep->arg[0], "remove") == 0)
  5669. {
  5670. if (strcmp(sep->arg[1], "copper") == 0)
  5671. {
  5672. value = atoi64(sep->arg[2]);
  5673. player->RemoveCoins(value);
  5674. if (client->GetPlayer() == player)
  5675. {
  5676. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5677. }
  5678. else {
  5679. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5680. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5681. }
  5682. }
  5683. else if (strcmp(sep->arg[1], "silver") == 0)
  5684. {
  5685. value = atoi64(sep->arg[2]) * 100;
  5686. player->RemoveCoins(value);
  5687. if (client->GetPlayer() == player)
  5688. {
  5689. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5690. }
  5691. else {
  5692. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5693. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5694. }
  5695. }
  5696. else if (strcmp(sep->arg[1], "gold") == 0)
  5697. {
  5698. value = atoi64(sep->arg[2]) * 10000;
  5699. player->RemoveCoins(value);
  5700. if (client->GetPlayer() == player)
  5701. {
  5702. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5703. }
  5704. else {
  5705. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5706. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5707. }
  5708. }
  5709. else if (strcmp(sep->arg[1], "plat") == 0)
  5710. {
  5711. value = atoi64(sep->arg[2]) * 1000000;
  5712. player->RemoveCoins(value);
  5713. if (client->GetPlayer() == player)
  5714. {
  5715. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5716. }
  5717. else {
  5718. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5719. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5720. }
  5721. }
  5722. else
  5723. {
  5724. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5725. }
  5726. }
  5727. else if (strcmp(sep->arg[0], "set") == 0) {
  5728. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5729. int8 level = atoi(sep->arg[2]);
  5730. if (level > 0 && level < 256) {
  5731. if (player) {
  5732. if (client->GetPlayer() == player)
  5733. client->ChangeTSLevel(player->GetTSLevel(), level);
  5734. else
  5735. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5736. }
  5737. }
  5738. else
  5739. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5740. }
  5741. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5742. int8 tsclass = atoi(sep->arg[2]);
  5743. player->SetTradeskillClass(tsclass);
  5744. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5745. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5746. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5747. player->SetCharSheetChanged(true);
  5748. }
  5749. }
  5750. }
  5751. else
  5752. {
  5753. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5754. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5755. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5756. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5757. }
  5758. }
  5759. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5760. {
  5761. PrintSep(sep, "COMMAND_MODIFY");
  5762. // need at least 2 args for a valid command
  5763. if( sep && sep->arg[1] )
  5764. {
  5765. }
  5766. else
  5767. Command_Modify(client);
  5768. }
  5769. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5770. {
  5771. PrintSep(sep, "COMMAND_MODIFY");
  5772. // need at least 2 args for a valid command
  5773. if( sep && sep->arg[1] )
  5774. {
  5775. }
  5776. else
  5777. Command_Modify(client);
  5778. }
  5779. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5780. {
  5781. PrintSep(sep, "COMMAND_MODIFY");
  5782. // need at least 2 args for a valid command
  5783. if( sep && sep->arg[1] )
  5784. {
  5785. }
  5786. else
  5787. Command_Modify(client);
  5788. }
  5789. /*
  5790. Function: Command_ModifyQuest()
  5791. Purpose : to list players quest and completed quests
  5792. Params : Action : list, completed
  5793. : Target : Self, Player
  5794. Dev : Cynnar
  5795. Example : /modify quest list
  5796. : /modify quest completed
  5797. */
  5798. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5799. {
  5800. PrintSep(sep, "COMMAND_MODIFY");
  5801. int64 value = 0;
  5802. Player* player = client->GetPlayer();
  5803. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5804. player = (Player*)player->GetTarget();
  5805. // need at least 2 args for a valid command
  5806. if (sep && sep->arg[1])
  5807. {
  5808. if (strcmp(sep->arg[0], "list") == 0)
  5809. {
  5810. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5811. map<int32, Quest*>::iterator itr;
  5812. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5813. if (quests->size() == 0)
  5814. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5815. else
  5816. {
  5817. for (itr = quests->begin(); itr != quests->end(); itr++)
  5818. {
  5819. Quest* quest = itr->second;
  5820. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5821. }
  5822. }
  5823. }
  5824. else if (strcmp(sep->arg[0], "completed") == 0)
  5825. {
  5826. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5827. map<int32, Quest*>::iterator itr;
  5828. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5829. if (quests->size() == 0)
  5830. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5831. else
  5832. {
  5833. for (itr = quests->begin(); itr != quests->end(); itr++)
  5834. {
  5835. Quest* quest = itr->second;
  5836. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5837. }
  5838. }
  5839. }
  5840. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5841. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5842. else if (strcmp(sep->arg[0], "remove") == 0)
  5843. {
  5844. int32 quest_id = 0;
  5845. if (sep && sep->arg[1] && sep->IsNumber(1))
  5846. quest_id = atoul(sep->arg[1]);
  5847. if (quest_id > 0)
  5848. {
  5849. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5850. {
  5851. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5852. if (quest)
  5853. if (client->GetPlayer() == player)
  5854. {
  5855. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5856. }
  5857. else
  5858. {
  5859. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5860. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5861. }
  5862. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5863. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5864. }
  5865. client->RemovePlayerQuest(quest_id);
  5866. client->GetCurrentZone()->SendQuestUpdates(client);
  5867. }
  5868. }
  5869. else if (strcmp(sep->arg[0], "advance") == 0)
  5870. {
  5871. int32 quest_id = 0;
  5872. int32 step = 0;
  5873. if (sep && sep->arg[1] && sep->IsNumber(1))
  5874. {
  5875. quest_id = atoul(sep->arg[1]);
  5876. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5877. if (sep && sep->arg[2] && sep->IsNumber(1))
  5878. {
  5879. step = atoul(sep->arg[2]);
  5880. if (quest_id > 0 && step > 0)
  5881. {
  5882. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5883. {
  5884. if (client)
  5885. {
  5886. client->AddPendingQuestUpdate(quest_id, step);
  5887. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5888. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5889. }
  5890. }
  5891. }
  5892. else
  5893. {
  5894. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5895. }
  5896. }
  5897. else
  5898. {
  5899. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5900. }
  5901. }
  5902. else
  5903. {
  5904. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5905. }
  5906. }
  5907. else
  5908. {
  5909. Command_Modify(client);
  5910. }
  5911. }
  5912. else
  5913. {
  5914. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5915. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5916. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5917. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5918. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5919. }
  5920. }
  5921. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5922. {
  5923. PrintSep(sep, "COMMAND_MODIFY");
  5924. // need at least 2 args for a valid command
  5925. if( sep && sep->arg[1] )
  5926. {
  5927. if (strcmp(sep->arg[0], "add") == 0) {
  5928. const char* skill_name = sep->argplus[1];
  5929. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5930. if (skill) {
  5931. Player* player = 0;
  5932. Client* to_client = 0;
  5933. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5934. player = (Player*)client->GetPlayer()->GetTarget();
  5935. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5936. }
  5937. else {
  5938. player = client->GetPlayer();
  5939. to_client = client;
  5940. }
  5941. if (player)
  5942. {
  5943. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5944. {
  5945. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5946. if (to_client == client) {
  5947. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5948. }
  5949. else {
  5950. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5951. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5952. }
  5953. }
  5954. else
  5955. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5956. }
  5957. }
  5958. else
  5959. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5960. }
  5961. else if (strcmp(sep->arg[0], "remove") == 0) {
  5962. const char* skill_name = sep->argplus[1];
  5963. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5964. if (skill) {
  5965. Player* player = 0;
  5966. Client* to_client = 0;
  5967. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5968. player = (Player*)client->GetPlayer()->GetTarget();
  5969. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5970. }
  5971. else {
  5972. player = client->GetPlayer();
  5973. to_client = client;
  5974. }
  5975. if (player)
  5976. {
  5977. if (player->GetSkills()->HasSkill(skill->skill_id))
  5978. {
  5979. player->RemoveSkillFromDB(skill, true);
  5980. if (client == to_client) {
  5981. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5982. }
  5983. else {
  5984. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5985. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5986. }
  5987. }
  5988. else {
  5989. if (client == to_client)
  5990. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5991. else
  5992. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5993. }
  5994. }
  5995. }
  5996. else
  5997. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5998. }
  5999. else if (strcmp(sep->arg[0], "set") == 0) {
  6000. if (!sep->IsNumber(2)) {
  6001. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6002. return;
  6003. }
  6004. const char* skill_name = sep->arg[1];
  6005. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6006. if (skill) {
  6007. int16 val = atoi(sep->arg[2]);
  6008. Player* player = 0;
  6009. Client* to_client = 0;
  6010. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6011. player = (Player*)client->GetPlayer()->GetTarget();
  6012. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6013. }
  6014. else {
  6015. player = client->GetPlayer();
  6016. to_client = client;
  6017. }
  6018. if (player)
  6019. {
  6020. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6021. player->GetSkills()->SetSkill(skill->skill_id, val);
  6022. if (client != to_client)
  6023. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6024. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6025. }
  6026. else {
  6027. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6028. }
  6029. }
  6030. }
  6031. else {
  6032. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6033. }
  6034. }
  6035. else {
  6036. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6037. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6038. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6039. }
  6040. }
  6041. else {
  6042. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6043. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6044. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6045. }
  6046. }
  6047. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6048. {
  6049. PrintSep(sep, "COMMAND_MODIFY");
  6050. // need at least 2 args for a valid command
  6051. if( sep && sep->arg[1] )
  6052. {
  6053. }
  6054. else
  6055. Command_Modify(client);
  6056. }
  6057. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6058. {
  6059. PrintSep(sep, "COMMAND_MODIFY");
  6060. // need at least 2 args for a valid command
  6061. if( sep && sep->arg[1] )
  6062. {
  6063. }
  6064. else
  6065. Command_Modify(client);
  6066. }
  6067. /*
  6068. Function: Command_MOTD()
  6069. Purpose : Displays server MOTD
  6070. Params :
  6071. Dev : LethalEncounter
  6072. Example : /motd
  6073. */
  6074. void Commands::Command_MOTD(Client* client)
  6075. {
  6076. if (client)
  6077. ClientPacketFunctions::SendMOTD(client);
  6078. }
  6079. /*
  6080. Function: Command_Pet()
  6081. Purpose : Handle Pet {Command} commands
  6082. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6083. Dev :
  6084. Example : /pet preserve_master
  6085. */
  6086. void Commands::Command_Pet(Client* client, Seperator* sep)
  6087. {
  6088. PrintSep(sep, "COMMAND_PET");
  6089. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6090. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6091. if (strcmp(sep->arg[0], "hide") == 0) {
  6092. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6093. Entity* pet = client->GetPlayer()->GetDeityPet();
  6094. if (pet) {
  6095. if (pet->IsPrivateSpawn())
  6096. client->GetPlayer()->HideDeityPet(false);
  6097. else
  6098. client->GetPlayer()->HideDeityPet(true);
  6099. }
  6100. pet = client->GetPlayer()->GetCosmeticPet();
  6101. if (pet) {
  6102. if (pet->IsPrivateSpawn())
  6103. client->GetPlayer()->HideCosmeticPet(false);
  6104. else
  6105. client->GetPlayer()->HideCosmeticPet(true);
  6106. }
  6107. return;
  6108. }
  6109. // below is for all combat pets
  6110. if (!client->GetPlayer()->HasPet()) {
  6111. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6112. return;
  6113. }
  6114. if (strcmp(sep->arg[0], "stay") == 0) {
  6115. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6116. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6117. client->GetPlayer()->SetCharSheetChanged(true);
  6118. if (client->GetPlayer()->GetPet())
  6119. client->GetPlayer()->GetPet()->following = false;
  6120. if (client->GetPlayer()->GetCharmedPet())
  6121. client->GetPlayer()->GetCharmedPet()->following = false;
  6122. }
  6123. else if (strcmp(sep->arg[0], "follow") == 0) {
  6124. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6125. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6126. client->GetPlayer()->SetCharSheetChanged(true);
  6127. }
  6128. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6129. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6130. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6131. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6132. }
  6133. else {
  6134. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6135. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6136. }
  6137. client->GetPlayer()->SetCharSheetChanged(true);
  6138. }
  6139. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6140. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6141. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6142. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6143. }
  6144. else {
  6145. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6146. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6147. }
  6148. client->GetPlayer()->SetCharSheetChanged(true);
  6149. }
  6150. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6151. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6152. if (client->GetPlayer()->GetPet())
  6153. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6154. if (client->GetPlayer()->GetCharmedPet())
  6155. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6156. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6157. client->GetPlayer()->SetCharSheetChanged(true);
  6158. }
  6159. else if (strcmp(sep->arg[0], "attack") == 0) {
  6160. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6161. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6162. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6163. if (client->GetPlayer()->GetPet())
  6164. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6165. if (client->GetPlayer()->GetCharmedPet())
  6166. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6167. }
  6168. else
  6169. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6170. }
  6171. else
  6172. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6173. }
  6174. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6175. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6176. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6177. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6178. }
  6179. else
  6180. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6181. }
  6182. /*
  6183. Function: Command_PetName()
  6184. Purpose : Pet your name (???)
  6185. Params :
  6186. Dev :
  6187. Example :
  6188. */
  6189. void Commands::Command_PetName(Client* client, Seperator* sep)
  6190. {
  6191. PrintSep(sep, "COMMAND_PETNAME");
  6192. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6193. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6194. }
  6195. /*
  6196. Function: Command_NamePet()
  6197. Purpose : Name your pet
  6198. Params :
  6199. Dev :
  6200. Example :
  6201. */
  6202. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6203. {
  6204. PrintSep(sep, "COMMAND_NAME_PET");
  6205. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6206. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6207. }
  6208. /*
  6209. Function: Command_Rename()
  6210. Purpose : Renames existing pet
  6211. Params :
  6212. Dev :
  6213. Example :
  6214. */
  6215. void Commands::Command_Rename(Client* client, Seperator* sep)
  6216. {
  6217. PrintSep(sep, "COMMAND_RENAME");
  6218. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6219. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6220. }
  6221. /*
  6222. Function: Command_ConfirmRename()
  6223. Purpose : Confirms renaming your pet
  6224. Params :
  6225. Dev :
  6226. Example :
  6227. */
  6228. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6229. {
  6230. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6231. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6232. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6233. }
  6234. /*
  6235. Function: Command_PetOptions()
  6236. Purpose : Sets various pet options
  6237. Params :
  6238. Dev :
  6239. Example :
  6240. */
  6241. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6242. {
  6243. PrintSep(sep, "COMMAND_PETOPTIONS");
  6244. Player* player = client->GetPlayer();
  6245. Spawn* target = player->GetTarget();
  6246. if (!target)
  6247. return;
  6248. if (target == player->GetPet())
  6249. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6250. else if (target == player->GetCharmedPet())
  6251. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6252. else if (target == player->GetCosmeticPet())
  6253. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6254. else if (target == player->GetDeityPet())
  6255. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6256. }
  6257. /*
  6258. Function: Command_Random()
  6259. Purpose : Handles /random dice roll in-game
  6260. Params : 1-100
  6261. Dev : Scatman
  6262. Example : /randon 1 100
  6263. */
  6264. void Commands::Command_Random(Client* client, Seperator* sep)
  6265. {
  6266. char message[256] = {0};
  6267. if (sep)
  6268. {
  6269. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6270. 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])));
  6271. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6272. 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])));
  6273. else
  6274. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6275. }
  6276. else
  6277. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6278. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6279. }
  6280. /*
  6281. Function: Command_Randomize()
  6282. Purpose : Sets randomize (appearance) values for NPCs
  6283. Params : Attrib Name
  6284. Dev : Scatman
  6285. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6286. */
  6287. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6288. {
  6289. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6290. if (target)
  6291. {
  6292. if (target->IsNPC())
  6293. {
  6294. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6295. {
  6296. const char* value = sep->arg[0];
  6297. if (strncasecmp(value, "show", strlen(value)) == 0)
  6298. {
  6299. client->DisplayRandomizeFeatures(target->GetRandomize());
  6300. }
  6301. else
  6302. {
  6303. if (sep->arg[1] && sep->IsNumber(1))
  6304. {
  6305. int8 option = atoi(sep->arg[1]);
  6306. if (option == 0 || option == 1)
  6307. {
  6308. int32 feature = 0;
  6309. char feature_text[32] = {0};
  6310. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6311. feature = RANDOMIZE_GENDER;
  6312. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6313. }
  6314. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6315. feature = RANDOMIZE_RACE;
  6316. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6317. }
  6318. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6319. feature = RANDOMIZE_MODEL_TYPE;
  6320. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6321. }
  6322. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6323. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6324. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6325. }
  6326. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6327. feature = RANDOMIZE_HAIR_TYPE;
  6328. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6329. }
  6330. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6331. feature = RANDOMIZE_WING_TYPE;
  6332. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6333. }
  6334. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6335. feature = RANDOMIZE_CHEEK_TYPE;
  6336. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6337. }
  6338. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6339. feature = RANDOMIZE_CHIN_TYPE;
  6340. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6341. }
  6342. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6343. feature = RANDOMIZE_EAR_TYPE;
  6344. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6345. }
  6346. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6347. feature = RANDOMIZE_EYE_BROW_TYPE;
  6348. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6349. }
  6350. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6351. feature = RANDOMIZE_EYE_TYPE;
  6352. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6353. }
  6354. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6355. feature = RANDOMIZE_LIP_TYPE;
  6356. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6357. }
  6358. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6359. feature = RANDOMIZE_NOSE_TYPE;
  6360. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6361. }
  6362. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6363. feature = RANDOMIZE_EYE_COLOR;
  6364. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6365. }
  6366. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6367. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6368. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6369. }
  6370. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6371. feature = RANDOMIZE_HAIR_COLOR1;
  6372. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6373. }
  6374. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6375. feature = RANDOMIZE_HAIR_COLOR2;
  6376. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6377. }
  6378. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6379. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6380. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6381. }
  6382. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6383. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6384. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6385. }
  6386. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6387. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6388. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6389. }
  6390. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6391. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6392. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6393. }
  6394. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6395. feature = RANDOMIZE_SKIN_COLOR;
  6396. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6397. }
  6398. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6399. feature = RANDOMIZE_WING_COLOR1;
  6400. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6401. }
  6402. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6403. feature = RANDOMIZE_WING_COLOR2;
  6404. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6405. }
  6406. else {
  6407. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6408. 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'.");
  6409. }
  6410. if (feature > 0) {
  6411. if (option == 1) {
  6412. if (target->GetRandomize() & feature)
  6413. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6414. else {
  6415. target->AddRandomize(feature);
  6416. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6417. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6418. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6419. }
  6420. }
  6421. else {
  6422. if (target->GetRandomize() & feature) {
  6423. target->AddRandomize(-feature);
  6424. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6425. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6426. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6427. }
  6428. else
  6429. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6430. }
  6431. }
  6432. }
  6433. else
  6434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6435. }
  6436. else
  6437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6438. }
  6439. }
  6440. else {
  6441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6443. 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'.");
  6444. }
  6445. }
  6446. else
  6447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6448. }
  6449. else
  6450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6451. }
  6452. /*
  6453. Function: Command_ShowCloak()
  6454. Purpose : Character Settings combo box for Show Cloak
  6455. Params : true/false
  6456. Dev : John Adams
  6457. Example :
  6458. */
  6459. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6460. {
  6461. Player* player = client->GetPlayer();
  6462. if (sep && sep->arg[0])
  6463. {
  6464. const char* value = sep->arg[0];
  6465. if (strncasecmp(value, "true", strlen(value)) == 0)
  6466. {
  6467. player->set_character_flag(CF_SHOW_CLOAK);
  6468. player->reset_character_flag(CF2_SHOW_RANGED);
  6469. }
  6470. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6471. player->reset_character_flag(CF_SHOW_CLOAK);
  6472. else
  6473. {
  6474. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6475. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6476. }
  6477. }
  6478. }
  6479. /*
  6480. Function: Command_ShowHelm()
  6481. Purpose : Character Settings combo box for Show Helm
  6482. Params : true/false
  6483. Dev : John Adams
  6484. Example :
  6485. */
  6486. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6487. {
  6488. Player* player = client->GetPlayer();
  6489. if (sep && sep->arg[0])
  6490. {
  6491. const char* value = sep->arg[0];
  6492. if (strncasecmp(value, "true", strlen(value)) == 0)
  6493. {
  6494. player->reset_character_flag(CF_HIDE_HELM);
  6495. player->set_character_flag(CF_HIDE_HOOD);
  6496. }
  6497. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6498. player->set_character_flag(CF_HIDE_HELM);
  6499. else
  6500. {
  6501. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6502. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6503. }
  6504. }
  6505. }
  6506. /*
  6507. Function: Command_ShowHood()
  6508. Purpose : Character Settings combo box for Show Hood
  6509. Params : true/false
  6510. Dev : John Adams
  6511. Example :
  6512. */
  6513. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6514. {
  6515. Player* player = client->GetPlayer();
  6516. if (sep && sep->arg[0])
  6517. {
  6518. const char* value = sep->arg[0];
  6519. if (strncasecmp(value, "true", strlen(value)) == 0)
  6520. {
  6521. player->reset_character_flag(CF_HIDE_HOOD);
  6522. player->set_character_flag(CF_HIDE_HELM);
  6523. }
  6524. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6525. player->set_character_flag(CF_HIDE_HOOD);
  6526. else
  6527. {
  6528. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6529. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6530. }
  6531. }
  6532. }
  6533. /*
  6534. Function: Command_ShowHoodHelm()
  6535. Purpose : Character Settings combo box for Show Helm or Hood
  6536. Params : true/false
  6537. Dev : John Adams
  6538. Example :
  6539. */
  6540. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6541. {
  6542. Player* player = client->GetPlayer();
  6543. if (sep && sep->arg[0])
  6544. {
  6545. const char* value = sep->arg[0];
  6546. if (strncasecmp(value, "true", strlen(value)) == 0)
  6547. {
  6548. player->reset_character_flag(CF_HIDE_HOOD);
  6549. player->reset_character_flag(CF_HIDE_HELM);
  6550. }
  6551. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6552. {
  6553. // don't think we ever wind up in here...
  6554. player->set_character_flag(CF_HIDE_HOOD);
  6555. player->set_character_flag(CF_HIDE_HELM);
  6556. }
  6557. else
  6558. {
  6559. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6560. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6561. }
  6562. }
  6563. }
  6564. /*
  6565. Function: Command_ShowRanged()
  6566. Purpose : Character Settings combo box for Show Ranged weapon
  6567. Params : true/false
  6568. Dev : John Adams
  6569. Example :
  6570. */
  6571. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6572. {
  6573. Player* player = client->GetPlayer();
  6574. if (sep && sep->arg[0])
  6575. {
  6576. const char* value = sep->arg[0];
  6577. if (strncasecmp(value, "true", strlen(value)) == 0)
  6578. {
  6579. player->set_character_flag(CF2_SHOW_RANGED);
  6580. player->reset_character_flag(CF_SHOW_CLOAK);
  6581. }
  6582. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6583. player->reset_character_flag(CF2_SHOW_RANGED);
  6584. else
  6585. {
  6586. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6587. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6588. }
  6589. }
  6590. }
  6591. /*
  6592. Function:
  6593. Purpose :
  6594. Params :
  6595. Dev :
  6596. Example :
  6597. */
  6598. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6599. {
  6600. Player* player = 0;
  6601. Client* to_client = 0;
  6602. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6603. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6604. switch(handler)
  6605. {
  6606. case COMMAND_SKILL:
  6607. {
  6608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6610. break;
  6611. }
  6612. case COMMAND_SKILL_ADD:
  6613. {
  6614. if (sep && sep->arg[0])
  6615. {
  6616. const char* skill_name = sep->argplus[0];
  6617. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6618. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6619. {
  6620. player = to_client->GetPlayer();
  6621. if (player)
  6622. {
  6623. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6624. {
  6625. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6626. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6627. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6628. }
  6629. else
  6630. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6631. }
  6632. }
  6633. else if (skill) // add skill to yourself
  6634. {
  6635. player = client->GetPlayer();
  6636. if (player)
  6637. {
  6638. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6639. {
  6640. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6641. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6642. }
  6643. else
  6644. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6645. }
  6646. }
  6647. else
  6648. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6649. }
  6650. else
  6651. {
  6652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6654. }
  6655. break;
  6656. }
  6657. case COMMAND_SKILL_REMOVE:
  6658. {
  6659. if (sep && sep->arg[0])
  6660. {
  6661. const char* skill_name = sep->argplus[0];
  6662. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6663. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6664. {
  6665. player = to_client->GetPlayer();
  6666. if (player)
  6667. {
  6668. if (player->GetSkills()->HasSkill(skill->skill_id))
  6669. {
  6670. player->RemoveSkillFromDB(skill, true);
  6671. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6672. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6673. }
  6674. else
  6675. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6676. }
  6677. }
  6678. else if(skill) // remove skill from yourself
  6679. {
  6680. Player* player = client->GetPlayer();
  6681. if (player)
  6682. {
  6683. if (player->GetSkills()->HasSkill(skill->skill_id))
  6684. {
  6685. player->RemoveSkillFromDB(skill, true);
  6686. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6687. }
  6688. else
  6689. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6690. }
  6691. }
  6692. else
  6693. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6694. }
  6695. else
  6696. {
  6697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6698. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6699. }
  6700. break;
  6701. }
  6702. case COMMAND_SKILL_LIST:
  6703. {
  6704. if (sep && sep->arg[0])
  6705. {
  6706. const char* skill_name = sep->argplus[0];
  6707. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6708. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6709. map<int32, Skill*>::iterator itr;
  6710. if (skills && skills->size() > 0)
  6711. {
  6712. for (itr = skills->begin(); itr != skills->end(); itr++)
  6713. {
  6714. Skill* skill = itr->second;
  6715. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6716. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6717. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6718. }
  6719. }
  6720. }
  6721. else
  6722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6723. break;
  6724. }
  6725. }
  6726. }
  6727. /*
  6728. Function: Command_SpawnTemplate()
  6729. Purpose : Create or Use defined Spawn Templates
  6730. Params : create, save, rempve, list
  6731. Dev : John Adams
  6732. Example : /spawn template create "Test"
  6733. */
  6734. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6735. {
  6736. if (sep == NULL || sep->arg[0] == NULL)
  6737. {
  6738. 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.");
  6739. return;
  6740. }
  6741. // got params, continue
  6742. const char * template_cmd = sep->arg[0];
  6743. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6744. {
  6745. if (!sep->IsSet(1))
  6746. {
  6747. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6748. 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.");
  6749. return;
  6750. }
  6751. map<int32, string>* template_names = 0;
  6752. if (sep->IsNumber(1))
  6753. {
  6754. int32 location_id = 0;
  6755. location_id = atoi(sep->arg[1]);
  6756. template_names = database.GetSpawnTemplateListByID(location_id);
  6757. }
  6758. else
  6759. {
  6760. const char* name = 0;
  6761. name = sep->argplus[1];
  6762. template_names = database.GetSpawnTemplateListByName(name);
  6763. }
  6764. if(!template_names)
  6765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6766. else
  6767. {
  6768. map<int32, string>::iterator itr;
  6769. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6770. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6771. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6772. safe_delete(template_names);
  6773. }
  6774. }
  6775. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6776. {
  6777. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6778. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6779. {
  6780. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6781. {
  6782. // first, lookup to see if template name already exists
  6783. const char* name = 0;
  6784. name = sep->argplus[1];
  6785. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6786. if(!template_names)
  6787. {
  6788. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6789. if( new_template_id > 0 )
  6790. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6791. else
  6792. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6793. }
  6794. else
  6795. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6796. }
  6797. else
  6798. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6799. }
  6800. else
  6801. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6802. }
  6803. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6804. {
  6805. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6806. {
  6807. int32 template_id = 0;
  6808. template_id = atoi(sep->arg[1]);
  6809. if (database.RemoveSpawnTemplate(template_id))
  6810. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6811. else
  6812. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6813. }
  6814. else
  6815. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6816. }
  6817. // Renamed create to spawn
  6818. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6819. {
  6820. if (sep && sep->arg[1][0])
  6821. {
  6822. int32 new_location = 0;
  6823. if (sep->IsNumber(1))
  6824. {
  6825. int32 template_id = 0;
  6826. template_id = atoi(sep->arg[1]);
  6827. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6828. if( new_location > 0 )
  6829. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6830. else
  6831. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6832. }
  6833. else
  6834. {
  6835. const char* name = 0;
  6836. name = sep->argplus[1];
  6837. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6838. if( new_location > 0 )
  6839. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6840. else
  6841. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6842. }
  6843. }
  6844. else
  6845. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6846. }
  6847. else
  6848. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6849. }
  6850. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6851. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6852. float new_speed = atof(sep->arg[0]);
  6853. if (new_speed > 0.0f)
  6854. {
  6855. client->GetPlayer()->SetSpeed(new_speed, true);
  6856. client->GetPlayer()->SetCharSheetChanged(true);
  6857. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6858. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6859. }
  6860. else
  6861. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6862. }
  6863. else{
  6864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6865. }
  6866. }
  6867. /*
  6868. Function: Command_StationMarketPlace()
  6869. Purpose : just trying to eat the console spam for now
  6870. Params :
  6871. Dev : John
  6872. */
  6873. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6874. {
  6875. PrintSep(sep, "COMMAND_SMP");
  6876. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6877. // can't seem to reduce it any more get rid of it completely...
  6878. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6879. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6880. if (packet) {
  6881. packet->setDataByName("account_id", client->GetAccountID());
  6882. packet->setDataByName("character_id", client->GetCharacterID());
  6883. packet->setDataByName("unknown1", 1, 5);
  6884. packet->setDataByName("unknown1", 26, 6);
  6885. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6886. packet->setDataByName("unknown3", 248, 1);
  6887. client->QueuePacket(packet->serialize());
  6888. }
  6889. safe_delete(packet);
  6890. }
  6891. }
  6892. /*
  6893. Function: Command_StopDrinking()
  6894. Purpose : Stops player from auto-consuming drink
  6895. Params :
  6896. Dev : Zcoretri
  6897. Example : /stopdrinking
  6898. */
  6899. void Commands::Command_StopDrinking(Client* client)
  6900. {
  6901. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6902. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6903. }
  6904. /*
  6905. Function: Command_StopEating()
  6906. Purpose : Stops player from auto-consuming food
  6907. Params :
  6908. Dev : Zcoretri
  6909. Example : /stopeating
  6910. */
  6911. void Commands::Command_StopEating(Client* client)
  6912. {
  6913. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6914. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6915. }
  6916. /*
  6917. Function: Command_Title()
  6918. Purpose : Help for /title command
  6919. Params : n/a
  6920. Dev : Zcoretri
  6921. Example : /title
  6922. */
  6923. void Commands::Command_Title(Client* client)
  6924. {
  6925. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6926. }
  6927. /*
  6928. Function: Command_TitleList()
  6929. Purpose : List available titles for player
  6930. Params : n/a
  6931. Dev : Zcoretri
  6932. Example : /title list
  6933. */
  6934. void Commands::Command_TitleList(Client* client)
  6935. {
  6936. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6937. list<Title*>::iterator itr;
  6938. Title* title;
  6939. int16 i = 0;
  6940. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6941. for(itr = titles->begin(); itr != titles->end(); itr++)
  6942. {
  6943. title = *itr;
  6944. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6945. i++;
  6946. }
  6947. }
  6948. /*
  6949. Function: Command_TitleSetPrefix()
  6950. Purpose : Set Prefix title for player
  6951. Params : Title ID
  6952. Dev : Zcoretri
  6953. Example : /title setprefix 1
  6954. */
  6955. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6956. {
  6957. if (sep && sep->arg[0] && sep->IsNumber(0))
  6958. {
  6959. int32 index = atoul(sep->arg[0]);
  6960. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6961. client->SendTitleUpdate();
  6962. }
  6963. }
  6964. /*
  6965. Function: Command_TitleSetSuffix()
  6966. Purpose : Set Suffix title for player
  6967. Params : Title ID
  6968. Dev : Zcoretri
  6969. Example : /title setsuffix 1
  6970. */
  6971. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6972. {
  6973. if (sep && sep->arg[0] && sep->IsNumber(0))
  6974. {
  6975. int32 index = atoul(sep->arg[0]);
  6976. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6977. client->SendTitleUpdate();
  6978. }
  6979. }
  6980. /*
  6981. Function: Command_TitleFix()
  6982. Purpose : Fix title for player (???)
  6983. Params :
  6984. Dev : Zcoretri
  6985. Example :
  6986. */
  6987. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6988. {
  6989. PrintSep(sep, "COMMAND_TITLE_FIX");
  6990. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6991. }
  6992. /*
  6993. Function: Command_Toggle_Anonymous()
  6994. Purpose : Toggles player Anonymous
  6995. Params :
  6996. Dev : paulgh
  6997. Example : /anon
  6998. */
  6999. void Commands::Command_Toggle_Anonymous(Client* client)
  7000. {
  7001. Player* player = client->GetPlayer();
  7002. player->toggle_character_flag(CF_ANONYMOUS);
  7003. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7004. if (player->get_character_flag(CF_ANONYMOUS))
  7005. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7006. else
  7007. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7008. }
  7009. /*
  7010. Function: Command_Toggle_AutoConsume()
  7011. Purpose : Toggles player food/drink auto consume
  7012. Params : unknown
  7013. Dev : paulgh
  7014. Example : /set_auto_consume
  7015. */
  7016. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7017. {
  7018. Player* player = client->GetPlayer();
  7019. if (sep && sep->arg[0])
  7020. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7021. if (sep && sep->arg[0] && sep->IsNumber(0))
  7022. {
  7023. int8 slot = atoi(sep->arg[0]);
  7024. int8 flag = atoi(sep->arg[1]);
  7025. if (slot == EQ2_FOOD_SLOT)
  7026. {
  7027. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7028. player->SetCharSheetChanged(true);
  7029. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7030. if (flag == 1)
  7031. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7032. else
  7033. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7034. }
  7035. else
  7036. {
  7037. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7038. player->SetCharSheetChanged(true);
  7039. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7040. if (flag == 1)
  7041. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7042. else
  7043. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7044. }
  7045. }
  7046. }
  7047. /*
  7048. Function: Command_Toggle_BonusXP()
  7049. Purpose : Toggles player Bonus XP
  7050. Params :
  7051. Dev : John Adams
  7052. Example : /disable_char_bonus_exp
  7053. */
  7054. void Commands::Command_Toggle_BonusXP(Client* client)
  7055. {
  7056. Player* player = client->GetPlayer();
  7057. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7058. player->SetCharSheetChanged(true);
  7059. }
  7060. /*
  7061. Function: Command_Toggle_CombatXP()
  7062. Purpose : Toggles player Adventure XP
  7063. Params :
  7064. Dev : John Adams
  7065. Example : /disable_combat_exp
  7066. */
  7067. void Commands::Command_Toggle_CombatXP(Client* client)
  7068. {
  7069. Player* player = client->GetPlayer();
  7070. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7071. player->SetCharSheetChanged(true);
  7072. }
  7073. /*
  7074. Function: Command_Toggle_GMHide()
  7075. Purpose : Toggles hiding player GM status
  7076. Params :
  7077. Dev : Scatman
  7078. Example : /gm_hide
  7079. */
  7080. void Commands::Command_Toggle_GMHide(Client* client)
  7081. {
  7082. Player* player = client->GetPlayer();
  7083. player->toggle_character_flag(CF_HIDE_STATUS);
  7084. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7085. }
  7086. /*
  7087. Function: Command_Toggle_GMVanish()
  7088. Purpose : Toggles hiding GM players from /who searches
  7089. Params :
  7090. Dev : Scatman
  7091. Example : /gm_vanish
  7092. */
  7093. void Commands::Command_Toggle_GMVanish(Client* client)
  7094. {
  7095. Player* player = client->GetPlayer();
  7096. player->toggle_character_flag(CF_GM_HIDDEN);
  7097. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7098. }
  7099. /*
  7100. Function: Command_Toggle_Illusions()
  7101. Purpose : Toggles player illusion form
  7102. Params : not sure sep is needed, testing
  7103. Dev : paulgh
  7104. Example : /hide_illusions
  7105. */
  7106. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7107. {
  7108. if (sep && sep->arg[0])
  7109. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7110. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7111. }
  7112. /*
  7113. Function: Command_Toggle_LFG()
  7114. Purpose : Toggles player LFG Flag
  7115. Params :
  7116. Dev : paulgh
  7117. Example : /lfg
  7118. */
  7119. void Commands::Command_Toggle_LFG(Client* client)
  7120. {
  7121. Player* player = client->GetPlayer();
  7122. player->toggle_character_flag(CF_LFG);
  7123. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7124. if (player->get_character_flag(CF_LFG))
  7125. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7126. else
  7127. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7128. }
  7129. /*
  7130. Function: Command_Toggle_LFW()
  7131. Purpose : Toggles player LFW Flag
  7132. Params :
  7133. Dev : paulgh
  7134. Example : /lfw
  7135. */
  7136. void Commands::Command_Toggle_LFW(Client* client)
  7137. {
  7138. Player* player = client->GetPlayer();
  7139. player->toggle_character_flag(CF_LFW);
  7140. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7141. if (player->get_character_flag(CF_LFW))
  7142. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7143. else
  7144. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7145. }
  7146. /*
  7147. Function: Command_Toggle_QuestXP()
  7148. Purpose : Toggles player Quest XP
  7149. Params :
  7150. Dev : John Adams
  7151. Example : /disable_quest_exp
  7152. */
  7153. void Commands::Command_Toggle_QuestXP(Client* client)
  7154. {
  7155. Player* player = client->GetPlayer();
  7156. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7157. player->SetCharSheetChanged(true);
  7158. }
  7159. /*
  7160. Function: Command_Toggle_Roleplaying()
  7161. Purpose : Toggles player Roleplaying flag
  7162. Params :
  7163. Dev : paulgh
  7164. Example : /role
  7165. */
  7166. void Commands::Command_Toggle_Roleplaying(Client* client)
  7167. {
  7168. Player* player = client->GetPlayer();
  7169. player->toggle_character_flag(CF_ROLEPLAYING);
  7170. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7171. if (player->get_character_flag(CF_ROLEPLAYING))
  7172. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7173. else
  7174. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7175. }
  7176. void Commands::Command_Toggle_Duels(Client* client)
  7177. {
  7178. Player* player = client->GetPlayer();
  7179. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7180. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7181. }
  7182. void Commands::Command_Toggle_Trades(Client* client)
  7183. {
  7184. Player* player = client->GetPlayer();
  7185. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7186. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7187. }
  7188. void Commands::Command_Toggle_Guilds(Client* client)
  7189. {
  7190. Player* player = client->GetPlayer();
  7191. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7192. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7193. }
  7194. void Commands::Command_Toggle_Groups(Client* client)
  7195. {
  7196. Player* player = client->GetPlayer();
  7197. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7198. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7199. }
  7200. void Commands::Command_Toggle_Raids(Client* client)
  7201. {
  7202. Player* player = client->GetPlayer();
  7203. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7204. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7205. }
  7206. void Commands::Command_Toggle_LON(Client* client)
  7207. {
  7208. Player* player = client->GetPlayer();
  7209. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7210. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7211. }
  7212. void Commands::Command_Toggle_VoiceChat(Client* client)
  7213. {
  7214. Player* player = client->GetPlayer();
  7215. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7216. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7217. }
  7218. /*
  7219. Function: Command_TradeStart()
  7220. Purpose : Starts item/coin trade between players
  7221. Params :
  7222. Dev :
  7223. Example :
  7224. */
  7225. #include "../Trade.h"
  7226. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7227. {
  7228. PrintSep(sep, "COMMAND_START_TRADE");
  7229. Entity* trader = client->GetPlayer();
  7230. Entity* trader2 = 0;
  7231. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7232. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7233. if (spawn) {
  7234. if (spawn->IsEntity())
  7235. trader2 = (Entity*)spawn;
  7236. }
  7237. }
  7238. else if (client->GetPlayer()->GetTarget()) {
  7239. if (client->GetPlayer()->GetTarget()->IsEntity())
  7240. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7241. }
  7242. // can only trade with player or bots
  7243. if (trader && trader2) {
  7244. if (trader == trader2) {
  7245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7246. }
  7247. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7248. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7249. if (trader->trade)
  7250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7251. else if (trader2->trade)
  7252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7253. else {
  7254. Trade* trade = new Trade(trader, trader2);
  7255. trader->trade = trade;
  7256. trader2->trade = trade;
  7257. }
  7258. }
  7259. else {
  7260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7261. }
  7262. }
  7263. else
  7264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7265. }
  7266. /*
  7267. Function: Command_Track()
  7268. Purpose : Starts/Stops Tracking for a player
  7269. Params :
  7270. Dev : Scatman
  7271. Example : /track
  7272. */
  7273. void Commands::Command_Track(Client* client)
  7274. {
  7275. if (!client->GetPlayer()->GetIsTracking())
  7276. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7277. else
  7278. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7279. }
  7280. /*
  7281. Function: Command_TradeAccept()
  7282. Purpose : Accepts item/coin trade between players
  7283. Params :
  7284. Dev :
  7285. Example :
  7286. */
  7287. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7288. {
  7289. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7290. Trade* trade = client->GetPlayer()->trade;
  7291. if (trade) {
  7292. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7293. if (trade_complete)
  7294. safe_delete(trade);
  7295. }
  7296. else
  7297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7298. }
  7299. /*
  7300. Function: Command_TradeReject()
  7301. Purpose : Rejects item/coin trade between players
  7302. Params :
  7303. Dev :
  7304. Example :
  7305. */
  7306. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7307. {
  7308. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7309. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7310. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7311. }
  7312. /*
  7313. Function: Command_TradeCancel()
  7314. Purpose : Cancels item/coin trade between players
  7315. Params :
  7316. Dev :
  7317. Example :
  7318. */
  7319. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7320. {
  7321. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7322. Trade* trade = client->GetPlayer()->trade;
  7323. if (trade) {
  7324. trade->CancelTrade(client->GetPlayer());
  7325. safe_delete(trade);
  7326. }
  7327. else
  7328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7329. }
  7330. /*
  7331. Function: Command_TradeSetCoin()
  7332. Purpose : Sets coin trade between players
  7333. Params :
  7334. Dev :
  7335. Example :
  7336. */
  7337. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7338. {
  7339. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7340. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7341. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7342. }
  7343. /*
  7344. Function: Command_TradeAddCoin()
  7345. Purpose : Adds coin to trade between players
  7346. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7347. Dev :
  7348. Example :
  7349. */
  7350. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7351. {
  7352. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7353. Trade* trade = client->GetPlayer()->trade;
  7354. if (trade) {
  7355. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7356. int32 amount = atoi(sep->arg[0]);
  7357. int64 val = 0;
  7358. switch (handler) {
  7359. case COMMAND_ADD_TRADE_COPPER:
  7360. {
  7361. val = amount;
  7362. trade->AddCoinToTrade(client->GetPlayer(), val);
  7363. break;
  7364. }
  7365. case COMMAND_ADD_TRADE_SILVER:
  7366. {
  7367. val = amount * 100;
  7368. trade->AddCoinToTrade(client->GetPlayer(), val);
  7369. break;
  7370. }
  7371. case COMMAND_ADD_TRADE_GOLD:
  7372. {
  7373. val = amount * 10000;
  7374. trade->AddCoinToTrade(client->GetPlayer(), val);
  7375. break;
  7376. }
  7377. case COMMAND_ADD_TRADE_PLAT:
  7378. {
  7379. val = amount * 1000000;
  7380. trade->AddCoinToTrade(client->GetPlayer(), val);
  7381. break;
  7382. }
  7383. default:
  7384. {
  7385. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7386. break;
  7387. }
  7388. }
  7389. }
  7390. else
  7391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7392. }
  7393. else
  7394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7395. }
  7396. /*
  7397. Function: Command_TradeRemoveCoin()
  7398. Purpose : Removes coin from trade between players
  7399. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7400. Dev :
  7401. Example :
  7402. */
  7403. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7404. {
  7405. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7406. Trade* trade = client->GetPlayer()->trade;
  7407. if (trade) {
  7408. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7409. int32 amount = atoi(sep->arg[0]);
  7410. int64 val = 0;
  7411. switch (handler) {
  7412. case COMMAND_REMOVE_TRADE_COPPER:
  7413. {
  7414. val = amount;
  7415. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7416. break;
  7417. }
  7418. case COMMAND_REMOVE_TRADE_SILVER:
  7419. {
  7420. val = amount * 100;
  7421. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7422. break;
  7423. }
  7424. case COMMAND_REMOVE_TRADE_GOLD:
  7425. {
  7426. val = amount * 10000;
  7427. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7428. break;
  7429. }
  7430. case COMMAND_REMOVE_TRADE_PLAT:
  7431. {
  7432. val = amount * 1000000;
  7433. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7434. break;
  7435. }
  7436. default:
  7437. {
  7438. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7439. break;
  7440. }
  7441. }
  7442. }
  7443. else
  7444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7445. }
  7446. else
  7447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7448. }
  7449. /*
  7450. Function: Command_TradeAddItem()
  7451. Purpose : Adds item to trade between players
  7452. Params :
  7453. Dev :
  7454. Example :
  7455. */
  7456. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7457. {
  7458. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7459. /*
  7460. arg[0] = item index
  7461. arg[1] = slot
  7462. arg[2] = quantity
  7463. */
  7464. if (!client->GetPlayer()->trade) {
  7465. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7467. return;
  7468. }
  7469. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7470. Item* item = 0;
  7471. int32 index = atoi(sep->arg[0]);
  7472. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7473. if (item) {
  7474. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7475. if (result == 1)
  7476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7477. else if (result == 2)
  7478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7479. else if (result == 3)
  7480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7481. else if (result == 255)
  7482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7483. }
  7484. else {
  7485. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7486. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7487. }
  7488. }
  7489. else
  7490. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7491. }
  7492. /*
  7493. Function: Command_TradeRemoveItem()
  7494. Purpose : Removes item from trade between players
  7495. Params :
  7496. Dev :
  7497. Example :
  7498. */
  7499. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7500. {
  7501. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7502. /*
  7503. arg[0] = trade window slot
  7504. */
  7505. Trade* trade = client->GetPlayer()->trade;
  7506. if (trade) {
  7507. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7508. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7509. }
  7510. else
  7511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7512. }
  7513. else
  7514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7515. }
  7516. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7517. {
  7518. Item *item = 0;
  7519. sint32 crc;
  7520. if (sep) {
  7521. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7522. if (client->GetVersion() < 1096) {
  7523. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7524. {
  7525. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7526. crc = atol(sep->arg[2]);
  7527. }
  7528. }
  7529. else {
  7530. // From the broker and links in chat
  7531. if (strcmp(sep->arg[0], "crc") == 0) {
  7532. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7533. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7534. crc = atol(sep->arg[3]);
  7535. }
  7536. }
  7537. // From inventory
  7538. if (strcmp(sep->arg[0], "dbid") == 0) {
  7539. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7540. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7541. crc = atol(sep->arg[4]);
  7542. }
  7543. }
  7544. }
  7545. if (item)
  7546. client->ShowDressingRoom(item, crc);
  7547. }
  7548. }
  7549. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7550. const char *channel_name, *password = NULL;
  7551. if (sep == NULL || !sep->IsSet(0)) {
  7552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7553. return;
  7554. }
  7555. channel_name = sep->arg[0];
  7556. if (sep->IsSet(1))
  7557. password = sep->arg[1];
  7558. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7559. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7560. return;
  7561. }
  7562. if (chat.IsInChannel(client, channel_name)) {
  7563. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7564. return;
  7565. }
  7566. if (chat.HasPassword(channel_name)) {
  7567. if (password == NULL) {
  7568. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7569. return;
  7570. }
  7571. if (!chat.PasswordMatches(channel_name, password)) {
  7572. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7573. return;
  7574. }
  7575. }
  7576. if (!chat.JoinChannel(client, channel_name))
  7577. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7578. }
  7579. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7580. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7581. Command_JoinChannel(client, sep);
  7582. }
  7583. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7584. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7586. PrintSep(sep, "tellchannel");
  7587. return;
  7588. }
  7589. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7590. }
  7591. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7592. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7593. if (!p) return;
  7594. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7595. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7596. //}
  7597. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7598. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7599. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7600. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7601. if (packet) {
  7602. client->QueuePacket(packet->serialize());
  7603. safe_delete(packet);
  7604. }
  7605. }*/
  7606. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7607. int32 numFaces = 0;
  7608. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7609. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7610. map<int32, vector<Face*> >::iterator itr;
  7611. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7612. numFaces += (*itr).second.size();
  7613. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7614. }*/
  7615. //uchar blah[] = {
  7616. // 1208 - OP_EQUpdateStoreCmd
  7617. // /*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
  7618. // /*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
  7619. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7620. // /*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
  7621. /*};
  7622. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7623. int8 val = 0;
  7624. int16 pos = 0;
  7625. int idx = 0;
  7626. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7627. pos = atoi(sep2->arg[idx]);
  7628. val = atoi(sep2->arg[idx+1]);
  7629. memset(blah+pos, val, 1);
  7630. idx+=2;
  7631. }
  7632. DumpPacket(blah, sizeof(blah));
  7633. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7634. if (client->GetPlayer()->GetTarget()) {
  7635. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7636. if (packet) {
  7637. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7638. packet->setDataByName("size", 0);
  7639. packet->setDataByName("unknown2", 0);
  7640. EQ2Packet* app = packet->serialize();
  7641. client->QueuePacket(app);
  7642. safe_delete(packet);
  7643. }
  7644. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7645. if (set_pov) {
  7646. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7647. EQ2Packet* app_pov = set_pov->serialize();
  7648. client->QueuePacket(app_pov);
  7649. safe_delete(set_pov);
  7650. }
  7651. }
  7652. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7653. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7654. if (packet) {
  7655. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7656. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7657. else
  7658. packet->setDataByName("Type", 2);
  7659. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7660. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7661. else
  7662. packet->setDataByName("race_id", 0);
  7663. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7664. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7665. else
  7666. packet->setDataByName("gender", 2);
  7667. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7668. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7669. else
  7670. packet->setDataByName("unknown", 0, 0);
  7671. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7672. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7673. else
  7674. packet->setDataByName("unknown", 0, 1);
  7675. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7676. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7677. else
  7678. packet->setDataByName("unknown", 0, 2);
  7679. client->QueuePacket(packet->serialize());
  7680. }
  7681. safe_delete(packet);
  7682. safe_delete(sep2);
  7683. }
  7684. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7685. const char *channel_name;
  7686. if (sep == NULL || !sep->IsSet(0)) {
  7687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7688. PrintSep(sep);
  7689. return;
  7690. }
  7691. channel_name = sep->arg[0];
  7692. if (!chat.IsInChannel(client, channel_name))
  7693. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7694. else if (!chat.LeaveChannel(client, channel_name))
  7695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7696. }
  7697. /*
  7698. Function:
  7699. Purpose :
  7700. Params :
  7701. Dev :
  7702. Example :
  7703. */
  7704. void Commands::Command_WeaponStats(Client* client)
  7705. {
  7706. Player* player = client->GetPlayer();
  7707. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7708. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7709. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7710. client->SimpleMessage(0, "Primary:");
  7711. if (primary) {
  7712. client->Message(0, "Name: %s", primary->name.c_str());
  7713. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7714. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7715. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7716. client->Message(0, "Proc Percent: %d%%", 0);
  7717. client->Message(0, "Procs Per Minute: %d", 0);
  7718. }
  7719. else {
  7720. client->SimpleMessage(0, "Name: fist");
  7721. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7722. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7723. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7724. client->Message(0, "Proc Percent: %d%%", 0);
  7725. client->Message(0, "Procs Per Minute: %d", 0);
  7726. }
  7727. client->SimpleMessage(0, " ");
  7728. client->SimpleMessage(0, " ");
  7729. if (secondary) {
  7730. client->SimpleMessage(0, "Secondary:");
  7731. client->Message(0, "Name: %s", secondary->name.c_str());
  7732. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7733. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7734. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7735. client->Message(0, "Proc Percent: %d%%", 0);
  7736. client->Message(0, "Procs Per Minute: %d", 0);
  7737. client->SimpleMessage(0, " ");
  7738. client->SimpleMessage(0, " ");
  7739. }
  7740. client->SimpleMessage(0, "Ranged:");
  7741. if (ranged) {
  7742. client->Message(0, "Name: %s", ranged->name.c_str());
  7743. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7744. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7745. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7746. client->Message(0, "Proc Percent: %d%%", 0);
  7747. client->Message(0, "Procs Per Minute: %d", 0);
  7748. }
  7749. else
  7750. client->SimpleMessage(0, "None");
  7751. }
  7752. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7753. const char *channel_name;
  7754. if (sep == NULL || !sep->IsSet(0)) {
  7755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7756. return;
  7757. }
  7758. channel_name = sep->arg[0];
  7759. if (!chat.ChannelExists(channel_name))
  7760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7761. else
  7762. chat.SendChannelUserList(client, channel_name);
  7763. }
  7764. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7765. {
  7766. ZoneServer* zone = 0;
  7767. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7768. if (zone_id > 0)
  7769. {
  7770. zone = zone_list.Get(zone_id, false);
  7771. if (zone)
  7772. {
  7773. zone->SetSafeX(client->GetPlayer()->GetX());
  7774. zone->SetSafeY(client->GetPlayer()->GetY());
  7775. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7776. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7777. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7779. else
  7780. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7781. }
  7782. }
  7783. }
  7784. /*
  7785. Function:
  7786. Purpose :
  7787. Params :
  7788. Dev :
  7789. Example :
  7790. */
  7791. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7792. {
  7793. ZoneInfo* zone_info = new ZoneInfo;
  7794. if (sep && sep->arg[0])
  7795. {
  7796. if (sep->IsNumber(0))
  7797. zone_info->id = atoi(sep->arg[0]);
  7798. else
  7799. zone_info->id = database.GetZoneID(sep->arg[0]);
  7800. if (zone_info->id > 0)
  7801. {
  7802. database.LoadZoneInfo(zone_info);
  7803. 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);
  7804. 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);
  7805. 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);
  7806. 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);
  7807. 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);
  7808. 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);
  7809. 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);
  7810. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7811. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7812. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7813. }
  7814. else
  7815. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7816. }
  7817. else
  7818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7819. safe_delete(zone_info);
  7820. }
  7821. /*
  7822. Function:
  7823. Purpose :
  7824. Params :
  7825. Dev :
  7826. Example :
  7827. */
  7828. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7829. {
  7830. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7831. {
  7832. ZoneServer* zone = 0;
  7833. int32 zone_id = 0;
  7834. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7835. {
  7836. zone_id = atoi(sep->arg[0]);
  7837. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7838. }
  7839. else
  7840. {
  7841. zone_id = database.GetZoneID(sep->arg[0]);
  7842. if (zone_id > 0)
  7843. zone = zone_list.Get(sep->arg[0], false);
  7844. }
  7845. if (zone_id > 0)
  7846. {
  7847. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7848. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7849. else
  7850. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7851. }
  7852. else
  7853. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7854. }
  7855. else
  7856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7857. }
  7858. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7859. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7861. return;
  7862. }
  7863. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7864. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7865. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7866. }
  7867. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7868. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7870. return;
  7871. }
  7872. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7873. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7874. }
  7875. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7876. Spawn* spawn = client->GetPlayer()->GetTarget();
  7877. if(spawn) {
  7878. client->SetMerchantTransaction(spawn);
  7879. if (spawn->GetMerchantID() > 0){
  7880. client->SendHailCommand(spawn);
  7881. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7882. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7883. client->SendBuyMerchantList(sell);
  7884. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7885. client->SendSellMerchantList(sell);
  7886. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7887. client->SendBuyBackList(sell);
  7888. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7889. if (packet) {
  7890. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7891. packet->setDataByName("type", 16);
  7892. EQ2Packet* outapp = packet->serialize();
  7893. if (outapp)
  7894. client->QueuePacket(outapp);
  7895. safe_delete(packet);
  7896. }
  7897. }
  7898. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7899. client->SendRepairList();
  7900. }
  7901. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7902. }
  7903. void Commands::Command_Weather(Client* client, Seperator* sep)
  7904. {
  7905. //PrintSep(sep, "Weather");
  7906. if( sep && sep->arg[0] )
  7907. {
  7908. ZoneServer* zsZone = client->GetCurrentZone();
  7909. const char* value = sep->arg[0];
  7910. // process single-param commands first
  7911. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7912. {
  7913. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7914. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7915. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7916. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7917. }
  7918. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7919. {
  7920. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7921. zsZone->ProcessWeather();
  7922. }
  7923. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7924. {
  7925. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7926. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7927. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7928. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7929. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7930. zsZone->SetWeatherPattern(1);
  7931. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7932. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7933. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7934. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7935. zsZone->ProcessWeather();
  7936. }
  7937. // process commands with params
  7938. if( sep->arg[1] )
  7939. {
  7940. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7941. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7942. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7943. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7944. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7945. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7946. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7947. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7948. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7949. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7950. }
  7951. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7952. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7953. zsZone->SetRain(zsZone->GetCurrentWeather());
  7954. }
  7955. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7956. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7957. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7958. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7959. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7960. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7961. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7962. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7963. }
  7964. }
  7965. else
  7966. {
  7967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7970. return;
  7971. }
  7972. }
  7973. void Commands::Command_Select(Client* client, Seperator* sep) {
  7974. if (sep && sep->arg[1]) {
  7975. Spawn* spawn = client->GetPlayer()->GetTarget();
  7976. if (spawn && strlen(sep->arg[1]) > 0)
  7977. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7978. }
  7979. }
  7980. /*
  7981. Function: Command_ConsumeFood()
  7982. Purpose : Consume Food/Drink and apply mods
  7983. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7984. Dev : Zcoretri
  7985. Example : /consume_food 22
  7986. */
  7987. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7988. if (sep && sep->arg[0] && sep->IsNumber(0))
  7989. {
  7990. Player* player = client->GetPlayer();
  7991. int8 slot = atoi(sep->arg[0]);
  7992. Item* item = player->GetEquipmentList()->GetItem(slot);
  7993. if(item) {
  7994. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7995. if(item->GetItemScript() && lua_interface){
  7996. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7997. if (slot == 22)
  7998. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7999. else
  8000. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  8001. }
  8002. }
  8003. if (item->details.count > 1) {
  8004. item->details.count -= 1;
  8005. item->save_needed = true;
  8006. }
  8007. else {
  8008. player->GetEquipmentList()->RemoveItem(slot, true);
  8009. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  8010. }
  8011. client->GetPlayer()->SetCharSheetChanged(true);
  8012. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8013. }
  8014. }
  8015. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  8016. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8017. if (atoi(sep->arg[0]) == 1) {
  8018. client->GetPlayer()->GetInfoStruct()->vision = 4;
  8019. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  8020. client->GetPlayer()->SetCharSheetChanged(true);
  8021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  8022. }
  8023. else {
  8024. client->GetPlayer()->GetInfoStruct()->vision = 0;
  8025. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  8026. client->GetPlayer()->SetCharSheetChanged(true);
  8027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  8028. }
  8029. }
  8030. else
  8031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  8032. }
  8033. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  8034. {
  8035. if(sep)
  8036. {
  8037. string data;
  8038. if(sep->arg[0]){
  8039. data = string(sep->arg[0]);
  8040. }
  8041. for(int i=1;i<sep->GetMaxArgNum();i++){
  8042. if(sep->arg[i])
  8043. data.append(" ").append(sep->arg[i]);
  8044. }
  8045. const char* target_name = 0;
  8046. int32 spawn_id = 0;
  8047. if(client->GetPlayer()->GetTarget())
  8048. {
  8049. target_name = client->GetPlayer()->GetTarget()->GetName();
  8050. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8051. }
  8052. else
  8053. target_name = "N/A";
  8054. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  8055. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  8056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  8057. else
  8058. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  8059. }
  8060. }
  8061. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  8062. PrintSep(sep, "Command_Attune_Inv");
  8063. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8064. // Get the item index from the first parameter
  8065. int16 index = atoi(sep->arg[0]);
  8066. // Check to see if this is a valid item index for the player, if not exit out of the function
  8067. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  8068. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  8069. return;
  8070. }
  8071. // Get the item
  8072. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  8073. if(item) {
  8074. // Valid item lets check to make sure this item is attunable, if not return out
  8075. if (!item->CheckFlag(ATTUNEABLE)) {
  8076. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  8077. return;
  8078. }
  8079. // Remove the attunable flag
  8080. item->generic_info.item_flags -= ATTUNEABLE;
  8081. // Set the attuned flag
  8082. item->generic_info.item_flags += ATTUNED;
  8083. // Flag this item for saving
  8084. item->save_needed = true;
  8085. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  8086. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  8087. EQ2Packet* outapp = 0;
  8088. for (int32 i=0;i<packets.size();i++) {
  8089. outapp = packets[i];
  8090. if(outapp)
  8091. client->QueuePacket(outapp);
  8092. }
  8093. }
  8094. }
  8095. }
  8096. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  8097. PrintSep(sep, "Command_Reset_Zone_Timer");
  8098. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8099. int32 db_id = atoul(sep->arg[0]);
  8100. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  8101. if (data) {
  8102. // TODO: add a check to timers to ensure it can be reset
  8103. // Delete the character from the instance
  8104. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  8105. data->instance_id = 0;
  8106. // Update the success time and set to 0 so the player can enter it again
  8107. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  8108. data->last_success_timestamp = 0;
  8109. }
  8110. }*/
  8111. }
  8112. void Commands::Command_Player(Client* client, Seperator* sep) {
  8113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  8114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  8115. }
  8116. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  8117. // /player coins add 10
  8118. // /player coins add plat 10
  8119. Player* player = client->GetPlayer();
  8120. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  8121. player = (Player*)player->GetTarget();
  8122. if (sep && sep->arg[0] && sep->arg[1]) {
  8123. const char* action = sep->arg[0];
  8124. int64 value = 0;
  8125. if (strncasecmp(action, "add", strlen(action)) == 0) {
  8126. if (sep->IsNumber(1)) {
  8127. value = atoi64(sep->arg[1]);
  8128. player->AddCoins(value);
  8129. if (client->GetPlayer() == player)
  8130. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8131. else {
  8132. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8133. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8134. }
  8135. return;
  8136. }
  8137. else if (sep->arg[2] && sep->IsNumber(2)) {
  8138. const char* type = sep->arg[1];
  8139. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  8140. value = atoi64(sep->arg[2]);
  8141. }
  8142. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  8143. value = atoi64(sep->arg[2]) * 100;
  8144. }
  8145. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  8146. value = atoi64(sep->arg[2]) * 10000;
  8147. }
  8148. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  8149. value = atoi64(sep->arg[2]) * 1000000;
  8150. }
  8151. player->AddCoins(value);
  8152. if (client->GetPlayer() == player)
  8153. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8154. else {
  8155. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8156. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8157. }
  8158. return;
  8159. }
  8160. }
  8161. }
  8162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  8163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  8164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  8165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  8166. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  8167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  8168. }
  8169. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  8170. PrintSep(sep, "ACHIEVEMENT_ADD");
  8171. if (sep && sep->IsSet(0)) {
  8172. int32 spell_id = atoul(sep->arg[1]);
  8173. int8 spell_tier = 0;
  8174. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8175. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8176. // addspellbookentry here
  8177. if (spell_tier >= data->maxRank) {
  8178. return;
  8179. }
  8180. if (!spell_tier) {
  8181. spell_tier = 1;
  8182. }
  8183. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8184. {
  8185. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8186. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8187. client->GetPlayer()->UnlockSpell(spell);
  8188. client->SendSpellUpdate(spell);
  8189. }
  8190. else
  8191. {
  8192. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8193. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8194. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8195. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8196. client->GetPlayer()->UnlockSpell(spell);
  8197. client->SendSpellUpdate(spell);
  8198. }
  8199. // cast spell here
  8200. if (!spell_tier)
  8201. spell_tier = 1;
  8202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8203. if (spell) {
  8204. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8205. }
  8206. }
  8207. else {
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8209. }
  8210. master_aa_list.DisplayAA(client, 0, 0);
  8211. }
  8212. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8213. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8214. if (packet) {
  8215. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8216. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8217. char command[255];
  8218. url = "browser " + url;
  8219. int32 spawn_id = 0;
  8220. int32 zone_id = 0;
  8221. string type;
  8222. if (client->GetCurrentZone())
  8223. zone_id = client->GetCurrentZone()->GetZoneID();
  8224. if (client->GetPlayer()->GetTarget()) {
  8225. Spawn* target = client->GetPlayer()->GetTarget();
  8226. if (target->IsWidget())
  8227. type = "widgets";
  8228. else if (target->IsSign())
  8229. type = "signs";
  8230. else if (target->IsObject())
  8231. type = "objects";
  8232. else if (target->IsNPC())
  8233. type = "npcs";
  8234. else if (target->IsGroundSpawn())
  8235. type = "ground";
  8236. else
  8237. type = "spawn";
  8238. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8239. }
  8240. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8241. packet->setDataByName("accept_command", command);
  8242. }
  8243. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8244. char command[255];
  8245. url = "browser " + url;
  8246. if (client->GetPlayer()->GetTarget())
  8247. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8248. packet->setDataByName("accept_command", command);
  8249. }
  8250. else {
  8251. string command = "browser " + url;
  8252. packet->setDataByName("accept_command", command.c_str());
  8253. }
  8254. packet->setDataByName("text", "Open the web editor?");
  8255. packet->setDataByName("accept_text", "Open");
  8256. packet->setDataByName("cancel_text", "Cancel");
  8257. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8258. packet->setDataByName("unknown2", 50);
  8259. packet->setDataByName("unknown4", 1);
  8260. client->QueuePacket(packet->serialize());
  8261. safe_delete(packet);
  8262. }
  8263. }
  8264. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8265. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8266. return;
  8267. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8268. if(client->GetCurrentRez()->active)
  8269. client->AcceptResurrection();
  8270. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8271. }
  8272. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8273. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8274. return;
  8275. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8276. if(client->GetCurrentRez()->active)
  8277. client->GetCurrentRez()->should_delete = true;
  8278. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8279. }
  8280. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8281. PrintSep(sep, "Switch_AA_Profile");
  8282. if (sep && sep->IsSet(0)) {
  8283. string type = sep->arg[0];
  8284. int8 newtemplate = atoul(sep->arg[1]);
  8285. master_aa_list.DisplayAA(client, newtemplate, 1);
  8286. }
  8287. }
  8288. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8289. PrintSep(sep, "Get_AA_Xml");
  8290. if (sep && sep->IsSet(0)) {
  8291. string tabnum = sep->arg[0];
  8292. string spellid = sep->arg[1];
  8293. }
  8294. }
  8295. void Commands::Add_AA(Client* client, Seperator* sep) {
  8296. PrintSep(sep, "Add_AA");
  8297. if (sep && sep->IsSet(0)) {
  8298. int32 spell_id = atoul(sep->arg[1]);
  8299. int8 spell_tier = 0;
  8300. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8301. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8302. // addspellbookentry here
  8303. if (spell_tier >= data->maxRank) {
  8304. return;
  8305. }
  8306. if (!spell_tier) {
  8307. spell_tier = 1;
  8308. }
  8309. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8310. {
  8311. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8312. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8313. client->GetPlayer()->UnlockSpell(spell);
  8314. client->SendSpellUpdate(spell);
  8315. }
  8316. else
  8317. {
  8318. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8319. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8320. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8321. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8322. client->GetPlayer()->UnlockSpell(spell);
  8323. client->SendSpellUpdate(spell);
  8324. }
  8325. // cast spell here
  8326. if (!spell_tier)
  8327. spell_tier = 1;
  8328. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8329. if (spell) {
  8330. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8331. }
  8332. }
  8333. else {
  8334. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8335. }
  8336. master_aa_list.DisplayAA(client, 0, 0);
  8337. }
  8338. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8339. PrintSep(sep, "Commit_AA_Profile");
  8340. if (sep && sep->IsSet(0)) {
  8341. }
  8342. }
  8343. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8344. PrintSep(sep, "Begin_AA_Profile");
  8345. if (sep && sep->IsSet(0)) {
  8346. master_aa_list.DisplayAA(client, 100, 2);
  8347. }
  8348. }
  8349. void Commands::Back_AA(Client* client, Seperator* sep) {
  8350. if (sep && sep->IsSet(0)) {
  8351. PrintSep(sep, "Back_AA");
  8352. }
  8353. }
  8354. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8355. if (sep && sep->IsSet(0)) {
  8356. PrintSep(sep, "Remove_AA");
  8357. }
  8358. }
  8359. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8360. MasterAAList master_aa_list;
  8361. PrintSep(sep, "Cancel_AA_Profile");
  8362. master_aa_list.DisplayAA(client, 0, 0);
  8363. }
  8364. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8365. if (sep && sep->IsSet(0)) {
  8366. PrintSep(sep, "Save_AA_Profile");
  8367. }
  8368. }
  8369. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8370. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8371. if (!sep->IsNumber(0)) return;
  8372. int32 request_id = atoul(sep->arg[0]);
  8373. if (!sep->IsNumber(1)) return;
  8374. sint32 item_id = atoi(sep->arg[1]);
  8375. if (client->IsCurrentTransmuteID(request_id)) {
  8376. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8377. }
  8378. else if (client->IsCurrentTransmuteID(item_id)) {
  8379. if (!sep->IsSet(2)) return;
  8380. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8381. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8382. }
  8383. }
  8384. }