Clone of UAS2 @ https://github.com/drudgedance/uas2

Avatar.cpp 266KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245
  1. /*
  2. * This file is part of UAS2.
  3. *
  4. * UAS2 is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * UAS2 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 UASv1; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *
  17. /**
  18. * @file Avatar.cpp
  19. * Implements general functionality for avatars (world characters).
  20. *
  21. * Functionality includes messages sent when logging in an avatar, as well as updating
  22. * attributes, vitals, skills, experience, inventory, housing information, etc.
  23. *
  24. * Loading of the actual avatar data is performed by the cDatabase class.
  25. *
  26. * Inherits from the cObject class.
  27. */
  28. #include <time.h>
  29. #include "Avatar.h"
  30. #include "CannedPackets.h"
  31. #include "Database.h"
  32. #include "DatFile.h"
  33. #include "WorldManager.h"
  34. #include "math.h"
  35. #include "SimpleAI.h"
  36. #include "MasterServer.h"
  37. #include "Job.h"
  38. #include "cSpell.h"
  39. /*
  40. Cubem0j0 -- Asheron's Call Formulas:
  41. Combat Burden (how much Stamina you use when attacking) = shield_burden + (1.5 * weapon_burden)
  42. Overall Burden = 150bu per point of Strength
  43. Natural Resistance =
  44. Natural Regeneration=
  45. Healing Rate = 2 * (max_health - current_health) with 50% base.
  46. Example: 200 max, 50 current: 2 * 150 = 300
  47. A base 300 skill has a 50% chance to heal.
  48. Armor Rending: Percentage of armor ignored = (skill - 160) / 400
  49. Critical Strike: Percentage critical hits = (skill - 100) / 600
  50. Crippling Blow: Critical damage multiplier = (skill - 40) / 60
  51. *Maximum Imbue Benefit*
  52. Armor Rending - 60% armor ignored
  53. Critical Strike - 50% critical strikes
  54. Crippling Blow - (6 * damage_multiplier) on critial strikes
  55. Resistance Rending - 150% damage (same as a Level 6 Life Vulnerability spell)
  56. (Damage over Time = (maximum damage)*((1-critical hit chance)*(2-variance)/2 + (critical hit chance)*(critical hit multiplier))*(Strength/Coordination modifier)*(Bow/Crossbow/Thrown Weapon modifier)*(rate-of-fire))
  57. Maximum Damage = Weapon's Max Damage + Blood Drinker (+ Unarmed Combat modifier)
  58. Excludes bonuses such as Heart Seeker or weapon modifications (UA / 10 for Phantom Katar)
  59. Critical hit chance = 0.10 for most weapons.
  60. For melee weapons with Critical Strike: (base_skill - 100) / 600
  61. For missile weapons with Critical Strike: (base_skill - 60) / 600
  62. Critical hit multiplier = 2 for most weapons.
  63. Some "old-school" quest weapons had higher values.
  64. For melee weapons: (base_skill - 40) / 60
  65. For missile weapons: (base_skill) / 60
  66. Strength/Coordination Modifier
  67. (Bow, Crossbow, and Dagger use Coordination; Thrown Weapons and all other melee weapons use Strength.)
  68. Unarmed Combat, Bow, Crossbow, Thrown Weapons: 1 + (attribute - 55) * .008
  69. Other weapons: 1 + (attribute - 55) * .011
  70. Unarmed Combat Modifier = (base_skill / 20)
  71. Bow/Crossbow/Thrown Weapon Modifier = (100 + weapon_modifier) / 100 * power_modifier = 1.5 for most weapons (.5 is used for Hollow and Phantom melee weapons)
  72. */
  73. /*
  74. The character model:
  75. Characters are composed of palettes (colors), textures (designs), and models (shapes).
  76. All of this character model (palette, texture, and model) information is stored in the portal.dat.
  77. The portal.dat is separated into groups of files:
  78. Files prefixed 0x0400xxxx are color look-up tables (CLUTs), used to determine palette information.
  79. Files prefixed 0x0500xxxx are textures, used to determine texture/design information.
  80. Files prefixed 0x0100xxxx are models, used to determine model/shape information.
  81. The default character palette is file 0x0400007E.
  82. The default character complex model (which consists of textures and models) is:
  83. 0x02000001 for male characters
  84. 0x0200004E for female characters
  85. The palette information for a character has three parts:
  86. 1. Palette WORD (palette portal.dat entry minus 0x04000000)
  87. 2. Offset BYTE (number of palette entries to skip)
  88. 3. Length BYTE (number of palette entries to copy)
  89. The texture information for a character has three parts:
  90. 1. Index BYTE (the index of the model whose texture the new texture is replacing)
  91. 2. Old Texture WORD (texture portal.dat entry minus 0x05000000)
  92. 3. New Texture WORD (texture portal.dat entry minus 0x05000000)
  93. The model information for a character has two parts:
  94. 1. Index BYTE (the index of the model being replaced)
  95. 2. Model WORD (model portal.dat entry minus 0x01000000)
  96. By default, characters have three palettes, four textures, and seventeen models.
  97. The three palettes are:
  98. 1. Skin Color (palettes 0 - 23)
  99. 2. Hair Color (palettes 24 - 31)
  100. 3. Eye Color (palettes 32 - 39)
  101. The four textures are:
  102. 1. Hair (index 0x10, a range of textures)
  103. 2. Forehead (index 0x10, a range of textures)
  104. 3. Nose (index 0x10, a range of textures)
  105. 4. Chin (index 0x10, a range of textures)
  106. The seventeen models (which constitute the seventeen parts of the character model) are:
  107. Number Index Body Part
  108. 1. 0x00 Waist
  109. 2. 0x01 Left Upper Leg
  110. 3. 0x02 Left Lower leg
  111. 4. 0x03 Left Shin
  112. 5. 0x04 Left Foot
  113. 6. 0x05 Right Upper leg
  114. 7. 0x06 Right Lower Leg
  115. 8. 0x07 Right Shin
  116. 9. 0x08 Right Foot
  117. 10. 0x09 Chest
  118. 11. 0x0A Upper Arm (shoulder) - Left
  119. 12. 0x0B Wrist - Left Arm
  120. 13. 0x0C Left Hand
  121. 14. 0x0D Upper Arm (shoulder) - Right
  122. 15. 0x0E Wrist - Right Arm
  123. 16. 0x0F Right Hand
  124. 17. 0x10 Head
  125. Palettes are appended to the character's natural palettes and any other supplemental palettes.
  126. -Each palette consists of 255 distinct colors.
  127. -Beginning with the color at the "Offset" value, "Length" palettes are copied to the character's palette.
  128. Textures are appended to the character's natural textures and any other supplemental textures.
  129. -The "New Texture" entry is applied to the "Index" part of the character.
  130. -This information is appended to the rest of the character's texture information.
  131. Models replace the character's natural models and any supplemental models they cover.
  132. -The "Model" entry is applied to the "Index" part of the character.
  133. -This information replaces the information for the "Index" part of the character.
  134. The character palette is as follows (per information from Todd's Hacking Zone: http://todd.acdev.org/):
  135. Index Range Size Use
  136. 0 - 23 24 Skin
  137. 24 - 31 8 Hair
  138. 32 - 39 8 Eyes
  139. 40 - 63 24 Shirt
  140. 64 - 71 8 Pants
  141. 72 - 79 8 Abdomen, Leather
  142. 80 - 91 12 Abdomen, Metal
  143. 92 - 95 4 Abdomen, Gold
  144. 96 - 107 12 Lower Arm, Metal
  145. 108 - 115 8 Lower Arm, Leather
  146. 116 - 127 12 Upper Arm, Metal
  147. 128 - 135 8 Upper Arm, Leather
  148. 136 - 151 16 Leg, Metal
  149. 152 - 159 8 Leg, Leather
  150. 160 - 167 8 Feet
  151. 168 - 173 6 Hands
  152. 174 - 185 12 Leather Armor
  153. 186 - 197 12 Armor
  154. 198 - 205 8 Armor
  155. 206 - 215 10 Armor
  156. 216 - 239 24 Armor, Primary
  157. 240 - 249 10 Helmet, Metal
  158. 250 - 255 6 Helmet, Leather
  159. */
  160. cMessage cAvatar::LocationPacket( )
  161. {
  162. cMessage cMove;
  163. cMove << 0xF748L
  164. << GetGUID( )
  165. << 0x34L
  166. << m_Location.m_dwLandBlock
  167. << m_Location.m_flX
  168. << m_Location.m_flY
  169. << m_Location.m_flZ
  170. << m_Location.m_flA
  171. << m_Location.m_flW
  172. << WORD(m_wNumLogins)
  173. << WORD(++m_wMoveCount)
  174. << WORD(m_wPortalCount)
  175. << WORD(0x0000);
  176. return cMove;
  177. }
  178. cMessage cAvatar::LoginCharacter()
  179. {
  180. cMessage cmReturn;
  181. cmReturn << 0xF746L << GetGUID( );
  182. return cmReturn;
  183. }
  184. void cAvatar::LogoutCharacter()
  185. {
  186. cFellowship* aFellowship;
  187. if (aFellowship = cFellowship::GetFellowshipByID(m_dwFellowshipID))
  188. {
  189. aFellowship->RemMember(GetGUID());
  190. SetFellowshipID(0);
  191. this->inFellow = false;
  192. }
  193. }
  194. /////////////////////////////////////////////////////////////////
  195. // Huge Login Packet
  196. /////////////////////////////////////////////////////////////////
  197. /**
  198. * Handles the message sent for the login of an avatar.
  199. *
  200. * The message includes information on name, race, sex, class, levels, attributes, vitals,
  201. * skills, experience, deaths, burden, pyreals, spelltabs, inventory, and equipment.
  202. * The function uses information loaded by cDatabase::LoadAvatarList. @see cDatabase::LoadAvatarList
  203. *
  204. * @return cMessage - Returns a Game Event (0x0000F7B0) server message of type Login Character (0x00000013).
  205. */
  206. cMessage cAvatar::CreateLoginPacket( DWORD F7B0seq )
  207. {
  208. this->inFellow = false;
  209. this->SetFellowshipID(0);
  210. cMessage cmRet;
  211. cCharacterServer::m_dwClientCount++;
  212. //Cube: UPDATE THIS SECTION
  213. cmRet << 0xF7B0L << m_dwGUID << F7B0seq << 0x13L;
  214. DWORD dwLoginMask = 0x0000001B;
  215. /*
  216. if (m_dwAllegianceID != 0)
  217. {
  218. dwLoginMask = dwLoginMask | 0x00000040; //0040 - Allegiance info
  219. }
  220. */
  221. cmRet << dwLoginMask;
  222. cmRet << 0xAL; //This should be # of slots equipped.
  223. WORD numstats = 8;//8;
  224. cmRet << numstats << WORD( 0x40 );
  225. cmRet << 0x5L;
  226. DWORD dwBurden = 0;
  227. cmRet << dwBurden;
  228. cmRet << 0x14L;
  229. DWORD dwNumPyreals = 1000;
  230. cmRet << dwNumPyreals;
  231. cmRet << 0x15L;
  232. cmRet << m_dwTotalXP;
  233. cmRet << 0x16L;
  234. cmRet << m_dwUnassignedXP;
  235. cmRet << 0x18L; //Skill credits
  236. cmRet << DWORD(m_bSkillCredits);
  237. cmRet << 0x19L;
  238. cmRet << m_cStats.m_dwLevel;
  239. cmRet << 0x28L << 0x1L;
  240. // cmRet << 0x2BL << m_dwDeaths; //Total Deaths
  241. cmRet << 0x2FL << 0x0L;
  242. //more unknown vectors
  243. cmRet << WORD( 0x5 ) << WORD( 0x20 );
  244. cmRet << 4L << 0L << 0x2CL << 0L << 0x2DL << 0L << 0x2EL << 0L << 0x2FL << 0L;
  245. //String Vector
  246. cmRet << WORD( 0x4 ) << WORD( 0x10 );
  247. cmRet << 0x1L;
  248. cmRet << Name( );
  249. cmRet << 0x3L;
  250. cmRet << cDatabase::ReturnGender( m_wGender );
  251. cmRet << 0x4L;
  252. cmRet << cDatabase::ReturnRace( m_wRace );
  253. cmRet << 0x5L;
  254. cmRet << cDatabase::ReturnClass( m_wClass );
  255. cmRet << WORD( 0x1 ) << WORD( 0x20 );
  256. cmRet << 0x4L;
  257. cmRet << 0x30000000L;
  258. //Allegiance Info
  259. if (dwLoginMask & 0x00000040)
  260. {
  261. cAllegiance* aAllegiance;
  262. int numRecords = 0;
  263. std::list< Member > memberList;
  264. if (aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID))
  265. {
  266. //Find the monarch's allegiance record
  267. if (aAllegiance->GetLeader() != m_dwGUID)
  268. {
  269. //Add the monarch's allegiance record
  270. Member memMonarch = aAllegiance->members.find(aAllegiance->GetLeader())->second;
  271. memberList.push_back( memMonarch );
  272. numRecords++;
  273. }
  274. //Find the player's allegiance record
  275. Member memPlayer = aAllegiance->members.find(m_dwGUID)->second;
  276. //Find the patron's allegiance record
  277. if (memPlayer.m_dwPatron != NULL)
  278. {
  279. Member memPatron = aAllegiance->members.find(memPlayer.m_dwPatron)->second;
  280. if (memPatron.m_dwGUID != aAllegiance->GetLeader()) //if the patron is not also the monarch
  281. {
  282. //Add the patron's allegiance record
  283. memberList.push_back( memPatron );
  284. numRecords++;
  285. }
  286. }
  287. }
  288. cmRet << WORD(numRecords); //count of entries
  289. cmRet << WORD(0x0030); //unknown (cannot be 0)
  290. for ( std::list<Member>::iterator list_iter = memberList.begin(); list_iter != memberList.end(); ++list_iter )
  291. {
  292. if ((*list_iter).m_dwGUID == aAllegiance->GetLeader())
  293. cmRet << DWORD(0x00000018);
  294. else
  295. cmRet << DWORD(0x00000019);
  296. cmRet << (*list_iter).m_dwGUID; // DWORD player GUID
  297. }
  298. memberList.clear();
  299. }
  300. /*cmRet << WORD( 0x1 ) << WORD( 0x10 );
  301. UCHAR corpseloc [] = {
  302. 0x0E, 0x00, 0x00, 0x00, 0x28, 0x00, 0xB4, 0xA9,
  303. 0x8B, 0x41, 0xC0, 0x42, 0x1A, 0x12, 0x3A, 0x43, 0xEB, 0xC9, 0x57, 0x42, 0xE9, 0x08, 0x2E, 0x3F,
  304. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0xBE, 0x3B, 0xBF};
  305. cmRet.pasteData( corpseloc, sizeof( corpseloc ) );*/
  306. DWORD loginmask2 = 0x103L;
  307. cmRet << loginmask2;
  308. cmRet << 0x1L;
  309. cmRet << 0x1FFL;
  310. // Attributes
  311. for( int i=0; i < 6; i++ )
  312. {
  313. //k109: Grab the base here so we can manipulate later...
  314. switch(i)
  315. {
  316. case 0:
  317. this->base_strength = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  318. strength_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  319. break;
  320. case 1:
  321. this->base_endurance = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  322. endurance_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  323. break;
  324. case 2:
  325. this->base_quickness = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  326. quickness_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  327. break;
  328. case 3:
  329. this->base_coordination = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  330. coordination_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  331. break;
  332. case 4:
  333. this->base_focus = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  334. focus_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  335. break;
  336. case 5:
  337. this->base_self = this->m_cStats.m_lpcAttributes[i].m_dwCurrent;
  338. self_exp_cost = m_cStats.m_lpcAttributes[i].m_dwXP;
  339. break;
  340. }
  341. cmRet << m_cStats.m_lpcAttributes[i].m_dwIncrement;
  342. cmRet << m_cStats.m_lpcAttributes[i].m_dwCurrent;
  343. //k109: This needs to be updated with our new attr exp columns data...
  344. cmRet << m_cStats.m_lpcAttributes[i].m_dwXP;
  345. }
  346. //Vitals
  347. for(i = 0; i < 3; i++ )
  348. {
  349. switch(i)
  350. {
  351. case 0:
  352. base_health = m_cStats.m_lpcVitals[i].m_dwCurrent;
  353. health_exp_cost = m_cStats.m_lpcVitals[i].m_dwXP;
  354. break;
  355. case 1:
  356. base_stamina = m_cStats.m_lpcVitals[i].m_dwCurrent;
  357. stamina_exp_cost = m_cStats.m_lpcVitals[i].m_dwXP;
  358. break;
  359. case 2:
  360. base_mana = m_cStats.m_lpcVitals[i].m_dwCurrent;
  361. mana_exp_cost = m_cStats.m_lpcVitals[i].m_dwXP;
  362. break;
  363. }
  364. cmRet << m_cStats.m_lpcVitals[i].m_dwIncreases << 0L << m_cStats.m_lpcVitals[i].m_dwXP << m_cStats.m_lpcVitals[i].m_dwCurrent;
  365. }
  366. cmRet << WORD( 0x23 ) << WORD( 0x20 );
  367. char cSkillOrder [] = {
  368. 0x20,0x21,0x01,0x22,0x02,0x23,0x03,0x24,0x04,0x25,0x05,0x26,
  369. 0x06,0x27,0x07,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x12,
  370. 0x13,0x14,0x15,0x16,0x17,0x18,0x1B,0x1C,0x1D,0x1E,0x1F
  371. };
  372. //Cube: Continuing the work on skills here, adding m_dwXP to the loading of skills.
  373. for(i = 0; i < sizeof( cSkillOrder ); i++ )
  374. {
  375. cmRet << DWORD( m_cStats.m_lpcSkills[cSkillOrder[i]].m_wID );
  376. cmRet << WORD( m_cStats.m_lpcSkills[cSkillOrder[i]].m_dwIncreases );
  377. cmRet << WORD(0x0001);
  378. cmRet << DWORD( m_cStats.m_lpcSkills[cSkillOrder[i]].m_wStatus );
  379. cmRet << DWORD( m_cStats.m_lpcSkills[cSkillOrder[i]].m_dwXP );
  380. if ( m_cStats.m_lpcSkills[cSkillOrder[i]].m_wStatus == 3)
  381. cmRet << DWORD(0x0AL);
  382. else if ( m_cStats.m_lpcSkills[cSkillOrder[i]].m_wStatus == 2 )
  383. cmRet << DWORD(0x05L);
  384. else
  385. cmRet << DWORD(0x0L);
  386. cmRet << DWORD(0x0L);
  387. DWORD s_unk1 = 0x76A11716;
  388. DWORD s_unk2 = 0x418FB0A3;
  389. cmRet << s_unk1 << s_unk2;
  390. CalcSkill(m_cStats.m_lpcSkills[cSkillOrder[i]].m_wID);
  391. }
  392. //spell entries;
  393. cmRet << WORD( m_wSpellCount ) << WORD( 0x40 );
  394. for(i = 0;i < m_wSpellCount;i++)
  395. {
  396. cmRet << m_SpellBook[i].dwSpell_ID << m_SpellBook[i].flCharge << m_SpellBook[i].dwUnknownA << m_SpellBook[i].dwUnknownB ;
  397. }
  398. cmRet << 0x4L; //Login Mask 3
  399. cmRet << this->m_dwOptions; //Options Mask 0x0024E568L; <-stretch UI Normal -> 0x0000E568L;
  400. //k109: There are 7 spell tabs total
  401. for(i = 0; i < 7; i++)
  402. {
  403. if(m_SpellTabs[i].dwTabCount == 0)
  404. {
  405. cmRet << 0L;
  406. }
  407. else
  408. {
  409. cmRet << m_SpellTabs[i].dwTabCount;
  410. UpdateConsole("Tab: %08x\r\n",m_SpellTabs[i].dwTabCount);
  411. for(int b = 0; b < int(m_SpellTabs[i].dwTabCount); b++)
  412. {
  413. cmRet << m_SpellTabs[i].dwSpell_ID[b];
  414. }
  415. }
  416. }
  417. int inv_count = 0;
  418. int equipCount = 0;
  419. int unequipCount = 0;
  420. for ( iterObject_lst itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  421. {
  422. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  423. this->m_vInventory[inv_count].dwObjectGUID = ( *itObject )->GetGUID();
  424. this->m_vInventory[inv_count].dwIsContainer = pcItemInv->m_isContainer;
  425. this->m_vInventory[inv_count].fEquipped = ( *itObject )->m_fEquipped;
  426. this->m_vInventory[inv_count].dwItemModelNumber = ( *itObject )->GetItemModelID();
  427. if ( ( *itObject )->m_fEquipped == 2 )
  428. {
  429. equipCount++;
  430. } else {
  431. unequipCount++;
  432. }
  433. inv_count++;
  434. }
  435. /*
  436. //spell entries;
  437. cmRet << WORD( 0x23 ) << WORD( 0x40 );
  438. DWORD unkfloat = 0x3F800000;
  439. cmRet << 63L << unkfloat << 0L << 0L;
  440. cmRet << 2483L << unkfloat << 0L << 0L;
  441. cmRet << 2416L << unkfloat << 0L << 0L;
  442. cmRet << 2368L << unkfloat << 0L << 0L;
  443. cmRet << 2302L << unkfloat << 0L << 0L;
  444. cmRet << 2366L << unkfloat << 0L << 0L;
  445. //
  446. cmRet << 2075L << unkfloat << 0L << 0L; // Imperil Self VII
  447. cmRet << 2928L << unkfloat << 0L << 0L; // Tusker Hide
  448. cmRet << 2929L << unkfloat << 0L << 0L; // Tusker Might
  449. cmRet << 2930L << unkfloat << 0L << 0L; // Tusker Skin
  450. cmRet << 2932L << unkfloat << 0L << 0L; // Tusker Leap
  451. cmRet << 2933L << unkfloat << 0L << 0L; // Tusker Sprint
  452. cmRet << 2934L << unkfloat << 0L << 0L; // Tusker Fists
  453. cmRet << 2791L << unkfloat << 0L << 0L; // Rolling Death
  454. cmRet << 3370L << unkfloat << 0L << 0L; // Winds of Celid
  455. cmRet << 1832L << unkfloat << 0L << 0L; // Torrential Acid
  456. cmRet << 1833L << unkfloat << 0L << 0L; // Squall of Swords
  457. cmRet << 1834L << unkfloat << 0L << 0L; // Firestorm
  458. cmRet << 1835L << unkfloat << 0L << 0L; // Splinterfall
  459. cmRet << 1836L << unkfloat << 0L << 0L; // Avalanche
  460. cmRet << 1837L << unkfloat << 0L << 0L; // Lighting Barrage
  461. cmRet << 1838L << unkfloat << 0L << 0L; // Stone Fists
  462. cmRet << 2048L << unkfloat << 0L << 0L; // Boon of the Demon
  463. cmRet << 2949L << unkfloat << 0L << 0L; // Bile of the Hopeslayer
  464. cmRet << 2357L << unkfloat << 0L << 0L; // Fauna Perlustration
  465. cmRet << 2672L << unkfloat << 0L << 0L; // Ring of True Pain
  466. cmRet << 2673L << unkfloat << 0L << 0L; // Ring of Unspeakable Agony
  467. cmRet << 2674L << unkfloat << 0L << 0L; // Vicious Rebuke
  468. cmRet << 2701L << unkfloat << 0L << 0L; // Elemental Fury
  469. cmRet << 2702L << unkfloat << 0L << 0L; // Elemental Fury
  470. cmRet << 2703L << unkfloat << 0L << 0L; // Elemental Fury
  471. cmRet << 2704L << unkfloat << 0L << 0L; // Elemental Fury
  472. cmRet << 2705L << unkfloat << 0L << 0L; // Elementalist's Boon
  473. cmRet << 2710L << unkfloat << 0L << 0L; // Volcanic Blast
  474. cmRet << 2941L << unkfloat << 0L << 0L; // Ulgrim's Recall
  475. cmRet << 0x4L; //Login Mask 3
  476. cmRet << 0x0100E568L; //Options Mask 0x0024E568L; <-stretch UI Normal -> 0x0000E568L; PLay sound only when active window 0x0100E568L
  477. cmRet << 0x6L << 2483L << 2416L << 2368L << 2302L << 2366L << 63L;; // Spell Tab 1
  478. cmRet << 0L << 0L << 0L << 0L; // Spell Tab2,3,4,5
  479. */
  480. cmRet << unequipCount; // inventory count
  481. for( int j = 0; j < unequipCount; j++)
  482. {
  483. if (this->m_vInventory[j].fEquipped != 2)
  484. {
  485. cmRet << this->m_vInventory[j].dwObjectGUID << this->m_vInventory[j].dwIsContainer;
  486. }
  487. }
  488. //Vector of Inventory
  489. //Item ID followed by container information
  490. // cmRet << 0xEB5797D6 << 0x0L; // Amuli Coat
  491. // cmRet << 0x81A02865 << 0x0L; // Pyreals
  492. // cmRet << 0L;
  493. cmRet << equipCount; // equipment count
  494. // Vector of Equipment Count
  495. for( int k = 0; k < equipCount; k++)
  496. {
  497. if (this->m_vInventory[k].fEquipped == 2)
  498. {
  499. cItemModels *pcItemEquip = cItemModels::FindModel( this->m_vInventory[k].dwItemModelNumber );
  500. cmRet << this->m_vInventory[k].dwObjectGUID << pcItemEquip->m_dwEquipPossible << pcItemEquip->m_dwCoverage;
  501. }
  502. }
  503. return cmRet;
  504. }
  505. /**
  506. * Handles the message sent for the creation of an avatar.
  507. *
  508. * The message includes information on the avatar's model (palette, texture, and model information),
  509. * name, icon, PK flag, inventory slots, pack slots, and total pyreals value.
  510. *
  511. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  512. */
  513. cMessage cAvatar::CreatePacket( )
  514. {
  515. cMessage cmReturn;
  516. float flpScale; // Scale used in Packet being Sent
  517. // float flmScale; // Model Data Scale
  518. struct PaletteChange
  519. {
  520. WORD m_wNewPalette;
  521. BYTE m_ucOffset;
  522. BYTE m_ucLength;
  523. } pc;
  524. WORD wModelID;
  525. WORD wIconID;
  526. DWORD dwAnimationStrip = 0x0L; // Always 0x09000001; portal.dat entry for human animation series
  527. DWORD dwUnkDatEntry = 0x0L; // Always 0x20000001; portal.dat entry for sound strings
  528. DWORD dwUnkDatEntry2 = 0x0L;
  529. DWORD dwModel = 0x0L; // The Model always 1 for Human. 0x02 = ?, 00 = ?, 00 = invisible parts, 00 body parts
  530. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  531. // Model Definition Data Starts
  532. //switch ( m_bAccessLevel)
  533. if (m_wModelNum != 0)
  534. {
  535. char szCommand[200];
  536. // char ModelName[75];
  537. WORD wModelNumber;
  538. WORD PaletteVector;
  539. WORD TextureVector;
  540. WORD ModelVector;
  541. BYTE bPaletteChange;
  542. BYTE bTextureChange;
  543. BYTE bModelChange;
  544. // BYTE bModelIndex;
  545. // WORD wOldTexture;
  546. // WORD wNewTexture;
  547. // WORD wNewModel;
  548. WORD wPaletteCode;
  549. RETCODE retcode;
  550. unsigned char ModelArray[255] = {0x00,};
  551. int iCol = 0;
  552. char readbuff01[5];
  553. char readbuff02[5];
  554. char readbuff03[9];
  555. char readbuff04[9];
  556. char readbuff05[9];
  557. char readbuff06[9];
  558. char readbuff07[5];
  559. // Model Load
  560. sprintf( szCommand, "SELECT * FROM avatar_templates WHERE ModelNum=%d;", m_wModelNum);
  561. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  562. retcode = SQLExecute( cDatabase::m_hStmt );
  563. iCol = 2;
  564. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_USHORT, &wModelNumber, sizeof( wModelNumber ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  565. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_ULONG, &PaletteVector, sizeof( PaletteVector ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  566. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_USHORT, &bPaletteChange, sizeof( BYTE ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  567. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_ULONG, &TextureVector, sizeof( TextureVector ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  568. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_USHORT, &bTextureChange, sizeof( BYTE ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  569. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_ULONG, &ModelVector, sizeof( ModelVector ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  570. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_USHORT, &bModelChange, sizeof( BYTE ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  571. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff01, sizeof( readbuff01 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  572. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff02, sizeof( readbuff02 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  573. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff03, sizeof( readbuff03 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  574. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff04, sizeof( readbuff04 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  575. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff05, sizeof( readbuff05 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  576. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff06, sizeof( readbuff06 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  577. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff07, sizeof( readbuff07 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  578. retcode = SQLFetch( cDatabase::m_hStmt ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  579. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  580. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  581. //Scan the text into hexadecimal
  582. sscanf(readbuff01,"%08x",&wModelID);
  583. sscanf(readbuff02,"%08x",&wIconID);
  584. sscanf(readbuff03,"%08x",&dwAnimationStrip);
  585. sscanf(readbuff04,"%08x",&dwUnkDatEntry);
  586. sscanf(readbuff05,"%08x",&dwUnkDatEntry2);
  587. sscanf(readbuff06,"%08x",&dwModel);
  588. sscanf(readbuff07,"%08x",&wPaletteCode);
  589. m_bBasicPaletteChange = m_wBasicPaletteVector;
  590. m_bBasicTextureChange = m_wBasicTextureVector;
  591. m_bBasicModelChange = m_wBasicModelVector;
  592. //Correct value fomatting
  593. dwAnimationStrip += 0x09000000;
  594. dwUnkDatEntry += 0x20000000;
  595. dwUnkDatEntry2 += 0x34000000;
  596. dwModel += 0x02000000;
  597. // Add the vector counts to the packet
  598. //cmReturn << bPaletteChange << bTextureChange << bModelChange;
  599. //cmReturn << m_bBasicPaletteChange << m_bBasicTextureChange << m_bBasicModelChange;
  600. int paletteChange = m_bBasicPaletteChange;
  601. int textureChange = m_bBasicTextureChange;
  602. //Loop through the palettes and textures of currently equipped items
  603. //Check whether they contribute palettes and textures to the character model
  604. for ( iterObject_lst itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  605. {
  606. if ( ( *itObject )->m_fEquipped == 2 )
  607. {
  608. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  609. if (pcItemInv->m_PortalLinker != 0)
  610. {
  611. if (this->m_wGender == 0)
  612. cPortalDat::LoadItemModel(( *itObject ), 0x0200004E);
  613. else
  614. cPortalDat::LoadItemModel(( *itObject ), 0x02000001);
  615. }
  616. if ( ( *itObject )->m_bWearPaletteChange != 0)
  617. paletteChange += ( *itObject )->m_bWearPaletteChange;
  618. if ( pcItemInv->m_bWearTextureChange != 0)
  619. textureChange += pcItemInv->m_bWearTextureChange;
  620. }
  621. }
  622. cmReturn << BYTE(paletteChange)
  623. << BYTE(textureChange)
  624. << BYTE(m_bBasicModelChange);
  625. // The avatar character model information (which consists of palettes, textures, and models)
  626. // is built upon the avatar's default appearance and any apparel currently worn. The apparel's
  627. // palette and texture information is appended to the character's default palette and texture
  628. // information. The apparel's models supercede/replace the respective character models.
  629. cmReturn << WORD(0x007E); // the human palette
  630. //Loop through the avatar's default palettes
  631. if ( m_bBasicPaletteChange != 0)
  632. {
  633. for (int i = 0; i < m_bBasicPaletteChange; i++)
  634. {
  635. cmReturn.pasteData((UCHAR*)&m_BasicVectorPal[i],sizeof(m_BasicVectorPal[i]));
  636. }
  637. }
  638. //Loop through the palettes of currently equipped items
  639. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  640. {
  641. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  642. if ( ( *itObject )->m_fEquipped == 2 )
  643. {
  644. if ( ( *itObject )->m_bWearPaletteChange != 0)
  645. {
  646. for (int i = 0; i < ( *itObject )->m_bWearPaletteChange; i++)
  647. {
  648. cmReturn.pasteData((UCHAR*)&( *itObject )->m_WearVectorPal[i],sizeof(( *itObject )->m_WearVectorPal[i]));
  649. }
  650. }
  651. }
  652. }
  653. //Loop through the avatar's default textures
  654. if ( m_bBasicTextureChange != 0)
  655. {
  656. for (int i = 0; i < m_bBasicTextureChange; i++)
  657. {
  658. cmReturn.pasteData((UCHAR*)&m_BasicVectorTex[i],sizeof(m_BasicVectorTex[i]));
  659. }
  660. }
  661. //Loop through the textures of currently equipped items
  662. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  663. {
  664. if ( ( *itObject )->m_fEquipped == 2 )
  665. {
  666. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  667. if ( pcItemInv->m_bWearTextureChange != 0)
  668. {
  669. for (int i = 0; i < pcItemInv->m_bWearTextureChange; i++)
  670. {
  671. cmReturn.pasteData((UCHAR*)&pcItemInv->m_WearVectorTex[i],sizeof(pcItemInv->m_WearVectorTex[i]));
  672. }
  673. }
  674. }
  675. }
  676. bool modelIsCovered;
  677. if ( m_bBasicModelChange != 0)
  678. {
  679. //Loop through the avatar's default models
  680. //Do not include avatar models superceded by item models
  681. for (int i = 0; i < m_bBasicModelChange; i++)
  682. {
  683. modelIsCovered = false;
  684. //Loop through the models of currently equipped items
  685. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  686. {
  687. if ( ( *itObject )->m_fEquipped == 2 )
  688. {
  689. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  690. if ( pcItemInv->m_bWearModelChange != 0)
  691. {
  692. for (int j = 0; j < pcItemInv->m_bWearModelChange; j++)
  693. {
  694. //Find whether the item affects the given avatar body part
  695. //If so, the item model index will equal the given avatar model index
  696. if(m_BasicVectorMod[i].m_bModelIndex == pcItemInv->m_WearVectorMod[j].m_bModelIndex)
  697. {
  698. modelIsCovered = true;
  699. }
  700. }
  701. }
  702. }
  703. }
  704. if (!modelIsCovered)
  705. cmReturn.pasteData((UCHAR*)&m_BasicVectorMod[i],sizeof(m_BasicVectorMod[i]));
  706. }
  707. }
  708. //Loop through the models of currently equipped items
  709. //If two items cover the same area, the one with a higher coverage value supercedes
  710. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  711. {
  712. if ( ( *itObject )->m_fEquipped == 2 )
  713. {
  714. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  715. if ( pcItemInv->m_bWearModelChange != 0)
  716. {
  717. for (int i = 0; i < pcItemInv->m_bWearModelChange; i++)
  718. {
  719. modelIsCovered = false;
  720. for ( iterObject_lst itObject2 = m_lstInventory.begin( ); itObject2 != m_lstInventory.end( ); ++itObject2 )
  721. {
  722. if ( ( *itObject2 )->m_fEquipped == 2 )
  723. {
  724. cItemModels *pcItemInv2 = cItemModels::FindModel(( *itObject2 )->GetItemModelID());
  725. if ( pcItemInv2->m_bWearModelChange != 0)
  726. {
  727. for (int j = 0; j < pcItemInv2->m_bWearModelChange; j++)
  728. {
  729. if (pcItemInv->m_WearVectorMod[i].m_bModelIndex == pcItemInv2->m_WearVectorMod[j].m_bModelIndex)
  730. if (pcItemInv->m_dwCoverage < pcItemInv2->m_dwCoverage)
  731. modelIsCovered = true;
  732. }
  733. }
  734. }
  735. }
  736. if (!modelIsCovered)
  737. cmReturn.pasteData((UCHAR*)&pcItemInv->m_WearVectorMod[i],sizeof(pcItemInv->m_WearVectorMod[i]));
  738. }
  739. }
  740. }
  741. }
  742. }
  743. else
  744. {
  745. //If a character has no m_modelNum value, just create a "generic" character
  746. BYTE ucPaletteChangeCount = 3; //changes depending on the player model
  747. BYTE ucTextureChangeCount = 4;
  748. BYTE ucModelChangeCount = 17;
  749. wModelID = 1;
  750. wIconID = 0x1036;
  751. dwAnimationStrip = 0x09000001;
  752. dwUnkDatEntry = 0x20000001;
  753. dwUnkDatEntry2 = 0x34000004;
  754. dwModel = 0x02000001;
  755. cmReturn << ucPaletteChangeCount << ucTextureChangeCount << ucModelChangeCount;
  756. //Make 3 palette changes
  757. pc.m_wNewPalette = 0x007E;
  758. pc.m_ucOffset = 174; // 182 Female
  759. pc.m_ucLength = 4; // 2 Female
  760. cmReturn.pasteData((UCHAR*)&pc,sizeof(pc));
  761. pc.m_wNewPalette = 0x1800;
  762. pc.m_ucOffset = 227; // 0 Female
  763. pc.m_ucLength = 2; // 3 Female
  764. cmReturn.pasteData((UCHAR*)&pc,sizeof(pc));
  765. pc.m_wNewPalette = 0x0818;
  766. pc.m_ucOffset = 175; // 191 Female
  767. pc.m_ucLength = 4; // 2 Female
  768. cmReturn.pasteData((UCHAR*)&pc,sizeof(pc));
  769. cmReturn << WORD(0x0820); //this value is unknown..it only exists if there are palette changes
  770. //Texture changes control the different textures on a character sub-model.
  771. //If the character is naked then there are only 4 (hair, eyes, nose, and mouth).
  772. //and they all take place on the head sub model.
  773. //If the character is clothed or has armor, there could be many texture
  774. //changes.
  775. #pragma pack( push, 1 )
  776. struct TextureChange
  777. {
  778. BYTE m_bModelIndex;
  779. WORD m_wOldTexture;
  780. WORD m_wNewTexture;
  781. } tc;
  782. #pragma pack(pop)
  783. //Hair Texture Array
  784. WORD wHairTextures[2][4] = { { 0x10B8, 0x10B8, 0x10B8, 0x10B7 }, { 0x11FD, 0x11FD, 0x11FD, 0x10B7 } };
  785. //Hair
  786. tc.m_bModelIndex = 0x10;
  787. tc.m_wOldTexture = 0x98;
  788. tc.m_wNewTexture = wHairTextures[m_wGender][m_wHairStyle];
  789. cmReturn.pasteData((UCHAR*)&tc,sizeof(tc));
  790. //Forehead
  791. tc.m_bModelIndex = 0x10;
  792. tc.m_wOldTexture = 0x24C;
  793. if( m_wHairStyle == 3 ) // Bald
  794. tc.m_wNewTexture = g_wAvatarTexturesBaldList[m_wRace][m_wGender][m_wHead];//0x110E;
  795. else
  796. tc.m_wNewTexture = g_wAvatarTexturesList[m_wRace][m_wGender][0][m_wHead];
  797. cmReturn.pasteData((UCHAR*)&tc,sizeof(tc));
  798. //Nose
  799. tc.m_bModelIndex = 0x10;
  800. tc.m_wOldTexture = 0x2F5;
  801. tc.m_wNewTexture = g_wAvatarTexturesList[m_wRace][m_wGender][1][m_wNose];//0x117B;
  802. cmReturn.pasteData((UCHAR*)&tc,sizeof(tc));
  803. //Chin
  804. tc.m_bModelIndex = 0x10;
  805. tc.m_wOldTexture = 0x25C;
  806. tc.m_wNewTexture = g_wAvatarTexturesList[m_wRace][m_wGender][2][m_wChin];//0x119A;
  807. cmReturn.pasteData((UCHAR*)&tc,sizeof(tc));
  808. // Female
  809. BYTE bModelIndexes[] = { 0x00, 0x01, 0x02, 0x05, 0x06, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x03, 0x07, 0x04, 0x08 };
  810. // Female Male
  811. // 0x005A - Regular 0x10B8 0x11FD
  812. // 0x04A7 - Bulky Hair 0x10B8 0x11FD
  813. // 0x049E - Ponytail 0x10B8 0x11FD
  814. // 0x005A - Baldness 0x10B7 0x10B7
  815. WORD wNewModels[2][16] =
  816. {
  817. { 0x0477, 0x04BE, 0x04C4, 0x04C6, 0x04C5, 0x04B6, 0x04CF, 0x04CD, 0x0076, 0x04D0, 0x04CE, 0x0077, 0x0479, 0x0478, 0x04BA, 0x04BC },
  818. { 0x004E, 0x004F, 0x004D, 0x0053, 0x0051, 0x0054, 0x0497, 0x0495, 0x0076, 0x04AD, 0x0496, 0x0077, 0x004C, 0x0050, 0x004B, 0x0052 }
  819. };
  820. WORD wHairModels[4] = { 0x005A, 0x04A7, 0x049E, 0x005A };
  821. for( int i = 0; i < sizeof( bModelIndexes ); i++ )
  822. cmReturn << bModelIndexes[i] << wNewModels[m_wGender][i];
  823. // Do Hair Model index is 0x10
  824. cmReturn << BYTE(0x10) << wHairModels[m_wHairStyle];
  825. }
  826. cmReturn.pasteAlign(4);
  827. // End of Model Definition Data
  828. DWORD dwFlags1 = 0x00019883;
  829. cmReturn << dwFlags1;
  830. cmReturn << WORD(0x4410); // Type of portal user is exiting. For begin it's 0x4410, for end it's 0x0408
  831. cmReturn << WORD(0x0040); // Unknown
  832. //Flags1 Mask
  833. {
  834. //Flags1 & 0x0010000 Initial Animation Bytes
  835. {
  836. DWORD dwNumInitAnimationBytes = 8;
  837. cmReturn << dwNumInitAnimationBytes;
  838. BYTE ucInitialAnimation[] = //determines in which animation the model starts
  839. {0x00, 0x00, 0x3D, 0x00, 0x00, 0xF0, 0xD0, 0x03};
  840. for(int blah = 0;blah<sizeof(ucInitialAnimation);blah++)
  841. cmReturn << ucInitialAnimation[blah];
  842. cmReturn << 0x00000000L; // Unknown DWORD
  843. }
  844. //Flags1 & 0x00008000 Location
  845. {
  846. cmReturn.pasteData( (UCHAR*)&m_Location, sizeof(m_Location) );
  847. } //Flags1 & 0x00000002
  848. {
  849. //DWORD dwAnimationStrip = 0x09000001; //Always 0x09000001, which is the human animation series
  850. cmReturn << dwAnimationStrip;
  851. }
  852. //Flags1 & 0x00000800
  853. {
  854. //DWORD dwUnkDatEntry = 0x20000001; //Always 0x20000001 for the portal.dat entry
  855. cmReturn << dwUnkDatEntry; // sound string
  856. }
  857. //Flags1 & 0x00001000
  858. {
  859. //DWORD dwUnkDatEntry2 = 0x34000004;
  860. cmReturn << dwUnkDatEntry2;
  861. }
  862. //Flags1 & 0x00000001
  863. {
  864. //DWORD dwModel = 0x02000001; //the model, always 1 for a human
  865. cmReturn << dwModel; // 0x02 = ?, 00 = ?, 00 = invisible parts, 00 body parts
  866. }
  867. }
  868. if (m_flAScale > 0)
  869. {
  870. flpScale = m_flAScale;
  871. }
  872. else
  873. {
  874. if ( m_wModelNum > 0 )
  875. {
  876. flpScale = 1; //flmScale;
  877. }
  878. else
  879. {
  880. flpScale = 1;
  881. }
  882. }
  883. cmReturn << flpScale; // Avatar Scale
  884. //Next comes some unknown flags...these flags contain information such
  885. //as whether or not the object is solid (collision detection), the radar color
  886. //PK information, and more. I will crack these some time
  887. // SeaGreens
  888. WORD wUnkFlag2 = 0x0001;
  889. WORD wUnkFlag3 = 0x0001;
  890. WORD wUnkFlag4 = 0;
  891. WORD wUnkFlag6 = 0;
  892. WORD wUnkFlag7 = 0;
  893. WORD wUnkFlag8 = 0;
  894. WORD wUnkFlag10 = 0;
  895. cmReturn << m_wPositionSequence //movement
  896. << wUnkFlag2 //animations
  897. << wUnkFlag3 //bubble modes
  898. << wUnkFlag4 //num jumps
  899. << m_wNumPortals
  900. << wUnkFlag6 //anim count
  901. << wUnkFlag7 //overrides
  902. << wUnkFlag8
  903. << m_wNumLogins
  904. << wUnkFlag10;
  905. DWORD dwFlags2 = 0x00800016; //Flags2 Defines what data comes next
  906. if (m_dwAllegianceID != 0)
  907. dwFlags2 = dwFlags2 & 0x00800056; // WORD 0040 - Monarch Information
  908. cmReturn << dwFlags2; // Word 0080 - Flag Word 0016 Length of Name
  909. cmReturn << Name( ); // Object's Name
  910. cmReturn << wModelID << wIconID;
  911. DWORD dwObjectFlags1 = 0x00000010; //Player Object Flags1, 0x00000010 = NPK Player/Monster
  912. DWORD dwObjectFlags2 = 0x0000001C; //Player Object Flags2, 0x00000010 = Selectable, 0x00000004 = Cannot be Picked up, 0x00000008 = Player
  913. if( m_fIsPK == 1 )
  914. dwObjectFlags2 |= 0x00000020; // PK Flag
  915. if( m_fIsPK == 2 )
  916. dwObjectFlags2 |= 0x02000000; // PKLite Flag
  917. if( m_fIsPK == 3 )
  918. dwObjectFlags2 = 0x00000014; // 0014 - Monster Flag Orange Dot
  919. if( m_fIsPK == 4 )
  920. dwObjectFlags2 = 0x00100012; // 0010 - blue dot
  921. if( m_lstInventory.size() > 0 )
  922. dwObjectFlags2 |= 0x00010000;
  923. cmReturn << dwObjectFlags1 << dwObjectFlags2;
  924. //Flags2 Mask
  925. {
  926. //Flags2 & 0x00000002
  927. if (dwFlags2 & 0x00000002)
  928. {
  929. BYTE bNumberOfSlots = 102; //number of slots in the main inventory pack
  930. cmReturn << bNumberOfSlots;
  931. }
  932. //Flags2 & 0x00000004
  933. if (dwFlags2 & 0x00000004)
  934. {
  935. BYTE bNumPackSlots = 7; //number of packs that can be stored
  936. cmReturn << bNumPackSlots;
  937. }
  938. //Flags2 & 0x00000010
  939. if (dwFlags2 & 0x00000010)
  940. {
  941. WORD wTotalStackValue = 5; // Total Value of Stack Items
  942. cmReturn << wTotalStackValue;
  943. }
  944. //Flags2 & 0x00000040
  945. if (dwFlags2 & 0x00000040)
  946. {
  947. if (cAllegiance* aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID))
  948. {
  949. cmReturn << DWORD(aAllegiance->GetLeader()); // Monarch GUID
  950. } else {
  951. cmReturn << 0x00000000;
  952. }
  953. }
  954. //Flags2 & 0x00800000
  955. if (dwFlags2 & 0x00800000)
  956. {
  957. DWORD dwUnknown4 = 0x00040000;
  958. cmReturn << dwUnknown4;
  959. }
  960. }
  961. //UpdateConsole("Avatar model loaded.\r\n");
  962. return cmReturn;
  963. }
  964. cMessage cAvatar::UpdateAvatarModel( )
  965. {
  966. cMessage cWrChange;
  967. //cItemModels *pcModel = cItemModels::FindModel(pcObj->GetItemModelID());
  968. //pcModel->m_dwEquipActual = 0L;
  969. //pcModel->m_dwFlags1 = (pcModel->m_dwFlags1 ^ 0x00020000);
  970. int paletteChange = m_bBasicPaletteChange;
  971. int textureChange = m_bBasicTextureChange;
  972. //Loop through the palettes and textures of previously equipped items
  973. for ( iterObject_lst itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  974. {
  975. if ( ( *itObject )->m_fEquipped == 2 )
  976. {
  977. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  978. if ( ( *itObject )->m_bWearPaletteChange != 0)
  979. paletteChange += ( *itObject )->m_bWearPaletteChange;
  980. if ( pcItemInv->m_bWearTextureChange != 0)
  981. textureChange += pcItemInv->m_bWearTextureChange;
  982. }
  983. }
  984. cWrChange << DWORD(0xF625)
  985. << DWORD(m_dwGUID)
  986. << BYTE(0x11) // 11 Vector Palettes
  987. << BYTE(paletteChange)
  988. << BYTE(textureChange)
  989. << BYTE(m_bBasicModelChange);
  990. cWrChange << WORD(0x007E);
  991. //Loop through the avatar's default palettes
  992. if ( m_bBasicPaletteChange != 0)
  993. {
  994. for (int i = 0; i < m_bBasicPaletteChange; i++)
  995. {
  996. cWrChange.pasteData((UCHAR*)&m_BasicVectorPal[i],sizeof(m_BasicVectorPal[i]));
  997. }
  998. }
  999. //Loop through the palettes of previously equipped items
  1000. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  1001. {
  1002. if ( ( *itObject )->m_fEquipped == 2 )
  1003. {
  1004. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  1005. if ( ( *itObject )->m_bWearPaletteChange != 0)
  1006. {
  1007. for (int i = 0; i < ( *itObject )->m_bWearPaletteChange; i++)
  1008. {
  1009. cWrChange.pasteData((UCHAR*)&( *itObject )->m_WearVectorPal[i],sizeof(( *itObject )->m_WearVectorPal[i]));
  1010. }
  1011. }
  1012. }
  1013. }
  1014. //Loop through the avatar's default textures
  1015. if ( m_bBasicTextureChange != 0)
  1016. {
  1017. for (int i = 0; i < m_bBasicTextureChange; i++)
  1018. {
  1019. cWrChange.pasteData((UCHAR*)&m_BasicVectorTex[i],sizeof(m_BasicVectorTex[i]));
  1020. }
  1021. }
  1022. //Loop through the textures of previously equipped items
  1023. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  1024. {
  1025. if ( ( *itObject )->m_fEquipped == 2 )
  1026. {
  1027. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  1028. if ( pcItemInv->m_bWearTextureChange != 0)
  1029. {
  1030. for (int i = 0; i < pcItemInv->m_bWearTextureChange; i++)
  1031. {
  1032. cWrChange.pasteData((UCHAR*)&pcItemInv->m_WearVectorTex[i],sizeof(pcItemInv->m_WearVectorTex[i]));
  1033. }
  1034. }
  1035. }
  1036. }
  1037. bool modelIsCovered;
  1038. if ( m_bBasicModelChange != 0)
  1039. {
  1040. //Loop through the avatar's default models
  1041. //Do not include avatar models superceded by item models
  1042. for (int i = 0; i < m_bBasicModelChange; i++)
  1043. {
  1044. modelIsCovered = false;
  1045. //Loop through the models of previously equipped items
  1046. for ( itObject =m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  1047. {
  1048. if ( ( *itObject )->m_fEquipped == 2 )
  1049. {
  1050. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  1051. if ( pcItemInv->m_bWearModelChange != 0)
  1052. {
  1053. for (int j = 0; j < pcItemInv->m_bWearModelChange; j++)
  1054. {
  1055. //Find whether the item affects the given avatar body part
  1056. //If so, the item model index will equal the given avatar model index
  1057. if(m_BasicVectorMod[i].m_bModelIndex == pcItemInv->m_WearVectorMod[j].m_bModelIndex)
  1058. {
  1059. modelIsCovered = true;
  1060. }
  1061. }
  1062. }
  1063. }
  1064. }
  1065. if (!modelIsCovered)
  1066. cWrChange.pasteData((UCHAR*)&m_BasicVectorMod[i],sizeof(m_BasicVectorMod[i]));
  1067. }
  1068. }
  1069. //Loop through the models of currently equipped items
  1070. //If two items cover the same area, the one with a higher coverage value supercedes
  1071. for ( itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  1072. {
  1073. if ( ( *itObject )->m_fEquipped == 2 )
  1074. {
  1075. cItemModels *pcItemInv = cItemModels::FindModel(( *itObject )->GetItemModelID());
  1076. if ( pcItemInv->m_bWearModelChange != 0)
  1077. {
  1078. for (int i = 0; i < pcItemInv->m_bWearModelChange; i++)
  1079. {
  1080. modelIsCovered = false;
  1081. for ( iterObject_lst itObject2 = m_lstInventory.begin( ); itObject2 != m_lstInventory.end( ); ++itObject2 )
  1082. {
  1083. if ( ( *itObject2 )->m_fEquipped == 2 )
  1084. {
  1085. cItemModels *pcItemInv2 = cItemModels::FindModel(( *itObject2 )->GetItemModelID());
  1086. if ( pcItemInv2->m_bWearModelChange != 0)
  1087. {
  1088. for (int j = 0; j < pcItemInv2->m_bWearModelChange; j++)
  1089. {
  1090. if (pcItemInv->m_WearVectorMod[i].m_bModelIndex == pcItemInv2->m_WearVectorMod[j].m_bModelIndex)
  1091. if (pcItemInv->m_dwCoverage < pcItemInv2->m_dwCoverage)
  1092. modelIsCovered = true;
  1093. }
  1094. }
  1095. }
  1096. }
  1097. if (!modelIsCovered)
  1098. cWrChange.pasteData((UCHAR*)&pcItemInv->m_WearVectorMod[i],sizeof(pcItemInv->m_WearVectorMod[i]));
  1099. }
  1100. }
  1101. }
  1102. }
  1103. cWrChange.pasteAlign(4);
  1104. cWrChange << m_wNumLogins;
  1105. cWrChange << ++m_wModelSequence;
  1106. return cWrChange;
  1107. }
  1108. /**
  1109. * Handles the message sent for an avatar's housing information.
  1110. *
  1111. * The message includes information on the house's purchase time, type,purchase and maintaince costs, name, and location.
  1112. *
  1113. * @return cMessage - Returns a Game Event (0x0000F7B0) server message of type House Information for Owners (0x00000225) or House Information for Non-Owners (0x00000226).
  1114. */
  1115. cMessage cAvatar::HousingInfo(DWORD F7B0seq)
  1116. {
  1117. char szCommand[512];
  1118. RETCODE retcode;
  1119. DWORD dwAccountID;
  1120. UINT dwAvatarGUID;
  1121. // WORD wAvatarCount;
  1122. DWORD dwHouseType;
  1123. DWORD dwPurchaseTime;
  1124. int i;
  1125. cMessage cmReturn;
  1126. cmReturn << 0xF7B0L
  1127. << m_dwGUID
  1128. << F7B0seq; // sequence number
  1129. sprintf( szCommand, "SELECT * FROM avatar WHERE AvatarGUID = %lu;",m_dwGUID );
  1130. retcode = SQLPrepare( cDatabase::m_hStmt,(unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1131. retcode = SQLExecute( cDatabase::m_hStmt );
  1132. retcode = SQLBindCol( cDatabase::m_hStmt, 3, SQL_C_ULONG, &dwAccountID, sizeof( dwAccountID ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1133. if (SQLFetch( cDatabase::m_hStmt ) != SQL_SUCCESS)
  1134. {
  1135. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1136. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1137. } else {
  1138. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1139. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1140. // sprintf( szCommand, "SELECT COUNT(houses_covenants.ID) FROM {oj avatar LEFT OUTER JOIN houses_covenants ON avatar.AvatarGUID=houses_covenants.OwnerID} WHERE avatar.OwnerID = %d;",AccountID );
  1141. bool owner = false;
  1142. dwAvatarGUID = NULL;
  1143. sprintf( szCommand, "SELECT AvatarGUID FROM avatar WHERE OwnerID = %d;",dwAccountID );
  1144. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1145. retcode = SQLExecute( cDatabase::m_hStmt );
  1146. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwAvatarGUID, sizeof( dwAvatarGUID ), NULL );CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1147. DWORD avatarArray[10];
  1148. for ( i = 0; SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS; ++i )
  1149. {
  1150. avatarArray[i] = dwAvatarGUID;
  1151. }
  1152. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1153. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1154. for ( i = 0; owner != true && i < 10; i++ )
  1155. {
  1156. sprintf( szCommand, "SELECT HouseID FROM houses_covenants WHERE OwnerID = %d;",avatarArray[i] );
  1157. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1158. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1159. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &m_wHouseID, sizeof( WORD ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1160. if (SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS)
  1161. {
  1162. owner = true;
  1163. }
  1164. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1165. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1166. }
  1167. if( owner != true )
  1168. {
  1169. cmReturn << 0x0226L;
  1170. } else {
  1171. sprintf( szCommand, "SELECT HouseType,PurchaseTime FROM houses_covenants WHERE HouseID = %d;",m_wHouseID );
  1172. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1173. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1174. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwHouseType, sizeof( dwHouseType ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1175. retcode = SQLBindCol( cDatabase::m_hStmt, 2, SQL_C_ULONG, &dwPurchaseTime, sizeof( dwPurchaseTime ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1176. retcode = SQLFetch( cDatabase::m_hStmt );
  1177. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1178. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1179. cmReturn << 0x0225L
  1180. << dwPurchaseTime
  1181. << dwPurchaseTime // maintainence last paid?
  1182. << dwHouseType // Cottage = 1; Villa = 2; Mansion = 3; Apartment = 4
  1183. << DWORD(0x0L); // unknown (0x00000000)
  1184. DWORD dwPurchaseCount; // Apartment = 2; Cottage, Villa = 3; Mansion = 6;
  1185. sprintf( szCommand, "SELECT COUNT(ID) FROM houses_purchase WHERE HouseID = %d;",m_wHouseID );
  1186. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1187. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1188. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwPurchaseCount, sizeof( dwPurchaseCount ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1189. retcode = SQLFetch( cDatabase::m_hStmt );
  1190. if( retcode == SQL_NO_DATA )
  1191. dwPurchaseCount = 0;
  1192. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1193. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1194. cmReturn << dwPurchaseCount;
  1195. DWORD dwBuyType;
  1196. DWORD dwBuyRequired;
  1197. DWORD dwBuyPaid;
  1198. // String buyName;
  1199. // String buyPluralName;
  1200. sprintf( szCommand, "SELECT ItemLinker,Required,Paid FROM houses_purchase WHERE HouseID = %d;",m_wHouseID );
  1201. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1202. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1203. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwBuyType, sizeof( dwBuyType ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1204. retcode = SQLBindCol( cDatabase::m_hStmt, 2, SQL_C_ULONG, &dwBuyRequired, sizeof( dwBuyRequired ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1205. retcode = SQLBindCol( cDatabase::m_hStmt, 3, SQL_C_ULONG, &dwBuyPaid, sizeof( dwBuyPaid ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1206. for ( i = 0; SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS; ++i )
  1207. {
  1208. cItemModels *pcModel = cItemModels::FindModel(dwBuyType);
  1209. std::string strPluralName = pcModel->m_strName.c_str();
  1210. strPluralName.assign(strPluralName);
  1211. cmReturn << dwBuyRequired // quantity required
  1212. << dwBuyPaid // quantity paid
  1213. << DWORD(pcModel->m_wModel) // item's object type
  1214. << pcModel->m_strName.c_str() // name of this item
  1215. << strPluralName.c_str(); // plural name of this item (if not specified, use <name> followed by 's' or 'es')
  1216. }
  1217. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1218. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1219. DWORD dwMaintenanceCount; // Apartment, Cottage = 1; Villa, Mansion = 2;
  1220. sprintf( szCommand, "SELECT COUNT(ID) FROM houses_maintenance WHERE HouseID = %d;",m_wHouseID );
  1221. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1222. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1223. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwMaintenanceCount, sizeof( dwMaintenanceCount ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1224. retcode = SQLFetch( cDatabase::m_hStmt );
  1225. if( retcode == SQL_NO_DATA )
  1226. dwMaintenanceCount = 0;
  1227. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1228. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  1229. cmReturn << dwMaintenanceCount; // the number of items required to pay the maintenance cost for this dwelling
  1230. DWORD dwMaintainType;
  1231. DWORD dwMaintainRequired;
  1232. DWORD dwMaintainPaid;
  1233. // String maintainName;
  1234. // String maintainPluralName;
  1235. sprintf( szCommand, "SELECT ItemLinker,Required,Paid FROM houses_maintenance WHERE HouseID = %d;",m_wHouseID );
  1236. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1237. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1238. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwMaintainType, sizeof( dwMaintainType ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1239. retcode = SQLBindCol( cDatabase::m_hStmt, 2, SQL_C_ULONG, &dwMaintainRequired, sizeof( dwMaintainRequired ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1240. retcode = SQLBindCol( cDatabase::m_hStmt, 3, SQL_C_ULONG, &dwMaintainPaid, sizeof( dwMaintainPaid ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1241. for ( i = 0; SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS; ++i )
  1242. {
  1243. cItemModels *pcModel = cItemModels::FindModel(dwMaintainType);
  1244. std::string strPluralName = pcModel->m_strName.c_str();
  1245. strPluralName.assign(strPluralName);
  1246. cmReturn << dwMaintainRequired // quantity required
  1247. << dwMaintainPaid // quantity paid
  1248. << DWORD(pcModel->m_wModel) // item's object type
  1249. << pcModel->m_strName.c_str() // name of this item
  1250. << strPluralName.c_str(); // plural name of this item (if not specified, use <name> followed by 's' or 'es')
  1251. }
  1252. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1253. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1254. cLocation locCovenant;
  1255. char locBuff[9];
  1256. char dwCovPosX[9];
  1257. char dwCovPosY[9];
  1258. char dwCovPosZ[9];
  1259. char dwCovOrientW[9];
  1260. char dwCovOrientX[9];
  1261. char dwCovOrientY[9];
  1262. char dwCovOrientZ[9];
  1263. sprintf( szCommand, "SELECT Landblock,Position_X,Position_Y,Position_Z,Orientation_W,Orientation_X,Orientation_Y,Orientation_Z FROM houses_covenants WHERE HouseID = %d;",m_wHouseID );
  1264. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1265. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  1266. int iCol = 1;
  1267. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, locBuff, sizeof( locBuff ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1268. /* retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flX, sizeof( &locCovenant.m_flX ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1269. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flY, sizeof( &locCovenant.m_flY ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1270. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flZ, sizeof( &locCovenant.m_flZ ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1271. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flA, sizeof( &locCovenant.m_flA ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1272. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flB, sizeof( &locCovenant.m_flB ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1273. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flC, sizeof( &locCovenant.m_flC ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1274. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_FLOAT, &locCovenant.m_flW, sizeof( &locCovenant.m_flW ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1275. */ retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovPosX, sizeof( dwCovPosX ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1276. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovPosY, sizeof( dwCovPosY ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1277. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovPosZ, sizeof( dwCovPosZ ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1278. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovOrientW, sizeof( dwCovOrientW ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1279. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovOrientX, sizeof( dwCovOrientX ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1280. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovOrientY, sizeof( dwCovOrientY ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1281. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, dwCovOrientZ, sizeof( dwCovOrientZ ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1282. if (SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS)
  1283. {
  1284. sscanf(locBuff,"%08x",&locCovenant.m_dwLandBlock);
  1285. sscanf(dwCovPosX,"%08x",&locCovenant.m_flX);
  1286. sscanf(dwCovPosY,"%08x",&locCovenant.m_flY);
  1287. sscanf(dwCovPosZ,"%08x",&locCovenant.m_flZ);
  1288. sscanf(dwCovOrientW,"%08x",&locCovenant.m_flA);
  1289. sscanf(dwCovOrientX,"%08x",&locCovenant.m_flB);
  1290. sscanf(dwCovOrientY,"%08x",&locCovenant.m_flC);
  1291. sscanf(dwCovOrientZ,"%08x",&locCovenant.m_flW);
  1292. }
  1293. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1294. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1295. cmReturn << locCovenant;
  1296. }
  1297. }
  1298. return cmReturn;
  1299. }
  1300. int cAvatar::CastMain(LPVOID wp, LPVOID lp )
  1301. {
  1302. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1303. //char szMessage[100];
  1304. //sprintf( szMessage, "dwAnim: %u\r\n",basic);
  1305. //UpdateConsole((char *)szMessage);
  1306. //cMessage cPart = pcClient->m_pcAvatar->Particle( 0x50 );
  1307. //cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, cPart, 3 );
  1308. return -1;
  1309. }
  1310. int cAvatar::WarAnimation1(LPVOID wp, LPVOID lp )
  1311. {
  1312. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1313. cClient* pcClient = cClient::FindClient( WarJobParam->GetCasterGUID() );
  1314. cSpell* pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  1315. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, pcClient->m_pcAvatar->LocationPacket(), 3 );
  1316. cLocation CastLocation = WarJobParam->GetCastLocation();
  1317. //if ( CastLocation.m_flA == pcClient->m_pcAvatar->m_Location.m_flA )
  1318. cMessage cmSpellWords = pcSpell->GetCastWords();
  1319. cmSpellWords << pcClient->m_pcAvatar->Name( );
  1320. //cmSpellWords.pasteAlign(2);
  1321. cmSpellWords << pcClient->m_pcAvatar->m_dwGUID << 0x11L;
  1322. pcClient->m_pcAvatar->SetLocation(pcClient->m_pcAvatar->m_Location);
  1323. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, cmSpellWords, 4 );
  1324. if (pcSpell->m_dwLevel != 1)
  1325. {
  1326. cMessage msg1 = pcClient->m_pcAvatar->WindupAnimation( pcSpell->GetWindup(), 1.0f );
  1327. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, msg1, 3 );
  1328. }
  1329. int iDelay = pcSpell->GetWindupDelay();
  1330. int iJob = cMasterServer::m_pcJobPool->CreateJob( &cAvatar::WarAnimation2, (LPVOID) WarJobParam, NULL, "WarAnimation2", iDelay, 1);
  1331. return -1;
  1332. }
  1333. int cAvatar::WarAnimation2(LPVOID wp, LPVOID lp )
  1334. {
  1335. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1336. cClient* pcClient = cClient::FindClient( WarJobParam->GetCasterGUID() );
  1337. if (!pcClient)
  1338. {
  1339. /*cMessage cmActionComplete;
  1340. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  1341. pcClient->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1342. */
  1343. SAFEDELETE( WarJobParam )
  1344. return 2;
  1345. }
  1346. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  1347. if (!pcSpell)
  1348. {
  1349. cMessage cmActionComplete;
  1350. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  1351. pcClient->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1352. pcClient->m_pcAvatar->m_fIsCasting = false;
  1353. SAFEDELETE( WarJobParam )
  1354. return 2;
  1355. }
  1356. BYTE bAnim = pcSpell->GetCastAnim();
  1357. cMessage msgTest = pcClient->m_pcAvatar->WarAnimation( bAnim, 1.0f );
  1358. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, msgTest, 3 );
  1359. int iDelay = pcSpell->GetCastAnimDelay()/4 + 1;
  1360. int iJob = cMasterServer::m_pcJobPool->CreateJob( &cAvatar::WarAnimation3, (LPVOID) WarJobParam, NULL, "WarAnimation3", iDelay, 1);
  1361. return -1;
  1362. }
  1363. int cAvatar::WarAnimation3(LPVOID wp, LPVOID lp )
  1364. {
  1365. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1366. cClient* pcClient = cClient::FindClient( WarJobParam->GetCasterGUID() );
  1367. if (!pcClient)
  1368. {
  1369. /*cMessage cmActionComplete;
  1370. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  1371. pcClient->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1372. */
  1373. SAFEDELETE( WarJobParam )
  1374. return 2;
  1375. }
  1376. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  1377. if (!pcSpell)
  1378. {
  1379. cMessage cmActionComplete;
  1380. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  1381. pcClient->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1382. pcClient->m_pcAvatar->m_fIsCasting = false;
  1383. SAFEDELETE( WarJobParam )
  1384. return 2;
  1385. }
  1386. cMessage msgTest2 = pcClient->m_pcAvatar->WarAnimation2( 1.0f );
  1387. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, msgTest2, 3 );
  1388. float flRange = cPhysics::GetRange(pcClient->m_pcAvatar->m_Location, WarJobParam->GetCastLocation());
  1389. if ( flRange > .15 )
  1390. {
  1391. cMessage cPart = pcClient->m_pcAvatar->Particle( 0x50 );
  1392. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, cPart, 3 );
  1393. cMessage cmFizzle;
  1394. cmFizzle << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x028AL << 0x0402L;
  1395. pcClient->AddPacket( WORLD_SERVER,cmFizzle,4);
  1396. }
  1397. else if ( strcmp(pcSpell->m_strSchool.c_str(), "War" ) == 0 )
  1398. {
  1399. cAvatar::CastWar( (LPVOID) WarJobParam );
  1400. }
  1401. else if ( strcmp( pcSpell->m_strSchool.c_str(), "Life" ) == 0 )
  1402. {
  1403. cAvatar::CastLife( (LPVOID) WarJobParam );
  1404. }
  1405. else if ( strcmp( pcSpell->m_strSchool.c_str(), "Creature" ) == 0 )
  1406. {
  1407. cAvatar::CastCreature( (LPVOID) WarJobParam );
  1408. }
  1409. else if ( strcmp( pcSpell->m_strSchool.c_str(), "Item" ) == 0 )
  1410. {
  1411. cAvatar::CastItem( (LPVOID) WarJobParam );
  1412. }
  1413. cMessage cmActionComplete;
  1414. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  1415. pcClient->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1416. pcClient->m_pcAvatar->m_fIsCasting = false;
  1417. SAFEDELETE( WarJobParam )
  1418. return -1;
  1419. }
  1420. /**
  1421. * Handles the message sent for the casting of a War Magic spell.
  1422. *
  1423. * This function is called whenever a War Magic spell is cast by a client's avatar.
  1424. * Returns a server message to the client.
  1425. */
  1426. void cAvatar::CastWar( LPVOID wp )
  1427. {
  1428. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1429. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  1430. if (pcSpell)
  1431. {
  1432. switch ( pcSpell->m_dwEffect )
  1433. {
  1434. case 117: case 118: case 119: case 120: case 121: case 122: case 123: //bolt, arc
  1435. {
  1436. int iWarModel = SHOCK_MODEL;
  1437. switch ( pcSpell->m_dwEffect )
  1438. {
  1439. case 117: //acid
  1440. {
  1441. iWarModel = ACID_MODEL;
  1442. break;
  1443. }
  1444. case 118: //shock
  1445. {
  1446. iWarModel = SHOCK_MODEL;
  1447. break;
  1448. }
  1449. case 119: //frost
  1450. {
  1451. iWarModel = FROST_MODEL;
  1452. break;
  1453. }
  1454. case 120: //lightning
  1455. {
  1456. iWarModel = LIGHTNING_MODEL;
  1457. break;
  1458. }
  1459. case 121: //flame
  1460. {
  1461. iWarModel = FLAME_MODEL;
  1462. break;
  1463. }
  1464. case 122: //force
  1465. {
  1466. iWarModel = FORCE_MODEL;
  1467. break;
  1468. }
  1469. case 123: //blade
  1470. {
  1471. iWarModel = BLADE_MODEL;
  1472. break;
  1473. }
  1474. }
  1475. cClient* pcClient = cClient::FindClient( WarJobParam->GetCasterGUID() );
  1476. if (pcClient)
  1477. {
  1478. float flUserHeading = cPhysics::GetAvatarHeading( pcClient->m_pcAvatar->m_Location );
  1479. float flTargetHeading;
  1480. cVelocity tarVel;
  1481. cClient* pcTargetObj = cClient::FindClient( WarJobParam->GetTargetGUID() );
  1482. if( !pcTargetObj )
  1483. {
  1484. cObject* pcTargetObject = cWorldManager::FindObject( WarJobParam->GetTargetGUID() );
  1485. if( !pcTargetObject )
  1486. {
  1487. }
  1488. else
  1489. {
  1490. flTargetHeading = cPhysics::GetHeadingTarget(pcClient->m_pcAvatar->m_Location,pcTargetObject->m_Location);
  1491. tarVel = cPhysics::GetTargetVelocity(pcClient->m_pcAvatar->m_Location,pcTargetObject->m_Location);
  1492. char szMessage[100];
  1493. sprintf( szMessage, "usrX: %f, usrY: %f, tarX: %f, tarY: %f\r\n", pcClient->m_pcAvatar->m_Location.m_flX, pcClient->m_pcAvatar->m_Location.m_flY, pcTargetObject->m_Location.m_flX, pcTargetObject->m_Location.m_flY);
  1494. //UpdateConsole((char *)szMessage);
  1495. }
  1496. }
  1497. else
  1498. {
  1499. flTargetHeading = cPhysics::GetHeadingTarget(pcClient->m_pcAvatar->m_Location,pcTargetObj->m_pcAvatar->m_Location);
  1500. tarVel = cPhysics::GetTargetVelocity(pcClient->m_pcAvatar->m_Location,pcTargetObj->m_pcAvatar->m_Location);
  1501. }
  1502. cWarSpell* warSpell = new cWarSpell(cWorldManager::NewGUID_Object(), WarJobParam->GetSpellID(), pcClient->m_pcAvatar->m_Location, tarVel, iWarModel);
  1503. cWorldManager::AddObject( warSpell, TRUE );
  1504. cMessage msgParticles = warSpell->WarParticle(warSpell,0x0004,1.0f);
  1505. cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, msgParticles, 3 );
  1506. //cMessage msgSpellAnim = warSpell->SpellAnim(warSpell,0x0049L,0x003CL);
  1507. //cWorldManager::SendToAllInFocus( pcClient->m_pcAvatar->m_Location, msgSpellAnim, 3 );
  1508. cSpellMoveParam* SpellMoveParam = new cSpellMoveParam( pcClient->m_pcAvatar->GetGUID(), warSpell->m_Location, warSpell->GetGUID() );
  1509. int iJob = cMasterServer::m_pcJobPool->CreateJob( warSpell->Move, (LPVOID) SpellMoveParam, NULL, "WarSpellMove", 1, 200);
  1510. }
  1511. break;
  1512. }
  1513. case 131: //acid blast
  1514. {
  1515. }
  1516. case 132: //shock blast
  1517. {
  1518. }
  1519. case 133: //frost blast
  1520. {
  1521. }
  1522. case 134: //lightning blast
  1523. {
  1524. }
  1525. case 135: //flame blast (also some monster spells)
  1526. {
  1527. }
  1528. case 137: //blade blast
  1529. {
  1530. }
  1531. case 207: //acid volley
  1532. {
  1533. }
  1534. case 208: //bludgeoning volley
  1535. {
  1536. }
  1537. case 209: //frost volley
  1538. {
  1539. }
  1540. case 210: //lightning volley
  1541. {
  1542. }
  1543. case 211: //flame volley
  1544. {
  1545. }
  1546. case 212: //force volley
  1547. {
  1548. }
  1549. case 213: //blade volley
  1550. {
  1551. }
  1552. case 222: //searing disc (8 waves of acid outward from caster)
  1553. {
  1554. }
  1555. case 223: //tectonic rifts (8 shock waves outward from caster), other similar shock wave spells
  1556. {
  1557. }
  1558. case 224: //halo of frost (8 waves of frost outward from caster)
  1559. {
  1560. }
  1561. case 225: //eye of the storm (8 waves of lightning outward from caster)
  1562. {
  1563. }
  1564. case 226: //cassius' ring of fire (8 waves of fire outward from caster)
  1565. {
  1566. }
  1567. case 227: //nuhmudira's spines (8 waves of force outward from caster)
  1568. {
  1569. }
  1570. case 228: //horizon's blades (8 blades outward from caster)
  1571. {
  1572. }
  1573. case 229: //blistering creeper (wall of 5 acid balls, 2 high)
  1574. {
  1575. }
  1576. case 230: //hammering crawler (wall of 5 shockwaves, 2 high)
  1577. {
  1578. }
  1579. case 231: //foon-ki's glacial flow (wall of 5 frost balls, 2 high)
  1580. {
  1581. }
  1582. case 232: //os' wall (wall of 5 lightning bolts, 2 high)
  1583. {
  1584. }
  1585. case 233: //slithering flames (wall of 5 fire balls, 2 high), demon's tongues (wall of lag?)
  1586. {
  1587. }
  1588. case 234: //spike strafe (wall of 5 force bolts, 2 high)
  1589. {
  1590. }
  1591. case 235: //bed of blades (wall of 5 blades, 2 high)
  1592. {
  1593. }
  1594. case 236: //torrential acid (9 streams of acid down at area around target)
  1595. {
  1596. }
  1597. case 237: //raining boulders and other various spells
  1598. {
  1599. }
  1600. case 238: //avalanche (up to 12 balls of frost down at area around target)
  1601. {
  1602. }
  1603. case 239: //lightning barrage (9 bolts of lightning down at area around target)
  1604. {
  1605. }
  1606. case 240: //firestorm (9 balls of flame down at area around target)
  1607. {
  1608. }
  1609. case 241: //splinterfall (9 force bolts down at area around target)
  1610. {
  1611. }
  1612. case 242: //squall of swords (9 blades down at area around target)
  1613. {
  1614. }
  1615. case 243: //acid streak
  1616. {
  1617. }
  1618. case 244: //shock wave streak
  1619. {
  1620. }
  1621. case 245: //frost streak
  1622. {
  1623. }
  1624. case 246: //lightning streak
  1625. {
  1626. }
  1627. case 247: //flame streak
  1628. {
  1629. }
  1630. case 248: //force streak
  1631. {
  1632. }
  1633. case 249: //blade streak
  1634. {
  1635. }
  1636. }
  1637. }
  1638. }
  1639. /**
  1640. * Handles the message sent for the casting of a Life Magic spell.
  1641. *
  1642. * This function is called whenever a Life Magic spell is cast by a client's avatar.
  1643. * Returns a server message to the client.
  1644. */
  1645. void cAvatar::CastLife( LPVOID wp )
  1646. {
  1647. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  1648. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  1649. if (pcSpell)
  1650. {
  1651. cMessage msgSpellEffect;
  1652. msgSpellEffect << 0xF755L << WarJobParam->GetTargetGUID() << pcSpell->m_dwEffectAnim << 0x3F2B4E94L;
  1653. cClient* pcTargetObj = cClient::FindClient( WarJobParam->GetTargetGUID() );
  1654. if( !pcTargetObj )
  1655. {
  1656. cObject* pcTargetObject = cWorldManager::FindObject( WarJobParam->GetTargetGUID() );
  1657. if( !pcTargetObject )
  1658. {
  1659. }
  1660. else
  1661. {
  1662. cWorldManager::SendToAllInFocus( pcTargetObject->m_Location, msgSpellEffect, 3 );
  1663. }
  1664. }
  1665. else
  1666. {
  1667. cWorldManager::SendToAllInFocus( pcTargetObj->m_pcAvatar->m_Location, msgSpellEffect, 3 );
  1668. }
  1669. switch ( pcSpell->m_dwEffect )
  1670. {
  1671. case 67: //increase caster's health
  1672. {
  1673. if ( pcTargetObj )
  1674. {
  1675. DWORD dwHeal = pcTargetObj->m_pcAvatar->GetHealValue( pcSpell->m_dwLevel );
  1676. int iNewHealth;
  1677. if (pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[0].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[0].m_lTrueCurrent < dwHeal)
  1678. {
  1679. dwHeal = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[0].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[0].m_lTrueCurrent;
  1680. }
  1681. iNewHealth = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[0].m_lTrueCurrent;
  1682. iNewHealth += dwHeal;
  1683. cMessage cmHeal1 = pcTargetObj->m_pcAvatar->UpdateHealth(dwHeal,iNewHealth);
  1684. pcTargetObj->AddPacket( WORLD_SERVER,cmHeal1,4);
  1685. char szHeal[200];
  1686. wsprintf( szHeal, "You heal yourself for %d points with %s!", dwHeal, pcSpell->m_strName.c_str() );
  1687. cMessage cmHeal2;
  1688. cmHeal2 << 0xF62C << szHeal << ColorGreen;
  1689. pcTargetObj->AddPacket( WORLD_SERVER, cmHeal2, 4 );
  1690. }
  1691. break;
  1692. }
  1693. case 79: //increase target's health
  1694. {
  1695. }
  1696. case 80: //decrease health (also Martyr's Hecatomb)
  1697. {
  1698. }
  1699. case 81: //increase stamina (also Mana Boost Self)
  1700. {
  1701. if (pcTargetObj)
  1702. {
  1703. DWORD dwStamina = pcTargetObj->m_pcAvatar->GetStaminaValue( pcSpell->m_dwLevel );
  1704. int iNewStamina;
  1705. if (pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent < dwStamina)
  1706. {
  1707. dwStamina = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  1708. }
  1709. iNewStamina = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  1710. iNewStamina += dwStamina;
  1711. cMessage cmStamina1 = pcTargetObj->m_pcAvatar->UpdateStamina(dwStamina,iNewStamina);
  1712. pcTargetObj->AddPacket( WORLD_SERVER,cmStamina1,4);
  1713. char szStamina[200];
  1714. wsprintf( szStamina, "You restore %d points of stamina with %s!", dwStamina, pcSpell->m_strName.c_str() );
  1715. cMessage cmStamina2;
  1716. cmStamina2 << 0xF62C << szStamina << ColorGreen;
  1717. pcTargetObj->AddPacket( WORLD_SERVER, cmStamina2, 4 );
  1718. }
  1719. break;
  1720. }
  1721. case 82: //decrease stamina (also Martyr's Tenacity)
  1722. {
  1723. }
  1724. case 83: //increase target's mana (also some max mana spells)
  1725. {
  1726. }
  1727. case 84: //decrease mana (also Martyr's Blight)
  1728. {
  1729. }
  1730. case 86: //decrease max mana (Malediction)
  1731. {
  1732. }
  1733. case 87: //drain health other, health to stamina, health to mana
  1734. {
  1735. }
  1736. case 88: //infuse health other
  1737. {
  1738. }
  1739. case 89: //drain stamina other, stamina to health, stamina to mana
  1740. {
  1741. if (pcTargetObj)
  1742. {
  1743. float flTransferValue = pcTargetObj->m_pcAvatar->GetTransferValue( pcSpell->m_dwLevel );
  1744. DWORD dwMana = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent / 2 * flTransferValue;
  1745. int iNewMana, iNewStamina;
  1746. if (pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[2].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[2].m_lTrueCurrent < dwMana)
  1747. {
  1748. dwMana = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[2].m_dwCurrent - pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[2].m_lTrueCurrent;
  1749. }
  1750. iNewMana = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[2].m_lTrueCurrent;
  1751. iNewMana += dwMana;
  1752. iNewStamina = pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  1753. iNewStamina -= pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent / 2;
  1754. cMessage cmMana1 = pcTargetObj->m_pcAvatar->UpdateMana(dwMana,iNewMana);
  1755. pcTargetObj->AddPacket( WORLD_SERVER,cmMana1,4);
  1756. cMessage cmStamina = pcTargetObj->m_pcAvatar->DecrementStamina(pcTargetObj->m_pcAvatar->m_cStats.m_lpcVitals[1].m_lTrueCurrent / 2,iNewStamina);
  1757. pcTargetObj->AddPacket( WORLD_SERVER,cmStamina,4);
  1758. char szMana[200];
  1759. wsprintf( szMana, "You transfer stamina into mana for %d points with %s!", dwMana, pcSpell->m_strName.c_str() );
  1760. cMessage cmMana2;
  1761. cmMana2 << 0xF62C << szMana << ColorGreen;
  1762. pcTargetObj->AddPacket( WORLD_SERVER, cmMana2, 4 );
  1763. }
  1764. break;
  1765. }
  1766. case 90: //infuse stamina other
  1767. {
  1768. }
  1769. case 91: //drain mana other, mana to health, mana to stamina
  1770. {
  1771. }
  1772. case 92: //infuse mana other
  1773. {
  1774. break;
  1775. }
  1776. case 93: //increase healing rate
  1777. {
  1778. DWORD dwFlags = 0x5008L;
  1779. DWORD dwKey = 0x03L;
  1780. float flValue = pcTargetObj->m_pcAvatar->GetRegenIncValue( pcSpell->m_dwLevel );
  1781. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1782. break;
  1783. }
  1784. case 94: //decrease healing rate
  1785. {
  1786. DWORD dwFlags = 0x5008L;
  1787. DWORD dwKey = 0x03L;
  1788. float flValue = pcTargetObj->m_pcAvatar->GetRegenDecValue( pcSpell->m_dwLevel );
  1789. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1790. break;
  1791. }
  1792. case 95: //increase stamina regen
  1793. {
  1794. DWORD dwFlags = 0x5008L;
  1795. DWORD dwKey = 0x04L;
  1796. float flValue = pcTargetObj->m_pcAvatar->GetRegenIncValue( pcSpell->m_dwLevel );
  1797. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1798. break;
  1799. }
  1800. case 96: //decrease stamina regen
  1801. {
  1802. DWORD dwFlags = 0x5008L;
  1803. DWORD dwKey = 0x04L;
  1804. float flValue = pcTargetObj->m_pcAvatar->GetRegenDecValue( pcSpell->m_dwLevel );
  1805. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1806. break;
  1807. }
  1808. case 97: //increase mana rate
  1809. {
  1810. DWORD dwFlags = 0x5008L;
  1811. DWORD dwKey = 0x05L;
  1812. float flValue = pcTargetObj->m_pcAvatar->GetRegenIncValue( pcSpell->m_dwLevel );
  1813. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1814. break;
  1815. }
  1816. case 98: //decrease mana rate
  1817. {
  1818. DWORD dwFlags = 0x5008L;
  1819. DWORD dwKey = 0x05L;
  1820. float flValue = pcTargetObj->m_pcAvatar->GetRegenDecValue( pcSpell->m_dwLevel );
  1821. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1822. break;
  1823. }
  1824. case 101: //acid prot
  1825. {
  1826. DWORD dwFlags = 0x5008L;
  1827. DWORD dwKey = 0x45L;
  1828. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1829. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1830. break;
  1831. }
  1832. case 102: //acid vuln
  1833. {
  1834. DWORD dwFlags = 0x5008L;
  1835. DWORD dwKey = 0x45L;
  1836. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1837. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1838. break;
  1839. }
  1840. case 103: //bludgeoning prot
  1841. {
  1842. DWORD dwFlags = 0x5008L;
  1843. DWORD dwKey = 0x42L;
  1844. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1845. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1846. break;
  1847. }
  1848. case 104: //bludgeoning vuln
  1849. {
  1850. DWORD dwFlags = 0x5008L;
  1851. DWORD dwKey = 0x42L;
  1852. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1853. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1854. break;
  1855. }
  1856. case 105: //cold prot
  1857. {
  1858. DWORD dwFlags = 0x5008L;
  1859. DWORD dwKey = 0x44L;
  1860. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1861. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1862. break;
  1863. }
  1864. case 106: //cold vuln
  1865. {
  1866. DWORD dwFlags = 0x5008L;
  1867. DWORD dwKey = 0x44L;
  1868. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1869. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1870. break;
  1871. }
  1872. case 107: //lightning prot
  1873. {
  1874. DWORD dwFlags = 0x5008L;
  1875. DWORD dwKey = 0x46L;
  1876. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1877. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1878. break;
  1879. }
  1880. case 108: //lightning vuln
  1881. {
  1882. DWORD dwFlags = 0x5008L;
  1883. DWORD dwKey = 0x46L;
  1884. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1885. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1886. break;
  1887. }
  1888. case 109: //fire prot
  1889. {
  1890. DWORD dwFlags = 0x5008L;
  1891. DWORD dwKey = 0x43L;
  1892. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1893. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1894. break;
  1895. }
  1896. case 110: //fire vuln
  1897. {
  1898. DWORD dwFlags = 0x5008L;
  1899. DWORD dwKey = 0x43L;
  1900. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1901. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1902. break;
  1903. }
  1904. case 111: //piercing prot
  1905. {
  1906. DWORD dwFlags = 0x5008L;
  1907. DWORD dwKey = 0x41L;
  1908. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1909. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1910. break;
  1911. }
  1912. case 112: //piercing vuln
  1913. {
  1914. DWORD dwFlags = 0x5008L;
  1915. DWORD dwKey = 0x41L;
  1916. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1917. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1918. break;
  1919. }
  1920. case 113: //slashing prot
  1921. {
  1922. DWORD dwFlags = 0x5008L;
  1923. DWORD dwKey = 0x40L;
  1924. float flValue = pcTargetObj->m_pcAvatar->GetProtValue( pcSpell->m_dwLevel );
  1925. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1926. break;
  1927. }
  1928. case 114: //slashing vuln
  1929. {
  1930. DWORD dwFlags = 0x5008L;
  1931. DWORD dwKey = 0x40L;
  1932. float flValue = pcTargetObj->m_pcAvatar->GetVulnValue( pcSpell->m_dwLevel );
  1933. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1934. break;
  1935. }
  1936. case 115: //increase armor
  1937. {
  1938. DWORD dwFlags = 0xA080L;
  1939. DWORD dwKey = 0x0L;
  1940. float flValue = pcTargetObj->m_pcAvatar->GetArmorValue( pcSpell->m_dwLevel );
  1941. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1942. break;
  1943. }
  1944. case 116: //decrease armor
  1945. {
  1946. DWORD dwFlags = 0xA080L;
  1947. DWORD dwKey = 0x0L;
  1948. float flValue = pcTargetObj->m_pcAvatar->GetArmorValue( pcSpell->m_dwLevel ) * -1;
  1949. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  1950. break;
  1951. }
  1952. case 250: //dispels
  1953. {
  1954. break;
  1955. }
  1956. case 273: //increase max health
  1957. {
  1958. }
  1959. case 275: //increase max stamina
  1960. {
  1961. }
  1962. case 277: //increase max mana
  1963. {
  1964. }
  1965. case 279: //increase max health
  1966. {
  1967. }
  1968. case 281: //increase max stamina
  1969. {
  1970. }
  1971. case 283: //increase max mana
  1972. {
  1973. }
  1974. case 285: //acid wards
  1975. {
  1976. }
  1977. case 287: //flame wards
  1978. {
  1979. }
  1980. case 289: //cold wards
  1981. {
  1982. }
  1983. case 291: //lightning wards
  1984. {
  1985. }
  1986. case 295: //timaru's shelter (increase target's armor)
  1987. {
  1988. }
  1989. case 379: //increase target's armor
  1990. {
  1991. }
  1992. case 401: //bludgeon wards
  1993. {
  1994. }
  1995. case 403: //slashing wards
  1996. {
  1997. }
  1998. case 405: //piercing wards
  1999. {
  2000. }
  2001. case 407: //major & minor stamina regen
  2002. {
  2003. DWORD dwFlags = 0x0L; //0x9001L;
  2004. DWORD dwKey = 0x0L; //0x01L;
  2005. float flValue = 0.0f; //pcSpell->m_dwLevel * 5 + 5;
  2006. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2007. break;
  2008. }
  2009. }
  2010. }
  2011. }
  2012. /**
  2013. * Handles the message sent for the casting of a Creature Enchantment spell.
  2014. *
  2015. * This function is called whenever a Creature Enchantment spell is cast by a client's avatar.
  2016. * Returns a server message to the client.
  2017. */
  2018. void cAvatar::CastCreature( LPVOID wp )
  2019. {
  2020. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  2021. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  2022. if (pcSpell)
  2023. {
  2024. cMessage msgSpellEffect;
  2025. msgSpellEffect << 0xF755L << WarJobParam->GetTargetGUID() << pcSpell->m_dwEffectAnim << 0x3F2B4E94L;
  2026. cClient* pcTargetObj = cClient::FindClient( WarJobParam->GetTargetGUID() );
  2027. if( !pcTargetObj )
  2028. {
  2029. cObject* pcTargetObject = cWorldManager::FindObject( WarJobParam->GetTargetGUID() );
  2030. if( !pcTargetObject )
  2031. {
  2032. }
  2033. else
  2034. {
  2035. cWorldManager::SendToAllInFocus( pcTargetObject->m_Location, msgSpellEffect, 3 );
  2036. }
  2037. }
  2038. else
  2039. {
  2040. cWorldManager::SendToAllInFocus( pcTargetObj->m_pcAvatar->m_Location, msgSpellEffect, 3 );
  2041. }
  2042. switch ( pcSpell->m_dwEffect )
  2043. {
  2044. case 1: //increase strength
  2045. {
  2046. DWORD dwFlags = 0x9001L;
  2047. DWORD dwKey = 0x01L;
  2048. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2049. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2050. break;
  2051. }
  2052. case 2: //decrease strength
  2053. {
  2054. DWORD dwFlags = 0x9001L;
  2055. DWORD dwKey = 0x01L;
  2056. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2057. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2058. break;
  2059. }
  2060. case 3: //increase endurance
  2061. {
  2062. DWORD dwFlags = 0x9001L;
  2063. DWORD dwKey = 0x02L;
  2064. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2065. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2066. break;
  2067. }
  2068. case 4: //decrease endurance
  2069. {
  2070. DWORD dwFlags = 0x9001L;
  2071. DWORD dwKey = 0x02L;
  2072. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2073. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2074. break;
  2075. }
  2076. case 5: //increase quickness
  2077. {
  2078. DWORD dwFlags = 0x9001L;
  2079. DWORD dwKey = 0x03L;
  2080. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2081. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2082. break;
  2083. }
  2084. case 6: //decrease quickness
  2085. {
  2086. DWORD dwFlags = 0x9001L;
  2087. DWORD dwKey = 0x03L;
  2088. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2089. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2090. break;
  2091. }
  2092. case 7: //increase coordination
  2093. {
  2094. DWORD dwFlags = 0x9001L;
  2095. DWORD dwKey = 0x04L;
  2096. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2097. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2098. break;
  2099. }
  2100. case 8: //decrease coordination
  2101. {
  2102. DWORD dwFlags = 0x9001L;
  2103. DWORD dwKey = 0x04L;
  2104. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2105. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2106. break;
  2107. }
  2108. case 9: //increase focus
  2109. {
  2110. DWORD dwFlags = 0x9001L;
  2111. DWORD dwKey = 0x05L;
  2112. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2113. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2114. break;
  2115. }
  2116. case 10: //decrease focus
  2117. {
  2118. DWORD dwFlags = 0x9001L;
  2119. DWORD dwKey = 0x05L;
  2120. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2121. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2122. break;
  2123. }
  2124. case 11: //increase self
  2125. {
  2126. DWORD dwFlags = 0x9001L;
  2127. DWORD dwKey = 0x06L;
  2128. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2129. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2130. break;
  2131. }
  2132. case 12: //decrease self
  2133. {
  2134. DWORD dwFlags = 0x9001L;
  2135. DWORD dwKey = 0x06L;
  2136. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2137. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2138. break;
  2139. }
  2140. case 13: //increase focus - Concentration
  2141. {
  2142. DWORD dwFlags = 0x9001L;
  2143. DWORD dwKey = 0x05L;
  2144. float flValue = 25.0f;
  2145. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2146. break;
  2147. }
  2148. case 15: //increase focus - Brilliance
  2149. {
  2150. DWORD dwFlags = 0x9001L;
  2151. DWORD dwKey = 0x05L;
  2152. float flValue = 50.0f;
  2153. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2154. break;
  2155. }
  2156. case 17: //increase axe
  2157. {
  2158. DWORD dwFlags = 0x9010L;
  2159. DWORD dwKey = 0x01L;
  2160. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2161. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2162. break;
  2163. }
  2164. case 18: //decrease axe
  2165. {
  2166. DWORD dwFlags = 0x9010L;
  2167. DWORD dwKey = 0x01L;
  2168. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2169. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2170. break;
  2171. }
  2172. case 19: //increase bow
  2173. {
  2174. DWORD dwFlags = 0x9010L;
  2175. DWORD dwKey = 0x02L;
  2176. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2177. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2178. break;
  2179. }
  2180. case 20: //decrease bow
  2181. {
  2182. DWORD dwFlags = 0x9010L;
  2183. DWORD dwKey = 0x02L;
  2184. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2185. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2186. break;
  2187. }
  2188. case 21: //increase crossbow
  2189. {
  2190. DWORD dwFlags = 0x9010L;
  2191. DWORD dwKey = 0x03L;
  2192. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2193. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2194. break;
  2195. }
  2196. case 22: //decrease crossbow
  2197. {
  2198. DWORD dwFlags = 0x9010L;
  2199. DWORD dwKey = 0x03L;
  2200. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2201. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2202. break;
  2203. }
  2204. case 23: //increase dagger
  2205. {
  2206. DWORD dwFlags = 0x9010L;
  2207. DWORD dwKey = 0x04L;
  2208. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2209. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2210. break;
  2211. }
  2212. case 24: //decrease dagger
  2213. {
  2214. DWORD dwFlags = 0x9010L;
  2215. DWORD dwKey = 0x04L;
  2216. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2217. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2218. break;
  2219. }
  2220. case 25: //increase mace
  2221. {
  2222. DWORD dwFlags = 0x9010L;
  2223. DWORD dwKey = 0x05L;
  2224. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2225. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2226. break;
  2227. }
  2228. case 26: //decrease mace
  2229. {
  2230. DWORD dwFlags = 0x9010L;
  2231. DWORD dwKey = 0x05L;
  2232. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2233. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2234. break;
  2235. }
  2236. case 27: //increase spear
  2237. {
  2238. DWORD dwFlags = 0x9010L;
  2239. DWORD dwKey = 0x09L;
  2240. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2241. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2242. break;
  2243. }
  2244. case 28: //decrease spear
  2245. {
  2246. DWORD dwFlags = 0x9010L;
  2247. DWORD dwKey = 0x09L;
  2248. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2249. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2250. break;
  2251. }
  2252. case 29: //increase staff
  2253. {
  2254. DWORD dwFlags = 0x9010L;
  2255. DWORD dwKey = 0x0AL;
  2256. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2257. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2258. break;
  2259. }
  2260. case 30: //decrease staff
  2261. {
  2262. DWORD dwFlags = 0x9010L;
  2263. DWORD dwKey = 0x0AL;
  2264. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2265. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2266. break;
  2267. }
  2268. case 31: //increase sword
  2269. {
  2270. DWORD dwFlags = 0x9010L;
  2271. DWORD dwKey = 0x0BL;
  2272. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2273. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2274. break;
  2275. }
  2276. case 32: //decrease sword
  2277. {
  2278. DWORD dwFlags = 0x9010L;
  2279. DWORD dwKey = 0x0BL;
  2280. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2281. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2282. break;
  2283. }
  2284. case 33: //increase thrown weapons
  2285. {
  2286. DWORD dwFlags = 0x9010L;
  2287. DWORD dwKey = 0x0CL;
  2288. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2289. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2290. break;
  2291. }
  2292. case 34: //decrease thrown weapons
  2293. {
  2294. DWORD dwFlags = 0x9010L;
  2295. DWORD dwKey = 0x0CL;
  2296. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2297. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2298. break;
  2299. }
  2300. case 35: //increase unarmed combat
  2301. {
  2302. DWORD dwFlags = 0x9010L;
  2303. DWORD dwKey = 0x0DL;
  2304. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2305. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2306. break;
  2307. }
  2308. case 36: //decrease unarmed combat
  2309. {
  2310. DWORD dwFlags = 0x9010L;
  2311. DWORD dwKey = 0x0DL;
  2312. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2313. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2314. break;
  2315. }
  2316. case 37: //increase melee defense
  2317. {
  2318. DWORD dwFlags = 0x9010L;
  2319. DWORD dwKey = 0x06L;
  2320. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2321. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2322. break;
  2323. }
  2324. case 38: //decrease melee defense
  2325. {
  2326. DWORD dwFlags = 0x9010L;
  2327. DWORD dwKey = 0x06L;
  2328. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2329. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2330. break;
  2331. }
  2332. case 39: //increase missile defense
  2333. {
  2334. DWORD dwFlags = 0x9010L;
  2335. DWORD dwKey = 0x07L;
  2336. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2337. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2338. break;
  2339. }
  2340. case 40: //decrease missile defense
  2341. {
  2342. DWORD dwFlags = 0x9010L;
  2343. DWORD dwKey = 0x07L;
  2344. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2345. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2346. break;
  2347. }
  2348. case 41: //increase magic defense
  2349. {
  2350. DWORD dwFlags = 0x9010L;
  2351. DWORD dwKey = 0x0FL;
  2352. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2353. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2354. break;
  2355. }
  2356. case 42: //decrease magic defense
  2357. {
  2358. DWORD dwFlags = 0x9010L;
  2359. DWORD dwKey = 0x0FL;
  2360. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2361. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2362. break;
  2363. }
  2364. case 43: //increase creature enchantment
  2365. {
  2366. DWORD dwFlags = 0x9010L;
  2367. DWORD dwKey = 0x1FL;
  2368. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2369. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2370. break;
  2371. }
  2372. case 44: //decrease creature enchantment
  2373. {
  2374. DWORD dwFlags = 0x9010L;
  2375. DWORD dwKey = 0x1FL;
  2376. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2377. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2378. break;
  2379. }
  2380. case 45: //increase item enchantment
  2381. {
  2382. DWORD dwFlags = 0x9010L;
  2383. DWORD dwKey = 0x20L;
  2384. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2385. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2386. break;
  2387. }
  2388. case 46: //decrease item enchantment
  2389. {
  2390. DWORD dwFlags = 0x9010L;
  2391. DWORD dwKey = 0x20L;
  2392. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2393. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2394. break;
  2395. }
  2396. case 47: //increase life magic
  2397. {
  2398. DWORD dwFlags = 0x9010L;
  2399. DWORD dwKey = 0x21L;
  2400. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2401. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2402. break;
  2403. }
  2404. case 48: //decrease life magic
  2405. {
  2406. DWORD dwFlags = 0x9010L;
  2407. DWORD dwKey = 0x21L;
  2408. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2409. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2410. break;
  2411. }
  2412. case 49: //increase war magic
  2413. {
  2414. DWORD dwFlags = 0x9010L;
  2415. DWORD dwKey = 0x22L;
  2416. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2417. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2418. break;
  2419. }
  2420. case 50: //decrease war magic
  2421. {
  2422. DWORD dwFlags = 0x9010L;
  2423. DWORD dwKey = 0x22L;
  2424. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2425. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2426. break;
  2427. }
  2428. case 51: //increase mana conversion
  2429. {
  2430. DWORD dwFlags = 0x9010L;
  2431. DWORD dwKey = 0x10L;
  2432. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2433. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2434. break;
  2435. }
  2436. case 52: //decrease mana conversion
  2437. {
  2438. DWORD dwFlags = 0x9010L;
  2439. DWORD dwKey = 0x10L;
  2440. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2441. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2442. break;
  2443. }
  2444. case 53: //increase arcane lore
  2445. {
  2446. DWORD dwFlags = 0x9010L;
  2447. DWORD dwKey = 0x0EL;
  2448. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2449. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2450. break;
  2451. }
  2452. case 54: //decrease arcane lore
  2453. {
  2454. DWORD dwFlags = 0x9010L;
  2455. DWORD dwKey = 0x0EL;
  2456. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2457. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2458. break;
  2459. }
  2460. case 55: //increase armor tinkering
  2461. {
  2462. DWORD dwFlags = 0x9010L;
  2463. DWORD dwKey = 0x1DL;
  2464. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2465. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2466. break;
  2467. }
  2468. case 56: //decrease armor tinkering
  2469. {
  2470. DWORD dwFlags = 0x9010L;
  2471. DWORD dwKey = 0x1DL;
  2472. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2473. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2474. break;
  2475. }
  2476. case 57: //increase item tinkering
  2477. {
  2478. DWORD dwFlags = 0x9010L;
  2479. DWORD dwKey = 0x12L;
  2480. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2481. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2482. break;
  2483. }
  2484. case 58: //decrease item tinkering
  2485. {
  2486. DWORD dwFlags = 0x9010L;
  2487. DWORD dwKey = 0x12L;
  2488. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2489. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2490. break;
  2491. }
  2492. case 59: //increase magic item tinkering
  2493. {
  2494. DWORD dwFlags = 0x9010L;
  2495. DWORD dwKey = 0x1EL;
  2496. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2497. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2498. break;
  2499. }
  2500. case 60: //decrease magic item tinkering
  2501. {
  2502. DWORD dwFlags = 0x9010L;
  2503. DWORD dwKey = 0x1EL;
  2504. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2505. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2506. break;
  2507. }
  2508. case 61: //increase weapon tinkering
  2509. {
  2510. DWORD dwFlags = 0x9010L;
  2511. DWORD dwKey = 0x1CL;
  2512. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2513. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2514. break;
  2515. }
  2516. case 62: //decrease weapon tinkering
  2517. {
  2518. DWORD dwFlags = 0x9010L;
  2519. DWORD dwKey = 0x1CL;
  2520. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2521. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2522. break;
  2523. }
  2524. case 63: //increase assess monster
  2525. {
  2526. DWORD dwFlags = 0x9010L;
  2527. DWORD dwKey = 0x1BL;
  2528. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2529. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2530. break;
  2531. }
  2532. case 64: //decrease assess monster
  2533. {
  2534. DWORD dwFlags = 0x9010L;
  2535. DWORD dwKey = 0x1BL;
  2536. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2537. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2538. break;
  2539. }
  2540. case 65: //increase deception
  2541. {
  2542. DWORD dwFlags = 0x9010L;
  2543. DWORD dwKey = 0x14L;
  2544. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2545. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2546. break;
  2547. }
  2548. case 66: //decrease deception
  2549. {
  2550. DWORD dwFlags = 0x9010L;
  2551. DWORD dwKey = 0x14L;
  2552. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2553. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2554. break;
  2555. }
  2556. case 67: //increase healing
  2557. {
  2558. DWORD dwFlags = 0x9010L;
  2559. DWORD dwKey = 0x15L;
  2560. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2561. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2562. break;
  2563. }
  2564. case 68: //decrease healing
  2565. {
  2566. DWORD dwFlags = 0x9010L;
  2567. DWORD dwKey = 0x15L;
  2568. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2569. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2570. break;
  2571. }
  2572. case 69: //increase jump
  2573. {
  2574. DWORD dwFlags = 0x9010L;
  2575. DWORD dwKey = 0x16L;
  2576. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2577. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2578. break;
  2579. }
  2580. case 70: //decrease jump
  2581. {
  2582. DWORD dwFlags = 0x9010L;
  2583. DWORD dwKey = 0x16L;
  2584. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2585. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2586. break;
  2587. }
  2588. case 71: //increase leadership
  2589. {
  2590. DWORD dwFlags = 0x9010L;
  2591. DWORD dwKey = 0x23L;
  2592. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2593. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2594. break;
  2595. }
  2596. case 72: //decrease leadership
  2597. {
  2598. DWORD dwFlags = 0x9010L;
  2599. DWORD dwKey = 0x23L;
  2600. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2601. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2602. break;
  2603. }
  2604. case 73: //increase lockpick
  2605. {
  2606. DWORD dwFlags = 0x9010L;
  2607. DWORD dwKey = 0x17L;
  2608. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2609. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2610. break;
  2611. }
  2612. case 74: //decrease lockpick
  2613. {
  2614. DWORD dwFlags = 0x9010L;
  2615. DWORD dwKey = 0x17L;
  2616. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2617. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2618. break;
  2619. }
  2620. case 75: //increase loyalty
  2621. {
  2622. DWORD dwFlags = 0x9010L;
  2623. DWORD dwKey = 0x24L;
  2624. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2625. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2626. break;
  2627. }
  2628. case 76: //decrease loyalty
  2629. {
  2630. DWORD dwFlags = 0x9010L;
  2631. DWORD dwKey = 0x24L;
  2632. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2633. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2634. break;
  2635. }
  2636. case 77: //increase run
  2637. {
  2638. DWORD dwFlags = 0x9010L;
  2639. DWORD dwKey = 0x18L;
  2640. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2641. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2642. break;
  2643. }
  2644. case 78: //decrease run
  2645. {
  2646. DWORD dwFlags = 0x9001L;
  2647. DWORD dwKey = 0x18L;
  2648. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2649. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2650. break;
  2651. }
  2652. case 204: //Vitae
  2653. {
  2654. break;
  2655. }
  2656. case 205: //increase assess person
  2657. {
  2658. DWORD dwFlags = 0x9010L;
  2659. DWORD dwKey = 0x13L;
  2660. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2661. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2662. break;
  2663. }
  2664. case 206: //decrease assess person
  2665. {
  2666. DWORD dwFlags = 0x9010L;
  2667. DWORD dwKey = 0x13L;
  2668. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2669. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2670. break;
  2671. }
  2672. case 216: //increase cooking
  2673. {
  2674. DWORD dwFlags = 0x9010L;
  2675. DWORD dwKey = 0x27L;
  2676. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2677. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2678. break;
  2679. }
  2680. case 217: //decrease cooking
  2681. {
  2682. DWORD dwFlags = 0x9010L;
  2683. DWORD dwKey = 0x27L;
  2684. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2685. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2686. break;
  2687. }
  2688. case 218: //increase fletching
  2689. {
  2690. DWORD dwFlags = 0x9010L;
  2691. DWORD dwKey = 0x25L;
  2692. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2693. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2694. break;
  2695. }
  2696. case 219: //decrease fletching
  2697. {
  2698. DWORD dwFlags = 0x9010L;
  2699. DWORD dwKey = 0x25L;
  2700. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2701. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2702. break;
  2703. }
  2704. case 220: //increase alchemy
  2705. {
  2706. DWORD dwFlags = 0x9010L;
  2707. DWORD dwKey = 0x26L;
  2708. float flValue = pcSpell->m_dwLevel * 5 + 5;
  2709. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2710. break;
  2711. }
  2712. case 221: //decrease alchemy
  2713. {
  2714. DWORD dwFlags = 0x9010L;
  2715. DWORD dwKey = 0x26L;
  2716. float flValue = pcSpell->m_dwLevel * -5 - 5;
  2717. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2718. break;
  2719. }
  2720. case 250: //dispels
  2721. {
  2722. break;
  2723. }
  2724. case 251: //increase target's creature enchantment
  2725. {
  2726. }
  2727. case 253: //increase target's item enchantment
  2728. {
  2729. }
  2730. case 255: //increase target's war magic
  2731. {
  2732. }
  2733. case 257: //increase health regen
  2734. {
  2735. }
  2736. case 259: //increase mana regen
  2737. {
  2738. }
  2739. case 261: //increase target's strength
  2740. {
  2741. }
  2742. case 263: //increase target's endurance
  2743. {
  2744. }
  2745. case 265: //increase target's quickness
  2746. {
  2747. }
  2748. case 267: //increase target's coordination
  2749. {
  2750. }
  2751. case 269: //increase target's focus
  2752. {
  2753. }
  2754. case 271: //increase target's self
  2755. {
  2756. }
  2757. case 293: //increase target's leadership
  2758. {
  2759. }
  2760. case 297: //timaru's shelter (increase target's quickness), increase target's missile defense
  2761. {
  2762. }
  2763. case 299: //increase target's magic defense
  2764. {
  2765. }
  2766. case 301: //increase target's coordination
  2767. {
  2768. }
  2769. case 303: //increase target's endurance
  2770. {
  2771. }
  2772. case 305: //increase target's strength
  2773. {
  2774. }
  2775. case 307: //increase target's quickness
  2776. {
  2777. }
  2778. case 309: //increase healing rate
  2779. {
  2780. }
  2781. case 311: //increase target's axe
  2782. {
  2783. }
  2784. case 313: //increase target's dagger
  2785. {
  2786. }
  2787. case 315: //increase target's mace
  2788. {
  2789. }
  2790. case 317: //increase target's spear
  2791. {
  2792. }
  2793. case 319: //increase target's staff
  2794. {
  2795. }
  2796. case 321: //increase target's melee defense
  2797. {
  2798. }
  2799. case 331: //increase target's bow
  2800. {
  2801. }
  2802. case 333: //increase target's alchemy
  2803. {
  2804. }
  2805. case 335: //increase target's arcane lore
  2806. {
  2807. }
  2808. case 337: //increase target's armor tinkering
  2809. {
  2810. }
  2811. case 339: //increase target's cooking
  2812. {
  2813. }
  2814. case 341: //increase target's crossbow
  2815. {
  2816. }
  2817. case 343: //increase target's deception
  2818. {
  2819. }
  2820. case 345: //increase target's loyalty
  2821. {
  2822. }
  2823. case 347: //increase target's fletching
  2824. {
  2825. }
  2826. case 349: //increase target's healing
  2827. {
  2828. }
  2829. case 351: //increase target's melee defense
  2830. {
  2831. }
  2832. case 353: //increase target's item tinkering
  2833. {
  2834. }
  2835. case 355: //increase target's jump
  2836. {
  2837. }
  2838. case 357: //increase target's life magic
  2839. {
  2840. }
  2841. case 359: //increase target's lockpick
  2842. {
  2843. }
  2844. case 361: //increase target's magic item tinkering
  2845. {
  2846. }
  2847. case 363: //increase target's mana conversion
  2848. {
  2849. }
  2850. case 365: //increase target's assess creature
  2851. {
  2852. }
  2853. case 367: //increase target's assess person
  2854. {
  2855. }
  2856. case 369: //increase target's run
  2857. {
  2858. }
  2859. case 371: //increase target's sword
  2860. {
  2861. }
  2862. case 373: //increase target's thrown weapons
  2863. {
  2864. }
  2865. case 375: //increase target's unarmed combat
  2866. {
  2867. }
  2868. case 377: //increase target's weapon tinkering
  2869. {
  2870. DWORD dwFlags = 0x0L; //0x9010L;
  2871. DWORD dwKey = 0x0L; //0x01L;
  2872. float flValue = 0.0f; //pcSpell->m_dwLevel * 5 + 5;
  2873. cEnchantment* pcEnchantment = new cEnchantment( pcSpell->m_dwSpellID, pcSpell->m_dwEffect, pcSpell->m_dwDifficulty, (double) pcSpell->m_iDuration, WarJobParam->GetCasterGUID(), WarJobParam->GetTargetGUID(), (double) timeGetTime(), dwFlags, dwKey, flValue );
  2874. break;
  2875. }
  2876. }
  2877. }
  2878. }
  2879. /**
  2880. * Handles the message sent for the casting of an Item Enchantment spell.
  2881. *
  2882. * This function is called whenever an Item Enchantment spell is cast by a client's avatar.
  2883. * Returns a server message to the client.
  2884. */
  2885. void cAvatar::CastItem( LPVOID wp )
  2886. {
  2887. cWarJobParam* WarJobParam = (cWarJobParam *) wp;
  2888. cSpell *pcSpell = cSpell::FindSpell( WarJobParam->GetSpellID() );
  2889. if (pcSpell)
  2890. {
  2891. switch ( pcSpell->m_dwEffect )
  2892. {
  2893. case 152: //increase weapon's attack skill mod
  2894. {
  2895. }
  2896. case 153: //decrease weapon's attack skill mod
  2897. {
  2898. }
  2899. case 154: //increase weapon's damage
  2900. {
  2901. }
  2902. case 155: //decrease weapon's damage
  2903. {
  2904. }
  2905. case 156: //increase weapon's defense skill mod
  2906. {
  2907. }
  2908. case 157: //decrease weapon's defense skill mod
  2909. {
  2910. }
  2911. case 158: //increase weapon's speed
  2912. {
  2913. }
  2914. case 159: //decrease weapon's speed
  2915. {
  2916. }
  2917. case 160: //increase armor value (impenetrability)
  2918. {
  2919. }
  2920. case 161: //decrease armor value (brittlemail)
  2921. {
  2922. }
  2923. case 162: //increase acid resistance
  2924. {
  2925. }
  2926. case 163: //decrease acid resistance
  2927. {
  2928. }
  2929. case 164: //increase bludgeon resistance
  2930. {
  2931. }
  2932. case 165: //decrease bludgeon resistance
  2933. {
  2934. }
  2935. case 166: //increase cold resistance
  2936. {
  2937. }
  2938. case 167: //decrease cold resistance
  2939. {
  2940. }
  2941. case 168: //increase lightning resistance
  2942. {
  2943. }
  2944. case 169: //decrease lightning resistance
  2945. {
  2946. }
  2947. case 170: //increase flame resistance
  2948. {
  2949. }
  2950. case 171: //decrease flame resistance
  2951. {
  2952. }
  2953. case 172: //increase piercing resistance
  2954. {
  2955. }
  2956. case 173: //decrease piercing resistance
  2957. {
  2958. }
  2959. case 174: //increase slashing resistance
  2960. {
  2961. }
  2962. case 175: //decrease slashing resistance
  2963. {
  2964. }
  2965. case 176: //lesser bludgeoning durance (increase bludgeon resistance)
  2966. {
  2967. }
  2968. case 178: //lesser slashing durance (increase slashing resistance)
  2969. {
  2970. }
  2971. case 180: //lesser piercing durance (increase piercing resistance)
  2972. {
  2973. }
  2974. case 182: //greater stimulation durance (increase lightning resistance)
  2975. {
  2976. }
  2977. case 184: //greater stasis durance (increase cold resistance)
  2978. {
  2979. }
  2980. case 186: //greater consumption durance (increase fire resistance)
  2981. {
  2982. }
  2983. case 188: //greater decay durance (increase acid resistance)
  2984. {
  2985. }
  2986. case 190: //hieromancer's ward (increase armor value)
  2987. {
  2988. }
  2989. case 192: //increase lock's pick resistance
  2990. {
  2991. }
  2992. case 193: //decrease lock's pick resistance
  2993. {
  2994. }
  2995. case 194: //increase item's appraisal resistance
  2996. {
  2997. }
  2998. case 195: //decrease item's appraisal resistance
  2999. {
  3000. }
  3001. case 200: //primary portal tie, secondary portal tie, lifestone tie
  3002. {
  3003. }
  3004. case 201: //primary portal recall, secondary portal recall, lifestone recall, portal recall
  3005. {
  3006. }
  3007. case 203: //portal summon spells
  3008. {
  3009. }
  3010. case 214: //portal sending, specific portal recalls
  3011. {
  3012. }
  3013. case 215: //lifestone sending
  3014. {
  3015. }
  3016. case 250: //dispels
  3017. {
  3018. }
  3019. case 323: //increase weapon's damage
  3020. {
  3021. }
  3022. case 325: //increase bow's damage
  3023. {
  3024. }
  3025. case 327: //increase bow's range
  3026. {
  3027. }
  3028. case 329: //increase weapon's defense skill
  3029. {
  3030. }
  3031. case 381: //major & minor acid bane
  3032. {
  3033. }
  3034. case 383: //major & minor bludgeon bane
  3035. {
  3036. }
  3037. case 385: //major & minor flame bane
  3038. {
  3039. }
  3040. case 387: //major & minor cold bane
  3041. {
  3042. }
  3043. case 389: //increase weapon's attack skill mod
  3044. {
  3045. }
  3046. case 391: //increase item's armor (major & minor impen)
  3047. {
  3048. }
  3049. case 393: //major & minor piercing bane
  3050. {
  3051. }
  3052. case 395: //major & minor slashing bane
  3053. {
  3054. }
  3055. case 397: //major & minor lightning bane
  3056. {
  3057. }
  3058. case 399: //increase weapon's speed (major & minor)
  3059. {
  3060. }
  3061. }
  3062. }
  3063. }
  3064. /**
  3065. * Determines the heal amount of a Heal spell.
  3066. *
  3067. * This function is called whenever a Heal spell is cast
  3068. * @param dwLevel - The level of the Heal Spell
  3069. * @return dwHeal - The amount of Health healed by the spell
  3070. */
  3071. DWORD cAvatar::GetHealValue( DWORD dwLevel )
  3072. {
  3073. int iHealMax, iHealMin;
  3074. switch ( dwLevel )
  3075. {
  3076. case 1:
  3077. {
  3078. iHealMax = 15;
  3079. iHealMin = 8;
  3080. break;
  3081. }
  3082. case 2:
  3083. {
  3084. iHealMax = 20;
  3085. iHealMin = 11;
  3086. break;
  3087. }
  3088. case 3:
  3089. {
  3090. iHealMax = 30;
  3091. iHealMin = 16;
  3092. break;
  3093. }
  3094. case 4:
  3095. {
  3096. iHealMax = 50;
  3097. iHealMin = 26;
  3098. break;
  3099. }
  3100. case 5:
  3101. {
  3102. iHealMax = 75;
  3103. iHealMin = 38;
  3104. break;
  3105. }
  3106. case 6:
  3107. {
  3108. iHealMax = 100;
  3109. iHealMin = 50;
  3110. break;
  3111. }
  3112. case 7:
  3113. {
  3114. iHealMax = 125;
  3115. iHealMin = 75;
  3116. break;
  3117. }
  3118. }
  3119. srand( timeGetTime( ) );
  3120. DWORD dwHeal = rand() % (iHealMax - iHealMin) + iHealMin;
  3121. return dwHeal;
  3122. }
  3123. /**
  3124. * Determines the infused amount of an Infuse Stamina spell.
  3125. *
  3126. * This function is called whenever an Infuse Stamina spell is cast
  3127. * @param dwLevel - The level of the Infuse Stamina Spell
  3128. * @return dwStamina - The amount of Stamina infused by the spell
  3129. */
  3130. DWORD cAvatar::GetStaminaValue( DWORD dwLevel )
  3131. {
  3132. int iStaminaMax, iStaminaMin;
  3133. switch ( dwLevel )
  3134. {
  3135. case 1:
  3136. {
  3137. iStaminaMax = 20;
  3138. iStaminaMin = 11;
  3139. break;
  3140. }
  3141. case 2:
  3142. {
  3143. iStaminaMax = 30;
  3144. iStaminaMin = 16;
  3145. break;
  3146. }
  3147. case 3:
  3148. {
  3149. iStaminaMax = 50;
  3150. iStaminaMin = 26;
  3151. break;
  3152. }
  3153. case 4:
  3154. {
  3155. iStaminaMax = 75;
  3156. iStaminaMin = 38;
  3157. break;
  3158. }
  3159. case 5:
  3160. {
  3161. iStaminaMax = 100;
  3162. iStaminaMin = 51;
  3163. break;
  3164. }
  3165. case 6:
  3166. {
  3167. iStaminaMax = 150;
  3168. iStaminaMin = 76;
  3169. break;
  3170. }
  3171. case 7:
  3172. {
  3173. iStaminaMax = 175;
  3174. iStaminaMin = 100;
  3175. break;
  3176. }
  3177. }
  3178. srand( timeGetTime( ) );
  3179. DWORD dwStamina = rand() % (iStaminaMax - iStaminaMin) + iStaminaMin;
  3180. return dwStamina;
  3181. }
  3182. /**
  3183. * Determines the rate of vital replenishment after a Regeneration spell.
  3184. *
  3185. * This function is called whenever a Regeneration spell is cast
  3186. * @param dwLevel - The level of the Regeneration Spell
  3187. * @return flValue - The new rate of regeneration for the vital with the spell
  3188. */
  3189. float cAvatar::GetRegenIncValue( DWORD dwLevel )
  3190. {
  3191. float flValue;
  3192. switch( dwLevel )
  3193. {
  3194. case 1:
  3195. {
  3196. flValue = 1.10f;
  3197. break;
  3198. }
  3199. case 2:
  3200. {
  3201. flValue = 1.25f;
  3202. break;
  3203. }
  3204. case 3:
  3205. {
  3206. flValue = 1.40f;
  3207. break;
  3208. }
  3209. case 4:
  3210. {
  3211. flValue = 1.55f;
  3212. break;
  3213. }
  3214. case 5:
  3215. {
  3216. flValue = 1.70f;
  3217. break;
  3218. }
  3219. case 6:
  3220. {
  3221. flValue = 1.85f;
  3222. break;
  3223. }
  3224. case 7:
  3225. {
  3226. flValue = 2.15f;
  3227. break;
  3228. }
  3229. }
  3230. return flValue;
  3231. }
  3232. /**
  3233. * Determines the rate of vital replenishment after a Fester spell.
  3234. *
  3235. * This function is called whenever a Fester spell is cast
  3236. * @param dwLevel - The level of the Fester Spell
  3237. * @return flValue - The new rate of regeneration for the vital with the spell
  3238. */
  3239. float cAvatar::GetRegenDecValue( DWORD dwLevel )
  3240. {
  3241. float flValue;
  3242. switch( dwLevel )
  3243. {
  3244. case 1:
  3245. {
  3246. flValue = 0.91f;
  3247. break;
  3248. }
  3249. case 2:
  3250. {
  3251. flValue = 0.80f;
  3252. break;
  3253. }
  3254. case 3:
  3255. {
  3256. flValue = 0.71f;
  3257. break;
  3258. }
  3259. case 4:
  3260. {
  3261. flValue = 0.65f;
  3262. break;
  3263. }
  3264. case 5:
  3265. {
  3266. flValue = 0.59f;
  3267. break;
  3268. }
  3269. case 6:
  3270. {
  3271. flValue = 0.54f;
  3272. break;
  3273. }
  3274. case 7:
  3275. {
  3276. flValue = 0.40f;
  3277. break;
  3278. }
  3279. }
  3280. return flValue;
  3281. }
  3282. /**
  3283. * Determines the damage percentage after a Protection spell
  3284. *
  3285. * This function is called whenever a Protection spell is cast
  3286. * @param dwLevel - The level of the Protection Spell
  3287. * @return flValue - The new damage percentage for the damage type with the spell
  3288. */
  3289. float cAvatar::GetProtValue( DWORD dwLevel )
  3290. {
  3291. float flValue;
  3292. switch( dwLevel )
  3293. {
  3294. case 1:
  3295. {
  3296. flValue = 0.91f;
  3297. break;
  3298. }
  3299. case 2:
  3300. {
  3301. flValue = 0.80f;
  3302. break;
  3303. }
  3304. case 3:
  3305. {
  3306. flValue = 0.67f;
  3307. break;
  3308. }
  3309. case 4:
  3310. {
  3311. flValue = 0.57f;
  3312. break;
  3313. }
  3314. case 5:
  3315. {
  3316. flValue = 0.50f;
  3317. break;
  3318. }
  3319. case 6:
  3320. {
  3321. flValue = 0.40f;
  3322. break;
  3323. }
  3324. case 7:
  3325. {
  3326. flValue = 0.35f;
  3327. break;
  3328. }
  3329. }
  3330. return flValue;
  3331. }
  3332. /**
  3333. * Determines the damage percentage after a Vulnerability spell
  3334. *
  3335. * This function is called whenever a Vulnerability spell is cast
  3336. * @param dwLevel - The level of the Vulnerability Spell
  3337. * @return flValue - The new damage percentage for the damage type with the spell
  3338. */
  3339. float cAvatar::GetVulnValue( DWORD dwLevel )
  3340. {
  3341. float flValue;
  3342. switch( dwLevel )
  3343. {
  3344. case 1:
  3345. {
  3346. flValue = 1.10f;
  3347. break;
  3348. }
  3349. case 2:
  3350. {
  3351. flValue = 1.25f;
  3352. break;
  3353. }
  3354. case 3:
  3355. {
  3356. flValue = 1.50f;
  3357. break;
  3358. }
  3359. case 4:
  3360. {
  3361. flValue = 1.75f;
  3362. break;
  3363. }
  3364. case 5:
  3365. {
  3366. flValue = 2.00f;
  3367. break;
  3368. }
  3369. case 6:
  3370. {
  3371. flValue = 2.50f;
  3372. break;
  3373. }
  3374. case 7:
  3375. {
  3376. flValue = 2.85f;
  3377. break;
  3378. }
  3379. }
  3380. return flValue;
  3381. }
  3382. /**
  3383. * Determines the increase in Armor Level after an Invulnerability spell
  3384. *
  3385. * This function is called whenever an Invulnerability spell is cast
  3386. * @param dwLevel - The level of the Invulnerability Spell
  3387. * @return flValue - The increase in Armor Level by the spell
  3388. */
  3389. float cAvatar::GetArmorValue( DWORD dwLevel )
  3390. {
  3391. float flValue;
  3392. switch( dwLevel )
  3393. {
  3394. case 1:
  3395. {
  3396. flValue = 20.0f;
  3397. break;
  3398. }
  3399. case 2:
  3400. {
  3401. flValue = 50.0f;
  3402. break;
  3403. }
  3404. case 3:
  3405. {
  3406. flValue = 75.0f;
  3407. break;
  3408. }
  3409. case 4:
  3410. {
  3411. flValue = 100.0f;
  3412. break;
  3413. }
  3414. case 5:
  3415. {
  3416. flValue = 150.0f;
  3417. break;
  3418. }
  3419. case 6:
  3420. {
  3421. flValue = 200.0f;
  3422. break;
  3423. }
  3424. case 7:
  3425. {
  3426. flValue = 225.0f;
  3427. break;
  3428. }
  3429. }
  3430. return flValue;
  3431. }
  3432. /**
  3433. * Determines the amount of vital transferred by a Vital to Vital spell
  3434. *
  3435. * This function is called whenever a Vital to Vital spell is cast
  3436. * @param dwLevel - The level of the Vital to Vital Spell
  3437. * @return flValue - The percentage of vital transferred by the spell
  3438. */
  3439. float cAvatar::GetTransferValue( DWORD dwLevel )
  3440. {
  3441. float flValue;
  3442. switch( dwLevel )
  3443. {
  3444. case 1:
  3445. {
  3446. flValue = 0.75f;
  3447. break;
  3448. }
  3449. case 2:
  3450. {
  3451. flValue = 0.90f;
  3452. break;
  3453. }
  3454. case 3:
  3455. {
  3456. flValue = 1.05f;
  3457. break;
  3458. }
  3459. case 4:
  3460. {
  3461. flValue = 1.20f;
  3462. break;
  3463. }
  3464. case 5:
  3465. {
  3466. flValue = 1.35f;
  3467. break;
  3468. }
  3469. case 6:
  3470. {
  3471. flValue = 1.50f;
  3472. break;
  3473. }
  3474. case 7:
  3475. {
  3476. flValue = 1.75f;
  3477. break;
  3478. }
  3479. }
  3480. return flValue;
  3481. }
  3482. /**
  3483. * Handles the message sent for the updating of an avatar's location.
  3484. *
  3485. * @return cMessage - Returns an 0x0000F748 server message.
  3486. */
  3487. cMessage cAvatar::SetPosition()
  3488. {
  3489. cMessage cmSetPosition;
  3490. DWORD dwFlags = 0x34L;
  3491. cmSetPosition << 0xF748L
  3492. << m_dwGUID
  3493. << 0x34L;
  3494. cmSetPosition << m_Location.m_dwLandBlock
  3495. << m_Location.m_flX
  3496. << m_Location.m_flY
  3497. << m_Location.m_flZ
  3498. << m_Location.m_flA
  3499. //<< m_Location.m_flB
  3500. //<< m_Location.m_flC
  3501. << m_Location.m_flW;
  3502. return cmSetPosition;
  3503. }
  3504. /**
  3505. * Handles the message sent for an avatar's recall to a lifestone.
  3506. *
  3507. * @return cMessage - Returns a Toggle Object Visibility (0x0000F74B) server message.
  3508. */
  3509. cMessage cAvatar::LifestoneRecall( )
  3510. {
  3511. cMessage cmLifestone;
  3512. cmLifestone << 0xF74B
  3513. << m_dwGUID
  3514. << WORD(0x0408)
  3515. << WORD(0x40)
  3516. << WORD(m_wNumLogins)
  3517. << WORD(m_wPortalCount++);
  3518. return cmLifestone;
  3519. }
  3520. /**
  3521. * Handles the message sent for the avatar's animation when recalling to a lifestone.
  3522. *
  3523. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  3524. */
  3525. cMessage cAvatar::LSAnimate( )
  3526. {
  3527. cMessage cmLifestone;
  3528. cmLifestone << 0xF74C
  3529. << m_dwGUID
  3530. << m_wNumLogins
  3531. << ++m_wCurAnim
  3532. << ++m_wMeleeSequence
  3533. << WORD(0x0000) //activity (idle)
  3534. << BYTE(0x00) //animation type (general animation)
  3535. << BYTE(0x00) //type flags (no target)
  3536. << WORD(0x003D) //standing
  3537. << DWORD(0x02B4F080) //flags
  3538. << WORD(0x0137)
  3539. << m_wMeleeSequence
  3540. << float(1)
  3541. << DWORD(0x023F4B41);
  3542. return cmLifestone;
  3543. }
  3544. /**
  3545. * Handles the message sent for the server text when recalling to a lifestone.
  3546. *
  3547. * @return cMessage - Returns a Server Text (0x0000F62C) server message.
  3548. */
  3549. cMessage cAvatar::LSMessage( )
  3550. {
  3551. cMessage cmLifestone;
  3552. char szTextBuffer[1024];
  3553. sprintf(&szTextBuffer[0],"%s is recalling to the lifestone.", Name( ));
  3554. DWORD dwColor = 0x17L;
  3555. cmLifestone << 0xF62CL << szTextBuffer << dwColor;
  3556. return cmLifestone;
  3557. }
  3558. /**
  3559. * Handles the message sent for an avatar's recall to the Marketplace.
  3560. *
  3561. * @return cMessage - Returns a Toggle Object Visibility (0x0000F74B) server message.
  3562. */
  3563. cMessage cAvatar::MarketplaceRecall( )
  3564. {
  3565. cMessage cmMarketplace;
  3566. cmMarketplace << 0xF74B
  3567. << m_dwGUID
  3568. << WORD(0x0408)
  3569. << WORD(0x40)
  3570. << WORD(m_wNumLogins)
  3571. << WORD(m_wPortalCount++);
  3572. return cmMarketplace;
  3573. }
  3574. /**
  3575. * Handles the message sent for the avatar's animation when recalling to the Marketplace.
  3576. *
  3577. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  3578. */
  3579. cMessage cAvatar::MPAnimate( )
  3580. {
  3581. cMessage cmMarketplace;
  3582. cmMarketplace << 0xF74C
  3583. << m_dwGUID
  3584. << m_wNumLogins
  3585. << ++m_wCurAnim
  3586. << ++m_wMeleeSequence
  3587. << WORD(0x0000) //activity (idle)
  3588. << BYTE(0x00) //animation type (general animation)
  3589. << BYTE(0x00) //type flags (no target)
  3590. << WORD(0x003D) //standing
  3591. << DWORD(0x02B5F080) //flags
  3592. << WORD(0x0137)
  3593. << m_wMeleeSequence
  3594. << float(1)
  3595. << DWORD(0x0BA9C719);
  3596. return cmMarketplace;
  3597. }
  3598. /**
  3599. * Handles the message sent for the server text when recalling to the Marketplace.
  3600. *
  3601. * @return cMessage - Returns a Server Text (0x0000F62C) server message.
  3602. */
  3603. cMessage cAvatar::MPMessage( )
  3604. {
  3605. cMessage cmMarketplace;
  3606. char szTextBuffer[1024];
  3607. sprintf(&szTextBuffer[0],"%s is going to the Marketplace.", Name( ));
  3608. DWORD dwColor = 0x17L;
  3609. cmMarketplace << 0xF62CL << szTextBuffer << dwColor;
  3610. return cmMarketplace;
  3611. }
  3612. /**
  3613. * Handles the message sent for an avatar's recall to a house.
  3614. *
  3615. * @return cMessage - Returns a Toggle Object Visibility (0x0000F74B) server message.
  3616. */
  3617. cMessage cAvatar::HouseRecall( )
  3618. {
  3619. cMessage cmHouseRecall;
  3620. cmHouseRecall << 0xF74B
  3621. << m_dwGUID
  3622. << WORD(0x0408)
  3623. << WORD(0x40)
  3624. << WORD(m_wNumLogins)
  3625. << WORD(m_wPortalCount++);
  3626. return cmHouseRecall;
  3627. }
  3628. /**
  3629. * Handles the message sent for the avatar's animation when recalling to a house.
  3630. *
  3631. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  3632. */
  3633. cMessage cAvatar::HRAnimate( )
  3634. {
  3635. cMessage cmHouseRecall;
  3636. cmHouseRecall << 0xF74C
  3637. << m_dwGUID
  3638. << m_wNumLogins
  3639. << ++m_wCurAnim
  3640. << ++m_wMeleeSequence
  3641. << WORD(0x0000) //activity (idle)
  3642. << BYTE(0x00) //animation type (general animation)
  3643. << BYTE(0x00) //type flags (no target)
  3644. << WORD(0x003D) //standing
  3645. << DWORD(0x00000080) //flags
  3646. << WORD(0x0137) //animation
  3647. << m_wMeleeSequence
  3648. << float(1);
  3649. return cmHouseRecall;
  3650. /* animations
  3651. 0x0137 - recall
  3652. 0x0085 - shake head
  3653. 0x008B - scratch head
  3654. */
  3655. }
  3656. /**
  3657. * Handles the message sent for the server text when recalling to a house.
  3658. *
  3659. * @return cMessage - Returns a Server Text (0x0000F62C) server message.
  3660. */
  3661. cMessage cAvatar::HRMessage( )
  3662. {
  3663. cMessage cmHouseRecall;
  3664. char szTextBuffer[1024];
  3665. sprintf(&szTextBuffer[0],"%s is recalling home.", Name( ));
  3666. DWORD dwColor = 0x17L;
  3667. cmHouseRecall << 0xF62CL << szTextBuffer << dwColor;
  3668. return cmHouseRecall;
  3669. }
  3670. cMessage cAvatar::ConfirmPanelRequest(DWORD F7B0seq, DWORD type, DWORD ConfirmSeq, std::string targetName)
  3671. {
  3672. cMessage cmConfirm;
  3673. cmConfirm << 0xF7B0L << m_dwGUID << F7B0seq << 0x274L
  3674. << type
  3675. << ConfirmSeq
  3676. << targetName.c_str();
  3677. return cmConfirm;
  3678. }
  3679. void cAvatar::SwearAllegiance(std::string szTargetName, DWORD dwReply, DWORD dwSenderGUID)
  3680. {
  3681. cClient* pcClient = cClient::FindClient(m_dwGUID);
  3682. cClient* pcSendClient = cClient::FindClient(dwSenderGUID);
  3683. if (dwReply == 1)
  3684. {
  3685. if (pcClient)
  3686. {
  3687. cMessage cmSwornMessage;
  3688. char szTextBuffer[255];
  3689. sprintf(&szTextBuffer[0],"%s has sworn allegiance to you.", szTargetName.c_str());
  3690. DWORD dwColor = 0x17L;
  3691. cmSwornMessage << 0xF62CL << szTextBuffer << dwColor;
  3692. pcClient->AddPacket( WORLD_SERVER, cmSwornMessage, 4 );
  3693. }
  3694. if (pcSendClient)
  3695. {
  3696. if (pcSendClient->m_pcAvatar)
  3697. {
  3698. // add the avatar to the allegiance
  3699. cAvatar* pcSwornAvatar = pcSendClient->m_pcAvatar;
  3700. cAllegiance::AddNewMember(pcSwornAvatar->GetGUID(), this->m_dwGUID, pcSwornAvatar->GetAllegianceID(), this->m_dwAllegianceID);
  3701. }
  3702. }
  3703. } else
  3704. {
  3705. }
  3706. // send the reply to the originating client
  3707. if (pcSendClient)
  3708. if (pcSendClient->m_pcAvatar)
  3709. pcSendClient->m_pcAvatar->SwearAllegianceReply(m_strCharacterName, dwReply);
  3710. }
  3711. void cAvatar::SwearAllegianceReply(std::string szTargetName, DWORD dwReply)
  3712. {
  3713. cClient* pcClient = cClient::FindClient(m_dwGUID);
  3714. if (pcClient)
  3715. {
  3716. if (dwReply == 1)
  3717. {
  3718. cMessage cmSwornMessage;
  3719. char szTextBuffer[255];
  3720. sprintf(&szTextBuffer[0],"%s has accepted your oath of allegiance.", szTargetName.c_str());
  3721. DWORD dwColor = 0x17L;
  3722. cmSwornMessage << 0xF62CL << szTextBuffer << dwColor;
  3723. pcClient->AddPacket( WORLD_SERVER, cmSwornMessage, 4 );
  3724. // kneeling animation
  3725. cMessage cmSAAnimation;
  3726. cmSAAnimation << 0xF74C
  3727. << m_dwGUID
  3728. << m_wNumLogins
  3729. << ++m_wCurAnim
  3730. << ++m_wMeleeSequence
  3731. << WORD(0x0000) //activity (idle)
  3732. << BYTE(0x00) //animation type (general animation)
  3733. << BYTE(0x00) //type flags (no target)
  3734. << WORD(0x003D) //standing
  3735. << DWORD(0x000000C0) //flags
  3736. << float(1.5)
  3737. << WORD(0x0092)
  3738. //<< WORD(0x0009) //changes //0x0009 0x0053
  3739. << m_wMeleeSequence
  3740. << float(1);
  3741. /*
  3742. << DWORD(0x01L) //changes //0x01L 0x03L
  3743. << WORD(0x99D6) //changes //0x74E8 //0x99D6
  3744. << WORD(0x0441) //changes //0x0444 //0x0441
  3745. << WORD(0x0001)
  3746. << DWORD(0x00000021)
  3747. << WORD(0x0004)
  3748. << WORD(0x02DA)
  3749. << WORD(0x0000)
  3750. << BYTE(0x02) //changes //0x00L //0x02L
  3751. << dwTarget //target GUID
  3752. << DWORD(0x0000001A)
  3753. << dwTarget; //target GUID
  3754. */
  3755. cWorldManager::SendToAllInFocus( m_Location, cmSAAnimation, 3 );
  3756. } else
  3757. {
  3758. cMessage cmSwornMessage;
  3759. char szTextBuffer[255];
  3760. sprintf(&szTextBuffer[0],"%s has declined your offer of allegiance.", szTargetName.c_str());
  3761. DWORD dwColor = 0x17L;
  3762. cmSwornMessage << 0xF62CL << szTextBuffer << dwColor;
  3763. pcClient->AddPacket( WORLD_SERVER, cmSwornMessage, 4 );
  3764. }
  3765. }
  3766. }
  3767. void cAvatar::BreakAllegiance(DWORD dwBrokenMemberGUID)
  3768. {
  3769. cClient* pcClient = cClient::FindClient(m_dwGUID);
  3770. cClient* pcReplyClient;
  3771. cAllegiance* aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID);
  3772. pcReplyClient = cClient::FindClient(dwBrokenMemberGUID);
  3773. if (aAllegiance)
  3774. {
  3775. if (pcClient)
  3776. {
  3777. std::string szMemberName = aAllegiance->GetMemberName(dwBrokenMemberGUID);
  3778. cMessage cmBreakMessage;
  3779. char szTextBuffer[255];
  3780. sprintf(&szTextBuffer[0],"You have broken your Allegiance to %s!", szMemberName.c_str());
  3781. DWORD dwColor = 0x17L;
  3782. cmBreakMessage << 0xF62CL << szTextBuffer << dwColor;
  3783. pcClient->AddPacket( WORLD_SERVER, cmBreakMessage, 4 );
  3784. }
  3785. Member* thisMember = aAllegiance->FindMember(m_dwGUID);
  3786. if (thisMember)
  3787. {
  3788. if (dwBrokenMemberGUID == thisMember->m_dwPatron)
  3789. { // broke with patron; remove oneself
  3790. cAllegiance::RemMember(m_dwGUID, this->m_dwAllegianceID);
  3791. }
  3792. else
  3793. { // removed vassal/follower; remove that member
  3794. cAllegiance::RemMember(dwBrokenMemberGUID, this->m_dwAllegianceID);
  3795. }
  3796. // send the reply to the player with whom the break occurred, if online
  3797. if (pcReplyClient)
  3798. pcReplyClient->m_pcAvatar->BreakAllegianceReply(this->Name());
  3799. }
  3800. }
  3801. }
  3802. void cAvatar::BreakAllegianceReply(std::string szMemberName)
  3803. {
  3804. cClient* pcClient = cClient::FindClient(m_dwGUID);
  3805. if (pcClient)
  3806. {
  3807. cMessage cmBreakMessage;
  3808. char szTextBuffer[255];
  3809. sprintf(&szTextBuffer[0],"%s has broken their Allegiance to you!", szMemberName.c_str());
  3810. DWORD dwColor = 0x17L;
  3811. cmBreakMessage << 0xF62CL << szTextBuffer << dwColor;
  3812. pcClient->AddPacket( WORLD_SERVER, cmBreakMessage, 4 );
  3813. }
  3814. }
  3815. cMessage cAvatar::Animation( WORD wAnim, float flPlaySpeed )
  3816. {
  3817. cMessage cAnim;
  3818. WORD wAnimPart2;
  3819. static BYTE Canimation[] = {
  3820. 0x4C, 0xF7, 0x00, 0x00, 0x56, 0x1F, 0x05, 0x50, 0x3C, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
  3821. 0x00, 0x00, 0x3D, 0x00, 0x80, 0xF0, 0xD0, 0x03, 0x7C, 0x00, 0x01, 0x00, 0xCA, 0x3F, 0x00, 0x00,//0x00, 0x00, 0x80, 0x3F,
  3822. };
  3823. ++m_wCurAnim;
  3824. CopyMemory( &Canimation[04], &m_dwGUID, 4 );
  3825. CopyMemory( &Canimation[8], &m_wNumLogins, 2 );
  3826. CopyMemory( &Canimation[10], &m_wCurAnim, 2 );
  3827. CopyMemory( &Canimation[12], &++m_wMeleeSequence, 2 );
  3828. CopyMemory( &Canimation[24], &wAnim, 2 );
  3829. CopyMemory( &Canimation[28], &flPlaySpeed, 4 );
  3830. wAnimPart2 = m_wCurAnim - 6;
  3831. CopyMemory( &Canimation[26], &wAnimPart2, 2 );
  3832. cAnim.CannedData( Canimation, sizeof( Canimation ) );
  3833. return cAnim;
  3834. }
  3835. cMessage cAvatar::WarAnim( WORD wAnim, float flPlaySpeed )
  3836. {
  3837. cMessage cWarAnim;
  3838. WORD wAnimPart2;
  3839. static BYTE CWarAnimation[] = {
  3840. 0x4C, 0xF7, 0x00, 0x00,
  3841. 0x47, 0x69, 0x02, 0x50, //character
  3842. 0x6B, 0x0A, //numLogins
  3843. 0x3B, 0x00, //Sequence
  3844. 0x0C, 0x00, //numanimations
  3845. 0x00, 0x00, //activity 0x0 idle , 0x1 active
  3846. 0x00, 0x00, //0x00, 0x00, //0x00, 0x00, //animation type 0 - general 6 - run to object 7 - run to position 8- face object 9-face position
  3847. 0x49, // Stance Mode 3C melee UA, 3D standing, 3E melee weapon, 3F bow, 40 melee weapon shield, 49 Spellcasting
  3848. 0x00,
  3849. 0x41, 0xF0, 0x9A, 0x02, //0x47, 0xF0, 0x9A, 0x02, //0x6D, 0x02, //Flags
  3850. 0x49, 0x00, //0x49, 0x00, // Stance 2
  3851. 0x00, 0x00, //0x33, 0x00, //0x33, 0x00, // animation 1
  3852. 0xC0, 0xBF, //0x00, 0x00,
  3853. 0x00, 0x00, //0x00, 0x40,
  3854. //0x04, 0x00, //0x00, 0x00,
  3855. //0x00, 0x00, //0xC0, 0xBF, //0x3F, // Speed Animation 1
  3856. //0x00, 0x40, 0x00, 0x00,
  3857. };
  3858. ++m_wCurAnim;
  3859. CopyMemory( &CWarAnimation[04], &m_dwGUID, 4 );
  3860. CopyMemory( &CWarAnimation[8], &m_wNumLogins, 2 );
  3861. CopyMemory( &CWarAnimation[10], &m_wCurAnim, 2 );
  3862. CopyMemory( &CWarAnimation[12], &m_wMeleeSequence, 2 );
  3863. //CopyMemory( &CWarAnimation[24], &wAnim, 2 );
  3864. //CopyMemory( &CWarAnimation[28], &flPlaySpeed, 4 );
  3865. wAnimPart2 = m_wCurAnim - 6;
  3866. //CopyMemory( &CWarAnimation[26], &wAnimPart2, 2 );
  3867. cWarAnim.CannedData( CWarAnimation, sizeof( CWarAnimation ) );
  3868. cWarAnim << WORD(0x0000);
  3869. return cWarAnim;
  3870. }
  3871. //Spell Windup Animation
  3872. cMessage cAvatar::WindupAnimation( WORD wAnim1, float flPlaySpeed )
  3873. {
  3874. cMessage cWindupAnim;
  3875. WORD wAnimPart2;
  3876. static BYTE CWindupAnimation[] = {
  3877. 0x4C, 0xF7, 0x00, 0x00,
  3878. 0x47, 0x69, 0x02, 0x50, //character
  3879. 0x6B, 0x0A, //numLogins
  3880. 0x3B, 0x00, //Sequence
  3881. 0x0C, 0x00, //numanimations
  3882. 0x00, 0x00, //activity 0x0 idle , 0x1 active
  3883. 0x00, 0x00, //animation type 0 - general 6 - run to object 7 - run to position 8- face object 9-face position
  3884. 0x49, // Stance Mode 3C melee UA, 3D standing, 3E melee weapon, 3F bow, 40 melee weapon shield, 49 Spellcasting
  3885. 0x00,
  3886. 0xC1, 0xF0, 0x9A, 0x02, //0x47, 0xF0, 0x6D, 0x02, //Flags
  3887. 0x49, 0x00,
  3888. 0x00, 0x00,
  3889. 0xC0, 0x3F,
  3890. 0x00, 0x00,
  3891. 0x04, 0x00,
  3892. 0x00, 0x00,
  3893. 0x00, 0x40,
  3894. 0x00, 0x00,
  3895. };
  3896. ++m_wCurAnim;
  3897. CopyMemory( &CWindupAnimation[04], &m_dwGUID, 4 );
  3898. CopyMemory( &CWindupAnimation[8], &m_wNumLogins, 2 );
  3899. CopyMemory( &CWindupAnimation[10], &m_wCurAnim, 2 );
  3900. CopyMemory( &CWindupAnimation[12], &m_wMeleeSequence, 2 );
  3901. CopyMemory( &CWindupAnimation[24], &wAnim1, 2 );
  3902. //CopyMemory( &CWindupAnimation[28], &flPlaySpeed, 4 );
  3903. wAnimPart2 = m_wCurAnim - 6;
  3904. //CopyMemory( &CWindupAnimation[26], &wAnimPart2, 2 );
  3905. cWindupAnim.CannedData( CWindupAnimation, sizeof( CWindupAnimation ) );
  3906. return cWindupAnim;
  3907. }
  3908. /**
  3909. * Handles the message sent for the avatar's animation when casting a war spell.
  3910. *
  3911. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  3912. */
  3913. cMessage cAvatar::WarAnimation( WORD wAnim1, float flPlaySpeed )
  3914. {
  3915. cMessage cWarAnim;
  3916. WORD wAnimPart2;
  3917. static BYTE CWarAnimation[] = {
  3918. 0x4C, 0xF7, 0x00, 0x00,
  3919. 0x47, 0x69, 0x02, 0x50, //character
  3920. 0x6B, 0x0A, //numLogins
  3921. 0x3B, 0x00, //Sequence
  3922. 0x0C, 0x00, //numanimations
  3923. 0x00, 0x00, //activity 0x0 idle , 0x1 active
  3924. 0x00, 0x00, //animation type 0 - general 6 - run to object 7 - run to position 8- face object 9-face position
  3925. 0x49, // Stance Mode 3C melee UA, 3D standing, 3E melee weapon, 3F bow, 40 melee weapon shield, 49 Spellcasting
  3926. 0x00,
  3927. 0x47, 0xF0, 0x9A, 0x02, //0x47, 0xF0, 0x6D, 0x02, //Flags
  3928. 0x49, 0x00,
  3929. 0x33, 0x00, // cast animation, wAnim1
  3930. 0x00, 0x00,
  3931. 0x00, 0x40,
  3932. 0x00, 0x00,
  3933. 0xC0, 0xBF, //0xC0, 0x3F, // Speed Animation 1
  3934. };
  3935. ++m_wCurAnim;
  3936. CopyMemory( &CWarAnimation[04], &m_dwGUID, 4 );
  3937. CopyMemory( &CWarAnimation[8], &m_wNumLogins, 2 );
  3938. CopyMemory( &CWarAnimation[10], &m_wCurAnim, 2 );
  3939. CopyMemory( &CWarAnimation[12], &m_wMeleeSequence, 2 );
  3940. CopyMemory( &CWarAnimation[26], &wAnim1, 2 );
  3941. //CopyMemory( &CWarAnimation[28], &flPlaySpeed, 4 );
  3942. wAnimPart2 = m_wCurAnim - 6;
  3943. //CopyMemory( &CWarAnimation[26], &wAnimPart2, 2 );
  3944. cWarAnim.CannedData( CWarAnimation, sizeof( CWarAnimation ) );
  3945. //cWarAnim << WORD(0x0000);
  3946. return cWarAnim;
  3947. }
  3948. /**
  3949. * Handles the message sent for the avatar's animation when casting a war spell.
  3950. *
  3951. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  3952. */
  3953. cMessage cAvatar::WarAnimation2( float flPlaySpeed )
  3954. {
  3955. cMessage cWarAnim;
  3956. WORD wAnimPart2;
  3957. static BYTE CWarAnimation[] = {
  3958. 0x4C, 0xF7, 0x00, 0x00,
  3959. 0x47, 0x69, 0x02, 0x50, //character
  3960. 0x6B, 0x0A, //numLogins
  3961. 0x3B, 0x00, //Sequence
  3962. 0x0C, 0x00, //numanimations
  3963. 0x00, 0x00, //activity 0x0 idle , 0x1 active
  3964. 0x00, 0x00, //animation type 0 - general 6 - run to object 7 - run to position 8- face object 9-face position
  3965. 0x49, 0x00, // Stance Mode 3C melee UA, 3D standing, 3E melee weapon, 3F bow, 40 melee weapon shield, 49 Spellcasting
  3966. 0x41, 0xF0, 0x9A, 0x02, //0x41, 0xF0, 0x6D, 0x02, //Flags
  3967. 0x49, 0x00, // Stance 2
  3968. 0x00, 0x00,
  3969. 0xC0, 0xBF, 0x00, 0x00, //0xC0, 0x3F, 0x00, 0x00,
  3970. };
  3971. ++m_wCurAnim;
  3972. CopyMemory( &CWarAnimation[04], &m_dwGUID, 4 );
  3973. CopyMemory( &CWarAnimation[8], &m_wNumLogins, 2 );
  3974. CopyMemory( &CWarAnimation[10], &m_wCurAnim, 2 );
  3975. CopyMemory( &CWarAnimation[12], &m_wMeleeSequence, 2 );
  3976. // CopyMemory( &CWarAnimation[28], &flPlaySpeed, 4 );
  3977. wAnimPart2 = m_wCurAnim - 6;
  3978. //CopyMemory( &CWarAnimation[26], &wAnimPart2, 2 );
  3979. cWarAnim.CannedData( CWarAnimation, sizeof( CWarAnimation ) );
  3980. return cWarAnim;
  3981. }
  3982. cMessage cAvatar::AddEnchant(DWORD F7B0seq, DWORD dwSpellID, WORD wEnchantLayer, WORD wSpellFamily, DWORD dwDifficulty, double dDuration, DWORD dwCasterGUID, double dCastTime, DWORD dwFlags, DWORD dwKey, float flValue)
  3983. {
  3984. cMessage cmEnchant;
  3985. cmEnchant << 0xF7B0L
  3986. << GetGUID()
  3987. << F7B0seq
  3988. << 0x004EL
  3989. << (WORD) dwSpellID
  3990. << wEnchantLayer
  3991. << wSpellFamily
  3992. << (WORD) 0x0001 //unknown0
  3993. << dwDifficulty
  3994. << (double) (timeGetTime() - dCastTime)
  3995. << dDuration
  3996. << dwCasterGUID
  3997. << 0x0L //unknown1
  3998. << 0xC4268000 //unknown2 (-666), for Vitae it's 3F800000 (1)
  3999. << dCastTime
  4000. << dwFlags //Vitae - 0x00A06012, Armor self - 0x0000A080, attributes (focus) - 0x00009001, skills - 0x00009010, all stats/attr/skills - 0x0000A001, all skills - 0x0000A010, prots/regen - 0x00005008
  4001. << dwKey //prots: blade 40, pierce 41, bludgeon 42, fire 43, cold 44, acid 45, lightning 46; regens: health 3, stamina 4, mana 5
  4002. << flValue
  4003. << 0x0L; //unknown3
  4004. return cmEnchant;
  4005. }
  4006. /**
  4007. * Handles the message sent to the avatar when a spell timer expires.
  4008. *
  4009. * @return cMessage - Returns an 0x0000F7B0 server message.
  4010. */
  4011. cMessage cAvatar::RemoveEnchant(DWORD F7B0seq, DWORD dwSpellID, WORD wEnchantLayer)
  4012. {
  4013. cMessage cmEnchant;
  4014. cmEnchant << 0xF7B0L
  4015. << GetGUID()
  4016. << F7B0seq
  4017. << 0x004FL
  4018. << dwSpellID
  4019. << wEnchantLayer;
  4020. return cmEnchant;
  4021. }
  4022. // Start Combat Routines
  4023. cMessage cAvatar::ChangeCombatMode(BOOL fMode, BYTE WieldType)
  4024. {
  4025. cMessage cmRet;
  4026. if(fMode==TRUE)
  4027. {
  4028. switch(WieldType)
  4029. {
  4030. //Unarmed
  4031. case 0x00:
  4032. {
  4033. unsigned char Canim4 [] = {
  4034. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
  4035. 0x00, 0x00, 0x3C, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00,
  4036. };
  4037. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4038. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4039. m_wCurAnim++;
  4040. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4041. m_wMeleeSequence++;
  4042. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4043. cmRet.pasteData(Canim4,sizeof(Canim4));
  4044. break;
  4045. }
  4046. //Melee Weapon
  4047. case 0x01:
  4048. {
  4049. unsigned char Canim4 [] =
  4050. {
  4051. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
  4052. 0x00, 0x00, 0x3E, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00,
  4053. };
  4054. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4055. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4056. m_wCurAnim++;
  4057. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4058. m_wMeleeSequence++;
  4059. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4060. cmRet.pasteData(Canim4,sizeof(Canim4));
  4061. break;
  4062. }
  4063. }
  4064. }
  4065. else
  4066. {
  4067. unsigned char Canim4 [] = {
  4068. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x49, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00,
  4069. 0x00, 0x00, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00,
  4070. };
  4071. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4072. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4073. m_wCurAnim++;
  4074. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4075. m_wMeleeSequence++;
  4076. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4077. cmRet.pasteData(Canim4,sizeof(Canim4));
  4078. }
  4079. return cmRet;
  4080. }
  4081. cMessage cAvatar::ChangeSpellMode(BOOL fMode)
  4082. {
  4083. cMessage cmRet;
  4084. if(fMode==TRUE)
  4085. {
  4086. unsigned char Canim4 [] = {
  4087. 0x4C, 0xF7, 0x00, 0x00, 0x47, 0x69, 0x02, 0x50, 0x6C, 0x0A, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00,
  4088. 0x00, 0x00, 0x49, 0x00, 0x01, 0xF0, 0x99, 0x02, 0x49, 0x00, 0x00, 0x00,
  4089. };
  4090. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4091. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4092. m_wCurAnim++;
  4093. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4094. m_wMeleeSequence++;
  4095. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4096. cmRet.pasteData(Canim4,sizeof(Canim4));
  4097. }
  4098. else
  4099. {
  4100. unsigned char Canim4 [] = {
  4101. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x49, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00,
  4102. 0x00, 0x00, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00,
  4103. };
  4104. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4105. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4106. m_wCurAnim++;
  4107. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4108. m_wMeleeSequence++;
  4109. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4110. cmRet.pasteData(Canim4,sizeof(Canim4));
  4111. }
  4112. return cmRet;
  4113. }
  4114. cMessage cAvatar::ChangeMissileMode(BOOL fMode, WORD AmmoType)
  4115. {
  4116. cMessage cmRet;
  4117. if(fMode == TRUE)
  4118. {
  4119. switch(AmmoType)
  4120. {
  4121. case 0x0001:
  4122. {
  4123. //Equip animation
  4124. unsigned char Canim4 [] =
  4125. {
  4126. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
  4127. 0x00, 0x00, 0x3F, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00,
  4128. };
  4129. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4130. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4131. m_wCurAnim++;
  4132. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4133. m_wMeleeSequence++;
  4134. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4135. cmRet.pasteData(Canim4,sizeof(Canim4));
  4136. //Grabbing arrow animation
  4137. unsigned char Canim5 [] =
  4138. {
  4139. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00,
  4140. 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00,
  4141. };
  4142. CopyMemory(&Canim5[4],&m_dwGUID,4);
  4143. CopyMemory( &Canim5[8], &m_wNumLogins, 2 );
  4144. m_wCurAnim++;
  4145. CopyMemory(&Canim5[10],&m_wCurAnim,2);
  4146. m_wMeleeSequence++;
  4147. CopyMemory(&Canim5[12],&m_wMeleeSequence,2);
  4148. cmRet.pasteData(Canim5,sizeof(Canim5));
  4149. break;
  4150. }
  4151. case 0x0002:
  4152. {
  4153. //Equip animation
  4154. unsigned char Canim4 [] =
  4155. {
  4156. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
  4157. 0x00, 0x00, 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
  4158. };
  4159. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4160. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4161. m_wCurAnim++;
  4162. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4163. m_wMeleeSequence++;
  4164. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4165. cmRet.pasteData(Canim4,sizeof(Canim4));
  4166. //Grabbing arrow animation
  4167. unsigned char Canim5 [] =
  4168. {
  4169. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3D, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00,
  4170. 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00,
  4171. };
  4172. CopyMemory(&Canim5[4],&m_dwGUID,4);
  4173. CopyMemory( &Canim5[8], &m_wNumLogins, 2 );
  4174. m_wCurAnim++;
  4175. CopyMemory(&Canim5[10],&m_wCurAnim,2);
  4176. m_wMeleeSequence++;
  4177. CopyMemory(&Canim5[12],&m_wMeleeSequence,2);
  4178. cmRet.pasteData(Canim5,sizeof(Canim5));
  4179. break;
  4180. }
  4181. }
  4182. }
  4183. else
  4184. {
  4185. unsigned char Canim4 [] = {
  4186. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x49, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00,
  4187. 0x00, 0x00, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00,
  4188. };
  4189. CopyMemory(&Canim4[4],&m_dwGUID,4);
  4190. CopyMemory( &Canim4[8], &m_wNumLogins, 2 );
  4191. m_wCurAnim++;
  4192. CopyMemory(&Canim4[10],&m_wCurAnim,2);
  4193. m_wMeleeSequence++;
  4194. CopyMemory(&Canim4[12],&m_wMeleeSequence,2);
  4195. cmRet.pasteData(Canim4,sizeof(Canim4));
  4196. }
  4197. return cmRet;
  4198. }
  4199. /**
  4200. * Handles the message sent for the avatar's animation when combating.
  4201. *
  4202. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  4203. */
  4204. cMessage cAvatar::CombatAnimation(DWORD dwTarget)
  4205. {
  4206. cMessage cmRet;
  4207. /*
  4208. unsigned char Canimation [] = {
  4209. 0x4C, 0xF7, 0x00, 0x00, 0xE6, 0xD2, 0x09, 0x50, 0x3C, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00,
  4210. 0x00, 0x01, 0x00, 0x00, 0xC1, 0x80, 0x99, 0xB1, 0x3E, 0x00, 0x00, 0x00, 0x10, 0xC0, 0x67, 0x00,
  4211. 0x01, 0x00, 0xE4, 0x38, 0x8E, 0x3F, 0x00, 0x00, 0x20, 0x8B, 0x99, 0xB1,
  4212. };
  4213. CopyMemory(&Canimation[4],&m_dwGUID,4);
  4214. CopyMemory( &Canimation[8], &m_wNumLogins, 2 );
  4215. m_wCurAnim++;
  4216. CopyMemory(&Canimation[10],&m_wCurAnim,2);
  4217. m_wMeleeSequence++;
  4218. CopyMemory(&Canimation[12],&m_wMeleeSequence,2);
  4219. CopyMemory(&Canimation[0x28],&dwTarget,4);
  4220. CopyMemory(&Canimation[0x20],&m_wCurAnim,2);
  4221. cmRet.pasteData(Canimation,sizeof(Canimation));
  4222. */
  4223. cmRet << 0xF74CL << this->m_dwGUID << this->m_wNumLogins << ++this->m_wCurAnim
  4224. << ++this->m_wMeleeSequence
  4225. << WORD(0x0000) //Active
  4226. << BYTE(0x00) //General animation
  4227. << BYTE(0x01) //Has target
  4228. << WORD(0x003E) //Stance
  4229. << DWORD(0x00C1) //Flags
  4230. << WORD(0x003E) //Stance
  4231. << WORD(0xC010)
  4232. << WORD(0x0060)
  4233. << this->m_wCurAnim
  4234. << float(1.0)
  4235. << WORD(0x0000)
  4236. << dwTarget;
  4237. return cmRet;
  4238. }
  4239. cMessage cAvatar::DoDamageMessage(DWORD F7B0seq,std::string target,DWORD damagetype,double severity,DWORD amount)
  4240. {
  4241. cMessage cmRet;
  4242. cmRet << 0xF7B0L << m_dwGUID << F7B0seq << 0x01B1L << target.c_str() << damagetype << severity << amount;
  4243. return cmRet;
  4244. }
  4245. cMessage cAvatar::RecieveDamageMessage(DWORD F7B0seq,std::string giver,DWORD damagetype,double severity,DWORD amount,DWORD location)
  4246. {
  4247. cMessage cmRet;
  4248. cmRet << 0xF7B0L << m_dwGUID << F7B0seq << 0x01B2L << giver.c_str() << damagetype << severity << amount << location;
  4249. return cmRet;
  4250. }
  4251. cMessage cAvatar::AttackBeginMessage(DWORD F7B0seq, DWORD pcGUID)
  4252. {
  4253. //cClient m_pcClient;
  4254. cMessage cmRet;
  4255. cmRet << 0xF7B0L << m_dwGUID << F7B0seq << 0x01B8L;
  4256. return cmRet;
  4257. }
  4258. cMessage cAvatar::AttackCompleteMessage(DWORD F7B0seq)
  4259. {
  4260. cMessage cmRet;
  4261. cmRet << 0xF7B0L << m_dwGUID << F7B0seq << 0x01A7L << 0x37L;
  4262. return cmRet;
  4263. }
  4264. //////////////////////////////////////
  4265. // Stats updates
  4266. //////////////////////////////////////
  4267. /**
  4268. * Handles the message sent to the avatar when experience is awarded to the unassigned experience value.
  4269. *
  4270. * @param amount - The amount of experience to award.
  4271. */
  4272. void cAvatar::UpdateHuntingExp(DWORD amount)
  4273. {
  4274. cFellowship* aFellowship;
  4275. if (aFellowship = cFellowship::GetFellowshipByID(m_dwFellowshipID))
  4276. {
  4277. aFellowship->DistributeXP(this->GetGUID(), this->m_Location, amount);
  4278. }
  4279. else
  4280. {
  4281. cAllegiance* aAllegiance;
  4282. if (aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID))
  4283. {
  4284. //Find the avatar's allegiance record
  4285. Member* memAvatar = &aAllegiance->members.find(m_dwGUID)->second;
  4286. aAllegiance->VassalPassupXP(memAvatar, amount, false);
  4287. }
  4288. cClient* pcClient = cClient::FindClient(m_dwGUID);
  4289. pcClient->AddPacket( WORLD_SERVER, UpdateUnassignedExp(amount), 4 );
  4290. }
  4291. }
  4292. /**
  4293. * Handles the message sent to the avatar when experience is awarded through a fellowship.
  4294. *
  4295. * @param amount - The amount of experience to award.
  4296. */
  4297. void cAvatar::UpdateFellowshipExp(DWORD amount)
  4298. {
  4299. cAllegiance* aAllegiance;
  4300. if (aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID))
  4301. {
  4302. //Find the avatar's allegiance record
  4303. Member* memAvatar = &aAllegiance->members.find(m_dwGUID)->second;
  4304. aAllegiance->VassalPassupXP(memAvatar, amount, false);
  4305. }
  4306. cClient* pcClient = cClient::FindClient(m_dwGUID);
  4307. pcClient->AddPacket( WORLD_SERVER, UpdateUnassignedExp(amount), 4 );
  4308. }
  4309. /**
  4310. * Handles the message sent to the avatar when experience is awarded to the unassigned experience value.
  4311. *
  4312. * @param amount - The amount of experience to award.
  4313. *
  4314. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4315. */
  4316. cMessage cAvatar::UpdateUnassignedExp(DWORD amount)
  4317. {
  4318. DWORD xpAmount = AwardUnassignedXP(amount);
  4319. cMessage cmRet;
  4320. cmRet << 0x237L << m_bStatSequence++ << 0x16L << xpAmount;
  4321. return cmRet;
  4322. }
  4323. /**
  4324. * Handles the message sent to the avatar when experience is decremented from the unassigned experience value.
  4325. *
  4326. * @param amount - The amount of experience to decrement.
  4327. *
  4328. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4329. */
  4330. cMessage cAvatar::DecrementUnassignedExp(DWORD amount)
  4331. {
  4332. DWORD xpAmount = SpendUnassignedXP(amount);
  4333. cMessage cmRet;
  4334. cmRet << 0x237L << m_bStatSequence++ << 0x16L << xpAmount;
  4335. return cmRet;
  4336. }
  4337. /**
  4338. * Handles the message sent to the avatar when experience is awarded to the total experience value.
  4339. *
  4340. * @param amount - The amount of experience to award.
  4341. *
  4342. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4343. */
  4344. cMessage cAvatar::UpdateTotalExp(DWORD amount)
  4345. {
  4346. DWORD xpAmount = AwardTotalExp(amount);
  4347. cMessage cmRet;
  4348. cmRet << 0x237L << m_bStatSequence++ << 0x15L << xpAmount;
  4349. return cmRet;
  4350. }
  4351. /**
  4352. * Handles the message sent to the avatar when experience is awarded to skill experience value.
  4353. *
  4354. * @param amount - The amount of experience to award.
  4355. * @param skill - The skill to which the experience is awarded.
  4356. *
  4357. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4358. */
  4359. cMessage cAvatar::UpdateSkillExp(DWORD amount, BYTE skill)
  4360. {
  4361. DWORD xpAmount = AwardUnassignedXP(amount);
  4362. cMessage cmRet;
  4363. cmRet << 0x237L << m_bStatSequence++ << 0x18L << skill << xpAmount;
  4364. return cmRet;
  4365. }
  4366. /**
  4367. * Handles the message sent when an avatar's pyreal amount changes.
  4368. *
  4369. * @param amount - The amount of pyreals to add or remove.
  4370. * @param positive - Whether the amount is positive or negative
  4371. *
  4372. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4373. */
  4374. cMessage cAvatar::UpdatePyreals(DWORD amount, int positive)
  4375. {
  4376. DWORD pyrealsAmount;
  4377. if (positive == 1)
  4378. pyrealsAmount = AddPyreals(amount);
  4379. else
  4380. pyrealsAmount = RemovePyreals(amount);
  4381. cMessage cmRet;
  4382. cmRet << 0x237L << m_bStatSequence++ << 0x14L << DWORD(pyrealsAmount);
  4383. return cmRet;
  4384. }
  4385. /**
  4386. * Handles the message sent when an avatar's burden amount changes.
  4387. *
  4388. * @param amount - The amount of burden to add or remove.
  4389. * @param positive - Whether the amount should add or remove burden.
  4390. *
  4391. * @return cMessage - Returns an Update Statistic (0x00000237) server message.
  4392. */
  4393. cMessage cAvatar::UpdateBurden(DWORD amount, int action)
  4394. {
  4395. DWORD burdenAmount;
  4396. if (action == 0)
  4397. {
  4398. //Add Burden
  4399. burdenAmount = AddBurden(amount);
  4400. }
  4401. else
  4402. {
  4403. burdenAmount = RemoveBurden(amount);
  4404. }
  4405. cMessage cmRet;
  4406. cmRet << 0x237L << m_bStatSequence++ << 0x05L << burdenAmount;
  4407. return cmRet;
  4408. }
  4409. /**
  4410. * Calculates the total base value of a skill.
  4411. *
  4412. * The base value will be equal to the creation value plus creation bonus (if trained or specialized) plus skill increments plus any attribute bonus to the skill.
  4413. * The resultant value is used for server-side calculations; the client maintains its own value (which should match the server's value).
  4414. *
  4415. * @param skillID - The numeric representation of the skill.
  4416. */
  4417. void cAvatar::CalcSkill(DWORD skillID)
  4418. {
  4419. int skillArrayNum = skillID;
  4420. int total_skill;
  4421. int skillBonus = 0;
  4422. if (m_cStats.m_lpcSkills[skillArrayNum].m_wStatus == 3)
  4423. m_cStats.m_lpcSkills[skillArrayNum].m_dwBonus = 10;
  4424. else if (m_cStats.m_lpcSkills[skillArrayNum].m_wStatus == 2)
  4425. m_cStats.m_lpcSkills[skillArrayNum].m_dwBonus = 5;
  4426. else
  4427. m_cStats.m_lpcSkills[skillArrayNum].m_dwBonus = 0;
  4428. total_skill = this->m_cStats.m_lpcSkills[skillArrayNum].m_dwIncreases + m_cStats.m_lpcSkills[skillArrayNum].m_dwBonus;
  4429. //Add the attribute bonuses
  4430. switch(skillID)
  4431. {
  4432. //The client rounds the result of attribute contributions to the skill level.
  4433. //Given that high accuracy is not required, flooring the value plus one-half is precise enough.
  4434. case 0x01: //Axe
  4435. {
  4436. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4437. }
  4438. break;
  4439. case 0x02: //Bow
  4440. {
  4441. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 2 + .5);
  4442. }
  4443. break;
  4444. case 0x03: //Crossbow
  4445. {
  4446. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 2 + .5);
  4447. }
  4448. break;
  4449. case 0x04: //Dagger
  4450. {
  4451. total_skill += floor((double)(this->base_quickness + this->m_cStats.m_lpcAttributes[2].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4452. }
  4453. break;
  4454. case 0x05: //Mace
  4455. {
  4456. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4457. }
  4458. break;
  4459. case 0x06: //Melee Defense
  4460. {
  4461. total_skill += floor((double)(this->base_quickness + this->m_cStats.m_lpcAttributes[2].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4462. }
  4463. break;
  4464. case 0x07: //Missile Defense
  4465. {
  4466. total_skill += floor((double)(this->base_quickness + this->m_cStats.m_lpcAttributes[2].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 5 + .5);
  4467. }
  4468. break;
  4469. case 0x08:
  4470. {
  4471. }
  4472. break;
  4473. case 0x09: //Spear
  4474. {
  4475. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4476. }
  4477. break;
  4478. case 0x0A: //Staff
  4479. {
  4480. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4481. }
  4482. break;
  4483. case 0x0B: //Sword
  4484. {
  4485. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4486. }
  4487. break;
  4488. case 0x0C: //Thrown Weapons
  4489. {
  4490. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 2 + .5);
  4491. }
  4492. break;
  4493. case 0x0D: //Unarmed Combat
  4494. {
  4495. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 3 + .5);
  4496. }
  4497. break;
  4498. case 0x0E: //Arcane Lore
  4499. {
  4500. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4501. }
  4502. break;
  4503. case 0x0F: //Magic Defense
  4504. {
  4505. total_skill += floor((double)(this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement + this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 7 + .5);
  4506. }
  4507. break;
  4508. case 0x10: //Mana Conversion
  4509. {
  4510. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 6 + .5);
  4511. }
  4512. break;
  4513. case 0x11:
  4514. {
  4515. }
  4516. break;
  4517. case 0x12: //Appraise Item
  4518. {
  4519. total_skill += 0;
  4520. }
  4521. break;
  4522. case 0x13: //Assess Person
  4523. {
  4524. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 2 + .5);
  4525. }
  4526. break;
  4527. case 0x14: //Deception
  4528. {
  4529. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 4 + .5);
  4530. }
  4531. break;
  4532. case 0x15: //Healing
  4533. {
  4534. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4535. }
  4536. break;
  4537. case 0x16: //Jump
  4538. {
  4539. total_skill += floor((double)(this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement + this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement) / 2 + .5);
  4540. }
  4541. break;
  4542. case 0x17: //Lockpick
  4543. {
  4544. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement + this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4545. }
  4546. break;
  4547. case 0x18: //Run
  4548. {
  4549. total_skill += this->base_quickness + this->m_cStats.m_lpcAttributes[2].m_dwIncrement;
  4550. }
  4551. break;
  4552. case 0x19:
  4553. {
  4554. }
  4555. break;
  4556. case 0x1A:
  4557. {
  4558. }
  4559. break;
  4560. case 0x1B: //Assess Creature
  4561. {
  4562. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 2 + .5);
  4563. }
  4564. break;
  4565. case 0x1C: //Appraise Weapon
  4566. {
  4567. total_skill += 0;
  4568. }
  4569. break;
  4570. case 0x1D: //Appraise Armor
  4571. {
  4572. total_skill += 0;
  4573. }
  4574. break;
  4575. case 0x1E: //Appraise Magic Item
  4576. {
  4577. total_skill += 0;
  4578. }
  4579. break;
  4580. case 0x1F: //Creature Enchantment
  4581. {
  4582. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 4 + .5);
  4583. }
  4584. break;
  4585. case 0x20: //Item Enchantment
  4586. {
  4587. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 4 + .5);
  4588. }
  4589. break;
  4590. case 0x21: //Life Magic
  4591. {
  4592. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 4 + .5);
  4593. }
  4594. break;
  4595. case 0x22: //War Magic
  4596. {
  4597. total_skill += floor((double)(this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement + this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement) / 4 + .5);
  4598. }
  4599. break;
  4600. case 0x23: //Leadership
  4601. {
  4602. total_skill += 0;
  4603. }
  4604. break;
  4605. case 0x24: //Loyalty
  4606. {
  4607. total_skill += 0;
  4608. }
  4609. break;
  4610. case 0x25: //Fletching
  4611. {
  4612. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement + this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4613. }
  4614. break;
  4615. case 0x26: //Alchemy
  4616. {
  4617. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement + this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4618. }
  4619. break;
  4620. case 0x27: //Cooking
  4621. {
  4622. total_skill += floor((double)(this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement + this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement) / 3 + .5);
  4623. }
  4624. break;
  4625. }
  4626. m_cStats.m_lpcSkills[skillArrayNum].m_dwTotal = total_skill;
  4627. }
  4628. //////////////////////////////////////
  4629. // Skill updates
  4630. //////////////////////////////////////
  4631. //String arrays used for updating skills
  4632. std::string skillSQL[0x29] = {"Unknown1Inc","AxeInc","BowInc","CrossbowInc","DaggerInc","MaceInc","MeleeDefenseInc",
  4633. "MissileDefenseInc","Unknown2Inc","SpearInc","StaffInc","SwordInc","ThrownWeaponsInc","UnarmedCombatInc",
  4634. "ArcaneLoreInc","MagicDefenseInc","ManaConversionInc","Unknown3Inc","AppraiseItemInc","AssessPersonInc",
  4635. "DeceptionInc","HealingInc","JumpInc","LockpickInc","RunInc","Unknown4Inc","Unknown5Inc","AssessCreatureInc",
  4636. "AppraiseWeaponInc","AppraiseArmorInc","AppraiseMagicItemInc","CreatureEnchantmentInc","ItemEnchantmentInc",
  4637. "LifeMagicInc","WarMagicInc","LeadershipInc","LoyaltyInc","FletchingInc","AlchemyInc","CookingInc"};
  4638. std::string skillName[0x29] = {"Unknown1","Axe","Bow","Crossbow","Dagger","Mace","Melee Defense","Missile Defense",
  4639. "Unknown2","Spear","Staff","Sword","Thrown Weapons","Unarmed Combat","Arcane Lore","Magic Defense","Mana Conversion",
  4640. "Unknown3","Appraise Item","Assess Person","Deception","Healing","Jump","Lockpick","Run","Unknown4","Unknown5",
  4641. "Assess Creature","Appraise Weapon","Appraise Armor","Appraise Magic Item","Creature Enchantment",
  4642. "Item Enchantment","Life Magic","War Magic","Leadership","Loyalty","Fletching","Alchemy","Cooking"};
  4643. /**
  4644. * Handles the message sent when an avatar increments a skill.
  4645. * Also updates the database value.
  4646. *
  4647. * @param skillID - The numeric representation of the skill. The function generically switches depending upon the skillID.
  4648. * @param exp - The amount of experience spent incrementing the skill.
  4649. *
  4650. * @return cMessage - Returns a Skill Experience (0x0000023E) server message.
  4651. */
  4652. cMessage cAvatar::UpdateSkill(DWORD skillID, DWORD exp)
  4653. {
  4654. char szCommand[512];
  4655. RETCODE retcode;
  4656. this->m_cStats.m_lpcSkills[skillID].m_dwIncreases++;
  4657. this->m_cStats.m_lpcSkills[skillID].m_dwTotal++;
  4658. m_cStats.m_lpcSkills[skillID].m_dwXP += exp;
  4659. //Add the increase to the database
  4660. sprintf( szCommand, "UPDATE avatar_skills SET %s = %i WHERE AvatarGUID = %lu;",skillSQL[skillID].c_str(), this->m_cStats.m_lpcSkills[skillID].m_dwIncreases,this->GetGUID( ));
  4661. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4662. retcode = SQLExecute( cDatabase::m_hStmt );
  4663. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4664. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4665. //The Update Skill message
  4666. cMessage cmUpdateSkill;
  4667. cmUpdateSkill << 0x23EL << WORD(skillID) << BYTE(0x00) << BYTE(0x00) << WORD(this->m_cStats.m_lpcSkills[skillID].m_dwIncreases) << WORD(0x0001) << DWORD(this->m_cStats.m_lpcSkills[skillID].m_wStatus) << m_cStats.m_lpcSkills[skillID].m_dwXP << m_cStats.m_lpcSkills[skillID].m_dwBonus << DWORD(0x0L) << DWORD(0x0L) << DWORD(0x0L);
  4668. cMessage cSound = this->SoundEffect(118,1.0);
  4669. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4670. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base %s skill is now %d!",skillName[skillID].c_str(),this->m_cStats.m_lpcSkills[skillID].m_dwTotal );
  4671. return cmUpdateSkill;
  4672. }
  4673. //////////////////////////////////////
  4674. // Attribute updates
  4675. //////////////////////////////////////
  4676. /**
  4677. * Handles the message sent when an avatar's Strength attribute is incremented.
  4678. * Also updates the database value.
  4679. *
  4680. * @param exp - The amount of experience spent incrementing Strength.
  4681. *
  4682. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4683. */
  4684. cMessage cAvatar::UpdateStrength(DWORD exp)
  4685. {
  4686. char szCommand[512];
  4687. RETCODE retcode;
  4688. //When this message is fired, the "Raise Stat" button has already been pressed.
  4689. //The client will not let you click the "Raise" button if you don't have enough experience.
  4690. this->m_cStats.m_lpcAttributes[0].m_dwIncrement++;
  4691. //Add the increase to the database
  4692. sprintf( szCommand, "UPDATE avatar SET Strength = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[0].m_dwIncrement,this->GetGUID( ));
  4693. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4694. retcode = SQLExecute( cDatabase::m_hStmt );
  4695. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4696. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4697. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4698. strength_exp_cost += exp;
  4699. //Update database with the new total experience spent
  4700. sprintf( szCommand, "UPDATE avatar SET Str_exp_spent = %i WHERE AvatarGUID = %lu;",strength_exp_cost,this->GetGUID( ));
  4701. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4702. retcode = SQLExecute( cDatabase::m_hStmt );
  4703. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4704. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4705. //The Update Strength message
  4706. cMessage cmUpdStr;
  4707. cmUpdStr << 0x241L << 0x01L << this->m_cStats.m_lpcAttributes[0].m_dwIncrement << this->m_cStats.m_lpcAttributes[0].m_dwCurrent << strength_exp_cost;
  4708. cMessage cSound = this->SoundEffect(118,1.0);
  4709. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4710. //TODO: It seems that base_strength cannot be accessed (is equal to 0) because it is private? Why? (m_lpcAttributes entry used instead.)
  4711. //cMasterServer::ServerMessage(ColorBlue,NULL,"Your Base Strength is now %d!",this->base_strength + this->m_cStats.m_lpcAttributes[0].m_dwIncrement);
  4712. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Strength is now %d!",this->m_cStats.m_lpcAttributes[0].m_dwCurrent + this->m_cStats.m_lpcAttributes[0].m_dwIncrement);
  4713. //Skills affected by Strength
  4714. CalcSkill(0x0001); //Axe
  4715. CalcSkill(0x0005); //Mace
  4716. CalcSkill(0x0009); //Spear
  4717. CalcSkill(0x000A); //Staff
  4718. CalcSkill(0x000B); //Sword
  4719. CalcSkill(0x000C); //Thrown Weapons
  4720. CalcSkill(0x000D); //Unarmed Combat
  4721. CalcSkill(0x0016); //Jump
  4722. CalcSkill(0x001C); //Appraise Weapon / Weapon Tinkering
  4723. return cmUpdStr;
  4724. }
  4725. /**
  4726. * Handles the message sent when an avatar's Endurance attribute is incremented.
  4727. * Also updates the database value.
  4728. *
  4729. * @param exp - The amount of experience spent incrementing Endurance.
  4730. *
  4731. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4732. */
  4733. cMessage cAvatar::UpdateEndurance(DWORD exp)
  4734. {
  4735. char szCommand[512];
  4736. RETCODE retcode;
  4737. //When this message is fired, the "Raise Stat" button has already been pressed.
  4738. //The client will not let you click the "Raise" button if you don't have enough experience.
  4739. this->m_cStats.m_lpcAttributes[1].m_dwIncrement++;
  4740. //Add the increase to the database
  4741. sprintf( szCommand, "UPDATE avatar SET Endurance = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[1].m_dwIncrement,this->GetGUID( ));
  4742. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4743. retcode = SQLExecute( cDatabase::m_hStmt );
  4744. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4745. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4746. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4747. endurance_exp_cost += exp;
  4748. //Update database with the new total experience spent
  4749. sprintf( szCommand, "UPDATE avatar SET End_exp_spent = %i WHERE AvatarGUID = %lu;",endurance_exp_cost,this->GetGUID( ));
  4750. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4751. retcode = SQLExecute( cDatabase::m_hStmt );
  4752. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4753. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4754. //The Update Endurance message
  4755. cMessage cmUpdEnd;
  4756. cmUpdEnd << 0x241L << 0x02L << this->m_cStats.m_lpcAttributes[1].m_dwIncrement << this->m_cStats.m_lpcAttributes[1].m_dwCurrent << endurance_exp_cost;
  4757. cMessage cSound = this->SoundEffect(118,1.0);
  4758. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4759. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Endurance is now %d!",this->base_endurance + this->m_cStats.m_lpcAttributes[1].m_dwIncrement);
  4760. //Skills affected by Endurance
  4761. CalcSkill(0x001D); //Appraise Armor / Armor Tinkering
  4762. //Vitals affected by Endurance
  4763. CalcVital(0x0000); //Health
  4764. CalcVital(0x0001); //Stamina
  4765. return cmUpdEnd;
  4766. }
  4767. /**
  4768. * Handles the message sent when an avatar's Quickness attribute is incremented.
  4769. * Also updates the database value.
  4770. *
  4771. * @param exp - The amount of experience spent incrementing Quickness.
  4772. *
  4773. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4774. */
  4775. cMessage cAvatar::UpdateQuickness(DWORD exp)
  4776. {
  4777. char szCommand[512];
  4778. RETCODE retcode;
  4779. //When this message is fired, the "Raise Stat" button has already been pressed.
  4780. //The client will not let you click the "Raise" button if you don't have enough experience.
  4781. this->m_cStats.m_lpcAttributes[2].m_dwIncrement++;
  4782. //Add the increase to the database
  4783. sprintf( szCommand, "UPDATE avatar SET Quickness = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[2].m_dwIncrement,this->GetGUID( ));
  4784. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4785. retcode = SQLExecute( cDatabase::m_hStmt );
  4786. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4787. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4788. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4789. quickness_exp_cost += exp;
  4790. //Update database with the new total experience spent
  4791. sprintf( szCommand, "UPDATE avatar SET Qui_exp_spent = %i WHERE AvatarGUID = %lu;",quickness_exp_cost,this->GetGUID( ));
  4792. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4793. retcode = SQLExecute( cDatabase::m_hStmt );
  4794. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4795. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4796. //The Update Quickness message
  4797. cMessage cmUpdQuick;
  4798. cmUpdQuick << 0x241L << 0x03L << this->m_cStats.m_lpcAttributes[2].m_dwIncrement << this->m_cStats.m_lpcAttributes[2].m_dwCurrent << quickness_exp_cost;
  4799. cMessage cSound = this->SoundEffect(118,1.0);
  4800. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4801. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Quickness is now %d!",this->base_quickness + this->m_cStats.m_lpcAttributes[2].m_dwIncrement);
  4802. //Skills affected by Quickness
  4803. CalcSkill(0x0004); //Dagger
  4804. CalcSkill(0x0006); //Melee Defense
  4805. CalcSkill(0x0007); //Missile Defense
  4806. CalcSkill(0x0018); //Run
  4807. return cmUpdQuick;
  4808. }
  4809. /**
  4810. * Handles the message sent when an avatar's Coordination attribute is incremented.
  4811. * Also updates the database value.
  4812. *
  4813. * @param exp - The amount of experience spent incrementing Coordination.
  4814. *
  4815. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4816. */
  4817. cMessage cAvatar::UpdateCoordination(DWORD exp)
  4818. {
  4819. char szCommand[512];
  4820. RETCODE retcode;
  4821. //When this message is fired, the "Raise Stat" button has already been pressed.
  4822. //The client will not let you click the "Raise" button if you don't have enough experience.
  4823. this->m_cStats.m_lpcAttributes[3].m_dwIncrement++;
  4824. //Add the increase to the database
  4825. sprintf( szCommand, "UPDATE avatar SET Coordination = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[3].m_dwIncrement,this->GetGUID( ));
  4826. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4827. retcode = SQLExecute( cDatabase::m_hStmt );
  4828. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4829. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4830. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4831. coordination_exp_cost += exp;
  4832. //Update database with the new total experience spent
  4833. sprintf( szCommand, "UPDATE avatar SET Cor_exp_spent = %i WHERE AvatarGUID = %lu;",coordination_exp_cost,this->GetGUID( ));
  4834. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4835. retcode = SQLExecute( cDatabase::m_hStmt );
  4836. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4837. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4838. //The Update Coordination message
  4839. cMessage cmUpdCoord;
  4840. cmUpdCoord << 0x241L << 0x04L << this->m_cStats.m_lpcAttributes[3].m_dwIncrement << this->m_cStats.m_lpcAttributes[3].m_dwCurrent << coordination_exp_cost;
  4841. cMessage cSound = this->SoundEffect(118,1.0);
  4842. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4843. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Coordination is now %d!",this->base_coordination + this->m_cStats.m_lpcAttributes[3].m_dwIncrement);
  4844. //Skills affected by Coordination
  4845. CalcSkill(0x0001); //Axe
  4846. CalcSkill(0x0002); //Bow
  4847. CalcSkill(0x0003); //Crossbow
  4848. CalcSkill(0x0004); //Dagger
  4849. CalcSkill(0x0005); //Mace
  4850. CalcSkill(0x0006); //Melee Defense
  4851. CalcSkill(0x0007); //Missile Defense
  4852. CalcSkill(0x0009); //Spear
  4853. CalcSkill(0x000A); //Staff
  4854. CalcSkill(0x000B); //Sword
  4855. CalcSkill(0x000C); //Thrown Weapons
  4856. CalcSkill(0x000D); //Unarmed Combat
  4857. CalcSkill(0x0012); //Appraise Item / Item Tinkering
  4858. CalcSkill(0x0015); //Healing
  4859. CalcSkill(0x0016); //Jump
  4860. CalcSkill(0x0017); //Lockpick
  4861. CalcSkill(0x0026); //Alchemy
  4862. CalcSkill(0x0027); //Cooking
  4863. CalcSkill(0x0025); //Fletching
  4864. return cmUpdCoord;
  4865. }
  4866. /**
  4867. * Handles the message sent when an avatar's Focus attribute is incremented.
  4868. * Also updates the database value.
  4869. *
  4870. * @param exp - The amount of experience spent incrementing Focus.
  4871. *
  4872. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4873. */
  4874. cMessage cAvatar::UpdateFocus(DWORD exp)
  4875. {
  4876. char szCommand[512];
  4877. RETCODE retcode;
  4878. //When this message is fired, the "Raise Stat" button has already been pressed.
  4879. //The client will not let you click the "Raise" button if you don't have enough experience.
  4880. this->m_cStats.m_lpcAttributes[4].m_dwIncrement++;
  4881. //Add the increase to the database
  4882. sprintf( szCommand, "UPDATE avatar SET Focus = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[4].m_dwIncrement,this->GetGUID( ));
  4883. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4884. retcode = SQLExecute( cDatabase::m_hStmt );
  4885. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4886. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4887. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4888. focus_exp_cost += exp;
  4889. //Update database with the new total experience spent
  4890. sprintf( szCommand, "UPDATE avatar SET Foc_exp_spent = %i WHERE AvatarGUID = %lu;",focus_exp_cost,this->GetGUID( ));
  4891. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4892. retcode = SQLExecute( cDatabase::m_hStmt );
  4893. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4894. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4895. //The Update Focus message
  4896. cMessage cmUpdFocus;
  4897. cmUpdFocus << 0x241L << 0x05L << this->m_cStats.m_lpcAttributes[4].m_dwIncrement << this->m_cStats.m_lpcAttributes[4].m_dwCurrent << focus_exp_cost;
  4898. cMessage cSound = this->SoundEffect(118,1.0);
  4899. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4900. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Focus is now %d!",this->base_focus + this->m_cStats.m_lpcAttributes[4].m_dwIncrement);
  4901. //Skills affected by Focus
  4902. CalcSkill(0x000E); //Arcane Lore
  4903. CalcSkill(0x000F); //Magic Defense
  4904. CalcSkill(0x0010); //Mana Conversion
  4905. CalcSkill(0x0012); //Appraise Item / Item Tinkering
  4906. CalcSkill(0x0013); //Assess Person
  4907. CalcSkill(0x0014); //Deception
  4908. CalcSkill(0x0015); //Healing
  4909. CalcSkill(0x0017); //Lockpick
  4910. CalcSkill(0x001B); //Assess Creature
  4911. CalcSkill(0x001C); //Appraise Weapon / Weapon Tinkering
  4912. CalcSkill(0x001D); //Appraise Armor / Armor Tinkering
  4913. CalcSkill(0x001E); //Appraise Magic Item / Magic Item Tinkering
  4914. CalcSkill(0x001F); //Creature Enchantment
  4915. CalcSkill(0x0020); //Item Enchantment
  4916. CalcSkill(0x0021); //Life Magic
  4917. CalcSkill(0x0022); //War Magic
  4918. CalcSkill(0x0025); //Fletching
  4919. CalcSkill(0x0026); //Alchemy
  4920. CalcSkill(0x0027); //Cooking
  4921. return cmUpdFocus;
  4922. }
  4923. /**
  4924. * Handles the message sent when an avatar's Self attribute is incremented.
  4925. * Also updates the database value.
  4926. *
  4927. * @param exp - The amount of experience spent incrementing Self.
  4928. *
  4929. * @return cMessage - Returns an Update Attribute (0x00000241) server message.
  4930. */
  4931. cMessage cAvatar::UpdateSelf(DWORD exp)
  4932. {
  4933. char szCommand[512];
  4934. RETCODE retcode;
  4935. //When this message is fired, the "Raise Stat" button has already been pressed.
  4936. //The client will not let you click the "Raise" button if you don't have enough experience.
  4937. this->m_cStats.m_lpcAttributes[5].m_dwIncrement++;
  4938. //Add the increase to the database
  4939. sprintf( szCommand, "UPDATE avatar SET Self = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcAttributes[5].m_dwIncrement,this->GetGUID( ));
  4940. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4941. retcode = SQLExecute( cDatabase::m_hStmt );
  4942. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4943. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4944. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  4945. self_exp_cost += exp;
  4946. //Update database with the new total experience spent
  4947. sprintf( szCommand, "UPDATE avatar SET Slf_exp_spent = %i WHERE AvatarGUID = %lu;",self_exp_cost,this->GetGUID( ));
  4948. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4949. retcode = SQLExecute( cDatabase::m_hStmt );
  4950. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4951. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  4952. //The Update Self message
  4953. cMessage cmUpdSelf;
  4954. cmUpdSelf << 0x241L << 0x06L << this->m_cStats.m_lpcAttributes[5].m_dwIncrement << this->m_cStats.m_lpcAttributes[5].m_dwCurrent << self_exp_cost;
  4955. cMessage cSound = this->SoundEffect(118,1.0);
  4956. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  4957. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Self is now %d!",this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement);
  4958. //Skills affected by Self
  4959. CalcSkill(0x000F); //Magic Defense
  4960. CalcSkill(0x0010); //Mana Conversion
  4961. CalcSkill(0x0013); //Assess Person
  4962. CalcSkill(0x0014); //Deception
  4963. CalcSkill(0x0017); //Lockpick
  4964. CalcSkill(0x001B); //Assess Creature
  4965. CalcSkill(0x001F); //Creature Enchantment
  4966. CalcSkill(0x0020); //Item Enchantment
  4967. CalcSkill(0x0021); //Life Magic
  4968. CalcSkill(0x0022); //War Magic
  4969. //Vitals affected by Self
  4970. CalcVital(0x0002); //Mana
  4971. return cmUpdSelf;
  4972. }
  4973. //////////////////////////////////////
  4974. // Vital updates
  4975. //////////////////////////////////////
  4976. /**
  4977. * Calculates the total base value of a vital (Health, Stamina, Mana).
  4978. *
  4979. * The base value will be equal to the creation valu plus increments to the vital.
  4980. * The resultant value is used for server-side calculations; the client maintains its own value (which should match the server's value).
  4981. *
  4982. * @param vitalID - The numeric representation of the skill.
  4983. */
  4984. void cAvatar::CalcVital(WORD vitalID)
  4985. {
  4986. int vitalArrayNum = vitalID;
  4987. int total_vital;
  4988. total_vital = this->m_cStats.m_lpcVitals[vitalArrayNum].m_dwIncreases;
  4989. //Add the vital bonuses
  4990. switch(vitalID)
  4991. {
  4992. //The client rounds the result of attribute contributions to the vital level.
  4993. //Given that high accuracy is not required, flooring the value plus one-half is precise enough.
  4994. case 0x0000: //Health
  4995. {
  4996. total_vital += floor((double)(this->base_endurance + this->m_cStats.m_lpcAttributes[1].m_dwIncrement) / 2 + .5);
  4997. base_health = total_vital;
  4998. }
  4999. break;
  5000. case 0x0001: //Stamina
  5001. {
  5002. total_vital += this->base_endurance + this->m_cStats.m_lpcAttributes[1].m_dwIncrement;
  5003. base_stamina = total_vital;
  5004. }
  5005. break;
  5006. case 0x0002: //Mana
  5007. {
  5008. total_vital += this->base_self + this->m_cStats.m_lpcAttributes[5].m_dwIncrement;
  5009. base_mana = total_vital;
  5010. }
  5011. break;
  5012. }
  5013. this->m_cStats.m_lpcVitals[vitalArrayNum].m_dwCurrent = total_vital;
  5014. }
  5015. /**
  5016. * Handles the message sent when an avatar's Health vital is incremented.
  5017. * Also updates the database value.
  5018. *
  5019. * @param exp - The amount of experience spent incrementing Health.
  5020. *
  5021. * @return cMessage - Returns an Update Secondary Attribute (0x00000243) server message.
  5022. */
  5023. cMessage cAvatar::RaiseHealth(DWORD exp)
  5024. {
  5025. char szCommand[512];
  5026. RETCODE retcode;
  5027. //When this message is fired, the "Raise Stat" button has already been pressed.
  5028. //The client will not let you click the "Raise" button if you don't have enough experience.
  5029. this->m_cStats.m_lpcVitals[0].m_dwIncreases++;
  5030. this->m_cStats.m_lpcVitals[0].m_dwCurrent++;
  5031. base_health++;
  5032. //Add the increase to the database
  5033. sprintf( szCommand, "UPDATE avatar SET HealthInc = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcVitals[0].m_dwIncreases,this->GetGUID( ));
  5034. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5035. retcode = SQLExecute( cDatabase::m_hStmt );
  5036. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5037. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5038. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  5039. health_exp_cost += exp;
  5040. //Update database with the new total experience spent
  5041. sprintf( szCommand, "UPDATE avatar SET Hlt_exp_spent = %i WHERE AvatarGUID = %lu;",health_exp_cost,this->GetGUID( ));
  5042. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5043. retcode = SQLExecute( cDatabase::m_hStmt );
  5044. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5045. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5046. //The Update Health message
  5047. cMessage cmRaiseHealth;
  5048. cmRaiseHealth << 0x243L << 0x01L << this->m_cStats.m_lpcVitals[0].m_dwIncreases << 0L << health_exp_cost << this->m_cStats.m_lpcVitals[0].m_lTrueCurrent;
  5049. cMessage cSound = this->SoundEffect(118,1.0);
  5050. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  5051. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Maximum Health is now %d!",this->base_health);
  5052. return cmRaiseHealth;
  5053. }
  5054. /**
  5055. * Handles the message sent when an avatar's Stamina vital is incremented.
  5056. * Also updates the database value.
  5057. *
  5058. * @param exp - The amount of experience spent incrementing Stamina.
  5059. *
  5060. * @return cMessage - Returns an Update Secondary Attribute (0x00000243) server message.
  5061. */
  5062. cMessage cAvatar::RaiseStamina(DWORD exp)
  5063. {
  5064. char szCommand[512];
  5065. RETCODE retcode;
  5066. //When this message is fired, the "Raise Stat" button has already been pressed.
  5067. //The client will not let you click the "Raise" button if you don't have enough experience.
  5068. this->m_cStats.m_lpcVitals[1].m_dwIncreases++;
  5069. this->m_cStats.m_lpcVitals[1].m_dwCurrent++;
  5070. base_stamina++;
  5071. //Add the increase to the database
  5072. sprintf( szCommand, "UPDATE avatar SET StaminaInc = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcVitals[1].m_dwIncreases,this->GetGUID( ));
  5073. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5074. retcode = SQLExecute( cDatabase::m_hStmt );
  5075. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5076. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5077. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  5078. stamina_exp_cost += exp;
  5079. //Update database with the new total experience spent
  5080. sprintf( szCommand, "UPDATE avatar SET Sta_exp_spent = %i WHERE AvatarGUID = %lu;",stamina_exp_cost,this->GetGUID( ));
  5081. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5082. retcode = SQLExecute( cDatabase::m_hStmt );
  5083. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5084. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5085. //The Update Stamina message
  5086. cMessage cmRaiseStamina;
  5087. cmRaiseStamina << 0x243L << 0x03L << this->m_cStats.m_lpcVitals[1].m_dwIncreases << 0L << stamina_exp_cost << this->m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  5088. cMessage cSound = this->SoundEffect(118,1.0);
  5089. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  5090. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Maximum Stamina is now %d!",this->base_stamina);
  5091. return cmRaiseStamina;
  5092. }
  5093. /**
  5094. * Handles the message sent when an avatar's Mana vital is incremented.
  5095. * Also updates the database value.
  5096. *
  5097. * @param exp - The amount of experience spent incrementing Mana.
  5098. *
  5099. * @return cMessage - Returns an Update Secondary Attribute (0x00000243) server message.
  5100. */
  5101. cMessage cAvatar::RaiseMana(DWORD exp)
  5102. {
  5103. char szCommand[512];
  5104. RETCODE retcode;
  5105. //When this message is fired, the "Raise Stat" button has already been pressed.
  5106. //The client will not let you click the "Raise" button if you don't have enough experience.
  5107. this->m_cStats.m_lpcVitals[2].m_dwIncreases++;
  5108. this->m_cStats.m_lpcVitals[2].m_dwCurrent++;
  5109. base_mana++;
  5110. //Add the increase to the database
  5111. sprintf( szCommand, "UPDATE avatar SET ManaInc = %i WHERE AvatarGUID = %lu;",this->m_cStats.m_lpcVitals[2].m_dwIncreases,this->GetGUID( ));
  5112. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5113. retcode = SQLExecute( cDatabase::m_hStmt );
  5114. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5115. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5116. //Set the avatar's experience cost equal to that of exp_cost + exp sent in the game event message.
  5117. mana_exp_cost += exp;
  5118. //Update database with the new total experience spent
  5119. sprintf( szCommand, "UPDATE avatar SET Man_exp_spent = %i WHERE AvatarGUID = %lu;",mana_exp_cost,this->GetGUID( ));
  5120. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5121. retcode = SQLExecute( cDatabase::m_hStmt );
  5122. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5123. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5124. //The Update Mana message
  5125. cMessage cmRaiseMana;
  5126. cmRaiseMana << 0x243L << 0x05L << this->m_cStats.m_lpcVitals[2].m_dwIncreases << 0L << mana_exp_cost << this->m_cStats.m_lpcVitals[2].m_lTrueCurrent;
  5127. cMessage cSound = this->SoundEffect(118,1.0);
  5128. cWorldManager::SendToAllInFocus( this->m_Location, cSound, 3 );
  5129. cMasterServer::ServerMessage(ColorBlue,NULL,"Your base Maximum Mana is now %d!",this->base_mana);
  5130. return cmRaiseMana;
  5131. }
  5132. /**
  5133. * Handles the message sent when an avatar's Health vital is decremented.
  5134. *
  5135. * @param amount - The amount of Health to decrement.
  5136. * @param &newHealth - The address of an integer that will represent the avatar's new Health
  5137. *
  5138. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5139. */
  5140. cMessage cAvatar::DecrementHealth(WORD amount,signed int &newhealth)
  5141. {
  5142. m_cStats.m_lpcVitals[0].m_lTrueCurrent -= amount;
  5143. if (m_cStats.m_lpcVitals[0].m_lTrueCurrent < 0)
  5144. m_cStats.m_lpcVitals[0].m_lTrueCurrent = 0;
  5145. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5146. if (aFellowship)
  5147. {
  5148. aFellowship->RelayMemberUpdate(GetGUID());
  5149. }
  5150. newhealth = m_cStats.m_lpcVitals[0].m_lTrueCurrent;
  5151. cMessage cmRet;
  5152. cmRet << 0x244L << m_bStatSequence++ << 0x2L << static_cast<DWORD> (m_cStats.m_lpcVitals[0].m_lTrueCurrent);// << 0x3CL;
  5153. return cmRet;
  5154. }
  5155. /**
  5156. * Handles the message sent when an avatar's Stamina vital is decremented.
  5157. *
  5158. * @param amount - The amount of Stamina to decrement.
  5159. * @param &newstamina - The address of an integer that will represent the avatar's new Stamina
  5160. *
  5161. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5162. */
  5163. cMessage cAvatar::DecrementStamina(WORD amount,signed int &newstamina)
  5164. {
  5165. m_cStats.m_lpcVitals[1].m_lTrueCurrent -= amount;
  5166. if (m_cStats.m_lpcVitals[1].m_lTrueCurrent < 0)
  5167. m_cStats.m_lpcVitals[1].m_lTrueCurrent = 0;
  5168. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5169. if (aFellowship)
  5170. {
  5171. aFellowship->RelayMemberUpdate(GetGUID());
  5172. }
  5173. newstamina = m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  5174. cMessage cmRet;
  5175. cmRet << 0x244L << m_bStatSequence++ << 0x4L << static_cast<DWORD> (m_cStats.m_lpcVitals[1].m_lTrueCurrent);// << 0x3CL;
  5176. return cmRet;
  5177. }
  5178. /**
  5179. * Handles the message sent when an avatar's Mana vital is decremented.
  5180. *
  5181. * @param amount - The amount of Mana to decrement.
  5182. * @param &newmana - The address of an integer that will represent the avatar's new Mana
  5183. *
  5184. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5185. */
  5186. cMessage cAvatar::DecrementMana(WORD amount,signed int &newmana)
  5187. {
  5188. m_cStats.m_lpcVitals[2].m_lTrueCurrent -= amount;
  5189. if (m_cStats.m_lpcVitals[2].m_lTrueCurrent < 0)
  5190. m_cStats.m_lpcVitals[2].m_lTrueCurrent = 0;
  5191. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5192. if (aFellowship)
  5193. {
  5194. aFellowship->RelayMemberUpdate(GetGUID());
  5195. }
  5196. newmana = m_cStats.m_lpcVitals[2].m_lTrueCurrent;
  5197. cMessage cmRet;
  5198. cmRet << 0x244L << m_bStatSequence++ << 0x6L << static_cast<DWORD> (m_cStats.m_lpcVitals[2].m_lTrueCurrent);// << 0x3CL;
  5199. return cmRet;
  5200. }
  5201. /**
  5202. * Handles the message sent when an avatar's Health vital is changed.
  5203. *
  5204. * @param dwNewHealth - The new Health value.
  5205. *
  5206. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5207. */
  5208. cMessage cAvatar::SetHealth(DWORD dwNewHealth)
  5209. {
  5210. m_cStats.m_lpcVitals[0].m_lTrueCurrent = static_cast<DWORD>(dwNewHealth);
  5211. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5212. if (aFellowship)
  5213. {
  5214. aFellowship->RelayMemberUpdate(GetGUID());
  5215. }
  5216. cMessage cmRet;
  5217. cmRet << 0x244L << m_bStatSequence++ << 0x2L << dwNewHealth;
  5218. return cmRet;
  5219. }
  5220. /**
  5221. * Handles the message sent when an avatar's Stamina vital is changed.
  5222. *
  5223. * @param dwNewStamina - The new Stamina value.
  5224. *
  5225. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5226. */
  5227. cMessage cAvatar::SetStamina(DWORD dwNewStamina)
  5228. {
  5229. m_cStats.m_lpcVitals[1].m_lTrueCurrent = static_cast<DWORD>(dwNewStamina);
  5230. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5231. if (aFellowship)
  5232. {
  5233. aFellowship->RelayMemberUpdate(GetGUID());
  5234. }
  5235. cMessage cmRet;
  5236. cmRet << 0x244L << m_bStatSequence++ << 0x4L << dwNewStamina;
  5237. return cmRet;
  5238. }
  5239. /**
  5240. * Handles the message sent when an avatar's Mana vital is changed.
  5241. *
  5242. * @param dwNewMana - The new Mana value.
  5243. *
  5244. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5245. */
  5246. cMessage cAvatar::SetMana(DWORD dwNewMana)
  5247. {
  5248. m_cStats.m_lpcVitals[2].m_lTrueCurrent = static_cast<DWORD>(dwNewMana);
  5249. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5250. if (aFellowship)
  5251. {
  5252. aFellowship->RelayMemberUpdate(GetGUID());
  5253. }
  5254. cMessage cmRet;
  5255. cmRet << 0x244L << m_bStatSequence++ << 0x6L << dwNewMana;
  5256. return cmRet;
  5257. }
  5258. /**
  5259. * Handles the message sent when an avatar's Health vital is updated by an item (food, drink, potion, etc).
  5260. *
  5261. * @param amount - The amount by which the avatar's Health should increase.
  5262. * @param &newvalue - The address of an integer that will represent the avatar's new Health
  5263. *
  5264. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5265. */
  5266. cMessage cAvatar::UpdateHealth(WORD amount,signed int &newvalue )
  5267. {
  5268. m_cStats.m_lpcVitals[0].m_lTrueCurrent += amount;
  5269. if (m_cStats.m_lpcVitals[0].m_lTrueCurrent > m_cStats.m_lpcVitals[0].m_dwCurrent)
  5270. m_cStats.m_lpcVitals[0].m_lTrueCurrent = m_cStats.m_lpcVitals[0].m_dwCurrent;
  5271. newvalue = m_cStats.m_lpcVitals[0].m_lTrueCurrent;
  5272. cMessage cmRet;
  5273. cmRet << 0x244L << m_bStatSequence++ << 0x2L << static_cast<DWORD> (m_cStats.m_lpcVitals[0].m_lTrueCurrent);
  5274. return cmRet;
  5275. }
  5276. /**
  5277. * Handles the message sent when an avatar's Stamina vital is updated by an item (food, drink, potion, etc).
  5278. *
  5279. * @param amount - The amount by which the avatar's Stamina should increase.
  5280. * @param &newvalue - The address of an integer that will represent the avatar's new Stamina
  5281. *
  5282. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5283. */
  5284. cMessage cAvatar::UpdateStamina(WORD amount,signed int &newvalue )
  5285. {
  5286. m_cStats.m_lpcVitals[1].m_lTrueCurrent += amount;
  5287. if (m_cStats.m_lpcVitals[1].m_lTrueCurrent > m_cStats.m_lpcVitals[1].m_dwCurrent)
  5288. m_cStats.m_lpcVitals[1].m_lTrueCurrent = m_cStats.m_lpcVitals[1].m_dwCurrent;
  5289. newvalue = m_cStats.m_lpcVitals[1].m_lTrueCurrent;
  5290. cMessage cmRet;
  5291. cmRet << 0x244L << m_bStatSequence++ << 0x4L << static_cast<DWORD> (m_cStats.m_lpcVitals[1].m_lTrueCurrent);
  5292. return cmRet;
  5293. }
  5294. /**
  5295. * Handles the message sent when an avatar's Mana vital is updated by an item (food, drink, potion, etc).
  5296. *
  5297. * @param amount - The amount by which the avatar's Mana should increase.
  5298. * @param &newvalue - The address of an integer that will represent the avatar's new Mana
  5299. *
  5300. * @return cMessage - Returns an Update Vital Statistic (0x00000244) server message.
  5301. */
  5302. cMessage cAvatar::UpdateMana(WORD amount,signed int &newvalue )
  5303. {
  5304. m_cStats.m_lpcVitals[2].m_lTrueCurrent += amount;
  5305. if (m_cStats.m_lpcVitals[2].m_lTrueCurrent > m_cStats.m_lpcVitals[2].m_dwCurrent)
  5306. m_cStats.m_lpcVitals[2].m_lTrueCurrent = m_cStats.m_lpcVitals[2].m_dwCurrent;
  5307. newvalue = m_cStats.m_lpcVitals[2].m_lTrueCurrent;
  5308. cMessage cmRet;
  5309. cmRet << 0x244L << m_bStatSequence++ << 0x6L << static_cast<DWORD> (m_cStats.m_lpcVitals[2].m_lTrueCurrent);
  5310. return cmRet;
  5311. }
  5312. cMessage cAvatar::AdjustHealthBar(DWORD dwGUID, DWORD F7B0Sequence )
  5313. {
  5314. cMessage cmHealthLoss;
  5315. double flHealthStat = ((( double )100/ m_cStats.m_lpcVitals[0].m_dwCurrent)* m_cStats.m_lpcVitals[0].m_lTrueCurrent)/100;
  5316. cmHealthLoss << 0xF7B0L << dwGUID << F7B0Sequence << 0x01C0L << m_dwGUID << float(flHealthStat);
  5317. return cmHealthLoss;
  5318. }
  5319. /**
  5320. * Updates the avatar's level.
  5321. *
  5322. * The level is calculated based upon a formula that uses the avatar's total experience.
  5323. * Whether to award a skill credit is determined based upon pre-defined table entries.
  5324. *
  5325. * The resultant value is used for server-side calculations; the client maintains its own value (which should match the server's value).
  5326. */
  5327. cMessage cAvatar::UpdateLevel()
  5328. {
  5329. cMessage cmRet;
  5330. //The level formula; calculates the level that corresponds to the current total experience
  5331. int level = floor( ( pow( (double)(9 * m_dwTotalXP + 6^5),(double)(1 / 5.0) ) - 6) + 1 );
  5332. while (this->m_cStats.m_dwLevel < level && this->m_cStats.m_dwLevel < MAX_LEVEL)
  5333. {
  5334. this->m_cStats.m_dwLevel++;
  5335. int nextSkillCreditLevel;
  5336. char szCommand [200];
  5337. RETCODE retcode;
  5338. //Determine whether a skill credit will be received
  5339. sprintf( szCommand, "SELECT skill_credits FROM exp_table WHERE ID = %d;",this->m_bTotalSkillCredits + 1);
  5340. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5341. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5342. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &nextSkillCreditLevel, sizeof( nextSkillCreditLevel ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5343. retcode = SQLFetch( cDatabase::m_hStmt );
  5344. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5345. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5346. if (this->m_cStats.m_dwLevel == nextSkillCreditLevel)
  5347. {
  5348. this->m_bSkillCredits++;
  5349. this->m_bTotalSkillCredits++;
  5350. }
  5351. nextSkillCreditLevel = 0;
  5352. //Determine at what level the next skill credit (if any) will be received
  5353. sprintf( szCommand, "SELECT skill_credits FROM exp_table WHERE ID = %d;",this->m_bTotalSkillCredits + 1);
  5354. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5355. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5356. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &nextSkillCreditLevel, sizeof( nextSkillCreditLevel ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5357. retcode = SQLFetch( cDatabase::m_hStmt );
  5358. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5359. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5360. if (this->m_cStats.m_dwLevel == MAX_LEVEL)
  5361. {
  5362. cMessage cParticle = this->Particle(140);
  5363. cWorldManager::SendToAllInFocus( this->m_Location, cParticle, 3 );
  5364. cMasterServer::ServerMessage(ColorBlue,NULL,"You have reached the maximum level of %d!",MAX_LEVEL);
  5365. } else {
  5366. cMessage cParticle = this->Particle(137);
  5367. cWorldManager::SendToAllInFocus( this->m_Location, cParticle, 3 );
  5368. cMasterServer::ServerMessage(ColorBlue,NULL,"Congratulations, you are now level %d! You have %d skill credits and will gain another at level %d.",this->m_cStats.m_dwLevel,this->m_bSkillCredits,nextSkillCreditLevel);
  5369. }
  5370. }
  5371. return cmRet;
  5372. }
  5373. /**
  5374. * Handles the message sent for the avatar's animation when running towards a combat target.
  5375. *
  5376. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  5377. */
  5378. cMessage cAvatar::RunToAnimation(DWORD dwGUID,DWORD dwTarget)
  5379. {
  5380. cMessage cmRet;
  5381. cmRet << 0xF74CL
  5382. << &dwGUID // GUID
  5383. << WORD(0x3C) // numLogins
  5384. << WORD(0x19) // Seq
  5385. << WORD(0x00) // numAnimations
  5386. << WORD(0x01) // activity 0x0 idle 0x1 active
  5387. << WORD(0x00) // Unkown
  5388. << 0x00000081 // Animation Flags
  5389. << WORD(0x07) //
  5390. << WORD(0x07) // Run
  5391. << WORD(0x3D) // Animation2
  5392. << 2.0f; // numAnimations
  5393. //<< ;
  5394. return cmRet;
  5395. }
  5396. /**
  5397. * Handles the message sent for the avatar's animation when turning towards a combat target.
  5398. *
  5399. * @return cMessage - Returns an Animation (0x0000F74C) server message.
  5400. */
  5401. cMessage cAvatar::TurnToTarget( float flHeading, DWORD dwTargetGUID )
  5402. {
  5403. cMessage cmTurnToTarget;
  5404. cmTurnToTarget << 0xF74CL
  5405. << m_dwGUID
  5406. << m_wNumLogins
  5407. << ++m_wCurAnim
  5408. << ++m_wMeleeSequence
  5409. << WORD(0x0000)
  5410. << BYTE(0x08)
  5411. << BYTE(0x00)
  5412. << WORD(0x0000) //stance: 0x0000 to finish with previous stance
  5413. << dwTargetGUID
  5414. << flHeading
  5415. << 0x1231EE0F //0x1139EE0F - old value, 0x00000000 doesn't end the cast animation
  5416. << 0x3F800000 //1.0f
  5417. << 0x00000000;
  5418. return cmTurnToTarget;
  5419. }
  5420. // End Combat Routines
  5421. //////////////////////////////////////
  5422. // Fellowship Commands
  5423. //////////////////////////////////////
  5424. /**
  5425. * Handles the creation of a fellowship.
  5426. *
  5427. * @param F7B0Sequence - The client's present F7B0 sequence value.
  5428. * @param strFellowName - The fellowship's name.
  5429. */
  5430. void cAvatar::CreateFellowship( DWORD F7B0Sequence, char strFellowName[50] )
  5431. {
  5432. cClient* pcClient = cClient::FindClient(m_dwGUID);
  5433. /*
  5434. Fellowship Settings:
  5435. 0x00000008 = Accept Fellowship Requests uncheckmarked
  5436. 0x00040000 = Share Fellowship Experience checkmarked
  5437. 0x00100000 = Share Fellowship Loot/Treasure checkmarked
  5438. 0x20000000 = Auto-Accept Fellowship Requests checkmarked
  5439. */
  5440. bool shareXP, shareLoot;
  5441. (this->m_dwOptions & 0x00040000) ? shareXP = true : shareXP = false;
  5442. (this->m_dwOptions & 0x00100000) ? shareLoot = true : shareLoot = false;
  5443. SetFellowshipID(cFellowship::NewFellowship(this->GetGUID(), this->Name(), strFellowName, shareXP, shareLoot));
  5444. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5445. if (aFellowship)
  5446. {
  5447. this->inFellow = true;
  5448. }
  5449. }
  5450. /**
  5451. * Handles the quitting from or disbanding of a fellowship.
  5452. */
  5453. void cAvatar::DisbandFellowship( )
  5454. {
  5455. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5456. aFellowship->RemMember(GetGUID());
  5457. SetFellowshipID(0);
  5458. this->inFellow = false;
  5459. }
  5460. /**
  5461. * Encapsulates messages sent to sender after an offer of fellowship is accepted or declined.
  5462. *
  5463. * @param szTargetName - The target character's name.
  5464. * @param dwReply - The reply (yes/no) to the offer of fellowship.
  5465. * @param dwReceiptGUID - The target character's GUID.
  5466. */
  5467. void cAvatar::FellowshipRecruitSend(std::string szTargetName, DWORD dwReply, DWORD dwReceiptGUID)
  5468. {
  5469. cClient* pcClient = cClient::FindClient(m_dwGUID);
  5470. cClient* pcRecvClient = cClient::FindClient(dwReceiptGUID);
  5471. if (pcRecvClient->m_pcAvatar)
  5472. {
  5473. cMessage cmRecruitText;
  5474. char szTextBuffer[255];
  5475. DWORD dwColor = 0x17L;
  5476. if (dwReply == 1)
  5477. {
  5478. sprintf(&szTextBuffer[0],"%s is now a member of your Fellowship.", pcRecvClient->m_pcAvatar->Name());
  5479. }
  5480. else
  5481. {
  5482. sprintf(&szTextBuffer[0],"%s has declined your offer of fellowship.", pcRecvClient->m_pcAvatar->Name());
  5483. }
  5484. cmRecruitText << 0xF62CL << szTextBuffer << dwColor;
  5485. pcClient->AddPacket( WORLD_SERVER, cmRecruitText, 4 );
  5486. }
  5487. }
  5488. /**
  5489. * Encapsulates messages sent to receiver after an offer of fellowship is accepted or declined.
  5490. *
  5491. * @param szTargetName - The sending character's name.
  5492. * @param dwReply - The reply (yes/no) to the offer of fellowship.
  5493. * @param dwSenderGUID - The sending character's GUID.
  5494. */
  5495. void cAvatar::FellowshipRecruitRecv(std::string szTargetName, DWORD dwReply, DWORD dwSenderGUID)
  5496. {
  5497. cClient* pcClient = cClient::FindClient(m_dwGUID);
  5498. cClient* pcSendClient = cClient::FindClient(dwSenderGUID);
  5499. if (pcSendClient->m_pcAvatar)
  5500. {
  5501. if (dwReply == 1)
  5502. {
  5503. // add the avatar to the fellowship
  5504. cAvatar* pcRecruitAvatar = pcSendClient->m_pcAvatar;
  5505. cFellowship* aFellowship = cFellowship::GetFellowshipByID(pcRecruitAvatar->m_dwFellowshipID);
  5506. aFellowship->AddMember(pcClient->m_pcAvatar->GetGUID());
  5507. this->inFellow = true;
  5508. SetFellowshipID(pcRecruitAvatar->m_dwFellowshipID);
  5509. cMessage cmRecruitText;
  5510. char szTextBuffer[255];
  5511. DWORD dwColor = 0x17L;
  5512. sprintf(&szTextBuffer[0],"You have been recruited into the %s fellowship, a fellowship led by %s.", aFellowship->GetName().c_str(), pcSendClient->m_pcAvatar->Name());
  5513. cmRecruitText << 0xF62CL << szTextBuffer << dwColor;
  5514. pcClient->AddPacket( WORLD_SERVER, cmRecruitText, 4 );
  5515. }
  5516. else
  5517. {
  5518. }
  5519. }
  5520. }
  5521. /**
  5522. * Removes a character from the fellowship and relays the relevant messages.
  5523. *
  5524. * @param dwMemberGUID - The GUID of the character to remove.
  5525. */
  5526. void cAvatar::FellowshipDismiss( DWORD dwMemberGUID )
  5527. {
  5528. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5529. if (aFellowship)
  5530. {
  5531. if (aFellowship->m_LeaderGUID == this->GetGUID())
  5532. {
  5533. aFellowship->DismissMember(dwMemberGUID);
  5534. }
  5535. }
  5536. }
  5537. /**
  5538. * Sets a fellowship open or closed and relays the relevant messages.
  5539. *
  5540. * @param dwOpen - Determines whether the fellowship is opened or closed (0 = closed; 1 = opened).
  5541. */
  5542. void cAvatar::OpenCloseFellowship( DWORD dwOpen )
  5543. {
  5544. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5545. if (aFellowship)
  5546. {
  5547. if (aFellowship->m_LeaderGUID == this->GetGUID())
  5548. {
  5549. aFellowship->SetOpenClose(dwOpen);
  5550. }
  5551. }
  5552. }
  5553. /**
  5554. * Promotes a character to fellowship leader and relays the relevant messages.
  5555. *
  5556. * @param dwNewLeaderGUID - The GUID of the character to promote.
  5557. */
  5558. void cAvatar::FellowshipLeader( DWORD dwNewLeaderGUID )
  5559. {
  5560. cFellowship* aFellowship = cFellowship::GetFellowshipByID(GetFellowshipID());
  5561. if (aFellowship)
  5562. {
  5563. if (aFellowship->m_LeaderGUID == this->GetGUID())
  5564. {
  5565. aFellowship->SetLeader(dwNewLeaderGUID);
  5566. }
  5567. }
  5568. }
  5569. /**
  5570. * Handles the message sent for an avatar's housing information.
  5571. * Also updates the respective database entries.
  5572. *
  5573. * @return cMessage - Returns a Game Event (0x0000F7B0) server message of type House Information for Non-Owners (0x00000226).
  5574. */
  5575. cMessage cAvatar::HouseAbandon( DWORD F7B0seq )
  5576. {
  5577. cMessage cmReturn;
  5578. cmReturn << 0xF7B0L
  5579. << GetGUID( )
  5580. << F7B0seq; // sequence number
  5581. if(!m_wHouseID)
  5582. {
  5583. //cMasterServer::ServerMessage(ColorGreen,this,"You must own a house to use this command!");
  5584. } else {
  5585. char szCommand[250];
  5586. RETCODE retcode;
  5587. char CovGUIDBuf[9];
  5588. DWORD CovGUID;
  5589. sprintf( szCommand, "SELECT GUID from houses_covenants WHERE HouseID = %d;",m_wHouseID );
  5590. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5591. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5592. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_CHAR, &CovGUIDBuf, sizeof( CovGUIDBuf ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  5593. if (SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS)
  5594. {
  5595. sscanf(CovGUIDBuf,"%08x",&CovGUID);
  5596. }
  5597. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5598. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5599. sprintf( szCommand, "UPDATE houses_covenants SET OwnerID = %d WHERE GUID = '%08x';",0,CovGUID );
  5600. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5601. retcode = SQLExecute( cDatabase::m_hStmt );
  5602. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5603. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5604. UpdateConsole (szCommand);
  5605. sprintf( szCommand, "UPDATE houses SET OwnerID = %d WHERE wModel = %d;",0,m_wHouseID );
  5606. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5607. retcode = SQLExecute( cDatabase::m_hStmt );
  5608. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5609. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5610. sprintf( szCommand, "UPDATE houses_purchase SET Paid = %d WHERE wModel = %d;",0,m_wHouseID );
  5611. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5612. retcode = SQLExecute( cDatabase::m_hStmt );
  5613. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5614. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5615. m_wHouseID = NULL;
  5616. cmReturn << 0x226L;
  5617. cMasterServer::ServerMessage(ColorGreen,NULL,"You abandon your house!");
  5618. }
  5619. return cmReturn;
  5620. }
  5621. /**
  5622. * Adds a guest to the avatar's house guest list database entries.
  5623. *
  5624. * @param strGuestName - The name of the guest to add.
  5625. */
  5626. void cAvatar::HouseGuestAdd( char strGuestName[50] )
  5627. {
  5628. if (m_wHouseID)
  5629. {
  5630. char szCommand[512];
  5631. RETCODE retcode;
  5632. UINT dwGuestGUID;
  5633. WORD wGuestCount = 0;
  5634. char szPacket[60];
  5635. sprintf( szCommand, "SELECT AvatarGUID FROM avatar WHERE Name = '%s';",strGuestName );
  5636. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5637. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5638. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwGuestGUID, sizeof( dwGuestGUID ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5639. retcode = SQLFetch( cDatabase::m_hStmt );
  5640. if( retcode == SQL_NO_DATA )
  5641. {
  5642. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5643. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5644. cMasterServer::ServerMessage(ColorGreen,NULL,"That character does not exist.");
  5645. } else {
  5646. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5647. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5648. sprintf( szCommand, "SELECT COUNT(ID) FROM houses_guest_lists WHERE HouseID = %d AND GuestGUID = %d;",m_wHouseID,dwGuestGUID );
  5649. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5650. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5651. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &wGuestCount, sizeof( wGuestCount ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5652. retcode = SQLFetch( cDatabase::m_hStmt );
  5653. if( wGuestCount > 0)
  5654. {
  5655. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5656. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5657. sprintf (szPacket, "%s is already on your guest list.",strGuestName);
  5658. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5659. } else {
  5660. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5661. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5662. sprintf( szCommand, "INSERT INTO houses_guest_lists ( HouseID,GuestGUID,StorageAccess ) VALUES (%lu,%lu,%d);",m_wHouseID,dwGuestGUID,0 );
  5663. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5664. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5665. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5666. sprintf (szPacket, "%s has been added to your guest list.",strGuestName);
  5667. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5668. }
  5669. }
  5670. }
  5671. }
  5672. /**
  5673. * Removes a guest from the avatar's house guest list database entries.
  5674. *
  5675. * @param strGuestName - The name of the guest to remove.
  5676. */
  5677. void cAvatar::HouseGuestRemoveName( char strGuestName[50] )
  5678. {
  5679. if (m_wHouseID)
  5680. {
  5681. char szCommand[512];
  5682. RETCODE retcode;
  5683. UINT dwGuestGUID;
  5684. WORD wGuestCount = 0;
  5685. char szPacket[60];
  5686. sprintf( szCommand, "SELECT AvatarGUID FROM avatar WHERE Name = '%s';",strGuestName );
  5687. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5688. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5689. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwGuestGUID, sizeof( dwGuestGUID ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5690. retcode = SQLFetch( cDatabase::m_hStmt );
  5691. if( retcode == SQL_NO_DATA )
  5692. {
  5693. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5694. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5695. cMasterServer::ServerMessage(ColorGreen,NULL,"That character does not exist.");
  5696. } else {
  5697. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5698. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5699. sprintf( szCommand, "SELECT COUNT(ID) FROM houses_guest_lists WHERE HouseID = %d AND GuestGUID = %lu;",m_wHouseID,dwGuestGUID );
  5700. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5701. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5702. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &wGuestCount, sizeof( wGuestCount ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5703. retcode = SQLFetch( cDatabase::m_hStmt );
  5704. if( wGuestCount > 0)
  5705. {
  5706. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5707. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5708. sprintf( szCommand, "DELETE FROM houses_guest_lists WHERE HouseID = %d AND GuestGUID = %lu;",m_wHouseID,dwGuestGUID );
  5709. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5710. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5711. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5712. sprintf (szPacket, "You have removed %s from your guest list.",strGuestName);
  5713. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5714. } else {
  5715. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5716. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5717. sprintf (szPacket, "%s is not on your guest list.",strGuestName);
  5718. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5719. }
  5720. }
  5721. }
  5722. }
  5723. /**
  5724. * The open/closed value of the avatar's house database entry.
  5725. *
  5726. * @param dwIsOpen - A value representing whether the house is now open or closed.
  5727. */
  5728. void cAvatar::HouseOpenClose( DWORD dwIsOpen )
  5729. {
  5730. if (m_wHouseID)
  5731. {
  5732. char szCommand[512];
  5733. RETCODE retcode;
  5734. DWORD dwWasOpen;
  5735. sprintf( szCommand, "SELECT isOpen FROM houses WHERE wModel = %d;",m_wHouseID );
  5736. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5737. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5738. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwWasOpen, sizeof( dwWasOpen ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5739. retcode = SQLFetch( cDatabase::m_hStmt );
  5740. if( retcode == SQL_NO_DATA )
  5741. {
  5742. //cMasterServer::ServerMessage(ColorGreen,this,"You must own a house to use this command.");
  5743. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5744. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5745. } else {
  5746. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5747. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5748. if (dwWasOpen == 1 && dwIsOpen == 1)
  5749. {
  5750. cMasterServer::ServerMessage(ColorGreen,NULL,"You already have an open house.");
  5751. } else if (dwWasOpen == 0 && dwIsOpen == 0) {
  5752. cMasterServer::ServerMessage(ColorGreen,NULL,"You already have a closed house.");
  5753. } else {
  5754. sprintf( szCommand, "UPDATE houses SET isOpen = %d WHERE OwnerID = (%d);",dwIsOpen, GetGUID( ) );
  5755. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5756. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5757. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5758. if (dwIsOpen == 1)
  5759. {
  5760. cMasterServer::ServerMessage(ColorGreen,NULL,"Your house is now open to the public.");
  5761. } else {
  5762. cMasterServer::ServerMessage(ColorGreen,NULL,"Your house is now closed to the public.");
  5763. }
  5764. }
  5765. }
  5766. }
  5767. }
  5768. /**
  5769. * Updates the storage permission for a guess on the avatar's house guest list database entries.
  5770. *
  5771. * @param strGuestName - The name of the guest to whose permissions should be modified.
  5772. * @param dwStorageSet - A value representing whether access to storage is permitted or revoked.
  5773. */
  5774. void cAvatar::HouseStorage( char strGuestName[50], DWORD dwStorageSet )
  5775. {
  5776. if (m_wHouseID)
  5777. {
  5778. char szCommand[512];
  5779. RETCODE retcode;
  5780. char GuestIDBuff[9];
  5781. DWORD GuestID;
  5782. WORD wGuestCount = 0;
  5783. DWORD StorageOpen;
  5784. char szPacket[60];
  5785. sprintf( szCommand, "SELECT AvatarGUID FROM avatar WHERE Name = '%s';",strGuestName );
  5786. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5787. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5788. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_CHAR, GuestIDBuff, sizeof( GuestIDBuff ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5789. retcode = SQLFetch( cDatabase::m_hStmt );
  5790. if( retcode == SQL_NO_DATA )
  5791. {
  5792. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5793. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5794. cMasterServer::ServerMessage(ColorGreen,NULL,"That character does not exist.");
  5795. } else {
  5796. sscanf(GuestIDBuff,"%08x",&GuestID);
  5797. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5798. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5799. sprintf( szCommand, "SELECT StorageAccess FROM houses_guest_lists WHERE HouseID = %d AND GuestGUID = %d;",m_wHouseID,GuestID );
  5800. retcode = SQLPrepare( cDatabase::m_hStmt, (BYTE *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5801. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5802. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &StorageOpen, sizeof( StorageOpen ), NULL ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5803. retcode = SQLFetch( cDatabase::m_hStmt );
  5804. if( retcode == SQL_NO_DATA )
  5805. {
  5806. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5807. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5808. sprintf (szPacket, "%s must be on your guest list to be given access to your home's storage.",strGuestName);
  5809. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5810. } else {
  5811. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5812. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5813. if(dwStorageSet == 1)
  5814. {
  5815. if (StorageOpen == 1)
  5816. {
  5817. sprintf (szPacket, "%s has already been given access to your home's storage.",strGuestName);
  5818. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5819. } else {
  5820. sprintf( szCommand, "UPDATE houses_guest_lists SET StorageAccess = %d WHERE HouseID = %d AND GuestGUID = %d;",1,m_wHouseID,GuestID );
  5821. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5822. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5823. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5824. sprintf (szPacket, "You have granted %s access to your home's storage. This is denoted by the asterisk next to their name in the guest list.",strGuestName);
  5825. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5826. }
  5827. } else {
  5828. if (StorageOpen == 1)
  5829. {
  5830. sprintf( szCommand, "UPDATE houses_guest_lists SET StorageAccess = %d WHERE HouseID = %d AND GuestGUID = %d;",0,m_wHouseID,GuestID );
  5831. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5832. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5833. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5834. sprintf (szPacket, "You have removed access to your home's storage from %s. This is denoted by the asterisk next to their name in the guest list.",strGuestName);
  5835. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5836. } else {
  5837. sprintf (szPacket, "%s does not currently have access to your home's storage.",strGuestName);
  5838. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5839. }
  5840. }
  5841. }
  5842. }
  5843. }
  5844. }
  5845. void cAvatar::HouseBootName( char strGuestName[50] ) { }
  5846. /**
  5847. * Removes all guests on the avatar's house guest list database entries.
  5848. */
  5849. void cAvatar::HouseStorageRemoveAll( )
  5850. {
  5851. if (m_wHouseID)
  5852. {
  5853. char szCommand[512];
  5854. RETCODE retcode;
  5855. char szPacket[60];
  5856. sprintf( szCommand, "UPDATE houses_guest_lists SET StorageAccess = %d WHERE HouseID = %d;",0,m_wHouseID );
  5857. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5858. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5859. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  5860. sprintf (szPacket, "You remove item storage permission from all your guests.");
  5861. cMasterServer::ServerMessage(ColorGreen,NULL,(char *)szPacket);
  5862. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5863. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5864. }
  5865. }
  5866. /**
  5867. * Handles the message sent for an avatar's housing guest list.
  5868. *
  5869. * @return cMessage - Returns a Game Event (0x0000F7B0) server message of type House Guest List (0x00000257).
  5870. */
  5871. cMessage cAvatar::HouseGuestList( DWORD F7B0seq )
  5872. {
  5873. cMessage cmReturn;
  5874. cmReturn << 0xF7B0L << GetGUID( ) << F7B0seq << 0x0257L;
  5875. char szCommand[250];
  5876. RETCODE retcode;
  5877. WORD IsOpen;
  5878. WORD AllegPerm = 0;
  5879. WORD wGuestCount = 0;
  5880. UINT dwGuestGUID;
  5881. DWORD StorageOpen;
  5882. char strGuestName[50];
  5883. std::string strName = "";
  5884. sprintf( szCommand, "SELECT isOpen FROM houses WHERE wModel = %d;",m_wHouseID );
  5885. //sprintf( szCommand, "SELECT OwnerID,wModel,isOpen FROM houses WHERE OwnerID = %d;",GetGUID( ) );
  5886. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5887. retcode = SQLExecute( cDatabase::m_hStmt );
  5888. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_SHORT, &IsOpen, sizeof( IsOpen ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  5889. retcode = SQLFetch( cDatabase::m_hStmt );
  5890. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5891. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5892. //cMasterServer::ServerMessage(ColorGreen,this,"Guest List:");
  5893. sprintf( szCommand, "SELECT COUNT(ID) FROM houses_guest_lists WHERE HouseID=%d;",m_wHouseID );
  5894. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5895. retcode = SQLExecute( cDatabase::m_hStmt );
  5896. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_SHORT, &wGuestCount, sizeof( wGuestCount ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  5897. retcode = SQLFetch( cDatabase::m_hStmt );
  5898. if( retcode == SQL_NO_DATA ) { wGuestCount = 0; }
  5899. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5900. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL )
  5901. BYTE houseBYTE = 0x00;
  5902. if (IsOpen == 1)
  5903. {
  5904. houseBYTE = houseBYTE | BYTE(0x01);
  5905. }
  5906. // Dwelling access control list
  5907. cmReturn << 0x10000002 // DWORD flags -- believed to be flags that control the size and content of this structure
  5908. << houseBYTE // xxx1 = open house; xx1x = allegiance guest; x1xx = allegiance storage
  5909. << BYTE(0x00) // WORD open: 0 = private dwelling, 1 = open to public
  5910. << WORD(0x0000) // unknown
  5911. << 0x00000000 // ObjectID allegiance -- allegiance monarch (if allegiance access granted)
  5912. << wGuestCount // WORD guestCount -- number of guests on list
  5913. << WORD(0x0300);// WORD guestLimit -- Maximum number of guests on guest list (cottage is 32)
  5914. //sprintf( szCommand, "SELECT GuestGUID,StorageAccess FROM houses_guest_lists WHERE HouseID=%d;",HouseID );
  5915. sprintf( szCommand, "SELECT houses_guest_lists.GuestGUID,houses_guest_lists.StorageAccess,avatar.Name FROM {oj houses_guest_lists LEFT OUTER JOIN avatar ON houses_guest_lists.GuestGUID=avatar.AvatarGUID} WHERE houses_guest_lists.HouseID=%d;",m_wHouseID );
  5916. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5917. retcode = SQLExecute( cDatabase::m_hStmt );
  5918. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &dwGuestGUID, sizeof( dwGuestGUID ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  5919. retcode = SQLBindCol( cDatabase::m_hStmt, 2, SQL_C_ULONG, &StorageOpen, sizeof( WORD ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5920. retcode = SQLBindCol( cDatabase::m_hStmt, 3, SQL_C_CHAR, strGuestName, sizeof( strGuestName ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5921. for ( int i = 0; SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS; ++i )
  5922. {
  5923. cmReturn << DWORD(dwGuestGUID) << StorageOpen; //0x0000 = access to dwelling; 0x0001 = access also to storage;
  5924. strName.assign(strGuestName);
  5925. cmReturn << strName.c_str(); // Guest's Name
  5926. }
  5927. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5928. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  5929. cmReturn << 0x00000000; // Number of GUIDs that follow?
  5930. //cmGuestList << m_pcAvatar->GetGUID( );//Unknown GUID
  5931. //if (IsOpen) { cMasterServer::ServerMessage(ColorGreen,this,"[ open house ]"); }
  5932. return cmReturn;
  5933. }
  5934. DWORD cAvatar::CalculateDamage( cObject *pcWeapon, float flPower, float flResistance )
  5935. {
  5936. srand( timeGetTime( ) );
  5937. int iRand = rand( );
  5938. iRand = (iRand > 6400) ? iRand % 6400 : iRand;
  5939. iRand = (iRand < 1600) ? 1600 + iRand : iRand;
  5940. double dLuckFactor = 3200.0f / (double)iRand;
  5941. // MaxDamage = (Strength * 0.2 * (flPower + 1.15)) / (flResistance + 5.0)
  5942. // This is the old formula
  5943. double dMaxDamage = (double)((m_cStats.m_lpcAttributes[0].m_dwCurrent - 55 * 0.11f) * ((flPower + .25f) * 4)) / (double)(flResistance + 7.5f);
  5944. // Cubem0j0: New formula
  5945. //double dMaxDamage = 0.11f * (m_cStats.m_lpcAttributes[0].m_dwCurrent-55)+1;
  5946. return dMaxDamage * dLuckFactor + (rand( ) % 2);
  5947. }
  5948. void cAvatar::CreateChildren( cClient *pcClientDestination )
  5949. {
  5950. /*cMessage cmReturn;
  5951. fGotObject = FALSE;
  5952. static iterObject_lst itObject = m_lstInventory.begin( );
  5953. iterObject_lst itObjectReturn;
  5954. if( m_lstInventory.size() > 0 )
  5955. {
  5956. while ( ( itObject != m_lstInventory.end( ) ) && ( !fGotObject ) )
  5957. {
  5958. if( ( *itObject )->m_fEquipped )
  5959. {
  5960. itObjectReturn = itObject;
  5961. ++itObject;
  5962. fGotObject = TRUE;
  5963. }
  5964. else
  5965. ++itObject;
  5966. }
  5967. if( fGotObject )
  5968. return ( *itObjectReturn )->CreatePacket( );
  5969. else
  5970. itObject = m_lstInventory.begin( );
  5971. return cmReturn;
  5972. }
  5973. else
  5974. {
  5975. itObject = m_lstInventory.begin( );
  5976. return cmReturn;
  5977. }*/
  5978. for ( iterObject_lst itObject = m_lstInventory.begin( ); itObject != m_lstInventory.end( ); ++itObject )
  5979. if ( ( *itObject )->m_fEquipped == 1)
  5980. pcClientDestination->AddPacket( WORLD_SERVER, ( *itObject )->CreatePacket( ), 3 );
  5981. }
  5982. float cAvatar::GetRange ( DWORD dwLandblock, float flX, float flY, float flZ, DWORD dwTargetLandblock, float flTarX, float flTarY, float flTarZ )
  5983. {
  5984. float nsCoord,ewCoord;
  5985. float nsTarCoord,ewTarCoord;
  5986. float intRange;
  5987. nsCoord = (((((dwLandblock & 0x00FF0000) / 0x0010000) & 0xFF) + 1) * 8) + static_cast<float>(flY / 24) - 1027.5;
  5988. ewCoord = (((((dwLandblock & 0xFF000000) / 0x1000000) & 0xFF) + 1) * 8) + static_cast<float>(flX / 24) - 1027.5;
  5989. nsTarCoord = (((((dwTargetLandblock & 0x00FF0000) / 0x0010000) & 0xFF) + 1) * 8) + static_cast<float>(flTarY / 24) - 1027.5;
  5990. ewTarCoord = (((((dwTargetLandblock & 0xFF000000) / 0x1000000) & 0xFF) + 1) * 8) + static_cast<float>(flTarX / 24) - 1027.5;
  5991. intRange = sqrt(pow(nsTarCoord - nsCoord,2) + pow(ewTarCoord - ewCoord,2));
  5992. return intRange;
  5993. }
  5994. float cAvatar::GetHeadingTarget( DWORD dwLandblock, float flX, float flY, float flZ, DWORD dwTargetLandblock, float flTarX, float flTarY, float flTarZ )
  5995. {
  5996. float nsCoord,ewCoord;
  5997. float nsTarCoord,ewTarCoord;
  5998. float flHeading;
  5999. float intRange;
  6000. flHeading = 0.0f;
  6001. nsCoord = (((((dwLandblock & 0x00FF0000) / 0x0010000) & 0xFF) + 1) * 8) + static_cast<float>(flY / 24) - 1027.5;
  6002. ewCoord = (((((dwLandblock & 0xFF000000) / 0x1000000) & 0xFF) + 1) * 8) + static_cast<float>(flX / 24) - 1027.5;
  6003. nsTarCoord = (((((dwTargetLandblock & 0x00FF0000) / 0x0010000) & 0xFF) + 1) * 8) + static_cast<float>(flTarY / 24) - 1027.5;
  6004. ewTarCoord = (((((dwTargetLandblock & 0xFF000000) / 0x1000000) & 0xFF) + 1) * 8) + static_cast<float>(flTarX / 24) - 1027.5;
  6005. intRange = sqrt(pow(nsTarCoord - nsCoord,2) + pow(ewTarCoord - ewCoord,2));
  6006. if(intRange > 0)
  6007. {
  6008. if(nsTarCoord - nsCoord < 0 )
  6009. {
  6010. flHeading = acos((ewTarCoord - ewCoord) / intRange) * 57.2957796;
  6011. }
  6012. else
  6013. {
  6014. flHeading = acos(-(ewTarCoord - ewCoord) / intRange) * 57.2957796 + 180;
  6015. }
  6016. }
  6017. return flHeading;
  6018. }
  6019. /**
  6020. * Handles the assessment of avatars.
  6021. *
  6022. * This function is called whenever an avatar is assessed by another client.
  6023. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  6024. */
  6025. void cAvatar::Assess(cClient *pcAssesser)
  6026. {
  6027. cMessage cmAssess;
  6028. WORD wAnimation;
  6029. wAnimation = 0x54L;
  6030. std::string monarchName = "";
  6031. std::string patronName = "";
  6032. DWORD playerRank = 0xFFFFFFFF;
  6033. DWORD monarchFollowers = 0xFFFFFFFF;
  6034. if (cAllegiance* aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID))
  6035. {
  6036. DWORD monarchGUID = DWORD(aAllegiance->GetLeader()); // Monarch's GUID
  6037. Member monarchRecord = aAllegiance->members.find(monarchGUID)->second; // Monarch's allegiance record
  6038. monarchFollowers = monarchRecord.m_dwFollowers; // Monarchs number of followers
  6039. // Do not display the monarch name if the player is the monarch
  6040. if (m_dwGUID != aAllegiance->GetLeader())
  6041. {
  6042. monarchName = aAllegiance->members.find(monarchGUID)->second.m_szName; // Monarch's Name
  6043. }
  6044. Member playerRecord = aAllegiance->members.find(m_dwGUID)->second; // Player's allegiance record
  6045. playerRank = DWORD(playerRecord.m_bRank); // Player's allegiance rank
  6046. if (m_dwGUID != aAllegiance->GetLeader())
  6047. {
  6048. DWORD patronGUID = playerRecord.m_dwPatron; // Patron's GUID
  6049. patronName = aAllegiance->members.find(patronGUID)->second.m_szName; // Patron's Name
  6050. }
  6051. }
  6052. DWORD flags;
  6053. DWORD dwCharacterFlags; // Needs Decoding
  6054. flags = 0x00000100L; // Flags 0x00000100 - Character Data
  6055. dwCharacterFlags = 0x0000000EL; // 0x04 - Level, Health | 0x08 - Stats | 0x02 - Miscellaneous
  6056. cmAssess << 0xF7B0L
  6057. << pcAssesser->m_pcAvatar->GetGUID( )
  6058. << ++pcAssesser->m_dwF7B0Sequence
  6059. << 0x000000C9L
  6060. << m_dwGUID
  6061. << flags
  6062. << 0x1L; // Success: 0 = False; 1 = True
  6063. // Process the flag-specified data
  6064. if (flags & 0x00000100)
  6065. {
  6066. cmAssess << dwCharacterFlags;
  6067. if (dwCharacterFlags & 0x00000004) // Mask 0x04
  6068. {
  6069. cmAssess << m_cStats.m_dwLevel //Level (0 if assess fails)
  6070. << m_cStats.m_lpcVitals[0].m_lTrueCurrent //Current Health
  6071. << m_cStats.m_lpcVitals[0].m_dwCurrent; //Maximum Health
  6072. }
  6073. if (dwCharacterFlags & 0x00000008) // Mask 0x08
  6074. {
  6075. cmAssess << m_cStats.m_lpcAttributes[0].m_dwCurrent + m_cStats.m_lpcAttributes[0].m_dwIncrement//m_cStats.m_dwStr
  6076. << m_cStats.m_lpcAttributes[1].m_dwCurrent + m_cStats.m_lpcAttributes[1].m_dwIncrement//m_cStats.m_dwEnd
  6077. << m_cStats.m_lpcAttributes[2].m_dwCurrent + m_cStats.m_lpcAttributes[2].m_dwIncrement//m_cStats.m_dwQuick
  6078. << m_cStats.m_lpcAttributes[3].m_dwCurrent + m_cStats.m_lpcAttributes[3].m_dwIncrement//m_cStats.m_dwCoord
  6079. << m_cStats.m_lpcAttributes[4].m_dwCurrent + m_cStats.m_lpcAttributes[4].m_dwIncrement//m_cStats.m_dwFocus
  6080. << m_cStats.m_lpcAttributes[5].m_dwCurrent + m_cStats.m_lpcAttributes[5].m_dwIncrement//m_cStats.m_dwSelf
  6081. << m_cStats.m_lpcVitals[1].m_lTrueCurrent //m_dwCurrentStamina
  6082. << m_cStats.m_lpcVitals[2].m_lTrueCurrent //m_cStats.m_dwCurrentMana
  6083. << m_cStats.m_lpcVitals[1].m_dwCurrent //m_dwMaxStamina
  6084. << m_cStats.m_lpcVitals[2].m_dwCurrent //m_dwMaxMana
  6085. << DWORD(m_wRace);
  6086. }
  6087. if (dwCharacterFlags & 0x00000002) // Mask 0x02
  6088. {
  6089. cmAssess << playerRank //DWORD rank (0xFFFFFFFF for a character without a patron)
  6090. << monarchFollowers //DWORD followers (number of followers of an allegiance monarch; otherwise 0xFFFFFFFF)
  6091. << m_cStats.m_lpcSkills[36].m_dwTotal //DWORD loyalty (loyalty of characters without a patron; otherwise 0)
  6092. << m_cStats.m_lpcSkills[35].m_dwTotal //DWORD leadership (leadership of characters without a patron; otherwise 0)
  6093. << DWORD(m_fIsPK) //DWORD PK (Non-PK = 0; PK = 1)
  6094. << m_strSexName //String sex
  6095. << m_strRaceName //String race
  6096. << m_strClassName //String class
  6097. << "" //String fellowship (empty string for none)
  6098. << monarchName.c_str() //String monarch (empty string for none)
  6099. << patronName.c_str() //String patron (empty string for none)
  6100. << DWORD(m_BasicVectorTex[1].m_wNewTexture | 0x05000000) //DWORD forehead texture
  6101. << DWORD(m_BasicVectorTex[2].m_wNewTexture | 0x05000000) //DWORD nose texture
  6102. << DWORD(m_BasicVectorTex[3].m_wNewTexture | 0x05000000) //DWORD chin texture
  6103. << DWORD(m_BasicVectorPal[2].m_wNewPalette | 0x04000000) //DWORD eyes palette
  6104. << DWORD(m_BasicVectorPal[1].m_wNewPalette | 0x04000000) //DWORD hair palette
  6105. << DWORD(m_BasicVectorPal[0].m_wNewPalette | 0x04000000); //DWORD skin palette
  6106. }
  6107. if (dwCharacterFlags & 0x00000001) // Mask 0x01
  6108. {
  6109. cmAssess << 0x00000000; //DWORD extra
  6110. }
  6111. }
  6112. if (flags & 0x00000800)
  6113. {
  6114. cmAssess << 0x00000000; //DWORD highlights
  6115. }
  6116. pcAssesser->AddPacket(WORLD_SERVER,cmAssess,4);
  6117. // the action has been completed
  6118. cMessage cmActionComplete;
  6119. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x00C9L << 0L;
  6120. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  6121. }
  6122. void cAvatar::SetIsPK_DB()
  6123. {
  6124. char szCommand[150];
  6125. // Update User's Database IsPK Flag
  6126. sprintf( szCommand, "UPDATE Avatar SET IsPK=%d WHERE AvatarGUID=%d;", m_fIsPK,m_dwGUID );
  6127. RETCODE retcode;
  6128. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6129. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6130. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6131. }
  6132. //Cubem0j0: Update quest table function.
  6133. void cAvatar::UpdateQuestCompletedTable(DWORD dwAvatarGUID, DWORD quest_id)
  6134. {
  6135. time_t rawtime;
  6136. struct tm * timeinfo;
  6137. char buffer [80];
  6138. time ( &rawtime );
  6139. timeinfo = localtime ( &rawtime );
  6140. strftime (buffer,80,"%X",timeinfo);
  6141. //Update the avatar quest completed table to reflect that this avatar has completed this quest
  6142. char szCommand[100];
  6143. RETCODE retcode;
  6144. //debug...
  6145. #ifdef _DEBUG
  6146. cMasterServer::ServerMessage( ColorYellow,NULL,"AvatarGUID is: %lu, quest_id is: %d",dwAvatarGUID,quest_id);
  6147. #endif
  6148. sprintf(szCommand,"INSERT INTO avatar_comp_quests (AvatarGUID,quest_id,completed) VALUES (%u,%lu,1);",dwAvatarGUID,quest_id);
  6149. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6150. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6151. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6152. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN( 0, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6153. }
  6154. /**
  6155. * Updates the database value of the avatar's location.
  6156. */
  6157. void cAvatar::UpdateAvatarLocation( )
  6158. {
  6159. //k109: Update avatar's location.
  6160. char szCommand[500];
  6161. RETCODE retcode;
  6162. DWORD dwLandblock = m_Location.m_dwLandBlock;
  6163. DWORD flX;
  6164. DWORD flY;
  6165. DWORD flZ;
  6166. DWORD flA;
  6167. DWORD flB;
  6168. DWORD flC;
  6169. DWORD flW;
  6170. DWORD dwGUID = m_dwGUID;
  6171. // cMasterServer::ServerMessage(ColorYellow,NULL,"Landblock: %08x %4.2f",who->m_pcAvatar->m_Location.m_dwLandBlock,myfl);
  6172. // floating point to 32-bit hexadecimal
  6173. flX = cDatabase::Float2Hex(m_Location.m_flX);
  6174. flY = cDatabase::Float2Hex(m_Location.m_flY);
  6175. flZ = cDatabase::Float2Hex(m_Location.m_flZ);
  6176. flA = cDatabase::Float2Hex(m_Location.m_flA);
  6177. flB = cDatabase::Float2Hex(m_Location.m_flB);
  6178. flC = cDatabase::Float2Hex(m_Location.m_flC);
  6179. flW = cDatabase::Float2Hex(m_Location.m_flW);
  6180. // cMasterServer::ServerMessage(ColorYellow,NULL,"Landblock: %08x %4.2f",who->m_pcAvatar->m_Location.m_dwLandBlock,myfl);
  6181. sprintf( szCommand, "UPDATE avatar_location SET Landblock = ('%08x'), Position_X = ('%08x'),Position_Y = ('%08x'),Position_Z = ('%08x'),Orientation_W = ('%08x'),Orientation_X = ('%08x'),Orientation_Y = ('%08x'),Orientation_Z = ('%08x') WHERE AvatarGUID = (%d);",dwLandblock, flX, flY, flZ, flA, flB, flC, flW, dwGUID );
  6182. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6183. retcode = SQLExecute( cDatabase::m_hStmt ); CHECKRETURN( 1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1 )
  6184. // retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6185. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_CLOSE ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6186. }
  6187. /**
  6188. * Updates the database value of the avatar's unassigned experience.
  6189. *
  6190. * @param *who - A pointer to the client whose avatar's unassigned experience value should be updated.
  6191. * @param exp - The present unassigned experience value.
  6192. */
  6193. void cAvatar::UpdateUnassignedXPDB(cClient *who, DWORD exp)
  6194. {
  6195. if (m_dwUnassignedXP < 4294967295)
  6196. {
  6197. char szCommand[150];
  6198. RETCODE retcode;
  6199. sprintf( szCommand, "UPDATE avatar set UnassignedXP = UnassignedXP + %lu where AvatarGUID = %lu;",exp,who->m_pcAvatar->GetGUID( ));
  6200. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6201. retcode = SQLExecute( cDatabase::m_hStmt );
  6202. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6203. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6204. }
  6205. }
  6206. /**
  6207. * Updates the database value of the avatar's total experience.
  6208. *
  6209. * @param *who - A pointer to the client whose avatar's total experience value should be updated.
  6210. * @param exp - The present total experience value.
  6211. */
  6212. void cAvatar::UpdateTotalXPDB(cClient *who, DWORD exp)
  6213. {
  6214. char szCommand[100];
  6215. RETCODE retcode;
  6216. sprintf( szCommand, "UPDATE avatar set TotalXP = TotalXP + %i where AvatarGUID = %lu;",exp,who->m_pcAvatar->GetGUID( ));
  6217. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6218. retcode = SQLExecute( cDatabase::m_hStmt );
  6219. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6220. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6221. }
  6222. /**
  6223. * Updates the database value of the avatar's level.
  6224. *
  6225. * @param *who - A pointer to the client whose avatar's level value should be updated.
  6226. * @param exp - The present level value.
  6227. */
  6228. void cAvatar::UpdateLevelDB(cClient *who)
  6229. {
  6230. char szCommand[100];
  6231. RETCODE retcode;
  6232. sprintf( szCommand, "UPDATE avatar set Level = %i where AvatarGUID = %lu;",who->m_pcAvatar->m_cStats.m_dwLevel,who->m_pcAvatar->GetGUID( ));
  6233. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6234. retcode = SQLExecute( cDatabase::m_hStmt );
  6235. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6236. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6237. }
  6238. /*
  6239. cMessage cAvatar::UpdateAvatarPalette()
  6240. {
  6241. cMessage cmReturn;
  6242. char szCommand[255];
  6243. RETCODE retcode;
  6244. sprintf( szCommand, "SELECT * FROM avatar_palettes WHERE dwlinker=%d ORDER BY VectorCount;", this->m_wModelNum);
  6245. BYTE bVectorCount;
  6246. // Define Temp Variables
  6247. char readbuff01[5];
  6248. char readbuff02[3];
  6249. char readbuff03[3];
  6250. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6251. retcode = SQLExecute( cDatabase::m_hStmt );
  6252. int iCol = 3;
  6253. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_USHORT, &bVectorCount, sizeof( bVectorCount ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6254. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff01 , sizeof( readbuff01 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6255. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff02 , sizeof( readbuff02 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6256. retcode = SQLBindCol( cDatabase::m_hStmt, iCol++, SQL_C_CHAR, &readbuff03 , sizeof( readbuff03 ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6257. for ( int i = 0; SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS && i < this->m_bPaletteChange; ++i )
  6258. {
  6259. //Cube: Change below, need to add a way to record Avatars p/t/m info.
  6260. sscanf(readbuff01,"%04x",&pc.m_wNewPalette);
  6261. sscanf(readbuff02,"%02x",&pc.m_ucOffset);
  6262. sscanf(readbuff03,"%02x",&pc.m_ucLength);
  6263. m_vectorPal[i].m_wNewPalette = pc.m_wNewPalette;
  6264. m_vectorPal[i].m_ucOffset = pc.m_ucOffset;
  6265. m_vectorPal[i].m_ucLength = pc.m_ucLength;
  6266. cmReturn << m_vectorPal[i].m_wNewPalette << m_vectorPal[i].m_ucOffset << m_vectorPal[i].m_ucLength;
  6267. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6268. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  6269. }
  6270. //Cube: Palette Code
  6271. cmReturn << WORD( 0x08A0 );
  6272. return cmReturn;
  6273. }
  6274. */
  6275. cMessage cAvatar::AllegianceInfo(DWORD F7B0seq)
  6276. {
  6277. cMessage cmReturn;
  6278. cmReturn << 0xF7B0 << GetGUID() << F7B0seq << 0x20L; // Allegiance Info
  6279. cAllegiance* aAllegiance ;
  6280. int numRecords = 0;
  6281. int numFollowers = 0;
  6282. int allegianceSize = 0;
  6283. DWORD allegianceLeader = 0;
  6284. DWORD dwRank = 0;
  6285. // std::string allegianceName = "";
  6286. std::list< Member > memberList;
  6287. std::list< DWORD > treeParentList;
  6288. aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID);
  6289. if (aAllegiance)
  6290. {
  6291. allegianceSize = aAllegiance->GetSize(); // allegiance size
  6292. // allegianceName = aAllegiance->GetName(); // allegiance name
  6293. allegianceLeader = aAllegiance->GetLeader();
  6294. // Find the monarch's allegiance record
  6295. Member memMonarch = aAllegiance->members.find(aAllegiance->GetLeader())->second;
  6296. // Add the monarch's allegiance record
  6297. memberList.push_back( memMonarch );
  6298. treeParentList.push_back( 0x00000001);
  6299. numRecords++;
  6300. // Find the player's allegiance record
  6301. Member memPlayer = aAllegiance->members.find(m_dwGUID)->second;
  6302. numFollowers = DWORD(memPlayer.m_dwFollowers); // avatar's follower count
  6303. dwRank = DWORD(memPlayer.m_bRank); // avatar's rank
  6304. // Find the patron's allegiance record
  6305. if (memPlayer.m_dwGUID != aAllegiance->GetLeader() && memPlayer.m_dwPatron != 0)
  6306. {
  6307. Member memPatron = aAllegiance->members.find(memPlayer.m_dwPatron)->second;
  6308. if (memPatron.m_dwGUID != aAllegiance->GetLeader()) // if the patron is not also the monarch
  6309. {
  6310. // Add the patron's allegiance record
  6311. memberList.push_back( memPatron );
  6312. treeParentList.push_back ( memMonarch.m_dwGUID ); // the monarch is always the patron's "tree parent"
  6313. numRecords++;
  6314. }
  6315. }
  6316. if (aAllegiance->GetLeader() != m_dwGUID) // if the player is not the monarch
  6317. {
  6318. // Add the player's allegiance record
  6319. memberList.push_back( memPlayer );
  6320. treeParentList.push_back ( memPlayer.m_dwPatron ); // the patron is always the (non-monarch) player's "tree parent"
  6321. numRecords++;
  6322. }
  6323. for (int iVas = 0; iVas < MAX_VASSALS; ++iVas)
  6324. {
  6325. // Find vassals' allegiance record
  6326. if (memPlayer.m_dwVassals[iVas] != 0)
  6327. {
  6328. // Add the vassal's allegiance record
  6329. Member memVassal = aAllegiance->members.find(memPlayer.m_dwVassals[iVas])->second;
  6330. memberList.push_back( memVassal );
  6331. treeParentList.push_back ( memVassal.m_dwPatron ); // the patron is always the (non-monarch) player's "tree parent"
  6332. numRecords++;
  6333. }
  6334. }
  6335. }
  6336. time_t curtime;
  6337. curtime = time (NULL); // the current time
  6338. cmReturn << DWORD(dwRank) // DWORD personal rank (rank + any rank bonus)
  6339. << DWORD(allegianceSize) // DWORD allegiance size (monarch + followers)
  6340. << DWORD(numFollowers) // DWORD personal number of followers
  6341. << WORD(numRecords) // WORD recordCount
  6342. << WORD(0x30) // WORD unknown1
  6343. << 0x01000000 // DWORD unknown2
  6344. << 0x0L // DWORD unknown3
  6345. << 0x0L // DWORD unknown4
  6346. << 0x0L // DWORD unknown5
  6347. << 0x0L // DWORD unknown6
  6348. << 0x0L // DWORD unknown7 (0-2?)
  6349. << 0x0L; // DWORD unknown8 (0-2?)
  6350. //<< 0x0L // DWORD unknown9
  6351. //<< 0x0000XXXX // DWORD allegiance chat channel number
  6352. //<< 0x0L // DWORD unknown10
  6353. //<< 0x0L // DWORD unknown11
  6354. //<< 0x0L // DWORD unknown12
  6355. //<< 0x0L // DWORD unknown13
  6356. //<< float(1) // float unknown14
  6357. //<< 0x0L // DWORD unknown15
  6358. //<< 0x0L // DWORD unknown16a
  6359. //<< 0x0L // DWORD unknown16b
  6360. //<< allegianceName.c_str() // STRING allegiance name
  6361. //<< DWORD(curtime) // DWORD time of update
  6362. std::list<Member>::iterator memberIter;
  6363. std::list<DWORD>::iterator treeParentIter;
  6364. for ( memberIter = memberList.begin(), treeParentIter = treeParentList.begin(); memberIter != memberList.end(), treeParentIter != treeParentList.end(); ++memberIter, ++treeParentIter )
  6365. {
  6366. // determine the character's age
  6367. UINT64 age = curtime - (*memberIter).m_timeBirth;
  6368. // determine the character's online/offline status
  6369. DWORD online = 0x00L;
  6370. if (cClient::FindClient( (*memberIter).m_dwGUID ))
  6371. online = 0x01L; // online
  6372. DWORD type = 0x0CL;
  6373. if ((*memberIter).m_dwGUID == allegianceLeader)
  6374. type = type | 0x10L; // leaders appear to always have value 0x0000001X
  6375. //else if (unknown circumstance)
  6376. // type = type | 0x01L; // unknown reason causes 0x000000XD
  6377. cmReturn << (*treeParentIter) // DWORD treeParent (monarch's = 1, pre-ToD?)
  6378. << (*memberIter).m_dwGUID // DWORD player GUID
  6379. << type // DWORD type
  6380. << (*memberIter).m_passupXP // DWORD total allegiance experience contribution
  6381. << online // DWORD online/offline (0 = offline; 1 = online)
  6382. << (*memberIter).m_bGender // BYTE gender (1 = male; 2 = female)
  6383. << (*memberIter).m_bRace // BYTE race (1 = Aluvian; 2 = Gharu'ndim; 3 = Sho)
  6384. << (*memberIter).m_bRank // BYTE rank (1-10)
  6385. << BYTE(0x00) // align to DWORD
  6386. << (*memberIter).m_wLoyalty // WORD loyalty
  6387. << (*memberIter).m_wLeadership // WORD leadership
  6388. << (*memberIter).m_timeRLSwear // DWORD unknown
  6389. << DWORD(age) // DWORD character age (in seconds)
  6390. << (*memberIter).m_szName.c_str(); // STRING character name
  6391. }
  6392. memberList.clear();
  6393. return cmReturn;
  6394. }
  6395. DWORD cAvatar::GetAllegianceFromDB()
  6396. {
  6397. DWORD allegianceID = 0;
  6398. char szCommand[100];
  6399. RETCODE retcode;
  6400. sprintf( szCommand, "SELECT AllegianceID FROM allegiance_members WHERE MemberGUID = %lu;",GetGUID( ));
  6401. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6402. retcode = SQLExecute( cDatabase::m_hStmt );
  6403. retcode = SQLBindCol( cDatabase::m_hStmt, 1, SQL_C_ULONG, &allegianceID, sizeof( DWORD ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6404. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6405. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  6406. return allegianceID;
  6407. }
  6408. cMessage cAvatar::SetPackContents(DWORD F7B0seq)
  6409. {
  6410. cMessage cmReturn;
  6411. cmReturn << 0xF7B0L << GetGUID( ) << F7B0seq << 0x000001CA << 0x0L;
  6412. return cmReturn;
  6413. }
  6414. void cAvatar::BreakAllegiance()
  6415. {
  6416. cAllegiance* aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID);
  6417. if (aAllegiance)
  6418. aAllegiance->UpdateAvatarRecordDB(this->m_dwGUID);
  6419. }
  6420. void cAvatar::UpdateAllegianceDB()
  6421. {
  6422. cAllegiance* aAllegiance = cAllegiance::GetAllegianceByID(m_dwAllegianceID);
  6423. if (aAllegiance)
  6424. aAllegiance->UpdateAvatarRecordDB(this->m_dwGUID);
  6425. }
  6426. /**
  6427. * Updates the database record of the avatar.
  6428. *
  6429. * @param *who - A pointer to the client whose avatar's database record should be updated.
  6430. */
  6431. void cAvatar::SaveToDB()
  6432. {
  6433. UpdateAvatarLocation();
  6434. if(m_dwAllegianceID != 0)
  6435. UpdateAllegianceDB();
  6436. }