bg_panimate.cpp 204 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641
  1. // this include must remain at the top of every bg_xxxx CPP file
  2. #include "common_headers.h"
  3. // define GAME_INCLUDE so that g_public.h does not define the
  4. // short, server-visible gclient_t and gentity_t structures,
  5. // because we define the full size ones in this file
  6. #define GAME_INCLUDE
  7. //#include "../renderer/tr_local.h"
  8. #include "q_shared.h"
  9. #include "g_shared.h"
  10. #include "bg_local.h"
  11. #include "../cgame/cg_local.h"
  12. #include "anims.h"
  13. #include "Q3_Interface.h"
  14. #include "g_local.h"
  15. #include "wp_saber.h"
  16. #include "g_vehicles.h"
  17. extern pmove_t *pm;
  18. extern pml_t pml;
  19. extern cvar_t *g_ICARUSDebug;
  20. extern cvar_t *g_timescale;
  21. extern cvar_t *g_synchSplitAnims;
  22. extern cvar_t *g_AnimWarning;
  23. extern cvar_t *g_noFootSlide;
  24. extern cvar_t *g_noFootSlideRunScale;
  25. extern cvar_t *g_noFootSlideWalkScale;
  26. extern cvar_t *g_saberAnimSpeed;
  27. extern cvar_t *g_saberAutoAim;
  28. extern cvar_t *g_speederControlScheme;
  29. extern cvar_t *g_saberNewControlScheme;
  30. extern qboolean InFront( vec3_t spot, vec3_t from, vec3_t fromAngles, float threshHold = 0.0f );
  31. extern void WP_ForcePowerDrain( gentity_t *self, forcePowers_t forcePower, int overrideAmt );
  32. extern qboolean ValidAnimFileIndex ( int index );
  33. extern qboolean PM_ControlledByPlayer( void );
  34. extern qboolean PM_DroidMelee( int npc_class );
  35. extern qboolean PM_PainAnim( int anim );
  36. extern qboolean PM_JumpingAnim( int anim );
  37. extern qboolean PM_FlippingAnim( int anim );
  38. extern qboolean PM_RollingAnim( int anim );
  39. extern qboolean PM_SwimmingAnim( int anim );
  40. extern qboolean PM_InKnockDown( playerState_t *ps );
  41. extern qboolean PM_InRoll( playerState_t *ps );
  42. extern qboolean PM_DodgeAnim( int anim );
  43. extern qboolean PM_InSlopeAnim( int anim );
  44. extern qboolean PM_ForceAnim( int anim );
  45. extern qboolean PM_InKnockDownOnGround( playerState_t *ps );
  46. extern qboolean PM_InSpecialJump( int anim );
  47. extern qboolean PM_RunningAnim( int anim );
  48. extern qboolean PM_WalkingAnim( int anim );
  49. extern qboolean PM_SwimmingAnim( int anim );
  50. extern qboolean PM_JumpingAnim( int anim );
  51. extern qboolean PM_SaberStanceAnim( int anim );
  52. extern qboolean PM_SaberDrawPutawayAnim( int anim );
  53. extern void PM_SetJumped( float height, qboolean force );
  54. extern qboolean PM_InGetUpNoRoll( playerState_t *ps );
  55. extern qboolean PM_CrouchAnim( int anim );
  56. extern qboolean G_TryingKataAttack( gentity_t *self, usercmd_t *cmd );
  57. extern qboolean G_TryingCartwheel( gentity_t *self, usercmd_t *cmd );
  58. extern qboolean G_TryingSpecial( gentity_t *self, usercmd_t *cmd );
  59. extern qboolean G_TryingJumpAttack( gentity_t *self, usercmd_t *cmd );
  60. extern qboolean G_TryingJumpForwardAttack( gentity_t *self, usercmd_t *cmd );
  61. extern qboolean G_TryingLungeAttack( gentity_t *self, usercmd_t *cmd );
  62. extern qboolean G_TryingPullAttack( gentity_t *self, usercmd_t *cmd, qboolean amPulling );
  63. extern qboolean G_InCinematicSaberAnim( gentity_t *self );
  64. extern qboolean G_ControlledByPlayer( gentity_t *self );
  65. extern int g_crosshairEntNum;
  66. int PM_AnimLength( int index, animNumber_t anim );
  67. qboolean PM_LockedAnim( int anim );
  68. qboolean PM_StandingAnim( int anim );
  69. qboolean PM_InOnGroundAnim ( playerState_t *ps );
  70. qboolean PM_SuperBreakWinAnim( int anim );
  71. qboolean PM_SuperBreakLoseAnim( int anim );
  72. qboolean PM_LockedAnim( int anim );
  73. saberMoveName_t PM_SaberFlipOverAttackMove( void );
  74. qboolean PM_CheckFlipOverAttackMove( qboolean checkEnemy );
  75. saberMoveName_t PM_SaberJumpForwardAttackMove( void );
  76. qboolean PM_CheckJumpForwardAttackMove( void );
  77. saberMoveName_t PM_SaberBackflipAttackMove( void );
  78. qboolean PM_CheckBackflipAttackMove( void );
  79. saberMoveName_t PM_SaberDualJumpAttackMove( void );
  80. qboolean PM_CheckDualJumpAttackMove( void );
  81. saberMoveName_t PM_SaberLungeAttackMove( qboolean fallbackToNormalLunge );
  82. qboolean PM_CheckLungeAttackMove( void );
  83. // Okay, here lies the much-dreaded Pat-created FSM movement chart... Heretic II strikes again!
  84. // Why am I inflicting this on you? Well, it's better than hardcoded states.
  85. // Ideally this will be replaced with an external file or more sophisticated move-picker
  86. // once the game gets out of prototype stage.
  87. // Silly, but I'm replacing these macros so they are shorter!
  88. #define AFLAG_IDLE (SETANIM_FLAG_NORMAL)
  89. #define AFLAG_ACTIVE (SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD | SETANIM_FLAG_HOLDLESS)
  90. #define AFLAG_WAIT (SETANIM_FLAG_HOLD | SETANIM_FLAG_HOLDLESS)
  91. #define AFLAG_FINISH (SETANIM_FLAG_HOLD)
  92. //FIXME: add the alternate anims for each style?
  93. saberMoveData_t saberMoveData[LS_MOVE_MAX] = {// NB:randomized
  94. // name anim(do all styles?)startQ endQ setanimflag blend, blocking chain_idle chain_attack trailLen
  95. {"None", BOTH_STAND1, Q_R, Q_R, AFLAG_IDLE, 350, BLK_NO, LS_NONE, LS_NONE, 0 }, // LS_NONE = 0,
  96. // General movements with saber
  97. {"Ready", BOTH_STAND2, Q_R, Q_R, AFLAG_IDLE, 350, BLK_WIDE, LS_READY, LS_S_R2L, 0 }, // LS_READY,
  98. {"Draw", BOTH_STAND1TO2, Q_R, Q_R, AFLAG_FINISH, 350, BLK_NO, LS_READY, LS_S_R2L, 0 }, // LS_DRAW,
  99. {"Putaway", BOTH_STAND2TO1, Q_R, Q_R, AFLAG_FINISH, 350, BLK_NO, LS_READY, LS_S_R2L, 0 }, // LS_PUTAWAY,
  100. // Attacks
  101. //UL2LR
  102. {"TL2BR Att", BOTH_A1_TL_BR, Q_TL, Q_BR, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_TL2BR, LS_R_TL2BR, 200 }, // LS_A_TL2BR
  103. //SLASH LEFT
  104. {"L2R Att", BOTH_A1__L__R, Q_L, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_L2R, LS_R_L2R, 200 }, // LS_A_L2R
  105. //LL2UR
  106. {"BL2TR Att", BOTH_A1_BL_TR, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_TIGHT, LS_R_BL2TR, LS_R_BL2TR, 200 }, // LS_A_BL2TR
  107. //LR2UL
  108. {"BR2TL Att", BOTH_A1_BR_TL, Q_BR, Q_TL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_BR2TL, LS_R_BR2TL, 200 }, // LS_A_BR2TL
  109. //SLASH RIGHT
  110. {"R2L Att", BOTH_A1__R__L, Q_R, Q_L, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_R2L, LS_R_R2L, 200 },// LS_A_R2L
  111. //UR2LL
  112. {"TR2BL Att", BOTH_A1_TR_BL, Q_TR, Q_BL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_TR2BL, LS_R_TR2BL, 200 }, // LS_A_TR2BL
  113. //SLASH DOWN
  114. {"T2B Att", BOTH_A1_T__B_, Q_T, Q_B, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_R_T2B, LS_R_T2B, 200 }, // LS_A_T2B
  115. //special attacks
  116. {"Back Stab", BOTH_A2_STABBACK1, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_A_BACKSTAB
  117. {"Back Att", BOTH_ATTACK_BACK, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_A_BACK
  118. {"CR Back Att", BOTH_CROUCHATTACKBACK1,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_A_BACK_CR
  119. {"RollStab", BOTH_ROLL_STAB, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_ROLL_STAB
  120. {"Lunge Att", BOTH_LUNGE2_B__T_, Q_B, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_A_LUNGE
  121. {"Jump Att", BOTH_FORCELEAP2_T__B_,Q_T, Q_B, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_A_JUMP_T__B_
  122. {"Flip Stab", BOTH_JUMPFLIPSTABDOWN,Q_R, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1_T___R, 200 }, // LS_A_FLIP_STAB
  123. {"Flip Slash", BOTH_JUMPFLIPSLASHDOWN1,Q_L,Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1__R_T_, 200 }, // LS_A_FLIP_SLASH
  124. {"DualJump Atk",BOTH_JUMPATTACK6, Q_R, Q_BL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1_BL_TR, 200 }, // LS_JUMPATTACK_DUAL
  125. {"DualJumpAtkL_A",BOTH_ARIAL_LEFT, Q_R, Q_TL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_A_TL2BR, 200 }, // LS_JUMPATTACK_ARIAL_LEFT
  126. {"DualJumpAtkR_A",BOTH_ARIAL_RIGHT, Q_R, Q_TR, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_A_TR2BL, 200 }, // LS_JUMPATTACK_ARIAL_RIGHT
  127. {"DualJumpAtkL_A",BOTH_CARTWHEEL_LEFT, Q_R,Q_TL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1_TL_BR, 200 }, // LS_JUMPATTACK_CART_LEFT
  128. {"DualJumpAtkR_A",BOTH_CARTWHEEL_RIGHT, Q_R,Q_TR, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1_TR_BL, 200 }, // LS_JUMPATTACK_CART_RIGHT
  129. {"DualJumpAtkLStaff", BOTH_BUTTERFLY_FL1,Q_R,Q_L, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1__L__R, 200 }, // LS_JUMPATTACK_STAFF_LEFT
  130. {"DualJumpAtkRStaff", BOTH_BUTTERFLY_FR1,Q_R,Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1__R__L, 200 }, // LS_JUMPATTACK_STAFF_RIGHT
  131. {"ButterflyLeft", BOTH_BUTTERFLY_LEFT,Q_R,Q_L, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1__L__R, 200 }, // LS_BUTTERFLY_LEFT
  132. {"ButterflyRight", BOTH_BUTTERFLY_RIGHT,Q_R,Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1__R__L, 200 }, // LS_BUTTERFLY_RIGHT
  133. {"BkFlip Atk", BOTH_JUMPATTACK7, Q_B, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_T1_T___R, 200 }, // LS_A_BACKFLIP_ATK
  134. {"DualSpinAtk", BOTH_SPINATTACK6, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_SPINATTACK_DUAL
  135. {"StfSpinAtk", BOTH_SPINATTACK7, Q_L, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_SPINATTACK
  136. {"LngLeapAtk", BOTH_FORCELONGLEAP_ATTACK,Q_R,Q_L, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_LEAP_ATTACK
  137. {"SwoopAtkR", BOTH_VS_ATR_S, Q_R, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 200 }, // LS_SWOOP_ATTACK_RIGHT
  138. {"SwoopAtkL", BOTH_VS_ATL_S, Q_L, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 200 }, // LS_SWOOP_ATTACK_LEFT
  139. {"TauntaunAtkR",BOTH_VT_ATR_S, Q_R, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_TAUNTAUN_ATTACK_RIGHT
  140. {"TauntaunAtkL",BOTH_VT_ATL_S, Q_L, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_TAUNTAUN_ATTACK_LEFT
  141. {"StfKickFwd", BOTH_A7_KICK_F, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_F
  142. {"StfKickBack", BOTH_A7_KICK_B, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_B
  143. {"StfKickRight",BOTH_A7_KICK_R, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_R
  144. {"StfKickLeft", BOTH_A7_KICK_L, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_L
  145. {"StfKickSpin", BOTH_A7_KICK_S, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_S_R2L, 200 }, // LS_KICK_S
  146. {"StfKickBkFwd",BOTH_A7_KICK_BF, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_S_R2L, 200 }, // LS_KICK_BF
  147. {"StfKickSplit",BOTH_A7_KICK_RL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_S_R2L, 200 }, // LS_KICK_RL
  148. {"StfKickFwdAir",BOTH_A7_KICK_F_AIR,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_F_AIR
  149. {"StfKickBackAir",BOTH_A7_KICK_B_AIR,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_B_AIR
  150. {"StfKickRightAir",BOTH_A7_KICK_R_AIR,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_R_AIR
  151. {"StfKickLeftAir",BOTH_A7_KICK_L_AIR,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_KICK_L_AIR
  152. {"StabDown", BOTH_STABDOWN, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_STABDOWN
  153. {"StabDownStf", BOTH_STABDOWN_STAFF,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_STABDOWN_STAFF
  154. {"StabDownDual",BOTH_STABDOWN_DUAL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_S_R2L, 200 }, // LS_STABDOWN_DUAL
  155. {"dualspinprot",BOTH_A6_SABERPROTECT,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 500 }, // LS_DUAL_SPIN_PROTECT
  156. {"StfSoulCal", BOTH_A7_SOULCAL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 500 }, // LS_STAFF_SOULCAL
  157. {"specialfast", BOTH_A1_SPECIAL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 2000}, // LS_A1_SPECIAL
  158. {"specialmed", BOTH_A2_SPECIAL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 2000}, // LS_A2_SPECIAL
  159. {"specialstr", BOTH_A3_SPECIAL, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 2000}, // LS_A3_SPECIAL
  160. {"upsidedwnatk",BOTH_FLIP_ATTACK7, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200}, // LS_UPSIDE_DOWN_ATTACK
  161. {"pullatkstab", BOTH_PULL_IMPALE_STAB,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200}, // LS_PULL_ATTACK_STAB
  162. {"pullatkswing",BOTH_PULL_IMPALE_SWING,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200}, // LS_PULL_ATTACK_SWING
  163. {"AloraSpinAtk",BOTH_ALORA_SPIN_SLASH,Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_SPINATTACK_ALORA
  164. {"Dual FB Atk", BOTH_A6_FB, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_DUAL_FB
  165. {"Dual LR Atk", BOTH_A6_LR, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_DUAL_LR
  166. {"StfHiltBash", BOTH_A7_HILT, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_HILT_BASH
  167. //starts
  168. {"TL2BR St", BOTH_S1_S1_TL, Q_R, Q_TL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_TL2BR, LS_A_TL2BR, 200 }, // LS_S_TL2BR
  169. {"L2R St", BOTH_S1_S1__L, Q_R, Q_L, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_L2R, LS_A_L2R, 200 }, // LS_S_L2R
  170. {"BL2TR St", BOTH_S1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_BL2TR, LS_A_BL2TR, 200 }, // LS_S_BL2TR
  171. {"BR2TL St", BOTH_S1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_BR2TL, LS_A_BR2TL, 200 }, // LS_S_BR2TL
  172. {"R2L St", BOTH_S1_S1__R, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_R2L, LS_A_R2L, 200 }, // LS_S_R2L
  173. {"TR2BL St", BOTH_S1_S1_TR, Q_R, Q_TR, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_TR2BL, LS_A_TR2BL, 200 }, // LS_S_TR2BL
  174. {"T2B St", BOTH_S1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 100, BLK_TIGHT, LS_A_T2B, LS_A_T2B, 200 }, // LS_S_T2B
  175. //returns
  176. {"TL2BR Ret", BOTH_R1_BR_S1, Q_BR, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_TL2BR
  177. {"L2R Ret", BOTH_R1__R_S1, Q_R, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_L2R
  178. {"BL2TR Ret", BOTH_R1_TR_S1, Q_TR, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_BL2TR
  179. {"BR2TL Ret", BOTH_R1_TL_S1, Q_TL, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_BR2TL
  180. {"R2L Ret", BOTH_R1__L_S1, Q_L, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_R2L
  181. {"TR2BL Ret", BOTH_R1_BL_S1, Q_BL, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_TR2BL
  182. {"T2B Ret", BOTH_R1_B__S1, Q_B, Q_R, AFLAG_FINISH, 100, BLK_TIGHT, LS_READY, LS_READY, 200 }, // LS_R_T2B
  183. //Transitions
  184. {"BR2R Trans", BOTH_T1_BR__R, Q_BR, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast arc bottom right to right
  185. {"BR2TR Trans", BOTH_T1_BR_TR, Q_BR, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast arc bottom right to top right (use: BOTH_T1_TR_BR)
  186. {"BR2T Trans", BOTH_T1_BR_T_, Q_BR, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast arc bottom right to top (use: BOTH_T1_T__BR)
  187. {"BR2TL Trans", BOTH_T1_BR_TL, Q_BR, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast weak spin bottom right to top left
  188. {"BR2L Trans", BOTH_T1_BR__L, Q_BR, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast weak spin bottom right to left
  189. {"BR2BL Trans", BOTH_T1_BR_BL, Q_BR, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast weak spin bottom right to bottom left
  190. {"R2BR Trans", BOTH_T1__R_BR, Q_R, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast arc right to bottom right (use: BOTH_T1_BR__R)
  191. {"R2TR Trans", BOTH_T1__R_TR, Q_R, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast arc right to top right
  192. {"R2T Trans", BOTH_T1__R_T_, Q_R, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast ar right to top (use: BOTH_T1_T___R)
  193. {"R2TL Trans", BOTH_T1__R_TL, Q_R, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast arc right to top left
  194. {"R2L Trans", BOTH_T1__R__L, Q_R, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast weak spin right to left
  195. {"R2BL Trans", BOTH_T1__R_BL, Q_R, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast weak spin right to bottom left
  196. {"TR2BR Trans", BOTH_T1_TR_BR, Q_TR, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast arc top right to bottom right
  197. {"TR2R Trans", BOTH_T1_TR__R, Q_TR, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast arc top right to right (use: BOTH_T1__R_TR)
  198. {"TR2T Trans", BOTH_T1_TR_T_, Q_TR, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast arc top right to top (use: BOTH_T1_T__TR)
  199. {"TR2TL Trans", BOTH_T1_TR_TL, Q_TR, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast arc top right to top left
  200. {"TR2L Trans", BOTH_T1_TR__L, Q_TR, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast arc top right to left
  201. {"TR2BL Trans", BOTH_T1_TR_BL, Q_TR, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast weak spin top right to bottom left
  202. {"T2BR Trans", BOTH_T1_T__BR, Q_T, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast arc top to bottom right
  203. {"T2R Trans", BOTH_T1_T___R, Q_T, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast arc top to right
  204. {"T2TR Trans", BOTH_T1_T__TR, Q_T, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast arc top to top right
  205. {"T2TL Trans", BOTH_T1_T__TL, Q_T, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast arc top to top left
  206. {"T2L Trans", BOTH_T1_T___L, Q_T, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast arc top to left
  207. {"T2BL Trans", BOTH_T1_T__BL, Q_T, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast arc top to bottom left
  208. {"TL2BR Trans", BOTH_T1_TL_BR, Q_TL, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast weak spin top left to bottom right
  209. {"TL2R Trans", BOTH_T1_TL__R, Q_TL, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast arc top left to right (use: BOTH_T1__R_TL)
  210. {"TL2TR Trans", BOTH_T1_TL_TR, Q_TL, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast arc top left to top right (use: BOTH_T1_TR_TL)
  211. {"TL2T Trans", BOTH_T1_TL_T_, Q_TL, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast arc top left to top (use: BOTH_T1_T__TL)
  212. {"TL2L Trans", BOTH_T1_TL__L, Q_TL, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast arc top left to left (use: BOTH_T1__L_TL)
  213. {"TL2BL Trans", BOTH_T1_TL_BL, Q_TL, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast arc top left to bottom left
  214. {"L2BR Trans", BOTH_T1__L_BR, Q_L, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast weak spin left to bottom right
  215. {"L2R Trans", BOTH_T1__L__R, Q_L, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast weak spin left to right
  216. {"L2TR Trans", BOTH_T1__L_TR, Q_L, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast arc left to top right (use: BOTH_T1_TR__L)
  217. {"L2T Trans", BOTH_T1__L_T_, Q_L, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast arc left to top (use: BOTH_T1_T___L)
  218. {"L2TL Trans", BOTH_T1__L_TL, Q_L, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast arc left to top left
  219. {"L2BL Trans", BOTH_T1__L_BL, Q_L, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_A_BL2TR, 150 }, //# Fast arc left to bottom left (use: BOTH_T1_BL__L)
  220. {"BL2BR Trans", BOTH_T1_BL_BR, Q_BL, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_A_BR2TL, 150 }, //# Fast weak spin bottom left to bottom right
  221. {"BL2R Trans", BOTH_T1_BL__R, Q_BL, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_A_R2L, 150 }, //# Fast weak spin bottom left to right
  222. {"BL2TR Trans", BOTH_T1_BL_TR, Q_BL, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_TR2BL, 150 }, //# Fast weak spin bottom left to top right
  223. {"BL2T Trans", BOTH_T1_BL_T_, Q_BL, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_A_T2B, 150 }, //# Fast arc bottom left to top (use: BOTH_T1_T__BL)
  224. {"BL2TL Trans", BOTH_T1_BL_TL, Q_BL, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_A_TL2BR, 150 }, //# Fast arc bottom left to top left (use: BOTH_T1_TL_BL)
  225. {"BL2L Trans", BOTH_T1_BL__L, Q_BL, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_A_L2R, 150 }, //# Fast arc bottom left to left
  226. //Bounces
  227. {"Bounce BR", BOTH_B1_BR___, Q_BR, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_T1_BR_TR, 150 },
  228. {"Bounce R", BOTH_B1__R___, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_T1__R__L, 150 },
  229. {"Bounce TR", BOTH_B1_TR___, Q_TR, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_T1_TR_TL, 150 },
  230. {"Bounce T", BOTH_B1_T____, Q_T, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_T1_T__BL, 150 },
  231. {"Bounce TL", BOTH_B1_TL___, Q_TL, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_T1_TL_TR, 150 },
  232. {"Bounce L", BOTH_B1__L___, Q_L, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_T1__L__R, 150 },
  233. {"Bounce BL", BOTH_B1_BL___, Q_BL, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_T1_BL_TR, 150 },
  234. //Deflected attacks (like bounces, but slide off enemy saber, not straight back)
  235. {"Deflect BR", BOTH_D1_BR___, Q_BR, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TL2BR, LS_T1_BR_TR, 150 },
  236. {"Deflect R", BOTH_D1__R___, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_R_L2R, LS_T1__R__L, 150 },
  237. {"Deflect TR", BOTH_D1_TR___, Q_TR, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_T1_TR_TL, 150 },
  238. {"Deflect T", BOTH_B1_T____, Q_T, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_T1_T__BL, 150 },
  239. {"Deflect TL", BOTH_D1_TL___, Q_TL, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BR2TL, LS_T1_TL_TR, 150 },
  240. {"Deflect L", BOTH_D1__L___, Q_L, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_R_R2L, LS_T1__L__R, 150 },
  241. {"Deflect BL", BOTH_D1_BL___, Q_BL, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_R_TR2BL, LS_T1_BL_TR, 150 },
  242. {"Deflect B", BOTH_D1_B____, Q_B, Q_B, AFLAG_ACTIVE, 100, BLK_NO, LS_R_BL2TR, LS_T1_T__BL, 150 },
  243. //Reflected attacks
  244. {"Reflected BR",BOTH_V1_BR_S1, Q_BR, Q_BR, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_BR
  245. {"Reflected R", BOTH_V1__R_S1, Q_R, Q_R, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1__R
  246. {"Reflected TR",BOTH_V1_TR_S1, Q_TR, Q_TR, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_TR
  247. {"Reflected T", BOTH_V1_T__S1, Q_T, Q_T, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_T_
  248. {"Reflected TL",BOTH_V1_TL_S1, Q_TL, Q_TL, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_TL
  249. {"Reflected L", BOTH_V1__L_S1, Q_L, Q_L, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1__L
  250. {"Reflected BL",BOTH_V1_BL_S1, Q_BL, Q_BL, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_BL
  251. {"Reflected B", BOTH_V1_B__S1, Q_B, Q_B, AFLAG_ACTIVE, 100, BLK_NO, LS_READY, LS_READY, 150 },// LS_V1_B_
  252. // Broken parries
  253. {"BParry Top", BOTH_H1_S1_T_, Q_T, Q_B, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UP,
  254. {"BParry UR", BOTH_H1_S1_TR, Q_TR, Q_BL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UR,
  255. {"BParry UL", BOTH_H1_S1_TL, Q_TL, Q_BR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UL,
  256. {"BParry LR", BOTH_H1_S1_BL, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR,
  257. {"BParry Bot", BOTH_H1_S1_B_, Q_B, Q_T, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL
  258. {"BParry LL", BOTH_H1_S1_BR, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL
  259. // Knockaways
  260. {"Knock Top", BOTH_K1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_T__BR, 150 }, // LS_PARRY_UP,
  261. {"Knock UR", BOTH_K1_S1_TR, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_TR__R, 150 }, // LS_PARRY_UR,
  262. {"Knock UL", BOTH_K1_S1_TL, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_T1_TL__L, 150 }, // LS_PARRY_UL,
  263. {"Knock LR", BOTH_K1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR,
  264. {"Knock LL", BOTH_K1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL
  265. // Parry
  266. {"Parry Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 150 }, // LS_PARRY_UP,
  267. {"Parry UR", BOTH_P1_S1_TR, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_TR2BL, 150 }, // LS_PARRY_UR,
  268. {"Parry UL", BOTH_P1_S1_TL, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_A_TL2BR, 150 }, // LS_PARRY_UL,
  269. {"Parry LR", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR,
  270. {"Parry LL", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL
  271. // Reflecting a missile
  272. {"Reflect Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 300 }, // LS_PARRY_UP,
  273. {"Reflect UR", BOTH_P1_S1_TL, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_A_TL2BR, 300 }, // LS_PARRY_UR,
  274. {"Reflect UL", BOTH_P1_S1_TR, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_TR2BL, 300 }, // LS_PARRY_UL,
  275. {"Reflect LR", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 300 }, // LS_PARRY_LR
  276. {"Reflect LL", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 300 }, // LS_PARRY_LL,
  277. };
  278. saberMoveName_t transitionMove[Q_NUM_QUADS][Q_NUM_QUADS] =
  279. {
  280. LS_NONE, //Can't transition to same pos!
  281. LS_T1_BR__R,//40
  282. LS_T1_BR_TR,
  283. LS_T1_BR_T_,
  284. LS_T1_BR_TL,
  285. LS_T1_BR__L,
  286. LS_T1_BR_BL,
  287. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  288. LS_T1__R_BR,//46
  289. LS_NONE, //Can't transition to same pos!
  290. LS_T1__R_TR,
  291. LS_T1__R_T_,
  292. LS_T1__R_TL,
  293. LS_T1__R__L,
  294. LS_T1__R_BL,
  295. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  296. LS_T1_TR_BR,//52
  297. LS_T1_TR__R,
  298. LS_NONE, //Can't transition to same pos!
  299. LS_T1_TR_T_,
  300. LS_T1_TR_TL,
  301. LS_T1_TR__L,
  302. LS_T1_TR_BL,
  303. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  304. LS_T1_T__BR,//58
  305. LS_T1_T___R,
  306. LS_T1_T__TR,
  307. LS_NONE, //Can't transition to same pos!
  308. LS_T1_T__TL,
  309. LS_T1_T___L,
  310. LS_T1_T__BL,
  311. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  312. LS_T1_TL_BR,//64
  313. LS_T1_TL__R,
  314. LS_T1_TL_TR,
  315. LS_T1_TL_T_,
  316. LS_NONE, //Can't transition to same pos!
  317. LS_T1_TL__L,
  318. LS_T1_TL_BL,
  319. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  320. LS_T1__L_BR,//70
  321. LS_T1__L__R,
  322. LS_T1__L_TR,
  323. LS_T1__L_T_,
  324. LS_T1__L_TL,
  325. LS_NONE, //Can't transition to same pos!
  326. LS_T1__L_BL,
  327. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  328. LS_T1_BL_BR,//76
  329. LS_T1_BL__R,
  330. LS_T1_BL_TR,
  331. LS_T1_BL_T_,
  332. LS_T1_BL_TL,
  333. LS_T1_BL__L,
  334. LS_NONE, //Can't transition to same pos!
  335. LS_NONE, //No transitions to bottom, and no anims start there, so shouldn't need any
  336. LS_T1_BL_BR,//NOTE: there are no transitions from bottom, so re-use the bottom right transitions
  337. LS_T1_BR__R,
  338. LS_T1_BR_TR,
  339. LS_T1_BR_T_,
  340. LS_T1_BR_TL,
  341. LS_T1_BR__L,
  342. LS_T1_BR_BL,
  343. LS_NONE //No transitions to bottom, and no anims start there, so shouldn't need any
  344. };
  345. void PM_VelocityForSaberMove( playerState_t *ps, vec3_t throwDir )
  346. {
  347. vec3_t vForward, vRight, vUp, startQ, endQ;
  348. AngleVectors( ps->viewangles, vForward, vRight, vUp );
  349. switch ( saberMoveData[ps->saberMove].startQuad )
  350. {
  351. case Q_BR:
  352. VectorScale( vRight, 1, startQ );
  353. VectorMA( startQ, -1, vUp, startQ );
  354. break;
  355. case Q_R:
  356. VectorScale( vRight, 2, startQ );
  357. break;
  358. case Q_TR:
  359. VectorScale( vRight, 1, startQ );
  360. VectorMA( startQ, 1, vUp, startQ );
  361. break;
  362. case Q_T:
  363. VectorScale( vUp, 2, startQ );
  364. break;
  365. case Q_TL:
  366. VectorScale( vRight, -1, startQ );
  367. VectorMA( startQ, 1, vUp, startQ );
  368. break;
  369. case Q_L:
  370. VectorScale( vRight, -2, startQ );
  371. break;
  372. case Q_BL:
  373. VectorScale( vRight, -1, startQ );
  374. VectorMA( startQ, -1, vUp, startQ );
  375. break;
  376. case Q_B:
  377. VectorScale( vUp, -2, startQ );
  378. break;
  379. }
  380. switch ( saberMoveData[ps->saberMove].endQuad )
  381. {
  382. case Q_BR:
  383. VectorScale( vRight, 1, endQ );
  384. VectorMA( endQ, -1, vUp, endQ );
  385. break;
  386. case Q_R:
  387. VectorScale( vRight, 2, endQ );
  388. break;
  389. case Q_TR:
  390. VectorScale( vRight, 1, endQ );
  391. VectorMA( endQ, 1, vUp, endQ );
  392. break;
  393. case Q_T:
  394. VectorScale( vUp, 2, endQ );
  395. break;
  396. case Q_TL:
  397. VectorScale( vRight, -1, endQ );
  398. VectorMA( endQ, 1, vUp, endQ );
  399. break;
  400. case Q_L:
  401. VectorScale( vRight, -2, endQ );
  402. break;
  403. case Q_BL:
  404. VectorScale( vRight, -1, endQ );
  405. VectorMA( endQ, -1, vUp, endQ );
  406. break;
  407. case Q_B:
  408. VectorScale( vUp, -2, endQ );
  409. break;
  410. }
  411. VectorMA( endQ, 2, vForward, endQ );
  412. VectorScale( throwDir, 125, throwDir );//FIXME: pass in the throw strength?
  413. VectorSubtract( endQ, startQ, throwDir );
  414. }
  415. qboolean PM_VelocityForBlockedMove( playerState_t *ps, vec3_t throwDir )
  416. {
  417. vec3_t vForward, vRight, vUp;
  418. AngleVectors( ps->viewangles, vForward, vRight, vUp );
  419. switch ( ps->saberBlocked )
  420. {
  421. case BLOCKED_UPPER_RIGHT:
  422. VectorScale( vRight, 1, throwDir );
  423. VectorMA( throwDir, 1, vUp, throwDir );
  424. break;
  425. case BLOCKED_UPPER_LEFT:
  426. VectorScale( vRight, -1, throwDir );
  427. VectorMA( throwDir, 1, vUp, throwDir );
  428. break;
  429. case BLOCKED_LOWER_RIGHT:
  430. VectorScale( vRight, 1, throwDir );
  431. VectorMA( throwDir, -1, vUp, throwDir );
  432. break;
  433. case BLOCKED_LOWER_LEFT:
  434. VectorScale( vRight, -1, throwDir );
  435. VectorMA( throwDir, -1, vUp, throwDir );
  436. break;
  437. case BLOCKED_TOP:
  438. VectorScale( vUp, 2, throwDir );
  439. break;
  440. default:
  441. return qfalse;
  442. break;
  443. }
  444. VectorMA( throwDir, 2, vForward, throwDir );
  445. VectorScale( throwDir, 250, throwDir );//FIXME: pass in the throw strength?
  446. return qtrue;
  447. }
  448. int PM_AnimLevelForSaberAnim( int anim )
  449. {
  450. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_D1_B____ )
  451. {
  452. return FORCE_LEVEL_1;
  453. }
  454. if ( anim >= BOTH_A2_T__B_ && anim <= BOTH_D2_B____ )
  455. {
  456. return FORCE_LEVEL_2;
  457. }
  458. if ( anim >= BOTH_A3_T__B_ && anim <= BOTH_D3_B____ )
  459. {
  460. return FORCE_LEVEL_3;
  461. }
  462. if ( anim >= BOTH_A4_T__B_ && anim <= BOTH_D4_B____ )
  463. {//desann
  464. return FORCE_LEVEL_4;
  465. }
  466. if ( anim >= BOTH_A5_T__B_ && anim <= BOTH_D5_B____ )
  467. {//tavion
  468. return FORCE_LEVEL_5;
  469. }
  470. if ( anim >= BOTH_A6_T__B_ && anim <= BOTH_D6_B____ )
  471. {//dual
  472. return SS_DUAL;
  473. }
  474. if ( anim >= BOTH_A7_T__B_ && anim <= BOTH_D7_B____ )
  475. {//staff
  476. return SS_STAFF;
  477. }
  478. return FORCE_LEVEL_0;
  479. }
  480. int PM_PowerLevelForSaberAnim( playerState_t *ps, int saberNum )
  481. {
  482. int anim = ps->torsoAnim;
  483. int animTimeElapsed = PM_AnimLength( g_entities[ps->clientNum].client->clientInfo.animFileIndex, (animNumber_t)anim ) - ps->torsoAnimTimer;
  484. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_D1_B____ )
  485. {
  486. //FIXME: these two need their own style
  487. if ( ps->saber[0].type == SABER_LANCE )
  488. {
  489. return FORCE_LEVEL_4;
  490. }
  491. else if ( ps->saber[0].type == SABER_TRIDENT )
  492. {
  493. return FORCE_LEVEL_3;
  494. }
  495. return FORCE_LEVEL_1;
  496. }
  497. if ( anim >= BOTH_A2_T__B_ && anim <= BOTH_D2_B____ )
  498. {
  499. return FORCE_LEVEL_2;
  500. }
  501. if ( anim >= BOTH_A3_T__B_ && anim <= BOTH_D3_B____ )
  502. {
  503. return FORCE_LEVEL_3;
  504. }
  505. if ( anim >= BOTH_A4_T__B_ && anim <= BOTH_D4_B____ )
  506. {//desann
  507. return FORCE_LEVEL_4;
  508. }
  509. if ( anim >= BOTH_A5_T__B_ && anim <= BOTH_D5_B____ )
  510. {//tavion
  511. return FORCE_LEVEL_2;
  512. }
  513. if ( anim >= BOTH_A6_T__B_ && anim <= BOTH_D6_B____ )
  514. {//dual
  515. return FORCE_LEVEL_2;
  516. }
  517. if ( anim >= BOTH_A7_T__B_ && anim <= BOTH_D7_B____ )
  518. {//staff
  519. return FORCE_LEVEL_2;
  520. }
  521. if ( ( anim >= BOTH_P1_S1_T_ && anim <= BOTH_P1_S1_BR )
  522. || ( anim >= BOTH_P6_S6_T_ && anim <= BOTH_P6_S6_BR )
  523. || ( anim >= BOTH_P7_S7_T_ && anim <= BOTH_P7_S7_BR ) )
  524. {//parries
  525. switch ( ps->saberAnimLevel )
  526. {
  527. case SS_STRONG:
  528. case SS_DESANN:
  529. return FORCE_LEVEL_3;
  530. break;
  531. case SS_TAVION:
  532. case SS_STAFF:
  533. case SS_DUAL:
  534. case SS_MEDIUM:
  535. return FORCE_LEVEL_2;
  536. break;
  537. case SS_FAST:
  538. return FORCE_LEVEL_1;
  539. break;
  540. default:
  541. return FORCE_LEVEL_0;
  542. break;
  543. }
  544. }
  545. if ( ( anim >= BOTH_K1_S1_T_ && anim <= BOTH_K1_S1_BR )
  546. || ( anim >= BOTH_K6_S6_T_ && anim <= BOTH_K6_S6_BR )
  547. || ( anim >= BOTH_K7_S7_T_ && anim <= BOTH_K7_S7_BR ) )
  548. {//knockaways
  549. return FORCE_LEVEL_3;
  550. }
  551. if ( ( anim >= BOTH_V1_BR_S1 && anim <= BOTH_V1_B__S1 )
  552. || ( anim >= BOTH_V6_BR_S6 && anim <= BOTH_V6_B__S6 )
  553. || ( anim >= BOTH_V7_BR_S7 && anim <= BOTH_V7_B__S7 ) )
  554. {//knocked-away attacks
  555. return FORCE_LEVEL_1;
  556. }
  557. if ( ( anim >= BOTH_H1_S1_T_ && anim <= BOTH_H1_S1_BR )
  558. || ( anim >= BOTH_H6_S6_T_ && anim <= BOTH_H6_S6_BR )
  559. || ( anim >= BOTH_H7_S7_T_ && anim <= BOTH_H7_S7_BR ) )
  560. {//broken parries
  561. return FORCE_LEVEL_0;
  562. }
  563. switch ( anim )
  564. {
  565. case BOTH_A2_STABBACK1:
  566. if ( ps->torsoAnimTimer < 450 )
  567. {//end of anim
  568. return FORCE_LEVEL_0;
  569. }
  570. else if ( animTimeElapsed < 400 )
  571. {//beginning of anim
  572. return FORCE_LEVEL_0;
  573. }
  574. return FORCE_LEVEL_3;
  575. break;
  576. case BOTH_ATTACK_BACK:
  577. if ( ps->torsoAnimTimer < 500 )
  578. {//end of anim
  579. return FORCE_LEVEL_0;
  580. }
  581. return FORCE_LEVEL_3;
  582. break;
  583. case BOTH_CROUCHATTACKBACK1:
  584. if ( ps->torsoAnimTimer < 800 )
  585. {//end of anim
  586. return FORCE_LEVEL_0;
  587. }
  588. return FORCE_LEVEL_3;
  589. break;
  590. case BOTH_BUTTERFLY_LEFT:
  591. case BOTH_BUTTERFLY_RIGHT:
  592. case BOTH_BUTTERFLY_FL1:
  593. case BOTH_BUTTERFLY_FR1:
  594. //FIXME: break up?
  595. return FORCE_LEVEL_3;
  596. break;
  597. case BOTH_FJSS_TR_BL:
  598. case BOTH_FJSS_TL_BR:
  599. //FIXME: break up?
  600. return FORCE_LEVEL_3;
  601. break;
  602. case BOTH_K1_S1_T_: //# knockaway saber top
  603. case BOTH_K1_S1_TR: //# knockaway saber top right
  604. case BOTH_K1_S1_TL: //# knockaway saber top left
  605. case BOTH_K1_S1_BL: //# knockaway saber bottom left
  606. case BOTH_K1_S1_B_: //# knockaway saber bottom
  607. case BOTH_K1_S1_BR: //# knockaway saber bottom right
  608. //FIXME: break up?
  609. return FORCE_LEVEL_3;
  610. break;
  611. case BOTH_LUNGE2_B__T_:
  612. if ( ps->torsoAnimTimer < 400 )
  613. {//end of anim
  614. return FORCE_LEVEL_0;
  615. }
  616. else if ( animTimeElapsed < 150 )
  617. {//beginning of anim
  618. return FORCE_LEVEL_0;
  619. }
  620. return FORCE_LEVEL_3;
  621. break;
  622. case BOTH_FORCELEAP2_T__B_:
  623. if ( ps->torsoAnimTimer < 400 )
  624. {//end of anim
  625. return FORCE_LEVEL_0;
  626. }
  627. else if ( animTimeElapsed < 550 )
  628. {//beginning of anim
  629. return FORCE_LEVEL_0;
  630. }
  631. return FORCE_LEVEL_3;
  632. break;
  633. case BOTH_VS_ATR_S:
  634. case BOTH_VS_ATL_S:
  635. case BOTH_VT_ATR_S:
  636. case BOTH_VT_ATL_S:
  637. return FORCE_LEVEL_3;//???
  638. break;
  639. case BOTH_JUMPFLIPSLASHDOWN1:
  640. if ( ps->torsoAnimTimer <= 900 )
  641. {//end of anim
  642. return FORCE_LEVEL_0;
  643. }
  644. else if ( animTimeElapsed < 550 )
  645. {//beginning of anim
  646. return FORCE_LEVEL_0;
  647. }
  648. return FORCE_LEVEL_3;
  649. break;
  650. case BOTH_JUMPFLIPSTABDOWN:
  651. if ( ps->torsoAnimTimer <= 1200 )
  652. {//end of anim
  653. return FORCE_LEVEL_0;
  654. }
  655. else if ( animTimeElapsed <= 250 )
  656. {//beginning of anim
  657. return FORCE_LEVEL_0;
  658. }
  659. return FORCE_LEVEL_3;
  660. break;
  661. case BOTH_JUMPATTACK6:
  662. /*
  663. if (pm->ps)
  664. {
  665. if ( ( pm->ps->legsAnimTimer >= 1450
  666. && PM_AnimLength( g_entities[ps->clientNum].client->clientInfo.animFileIndex, BOTH_JUMPATTACK6 ) - pm->ps->legsAnimTimer >= 400 )
  667. ||(pm->ps->legsAnimTimer >= 400
  668. && PM_AnimLength( g_entities[ps->clientNum].client->clientInfo.animFileIndex, BOTH_JUMPATTACK6 ) - pm->ps->legsAnimTimer >= 1100 ) )
  669. {//pretty much sideways
  670. return FORCE_LEVEL_3;
  671. }
  672. }
  673. */
  674. if ( ( ps->torsoAnimTimer >= 1450
  675. && animTimeElapsed >= 400 )
  676. ||(ps->torsoAnimTimer >= 400
  677. && animTimeElapsed >= 1100 ) )
  678. {//pretty much sideways
  679. return FORCE_LEVEL_3;
  680. }
  681. return FORCE_LEVEL_0;
  682. break;
  683. case BOTH_JUMPATTACK7:
  684. if ( ps->torsoAnimTimer <= 1200 )
  685. {//end of anim
  686. return FORCE_LEVEL_0;
  687. }
  688. else if ( animTimeElapsed < 200 )
  689. {//beginning of anim
  690. return FORCE_LEVEL_0;
  691. }
  692. return FORCE_LEVEL_3;
  693. break;
  694. case BOTH_SPINATTACK6:
  695. if ( animTimeElapsed <= 200 )
  696. {//beginning of anim
  697. return FORCE_LEVEL_0;
  698. }
  699. return FORCE_LEVEL_3;
  700. break;
  701. case BOTH_SPINATTACK7:
  702. if ( ps->torsoAnimTimer <= 500 )
  703. {//end of anim
  704. return FORCE_LEVEL_0;
  705. }
  706. else if ( animTimeElapsed < 500 )
  707. {//beginning of anim
  708. return FORCE_LEVEL_0;
  709. }
  710. return FORCE_LEVEL_3;
  711. break;
  712. case BOTH_FORCELONGLEAP_ATTACK:
  713. if ( animTimeElapsed <= 200 )
  714. {//1st four frames of anim
  715. return FORCE_LEVEL_3;
  716. }
  717. break;
  718. /*
  719. case BOTH_A7_KICK_F://these kicks attack, too
  720. case BOTH_A7_KICK_B:
  721. case BOTH_A7_KICK_R:
  722. case BOTH_A7_KICK_L:
  723. //FIXME: break up
  724. return FORCE_LEVEL_3;
  725. break;
  726. */
  727. case BOTH_STABDOWN:
  728. if ( ps->torsoAnimTimer <= 900 )
  729. {//end of anim
  730. return FORCE_LEVEL_3;
  731. }
  732. break;
  733. case BOTH_STABDOWN_STAFF:
  734. if ( ps->torsoAnimTimer <= 850 )
  735. {//end of anim
  736. return FORCE_LEVEL_3;
  737. }
  738. break;
  739. case BOTH_STABDOWN_DUAL:
  740. if ( ps->torsoAnimTimer <= 900 )
  741. {//end of anim
  742. return FORCE_LEVEL_3;
  743. }
  744. break;
  745. case BOTH_A6_SABERPROTECT:
  746. if ( ps->torsoAnimTimer < 650 )
  747. {//end of anim
  748. return FORCE_LEVEL_0;
  749. }
  750. return FORCE_LEVEL_3;
  751. break;
  752. case BOTH_A7_SOULCAL:
  753. if ( ps->torsoAnimTimer < 650 )
  754. {//end of anim
  755. return FORCE_LEVEL_0;
  756. }
  757. else if ( animTimeElapsed < 600 )
  758. {//beginning of anim
  759. return FORCE_LEVEL_0;
  760. }
  761. return FORCE_LEVEL_3;
  762. break;
  763. case BOTH_A1_SPECIAL:
  764. if ( ps->torsoAnimTimer < 600 )
  765. {//end of anim
  766. return FORCE_LEVEL_0;
  767. }
  768. else if ( animTimeElapsed < 200 )
  769. {//beginning of anim
  770. return FORCE_LEVEL_0;
  771. }
  772. return FORCE_LEVEL_3;
  773. break;
  774. case BOTH_A2_SPECIAL:
  775. if ( ps->torsoAnimTimer < 300 )
  776. {//end of anim
  777. return FORCE_LEVEL_0;
  778. }
  779. else if ( animTimeElapsed < 200 )
  780. {//beginning of anim
  781. return FORCE_LEVEL_0;
  782. }
  783. return FORCE_LEVEL_3;
  784. break;
  785. case BOTH_A3_SPECIAL:
  786. if ( ps->torsoAnimTimer < 700 )
  787. {//end of anim
  788. return FORCE_LEVEL_0;
  789. }
  790. else if ( animTimeElapsed < 200 )
  791. {//beginning of anim
  792. return FORCE_LEVEL_0;
  793. }
  794. return FORCE_LEVEL_3;
  795. break;
  796. case BOTH_FLIP_ATTACK7:
  797. return FORCE_LEVEL_3;
  798. break;
  799. case BOTH_PULL_IMPALE_STAB:
  800. if ( ps->torsoAnimTimer < 1000 )
  801. {//end of anim
  802. return FORCE_LEVEL_0;
  803. }
  804. return FORCE_LEVEL_3;
  805. break;
  806. case BOTH_PULL_IMPALE_SWING:
  807. if ( ps->torsoAnimTimer < 500 )//750 )
  808. {//end of anim
  809. return FORCE_LEVEL_0;
  810. }
  811. else if ( animTimeElapsed < 650 )//600 )
  812. {//beginning of anim
  813. return FORCE_LEVEL_0;
  814. }
  815. return FORCE_LEVEL_3;
  816. break;
  817. case BOTH_ALORA_SPIN_SLASH:
  818. if ( ps->torsoAnimTimer < 900 )
  819. {//end of anim
  820. return FORCE_LEVEL_0;
  821. }
  822. else if ( animTimeElapsed < 250 )
  823. {//beginning of anim
  824. return FORCE_LEVEL_0;
  825. }
  826. return FORCE_LEVEL_3;
  827. break;
  828. case BOTH_A6_FB:
  829. if ( ps->torsoAnimTimer < 250 )
  830. {//end of anim
  831. return FORCE_LEVEL_0;
  832. }
  833. else if ( animTimeElapsed < 250 )
  834. {//beginning of anim
  835. return FORCE_LEVEL_0;
  836. }
  837. return FORCE_LEVEL_3;
  838. break;
  839. case BOTH_A6_LR:
  840. if ( ps->torsoAnimTimer < 250 )
  841. {//end of anim
  842. return FORCE_LEVEL_0;
  843. }
  844. else if ( animTimeElapsed < 250 )
  845. {//beginning of anim
  846. return FORCE_LEVEL_0;
  847. }
  848. return FORCE_LEVEL_3;
  849. break;
  850. case BOTH_A7_HILT:
  851. return FORCE_LEVEL_0;
  852. break;
  853. //===SABERLOCK SUPERBREAKS START===========================================================================
  854. case BOTH_LK_S_DL_T_SB_1_W:
  855. if ( ps->torsoAnimTimer < 700 )
  856. {//end of anim
  857. return FORCE_LEVEL_0;
  858. }
  859. return FORCE_LEVEL_5;
  860. break;
  861. case BOTH_LK_S_ST_S_SB_1_W:
  862. if ( ps->torsoAnimTimer < 300 )
  863. {//end of anim
  864. return FORCE_LEVEL_0;
  865. }
  866. return FORCE_LEVEL_5;
  867. break;
  868. case BOTH_LK_S_DL_S_SB_1_W:
  869. case BOTH_LK_S_S_S_SB_1_W:
  870. if ( ps->torsoAnimTimer < 700 )
  871. {//end of anim
  872. return FORCE_LEVEL_0;
  873. }
  874. else if ( animTimeElapsed < 400 )
  875. {//beginning of anim
  876. return FORCE_LEVEL_0;
  877. }
  878. return FORCE_LEVEL_5;
  879. break;
  880. case BOTH_LK_S_ST_T_SB_1_W:
  881. case BOTH_LK_S_S_T_SB_1_W:
  882. if ( ps->torsoAnimTimer < 150 )
  883. {//end of anim
  884. return FORCE_LEVEL_0;
  885. }
  886. else if ( animTimeElapsed < 400 )
  887. {//beginning of anim
  888. return FORCE_LEVEL_0;
  889. }
  890. return FORCE_LEVEL_5;
  891. break;
  892. case BOTH_LK_DL_DL_T_SB_1_W:
  893. return FORCE_LEVEL_5;
  894. break;
  895. case BOTH_LK_DL_DL_S_SB_1_W:
  896. case BOTH_LK_DL_ST_S_SB_1_W:
  897. if ( animTimeElapsed < 1000 )
  898. {//beginning of anim
  899. return FORCE_LEVEL_0;
  900. }
  901. return FORCE_LEVEL_5;
  902. break;
  903. case BOTH_LK_DL_ST_T_SB_1_W:
  904. if ( ps->torsoAnimTimer < 950 )
  905. {//end of anim
  906. return FORCE_LEVEL_0;
  907. }
  908. else if ( animTimeElapsed < 650 )
  909. {//beginning of anim
  910. return FORCE_LEVEL_0;
  911. }
  912. return FORCE_LEVEL_5;
  913. break;
  914. case BOTH_LK_DL_S_S_SB_1_W:
  915. if ( saberNum != 0 )
  916. {//only right hand saber does damage in this suberbreak
  917. return FORCE_LEVEL_0;
  918. }
  919. if ( ps->torsoAnimTimer < 900 )
  920. {//end of anim
  921. return FORCE_LEVEL_0;
  922. }
  923. else if ( animTimeElapsed < 450 )
  924. {//beginning of anim
  925. return FORCE_LEVEL_0;
  926. }
  927. return FORCE_LEVEL_5;
  928. break;
  929. case BOTH_LK_DL_S_T_SB_1_W:
  930. if ( saberNum != 0 )
  931. {//only right hand saber does damage in this suberbreak
  932. return FORCE_LEVEL_0;
  933. }
  934. if ( ps->torsoAnimTimer < 250 )
  935. {//end of anim
  936. return FORCE_LEVEL_0;
  937. }
  938. else if ( animTimeElapsed < 150 )
  939. {//beginning of anim
  940. return FORCE_LEVEL_0;
  941. }
  942. return FORCE_LEVEL_5;
  943. break;
  944. case BOTH_LK_ST_DL_S_SB_1_W:
  945. return FORCE_LEVEL_5;
  946. break;
  947. case BOTH_LK_ST_DL_T_SB_1_W:
  948. //special suberbreak - doesn't kill, just kicks them backwards
  949. return FORCE_LEVEL_0;
  950. break;
  951. case BOTH_LK_ST_ST_S_SB_1_W:
  952. case BOTH_LK_ST_S_S_SB_1_W:
  953. if ( ps->torsoAnimTimer < 800 )
  954. {//end of anim
  955. return FORCE_LEVEL_0;
  956. }
  957. else if ( animTimeElapsed < 350 )
  958. {//beginning of anim
  959. return FORCE_LEVEL_0;
  960. }
  961. return FORCE_LEVEL_5;
  962. break;
  963. case BOTH_LK_ST_ST_T_SB_1_W:
  964. case BOTH_LK_ST_S_T_SB_1_W:
  965. return FORCE_LEVEL_5;
  966. break;
  967. //===SABERLOCK SUPERBREAKS START===========================================================================
  968. case BOTH_HANG_ATTACK:
  969. //FIME: break up
  970. if ( ps->torsoAnimTimer < 1000 )
  971. {//end of anim
  972. return FORCE_LEVEL_0;
  973. }
  974. else if ( animTimeElapsed < 250 )
  975. {//beginning of anim
  976. return FORCE_LEVEL_0;
  977. }
  978. else
  979. {//sweet spot
  980. return FORCE_LEVEL_5;
  981. }
  982. break;
  983. case BOTH_ROLL_STAB:
  984. if ( animTimeElapsed > 400 )
  985. {//end of anim
  986. return FORCE_LEVEL_0;
  987. }
  988. else
  989. {
  990. return FORCE_LEVEL_3;
  991. }
  992. break;
  993. }
  994. return FORCE_LEVEL_0;
  995. }
  996. qboolean PM_InAnimForSaberMove( int anim, int saberMove )
  997. {
  998. switch ( anim )
  999. {//special case anims
  1000. case BOTH_A2_STABBACK1:
  1001. case BOTH_ATTACK_BACK:
  1002. case BOTH_CROUCHATTACKBACK1:
  1003. case BOTH_ROLL_STAB:
  1004. case BOTH_BUTTERFLY_LEFT:
  1005. case BOTH_BUTTERFLY_RIGHT:
  1006. case BOTH_BUTTERFLY_FL1:
  1007. case BOTH_BUTTERFLY_FR1:
  1008. case BOTH_FJSS_TR_BL:
  1009. case BOTH_FJSS_TL_BR:
  1010. case BOTH_LUNGE2_B__T_:
  1011. case BOTH_FORCELEAP2_T__B_:
  1012. case BOTH_JUMPFLIPSLASHDOWN1://#
  1013. case BOTH_JUMPFLIPSTABDOWN://#
  1014. case BOTH_JUMPATTACK6:
  1015. case BOTH_JUMPATTACK7:
  1016. case BOTH_SPINATTACK6:
  1017. case BOTH_SPINATTACK7:
  1018. case BOTH_VS_ATR_S:
  1019. case BOTH_VS_ATL_S:
  1020. case BOTH_VT_ATR_S:
  1021. case BOTH_VT_ATL_S:
  1022. case BOTH_FORCELONGLEAP_ATTACK:
  1023. case BOTH_A7_KICK_F:
  1024. case BOTH_A7_KICK_B:
  1025. case BOTH_A7_KICK_R:
  1026. case BOTH_A7_KICK_L:
  1027. case BOTH_A7_KICK_S:
  1028. case BOTH_A7_KICK_BF:
  1029. case BOTH_A7_KICK_RL:
  1030. case BOTH_A7_KICK_F_AIR:
  1031. case BOTH_A7_KICK_B_AIR:
  1032. case BOTH_A7_KICK_R_AIR:
  1033. case BOTH_A7_KICK_L_AIR:
  1034. case BOTH_STABDOWN:
  1035. case BOTH_STABDOWN_STAFF:
  1036. case BOTH_STABDOWN_DUAL:
  1037. case BOTH_A6_SABERPROTECT:
  1038. case BOTH_A7_SOULCAL:
  1039. case BOTH_A1_SPECIAL:
  1040. case BOTH_A2_SPECIAL:
  1041. case BOTH_A3_SPECIAL:
  1042. case BOTH_FLIP_ATTACK7:
  1043. case BOTH_PULL_IMPALE_STAB:
  1044. case BOTH_PULL_IMPALE_SWING:
  1045. case BOTH_ALORA_SPIN_SLASH:
  1046. case BOTH_A6_FB:
  1047. case BOTH_A6_LR:
  1048. case BOTH_A7_HILT:
  1049. case BOTH_LK_S_DL_S_SB_1_W:
  1050. case BOTH_LK_S_DL_T_SB_1_W:
  1051. case BOTH_LK_S_ST_S_SB_1_W:
  1052. case BOTH_LK_S_ST_T_SB_1_W:
  1053. case BOTH_LK_S_S_S_SB_1_W:
  1054. case BOTH_LK_S_S_T_SB_1_W:
  1055. case BOTH_LK_DL_DL_S_SB_1_W:
  1056. case BOTH_LK_DL_DL_T_SB_1_W:
  1057. case BOTH_LK_DL_ST_S_SB_1_W:
  1058. case BOTH_LK_DL_ST_T_SB_1_W:
  1059. case BOTH_LK_DL_S_S_SB_1_W:
  1060. case BOTH_LK_DL_S_T_SB_1_W:
  1061. case BOTH_LK_ST_DL_S_SB_1_W:
  1062. case BOTH_LK_ST_DL_T_SB_1_W:
  1063. case BOTH_LK_ST_ST_S_SB_1_W:
  1064. case BOTH_LK_ST_ST_T_SB_1_W:
  1065. case BOTH_LK_ST_S_S_SB_1_W:
  1066. case BOTH_LK_ST_S_T_SB_1_W:
  1067. case BOTH_HANG_ATTACK:
  1068. return qtrue;
  1069. }
  1070. if ( PM_SaberDrawPutawayAnim( anim ) )
  1071. {
  1072. if ( saberMove == LS_DRAW || saberMove == LS_PUTAWAY )
  1073. {
  1074. return qtrue;
  1075. }
  1076. return qfalse;
  1077. }
  1078. else if ( PM_SaberStanceAnim( anim ) )
  1079. {
  1080. if ( saberMove == LS_READY )
  1081. {
  1082. return qtrue;
  1083. }
  1084. return qfalse;
  1085. }
  1086. int animLevel = PM_AnimLevelForSaberAnim( anim );
  1087. if ( animLevel <= 0 )
  1088. {//NOTE: this will always return false for the ready poses and putaway/draw...
  1089. return qfalse;
  1090. }
  1091. //drop the anim to the first level and start the checks there
  1092. anim -= (animLevel-FORCE_LEVEL_1)*SABER_ANIM_GROUP_SIZE;
  1093. //check level 1
  1094. if ( anim == saberMoveData[saberMove].animToUse )
  1095. {
  1096. return qtrue;
  1097. }
  1098. //check level 2
  1099. anim += SABER_ANIM_GROUP_SIZE;
  1100. if ( anim == saberMoveData[saberMove].animToUse )
  1101. {
  1102. return qtrue;
  1103. }
  1104. //check level 3
  1105. anim += SABER_ANIM_GROUP_SIZE;
  1106. if ( anim == saberMoveData[saberMove].animToUse )
  1107. {
  1108. return qtrue;
  1109. }
  1110. //check level 4
  1111. anim += SABER_ANIM_GROUP_SIZE;
  1112. if ( anim == saberMoveData[saberMove].animToUse )
  1113. {
  1114. return qtrue;
  1115. }
  1116. //check level 5
  1117. anim += SABER_ANIM_GROUP_SIZE;
  1118. if ( anim == saberMoveData[saberMove].animToUse )
  1119. {
  1120. return qtrue;
  1121. }
  1122. if ( anim >= BOTH_P1_S1_T_ && anim <= BOTH_H1_S1_BR )
  1123. {//parries, knockaways and broken parries
  1124. return (anim==saberMoveData[saberMove].animToUse);
  1125. }
  1126. return qfalse;
  1127. }
  1128. qboolean PM_SaberInIdle( int move )
  1129. {
  1130. switch ( move )
  1131. {
  1132. case LS_NONE:
  1133. case LS_READY:
  1134. case LS_DRAW:
  1135. case LS_PUTAWAY:
  1136. return qtrue;
  1137. break;
  1138. }
  1139. return qfalse;
  1140. }
  1141. qboolean PM_SaberInSpecialAttack( int anim )
  1142. {
  1143. switch ( anim )
  1144. {
  1145. case BOTH_A2_STABBACK1:
  1146. case BOTH_ATTACK_BACK:
  1147. case BOTH_CROUCHATTACKBACK1:
  1148. case BOTH_ROLL_STAB:
  1149. case BOTH_BUTTERFLY_LEFT:
  1150. case BOTH_BUTTERFLY_RIGHT:
  1151. case BOTH_BUTTERFLY_FL1:
  1152. case BOTH_BUTTERFLY_FR1:
  1153. case BOTH_FJSS_TR_BL:
  1154. case BOTH_FJSS_TL_BR:
  1155. case BOTH_LUNGE2_B__T_:
  1156. case BOTH_FORCELEAP2_T__B_:
  1157. case BOTH_JUMPFLIPSLASHDOWN1://#
  1158. case BOTH_JUMPFLIPSTABDOWN://#
  1159. case BOTH_JUMPATTACK6:
  1160. case BOTH_JUMPATTACK7:
  1161. case BOTH_SPINATTACK6:
  1162. case BOTH_SPINATTACK7:
  1163. case BOTH_FORCELONGLEAP_ATTACK:
  1164. case BOTH_VS_ATR_S:
  1165. case BOTH_VS_ATL_S:
  1166. case BOTH_VT_ATR_S:
  1167. case BOTH_VT_ATL_S:
  1168. case BOTH_A7_KICK_F:
  1169. case BOTH_A7_KICK_B:
  1170. case BOTH_A7_KICK_R:
  1171. case BOTH_A7_KICK_L:
  1172. case BOTH_A7_KICK_S:
  1173. case BOTH_A7_KICK_BF:
  1174. case BOTH_A7_KICK_RL:
  1175. case BOTH_A7_KICK_F_AIR:
  1176. case BOTH_A7_KICK_B_AIR:
  1177. case BOTH_A7_KICK_R_AIR:
  1178. case BOTH_A7_KICK_L_AIR:
  1179. case BOTH_STABDOWN:
  1180. case BOTH_STABDOWN_STAFF:
  1181. case BOTH_STABDOWN_DUAL:
  1182. case BOTH_A6_SABERPROTECT:
  1183. case BOTH_A7_SOULCAL:
  1184. case BOTH_A1_SPECIAL:
  1185. case BOTH_A2_SPECIAL:
  1186. case BOTH_A3_SPECIAL:
  1187. case BOTH_FLIP_ATTACK7:
  1188. case BOTH_PULL_IMPALE_STAB:
  1189. case BOTH_PULL_IMPALE_SWING:
  1190. case BOTH_ALORA_SPIN_SLASH:
  1191. case BOTH_A6_FB:
  1192. case BOTH_A6_LR:
  1193. case BOTH_A7_HILT:
  1194. case BOTH_LK_S_DL_S_SB_1_W:
  1195. case BOTH_LK_S_DL_T_SB_1_W:
  1196. case BOTH_LK_S_ST_S_SB_1_W:
  1197. case BOTH_LK_S_ST_T_SB_1_W:
  1198. case BOTH_LK_S_S_S_SB_1_W:
  1199. case BOTH_LK_S_S_T_SB_1_W:
  1200. case BOTH_LK_DL_DL_S_SB_1_W:
  1201. case BOTH_LK_DL_DL_T_SB_1_W:
  1202. case BOTH_LK_DL_ST_S_SB_1_W:
  1203. case BOTH_LK_DL_ST_T_SB_1_W:
  1204. case BOTH_LK_DL_S_S_SB_1_W:
  1205. case BOTH_LK_DL_S_T_SB_1_W:
  1206. case BOTH_LK_ST_DL_S_SB_1_W:
  1207. case BOTH_LK_ST_DL_T_SB_1_W:
  1208. case BOTH_LK_ST_ST_S_SB_1_W:
  1209. case BOTH_LK_ST_ST_T_SB_1_W:
  1210. case BOTH_LK_ST_S_S_SB_1_W:
  1211. case BOTH_LK_ST_S_T_SB_1_W:
  1212. case BOTH_HANG_ATTACK:
  1213. return qtrue;
  1214. }
  1215. return qfalse;
  1216. }
  1217. qboolean PM_SaberInAttack( int move )
  1218. {
  1219. if ( move >= LS_A_TL2BR && move <= LS_A_T2B )
  1220. {
  1221. return qtrue;
  1222. }
  1223. switch ( move )
  1224. {
  1225. case LS_A_BACK:
  1226. case LS_A_BACK_CR:
  1227. case LS_A_BACKSTAB:
  1228. case LS_ROLL_STAB:
  1229. case LS_A_LUNGE:
  1230. case LS_A_JUMP_T__B_:
  1231. case LS_A_FLIP_STAB:
  1232. case LS_A_FLIP_SLASH:
  1233. case LS_JUMPATTACK_DUAL:
  1234. case LS_JUMPATTACK_ARIAL_LEFT:
  1235. case LS_JUMPATTACK_ARIAL_RIGHT:
  1236. case LS_JUMPATTACK_CART_LEFT:
  1237. case LS_JUMPATTACK_CART_RIGHT:
  1238. case LS_JUMPATTACK_STAFF_LEFT:
  1239. case LS_JUMPATTACK_STAFF_RIGHT:
  1240. case LS_BUTTERFLY_LEFT:
  1241. case LS_BUTTERFLY_RIGHT:
  1242. case LS_A_BACKFLIP_ATK:
  1243. case LS_SPINATTACK_DUAL:
  1244. case LS_SPINATTACK:
  1245. case LS_LEAP_ATTACK:
  1246. case LS_SWOOP_ATTACK_RIGHT:
  1247. case LS_SWOOP_ATTACK_LEFT:
  1248. case LS_TAUNTAUN_ATTACK_RIGHT:
  1249. case LS_TAUNTAUN_ATTACK_LEFT:
  1250. case LS_KICK_F:
  1251. case LS_KICK_B:
  1252. case LS_KICK_R:
  1253. case LS_KICK_L:
  1254. case LS_KICK_S:
  1255. case LS_KICK_BF:
  1256. case LS_KICK_RL:
  1257. case LS_KICK_F_AIR:
  1258. case LS_KICK_B_AIR:
  1259. case LS_KICK_R_AIR:
  1260. case LS_KICK_L_AIR:
  1261. case LS_STABDOWN:
  1262. case LS_STABDOWN_STAFF:
  1263. case LS_STABDOWN_DUAL:
  1264. case LS_DUAL_SPIN_PROTECT:
  1265. case LS_STAFF_SOULCAL:
  1266. case LS_A1_SPECIAL:
  1267. case LS_A2_SPECIAL:
  1268. case LS_A3_SPECIAL:
  1269. case LS_UPSIDE_DOWN_ATTACK:
  1270. case LS_PULL_ATTACK_STAB:
  1271. case LS_PULL_ATTACK_SWING:
  1272. case LS_SPINATTACK_ALORA:
  1273. case LS_DUAL_FB:
  1274. case LS_DUAL_LR:
  1275. case LS_HILT_BASH:
  1276. return qtrue;
  1277. break;
  1278. }
  1279. return qfalse;
  1280. }
  1281. qboolean PM_SaberInTransition( int move )
  1282. {
  1283. if ( move >= LS_T1_BR__R && move <= LS_T1_BL__L )
  1284. {
  1285. return qtrue;
  1286. }
  1287. return qfalse;
  1288. }
  1289. qboolean PM_SaberInStart( int move )
  1290. {
  1291. if ( move >= LS_S_TL2BR && move <= LS_S_T2B )
  1292. {
  1293. return qtrue;
  1294. }
  1295. return qfalse;
  1296. }
  1297. qboolean PM_SaberInReturn( int move )
  1298. {
  1299. if ( move >= LS_R_TL2BR && move <= LS_R_T2B )
  1300. {
  1301. return qtrue;
  1302. }
  1303. return qfalse;
  1304. }
  1305. qboolean PM_SaberInTransitionAny( int move )
  1306. {
  1307. if ( PM_SaberInStart( move ) )
  1308. {
  1309. return qtrue;
  1310. }
  1311. else if ( PM_SaberInTransition( move ) )
  1312. {
  1313. return qtrue;
  1314. }
  1315. else if ( PM_SaberInReturn( move ) )
  1316. {
  1317. return qtrue;
  1318. }
  1319. return qfalse;
  1320. }
  1321. qboolean PM_SaberInBounce( int move )
  1322. {
  1323. if ( move >= LS_B1_BR && move <= LS_B1_BL )
  1324. {
  1325. return qtrue;
  1326. }
  1327. if ( move >= LS_D1_BR && move <= LS_D1_BL )
  1328. {
  1329. return qtrue;
  1330. }
  1331. return qfalse;
  1332. }
  1333. qboolean PM_SaberInBrokenParry( int move )
  1334. {
  1335. if ( move >= LS_V1_BR && move <= LS_V1_B_ )
  1336. {
  1337. return qtrue;
  1338. }
  1339. if ( move >= LS_H1_T_ && move <= LS_H1_BL )
  1340. {
  1341. return qtrue;
  1342. }
  1343. return qfalse;
  1344. }
  1345. qboolean PM_SaberInDeflect( int move )
  1346. {
  1347. if ( move >= LS_D1_BR && move <= LS_D1_B_ )
  1348. {
  1349. return qtrue;
  1350. }
  1351. return qfalse;
  1352. }
  1353. qboolean PM_SaberInParry( int move )
  1354. {
  1355. if ( move >= LS_PARRY_UP && move <= LS_PARRY_LL )
  1356. {
  1357. return qtrue;
  1358. }
  1359. return qfalse;
  1360. }
  1361. qboolean PM_SaberInKnockaway( int move )
  1362. {
  1363. if ( move >= LS_K1_T_ && move <= LS_K1_BL )
  1364. {
  1365. return qtrue;
  1366. }
  1367. return qfalse;
  1368. }
  1369. qboolean PM_SaberInReflect( int move )
  1370. {
  1371. if ( move >= LS_REFLECT_UP && move <= LS_REFLECT_LL )
  1372. {
  1373. return qtrue;
  1374. }
  1375. return qfalse;
  1376. }
  1377. qboolean PM_SaberInSpecial( int move )
  1378. {
  1379. switch( move )
  1380. {
  1381. case LS_A_BACK:
  1382. case LS_A_BACK_CR:
  1383. case LS_A_BACKSTAB:
  1384. case LS_ROLL_STAB:
  1385. case LS_A_LUNGE:
  1386. case LS_A_JUMP_T__B_:
  1387. case LS_A_FLIP_STAB:
  1388. case LS_A_FLIP_SLASH:
  1389. case LS_JUMPATTACK_DUAL:
  1390. case LS_JUMPATTACK_ARIAL_LEFT:
  1391. case LS_JUMPATTACK_ARIAL_RIGHT:
  1392. case LS_JUMPATTACK_CART_LEFT:
  1393. case LS_JUMPATTACK_CART_RIGHT:
  1394. case LS_JUMPATTACK_STAFF_LEFT:
  1395. case LS_JUMPATTACK_STAFF_RIGHT:
  1396. case LS_BUTTERFLY_LEFT:
  1397. case LS_BUTTERFLY_RIGHT:
  1398. case LS_A_BACKFLIP_ATK:
  1399. case LS_SPINATTACK_DUAL:
  1400. case LS_SPINATTACK:
  1401. case LS_LEAP_ATTACK:
  1402. case LS_SWOOP_ATTACK_RIGHT:
  1403. case LS_SWOOP_ATTACK_LEFT:
  1404. case LS_TAUNTAUN_ATTACK_RIGHT:
  1405. case LS_TAUNTAUN_ATTACK_LEFT:
  1406. case LS_KICK_F:
  1407. case LS_KICK_B:
  1408. case LS_KICK_R:
  1409. case LS_KICK_L:
  1410. case LS_KICK_S:
  1411. case LS_KICK_BF:
  1412. case LS_KICK_RL:
  1413. case LS_KICK_F_AIR:
  1414. case LS_KICK_B_AIR:
  1415. case LS_KICK_R_AIR:
  1416. case LS_KICK_L_AIR:
  1417. case LS_STABDOWN:
  1418. case LS_STABDOWN_STAFF:
  1419. case LS_STABDOWN_DUAL:
  1420. case LS_DUAL_SPIN_PROTECT:
  1421. case LS_STAFF_SOULCAL:
  1422. case LS_A1_SPECIAL:
  1423. case LS_A2_SPECIAL:
  1424. case LS_A3_SPECIAL:
  1425. case LS_UPSIDE_DOWN_ATTACK:
  1426. case LS_PULL_ATTACK_STAB:
  1427. case LS_PULL_ATTACK_SWING:
  1428. case LS_SPINATTACK_ALORA:
  1429. case LS_DUAL_FB:
  1430. case LS_DUAL_LR:
  1431. case LS_HILT_BASH:
  1432. return qtrue;
  1433. }
  1434. return qfalse;
  1435. }
  1436. qboolean PM_KickMove( int move )
  1437. {
  1438. switch( move )
  1439. {
  1440. case LS_KICK_F:
  1441. case LS_KICK_B:
  1442. case LS_KICK_R:
  1443. case LS_KICK_L:
  1444. case LS_KICK_S:
  1445. case LS_KICK_BF:
  1446. case LS_KICK_RL:
  1447. case LS_HILT_BASH:
  1448. case LS_KICK_F_AIR:
  1449. case LS_KICK_B_AIR:
  1450. case LS_KICK_R_AIR:
  1451. case LS_KICK_L_AIR:
  1452. return qtrue;
  1453. }
  1454. return qfalse;
  1455. }
  1456. saberMoveName_t PM_BrokenParryForAttack( int move )
  1457. {
  1458. //Our attack was knocked away by a knockaway parry
  1459. //FIXME: need actual anims for this
  1460. //FIXME: need to know which side of the saber was hit! For now, we presume the saber gets knocked away from the center
  1461. switch ( saberMoveData[move].startQuad )
  1462. {
  1463. case Q_B:
  1464. return LS_V1_B_;
  1465. break;
  1466. case Q_BR:
  1467. return LS_V1_BR;
  1468. break;
  1469. case Q_R:
  1470. return LS_V1__R;
  1471. break;
  1472. case Q_TR:
  1473. return LS_V1_TR;
  1474. break;
  1475. case Q_T:
  1476. return LS_V1_T_;
  1477. break;
  1478. case Q_TL:
  1479. return LS_V1_TL;
  1480. break;
  1481. case Q_L:
  1482. return LS_V1__L;
  1483. break;
  1484. case Q_BL:
  1485. return LS_V1_BL;
  1486. break;
  1487. }
  1488. return LS_NONE;
  1489. }
  1490. saberMoveName_t PM_BrokenParryForParry( int move )
  1491. {
  1492. //FIXME: need actual anims for this
  1493. //FIXME: need to know which side of the saber was hit! For now, we presume the saber gets knocked away from the center
  1494. switch ( move )
  1495. {
  1496. case LS_PARRY_UP:
  1497. //Hmm... since we don't know what dir the hit came from, randomly pick knock down or knock back
  1498. if ( Q_irand( 0, 1 ) )
  1499. {
  1500. return LS_H1_B_;
  1501. }
  1502. else
  1503. {
  1504. return LS_H1_T_;
  1505. }
  1506. break;
  1507. case LS_PARRY_UR:
  1508. return LS_H1_TR;
  1509. break;
  1510. case LS_PARRY_UL:
  1511. return LS_H1_TL;
  1512. break;
  1513. case LS_PARRY_LR:
  1514. return LS_H1_BR;
  1515. break;
  1516. case LS_PARRY_LL:
  1517. return LS_H1_BL;
  1518. break;
  1519. case LS_READY:
  1520. return LS_H1_B_;//???
  1521. break;
  1522. }
  1523. return LS_NONE;
  1524. }
  1525. saberMoveName_t PM_KnockawayForParry( int move )
  1526. {
  1527. //FIXME: need actual anims for this
  1528. //FIXME: need to know which side of the saber was hit! For now, we presume the saber gets knocked away from the center
  1529. switch ( move )
  1530. {
  1531. case BLOCKED_TOP://LS_PARRY_UP:
  1532. return LS_K1_T_;//push up
  1533. break;
  1534. case BLOCKED_UPPER_RIGHT://LS_PARRY_UR:
  1535. default://case LS_READY:
  1536. return LS_K1_TR;//push up, slightly to right
  1537. break;
  1538. case BLOCKED_UPPER_LEFT://LS_PARRY_UL:
  1539. return LS_K1_TL;//push up and to left
  1540. break;
  1541. case BLOCKED_LOWER_RIGHT://LS_PARRY_LR:
  1542. return LS_K1_BR;//push down and to left
  1543. break;
  1544. case BLOCKED_LOWER_LEFT://LS_PARRY_LL:
  1545. return LS_K1_BL;//push down and to right
  1546. break;
  1547. }
  1548. //return LS_NONE;
  1549. }
  1550. saberMoveName_t PM_SaberBounceForAttack( int move )
  1551. {
  1552. switch ( saberMoveData[move].startQuad )
  1553. {
  1554. case Q_B:
  1555. case Q_BR:
  1556. return LS_B1_BR;
  1557. break;
  1558. case Q_R:
  1559. return LS_B1__R;
  1560. break;
  1561. case Q_TR:
  1562. return LS_B1_TR;
  1563. break;
  1564. case Q_T:
  1565. return LS_B1_T_;
  1566. break;
  1567. case Q_TL:
  1568. return LS_B1_TL;
  1569. break;
  1570. case Q_L:
  1571. return LS_B1__L;
  1572. break;
  1573. case Q_BL:
  1574. return LS_B1_BL;
  1575. break;
  1576. }
  1577. return LS_NONE;
  1578. }
  1579. saberMoveName_t PM_AttackMoveForQuad( int quad )
  1580. {
  1581. switch ( quad )
  1582. {
  1583. case Q_B:
  1584. case Q_BR:
  1585. return LS_A_BR2TL;
  1586. break;
  1587. case Q_R:
  1588. return LS_A_R2L;
  1589. break;
  1590. case Q_TR:
  1591. return LS_A_TR2BL;
  1592. break;
  1593. case Q_T:
  1594. return LS_A_T2B;
  1595. break;
  1596. case Q_TL:
  1597. return LS_A_TL2BR;
  1598. break;
  1599. case Q_L:
  1600. return LS_A_L2R;
  1601. break;
  1602. case Q_BL:
  1603. return LS_A_BL2TR;
  1604. break;
  1605. }
  1606. return LS_NONE;
  1607. }
  1608. int saberMoveTransitionAngle[Q_NUM_QUADS][Q_NUM_QUADS] =
  1609. {
  1610. 0,//Q_BR,Q_BR,
  1611. 45,//Q_BR,Q_R,
  1612. 90,//Q_BR,Q_TR,
  1613. 135,//Q_BR,Q_T,
  1614. 180,//Q_BR,Q_TL,
  1615. 215,//Q_BR,Q_L,
  1616. 270,//Q_BR,Q_BL,
  1617. 45,//Q_BR,Q_B,
  1618. 45,//Q_R,Q_BR,
  1619. 0,//Q_R,Q_R,
  1620. 45,//Q_R,Q_TR,
  1621. 90,//Q_R,Q_T,
  1622. 135,//Q_R,Q_TL,
  1623. 180,//Q_R,Q_L,
  1624. 215,//Q_R,Q_BL,
  1625. 90,//Q_R,Q_B,
  1626. 90,//Q_TR,Q_BR,
  1627. 45,//Q_TR,Q_R,
  1628. 0,//Q_TR,Q_TR,
  1629. 45,//Q_TR,Q_T,
  1630. 90,//Q_TR,Q_TL,
  1631. 135,//Q_TR,Q_L,
  1632. 180,//Q_TR,Q_BL,
  1633. 135,//Q_TR,Q_B,
  1634. 135,//Q_T,Q_BR,
  1635. 90,//Q_T,Q_R,
  1636. 45,//Q_T,Q_TR,
  1637. 0,//Q_T,Q_T,
  1638. 45,//Q_T,Q_TL,
  1639. 90,//Q_T,Q_L,
  1640. 135,//Q_T,Q_BL,
  1641. 180,//Q_T,Q_B,
  1642. 180,//Q_TL,Q_BR,
  1643. 135,//Q_TL,Q_R,
  1644. 90,//Q_TL,Q_TR,
  1645. 45,//Q_TL,Q_T,
  1646. 0,//Q_TL,Q_TL,
  1647. 45,//Q_TL,Q_L,
  1648. 90,//Q_TL,Q_BL,
  1649. 135,//Q_TL,Q_B,
  1650. 215,//Q_L,Q_BR,
  1651. 180,//Q_L,Q_R,
  1652. 135,//Q_L,Q_TR,
  1653. 90,//Q_L,Q_T,
  1654. 45,//Q_L,Q_TL,
  1655. 0,//Q_L,Q_L,
  1656. 45,//Q_L,Q_BL,
  1657. 90,//Q_L,Q_B,
  1658. 270,//Q_BL,Q_BR,
  1659. 215,//Q_BL,Q_R,
  1660. 180,//Q_BL,Q_TR,
  1661. 135,//Q_BL,Q_T,
  1662. 90,//Q_BL,Q_TL,
  1663. 45,//Q_BL,Q_L,
  1664. 0,//Q_BL,Q_BL,
  1665. 45,//Q_BL,Q_B,
  1666. 45,//Q_B,Q_BR,
  1667. 90,//Q_B,Q_R,
  1668. 135,//Q_B,Q_TR,
  1669. 180,//Q_B,Q_T,
  1670. 135,//Q_B,Q_TL,
  1671. 90,//Q_B,Q_L,
  1672. 45,//Q_B,Q_BL,
  1673. 0//Q_B,Q_B,
  1674. };
  1675. int PM_SaberAttackChainAngle( int move1, int move2 )
  1676. {
  1677. if ( move1 == -1 || move2 == -1 )
  1678. {
  1679. return -1;
  1680. }
  1681. return saberMoveTransitionAngle[saberMoveData[move1].endQuad][saberMoveData[move2].startQuad];
  1682. }
  1683. qboolean PM_SaberKataDone( int curmove = LS_NONE, int newmove = LS_NONE )
  1684. {
  1685. if ( pm->ps->forceRageRecoveryTime > level.time )
  1686. {//rage recovery, only 1 swing at a time (tired)
  1687. if ( pm->ps->saberAttackChainCount > 0 )
  1688. {//swung once
  1689. return qtrue;
  1690. }
  1691. else
  1692. {//allow one attack
  1693. return qfalse;
  1694. }
  1695. }
  1696. else if ( (pm->ps->forcePowersActive&(1<<FP_RAGE)) )
  1697. {//infinite chaining when raged
  1698. return qfalse;
  1699. }
  1700. else if ( pm->ps->saber[0].maxChain == -1 )
  1701. {
  1702. return qfalse;
  1703. }
  1704. else if ( pm->ps->saber[0].maxChain != 0 )
  1705. {
  1706. if ( pm->ps->saberAttackChainCount >= pm->ps->saber[0].maxChain )
  1707. {
  1708. return qtrue;
  1709. }
  1710. else
  1711. {
  1712. return qfalse;
  1713. }
  1714. }
  1715. if ( pm->ps->saberAnimLevel == SS_DESANN || pm->ps->saberAnimLevel == SS_TAVION )
  1716. {//desann and tavion can link up as many attacks as they want
  1717. return qfalse;
  1718. }
  1719. //FIXME: instead of random, apply some sort of logical conditions to whether or
  1720. // not you can chain? Like if you were completely missed, you can't chain as much, or...?
  1721. // And/Or based on FP_SABER_OFFENSE level? So number of attacks you can chain
  1722. // increases with your FP_SABER_OFFENSE skill?
  1723. if ( pm->ps->saberAnimLevel == SS_STAFF )
  1724. {
  1725. //TEMP: for now, let staff attacks infinitely chain
  1726. return qfalse;
  1727. /*
  1728. if ( pm->ps->saberAttackChainCount > Q_irand( 3, 4 ) )
  1729. {
  1730. return qtrue;
  1731. }
  1732. else if ( pm->ps->saberAttackChainCount > 0 )
  1733. {
  1734. int chainAngle = PM_SaberAttackChainAngle( curmove, newmove );
  1735. if ( chainAngle < 135 || chainAngle > 215 )
  1736. {//if trying to chain to a move that doesn't continue the momentum
  1737. if ( pm->ps->saberAttackChainCount > 1 )
  1738. {
  1739. return qtrue;
  1740. }
  1741. }
  1742. else if ( chainAngle == 180 )
  1743. {//continues the momentum perfectly, allow it to chain 66% of the time
  1744. if ( pm->ps->saberAttackChainCount > 2 )
  1745. {
  1746. return qtrue;
  1747. }
  1748. }
  1749. else
  1750. {//would continue the movement somewhat, 50% chance of continuing
  1751. if ( pm->ps->saberAttackChainCount > 3 )
  1752. {
  1753. return qtrue;
  1754. }
  1755. }
  1756. }
  1757. */
  1758. }
  1759. else if ( pm->ps->saberAnimLevel == SS_DUAL )
  1760. {
  1761. //TEMP: for now, let staff attacks infinitely chain
  1762. return qfalse;
  1763. }
  1764. else if ( pm->ps->saberAnimLevel == FORCE_LEVEL_3 )
  1765. {
  1766. if ( curmove == LS_NONE || newmove == LS_NONE )
  1767. {
  1768. if ( pm->ps->saberAnimLevel >= FORCE_LEVEL_3 && pm->ps->saberAttackChainCount > Q_irand( 0, 1 ) )
  1769. {
  1770. return qtrue;
  1771. }
  1772. }
  1773. else if ( pm->ps->saberAttackChainCount > Q_irand( 2, 3 ) )
  1774. {
  1775. return qtrue;
  1776. }
  1777. else if ( pm->ps->saberAttackChainCount > 0 )
  1778. {
  1779. int chainAngle = PM_SaberAttackChainAngle( curmove, newmove );
  1780. if ( chainAngle < 135 || chainAngle > 215 )
  1781. {//if trying to chain to a move that doesn't continue the momentum
  1782. return qtrue;
  1783. }
  1784. else if ( chainAngle == 180 )
  1785. {//continues the momentum perfectly, allow it to chain 66% of the time
  1786. if ( pm->ps->saberAttackChainCount > 1 )
  1787. {
  1788. return qtrue;
  1789. }
  1790. }
  1791. else
  1792. {//would continue the movement somewhat, 50% chance of continuing
  1793. if ( pm->ps->saberAttackChainCount > 2 )
  1794. {
  1795. return qtrue;
  1796. }
  1797. }
  1798. }
  1799. }
  1800. else
  1801. {//FIXME: have chainAngle influence fast and medium chains as well?
  1802. if ( (pm->ps->saberAnimLevel == FORCE_LEVEL_2 || pm->ps->saberAnimLevel == SS_DUAL)
  1803. && pm->ps->saberAttackChainCount > Q_irand( 2, 5 ) )
  1804. {
  1805. return qtrue;
  1806. }
  1807. }
  1808. return qfalse;
  1809. }
  1810. qboolean PM_CheckEnemyInBack( float backCheckDist )
  1811. {
  1812. if ( !pm->gent || !pm->gent->client )
  1813. {
  1814. return qfalse;
  1815. }
  1816. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer())
  1817. && !g_saberAutoAim->integer && pm->cmd.forwardmove >= 0 )
  1818. {//don't auto-backstab
  1819. return qfalse;
  1820. }
  1821. if ( pm->ps->groundEntityNum == ENTITYNUM_NONE )
  1822. {//only when on ground
  1823. return qfalse;
  1824. }
  1825. trace_t trace;
  1826. vec3_t end, fwd, fwdAngles = {0,pm->ps->viewangles[YAW],0};
  1827. AngleVectors( fwdAngles, fwd, NULL, NULL );
  1828. VectorMA( pm->ps->origin, -backCheckDist, fwd, end );
  1829. pm->trace( &trace, pm->ps->origin, vec3_origin, vec3_origin, end, pm->ps->clientNum, CONTENTS_SOLID|CONTENTS_BODY );
  1830. if ( trace.fraction < 1.0f && trace.entityNum < ENTITYNUM_WORLD )
  1831. {
  1832. gentity_t *traceEnt = &g_entities[trace.entityNum];
  1833. if ( traceEnt
  1834. && traceEnt->health > 0
  1835. && traceEnt->client
  1836. && traceEnt->client->playerTeam == pm->gent->client->enemyTeam
  1837. && traceEnt->client->ps.groundEntityNum != ENTITYNUM_NONE )
  1838. {
  1839. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) )
  1840. {//player
  1841. if ( pm->gent )
  1842. {//set player enemy to traceEnt so he auto-aims at him
  1843. pm->gent->enemy = traceEnt;
  1844. }
  1845. }
  1846. return qtrue;
  1847. }
  1848. }
  1849. return qfalse;
  1850. }
  1851. saberMoveName_t PM_PickBackStab( void )
  1852. {
  1853. if ( !pm->gent || !pm->gent->client )
  1854. {
  1855. return LS_READY;
  1856. }
  1857. if ( pm->ps->dualSabers
  1858. && pm->ps->saber[1].Active() )
  1859. {
  1860. if ( pm->ps->pm_flags & PMF_DUCKED )
  1861. {
  1862. return LS_A_BACK_CR;
  1863. }
  1864. else
  1865. {
  1866. return LS_A_BACK;
  1867. }
  1868. }
  1869. if ( pm->gent->client->ps.saberAnimLevel == SS_TAVION )
  1870. {
  1871. return LS_A_BACKSTAB;
  1872. }
  1873. else if ( pm->gent->client->ps.saberAnimLevel == SS_DESANN )
  1874. {
  1875. if ( pm->ps->saberMove == LS_READY || !Q_irand( 0, 3 ) )
  1876. {
  1877. return LS_A_BACKSTAB;
  1878. }
  1879. else if ( pm->ps->pm_flags & PMF_DUCKED )
  1880. {
  1881. return LS_A_BACK_CR;
  1882. }
  1883. else
  1884. {
  1885. return LS_A_BACK;
  1886. }
  1887. }
  1888. else if ( pm->ps->saberAnimLevel == FORCE_LEVEL_2
  1889. || pm->ps->saberAnimLevel == SS_DUAL )
  1890. {//using medium attacks or dual sabers
  1891. if ( pm->ps->pm_flags & PMF_DUCKED )
  1892. {
  1893. return LS_A_BACK_CR;
  1894. }
  1895. else
  1896. {
  1897. return LS_A_BACK;
  1898. }
  1899. }
  1900. else
  1901. {
  1902. return LS_A_BACKSTAB;
  1903. }
  1904. }
  1905. saberMoveName_t PM_CheckStabDown( void )
  1906. {
  1907. if ( !pm->gent || !pm->gent->enemy || !pm->gent->enemy->client )
  1908. {
  1909. return LS_NONE;
  1910. }
  1911. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  1912. {//player
  1913. if ( G_TryingKataAttack( pm->gent, &pm->cmd ) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  1914. {//want to try a special
  1915. return LS_NONE;
  1916. }
  1917. }
  1918. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) )
  1919. {//player
  1920. if ( pm->ps->groundEntityNum == ENTITYNUM_NONE )//in air
  1921. {//sorry must be on ground (or have just jumped)
  1922. if ( level.time-pm->ps->lastOnGround <= 50 && (pm->ps->pm_flags&PMF_JUMPING) )
  1923. {//just jumped, it's okay
  1924. }
  1925. else
  1926. {
  1927. return LS_NONE;
  1928. }
  1929. }
  1930. /*
  1931. if ( pm->cmd.upmove > 0 )
  1932. {//trying to jump
  1933. }
  1934. else if ( pm->ps->groundEntityNum == ENTITYNUM_NONE //in air
  1935. && level.time-pm->ps->lastOnGround <= 250 //just left ground
  1936. && (pm->ps->pm_flags&PMF_JUMPING) )//jumped
  1937. {//just jumped
  1938. }
  1939. else
  1940. {
  1941. return LS_NONE;
  1942. }
  1943. */
  1944. pm->ps->velocity[2] = 0;
  1945. pm->cmd.upmove = 0;
  1946. }
  1947. else if ( (pm->ps->clientNum >= MAX_CLIENTS&&!PM_ControlledByPlayer()) )
  1948. {//NPC
  1949. if ( pm->ps->groundEntityNum == ENTITYNUM_NONE )//in air
  1950. {//sorry must be on ground (or have just jumped)
  1951. if ( level.time-pm->ps->lastOnGround <= 250 && (pm->ps->pm_flags&PMF_JUMPING) )
  1952. {//just jumped, it's okay
  1953. }
  1954. else
  1955. {
  1956. return LS_NONE;
  1957. }
  1958. }
  1959. if ( !pm->gent->NPC )
  1960. {//wtf???
  1961. return LS_NONE;
  1962. }
  1963. if ( Q_irand( 0, RANK_CAPTAIN ) > pm->gent->NPC->rank )
  1964. {//lower ranks do this less often
  1965. return LS_NONE;
  1966. }
  1967. }
  1968. vec3_t enemyDir, faceFwd, facingAngles = {0, pm->ps->viewangles[YAW], 0};
  1969. AngleVectors( facingAngles, faceFwd, NULL, NULL );
  1970. VectorSubtract( pm->gent->enemy->currentOrigin, pm->ps->origin, enemyDir );
  1971. float enemyZDiff = enemyDir[2];
  1972. enemyDir[2] = 0;
  1973. float enemyHDist = VectorNormalize( enemyDir )-(pm->gent->maxs[0]+pm->gent->enemy->maxs[0]);
  1974. float dot = DotProduct( enemyDir, faceFwd );
  1975. if ( //(pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer())
  1976. dot > 0.65f
  1977. //&& enemyHDist >= 32 //was 48
  1978. && enemyHDist <= 164//was 112
  1979. && PM_InKnockDownOnGround( &pm->gent->enemy->client->ps )//still on ground
  1980. && !PM_InGetUpNoRoll( &pm->gent->enemy->client->ps )//not getting up yet
  1981. && enemyZDiff <= 20 )
  1982. {//guy is on the ground below me, do a top-down attack
  1983. if ( pm->gent->enemy->s.number >= MAX_CLIENTS
  1984. || !G_ControlledByPlayer( pm->gent->enemy ) )
  1985. {//don't get up while I'm doing this
  1986. //stop them from trying to get up for at least another 3 seconds
  1987. TIMER_Set( pm->gent->enemy, "noGetUpStraight", 3000 );
  1988. }
  1989. //pick the right anim
  1990. if ( pm->ps->saberAnimLevel == SS_DUAL
  1991. || (pm->ps->dualSabers&&pm->ps->saber[1].Active()) )
  1992. {
  1993. return LS_STABDOWN_DUAL;
  1994. }
  1995. else if ( pm->ps->saberAnimLevel == SS_STAFF )
  1996. {
  1997. return LS_STABDOWN_STAFF;
  1998. }
  1999. else
  2000. {
  2001. return LS_STABDOWN;
  2002. }
  2003. }
  2004. return LS_NONE;
  2005. }
  2006. extern saberMoveName_t PM_NPCSaberAttackFromQuad( int quad );
  2007. saberMoveName_t PM_SaberFlipOverAttackMove( void );
  2008. saberMoveName_t PM_AttackForEnemyPos( qboolean allowFB, qboolean allowStabDown )
  2009. {
  2010. saberMoveName_t autoMove = LS_INVALID;
  2011. if( !pm->gent->enemy )
  2012. {
  2013. return LS_NONE;
  2014. }
  2015. vec3_t enemy_org, enemyDir, faceFwd, faceRight, faceUp, facingAngles = {0, pm->ps->viewangles[YAW], 0};
  2016. AngleVectors( facingAngles, faceFwd, faceRight, faceUp );
  2017. //FIXME: predict enemy position?
  2018. if ( pm->gent->enemy->client )
  2019. {
  2020. //VectorCopy( pm->gent->enemy->currentOrigin, enemy_org );
  2021. //HMM... using this will adjust for bbox size, so let's do that...
  2022. vec3_t size;
  2023. VectorSubtract( pm->gent->enemy->absmax, pm->gent->enemy->absmin, size );
  2024. VectorMA( pm->gent->enemy->absmin, 0.5, size, enemy_org );
  2025. VectorSubtract( pm->gent->enemy->client->renderInfo.eyePoint, pm->ps->origin, enemyDir );
  2026. }
  2027. else
  2028. {
  2029. if ( pm->gent->enemy->bmodel && VectorCompare( vec3_origin, pm->gent->enemy->currentOrigin ) )
  2030. {//a brush model without an origin brush
  2031. vec3_t size;
  2032. VectorSubtract( pm->gent->enemy->absmax, pm->gent->enemy->absmin, size );
  2033. VectorMA( pm->gent->enemy->absmin, 0.5, size, enemy_org );
  2034. }
  2035. else
  2036. {
  2037. VectorCopy( pm->gent->enemy->currentOrigin, enemy_org );
  2038. }
  2039. VectorSubtract( enemy_org, pm->ps->origin, enemyDir );
  2040. }
  2041. float enemyZDiff = enemyDir[2];
  2042. float enemyDist = VectorNormalize( enemyDir );
  2043. float dot = DotProduct( enemyDir, faceFwd );
  2044. if ( dot > 0 )
  2045. {//enemy is in front
  2046. if ( allowStabDown )
  2047. {//okay to try this
  2048. saberMoveName_t stabDownMove = PM_CheckStabDown();
  2049. if ( stabDownMove != LS_NONE )
  2050. {
  2051. return stabDownMove;
  2052. }
  2053. }
  2054. if ( (pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer())
  2055. && dot > 0.65f
  2056. && enemyDist <= 64 && pm->gent->enemy->client
  2057. && (enemyZDiff <= 20 || PM_InKnockDownOnGround( &pm->gent->enemy->client->ps ) || PM_CrouchAnim( pm->gent->enemy->client->ps.legsAnim ) ) )
  2058. {//swing down at them
  2059. return LS_A_T2B;
  2060. }
  2061. if ( allowFB )
  2062. {//directly in front anim allowed
  2063. if ( enemyDist > 200 || pm->gent->enemy->health <= 0 )
  2064. {//hmm, look in back for an enemy
  2065. if ( pm->ps->clientNum && !PM_ControlledByPlayer() )
  2066. {//player should never do this automatically
  2067. if ( pm->ps->groundEntityNum != ENTITYNUM_NONE )
  2068. {//only when on ground
  2069. if ( pm->gent && pm->gent->client && pm->gent->NPC && pm->gent->NPC->rank >= RANK_LT_JG && Q_irand( 0, pm->gent->NPC->rank ) > RANK_ENSIGN )
  2070. {//only fencers and higher can do this, higher rank does it more
  2071. if ( PM_CheckEnemyInBack( 100 ) )
  2072. {
  2073. return PM_PickBackStab();
  2074. }
  2075. }
  2076. }
  2077. }
  2078. }
  2079. //this is the default only if they're *right* in front...
  2080. if ( (pm->ps->clientNum&&!PM_ControlledByPlayer())
  2081. || ((pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg.renderingThirdPerson && !cg.zoomMode) )
  2082. {//NPC or player not in 1st person
  2083. if ( PM_CheckFlipOverAttackMove( qtrue ) )
  2084. {//enemy must be close and in front
  2085. return PM_SaberFlipOverAttackMove();
  2086. }
  2087. }
  2088. if ( PM_CheckLungeAttackMove() )
  2089. {//NPC
  2090. autoMove = PM_SaberLungeAttackMove( qtrue );
  2091. }
  2092. else
  2093. {
  2094. autoMove = LS_A_T2B;
  2095. }
  2096. }
  2097. else
  2098. {//pick a random one
  2099. if ( Q_irand( 0, 1 ) )
  2100. {
  2101. autoMove = LS_A_TR2BL;
  2102. }
  2103. else
  2104. {
  2105. autoMove = LS_A_TL2BR;
  2106. }
  2107. }
  2108. float dotR = DotProduct( enemyDir, faceRight );
  2109. if ( dotR > 0.35 )
  2110. {//enemy is to far right
  2111. autoMove = LS_A_L2R;
  2112. }
  2113. else if ( dotR < -0.35 )
  2114. {//far left
  2115. autoMove = LS_A_R2L;
  2116. }
  2117. else if ( dotR > 0.15 )
  2118. {//enemy is to near right
  2119. autoMove = LS_A_TR2BL;
  2120. }
  2121. else if ( dotR < -0.15 )
  2122. {//near left
  2123. autoMove = LS_A_TL2BR;
  2124. }
  2125. if ( DotProduct( enemyDir, faceUp ) > 0.5 )
  2126. {//enemy is above me
  2127. if ( autoMove == LS_A_TR2BL )
  2128. {
  2129. autoMove = LS_A_BL2TR;
  2130. }
  2131. else if ( autoMove == LS_A_TL2BR )
  2132. {
  2133. autoMove = LS_A_BR2TL;
  2134. }
  2135. }
  2136. }
  2137. else if ( allowFB )
  2138. {//back attack allowed
  2139. //if ( !PM_InKnockDown( pm->ps ) )
  2140. if ( pm->ps->groundEntityNum != ENTITYNUM_NONE )
  2141. {//only when on ground
  2142. if ( !pm->gent->enemy->client || pm->gent->enemy->client->ps.groundEntityNum != ENTITYNUM_NONE )
  2143. {//enemy not a client or is a client and on ground
  2144. if ( dot < -0.75f
  2145. && enemyDist < 128
  2146. && (pm->ps->saberAnimLevel == SS_FAST || pm->ps->saberAnimLevel == SS_STAFF || (pm->gent->client &&(pm->gent->client->NPC_class == CLASS_TAVION||pm->gent->client->NPC_class == CLASS_ALORA)&&Q_irand(0,2))) )
  2147. {//fast back-stab
  2148. if ( !(pm->ps->pm_flags&PMF_DUCKED) && pm->cmd.upmove >= 0 )
  2149. {//can't do it while ducked?
  2150. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) || (pm->gent->NPC && pm->gent->NPC->rank >= RANK_LT_JG) )
  2151. {//only fencers and above can do this
  2152. autoMove = LS_A_BACKSTAB;
  2153. }
  2154. }
  2155. }
  2156. else if ( pm->ps->saberAnimLevel != SS_FAST
  2157. && pm->ps->saberAnimLevel != SS_STAFF )
  2158. {//higher level back spin-attacks
  2159. if ( (pm->ps->clientNum&&!PM_ControlledByPlayer()) || ((pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg.renderingThirdPerson && !cg.zoomMode) )
  2160. {
  2161. if ( (pm->ps->pm_flags&PMF_DUCKED) || pm->cmd.upmove < 0 )
  2162. {
  2163. autoMove = LS_A_BACK_CR;
  2164. }
  2165. else
  2166. {
  2167. autoMove = LS_A_BACK;
  2168. }
  2169. }
  2170. }
  2171. }
  2172. }
  2173. }
  2174. return autoMove;
  2175. }
  2176. qboolean PM_InSecondaryStyle( void )
  2177. {
  2178. if ( pm->ps->saber[0].numBlades > 1
  2179. && pm->ps->saber[0].singleBladeStyle
  2180. && pm->ps->saber[0].singleBladeStyle != pm->ps->saber[0].style
  2181. && pm->ps->saberAnimLevel == pm->ps->saber[0].singleBladeStyle )
  2182. {
  2183. return qtrue;
  2184. }
  2185. if ( pm->ps->dualSabers
  2186. && !pm->ps->saber[1].Active() )//pm->ps->saberAnimLevel != SS_DUAL )
  2187. {
  2188. return qtrue;
  2189. }
  2190. return qfalse;
  2191. }
  2192. saberMoveName_t PM_SaberLungeAttackMove( qboolean fallbackToNormalLunge )
  2193. {
  2194. G_DrainPowerForSpecialMove( pm->gent, FP_SABER_OFFENSE, SABER_ALT_ATTACK_POWER_FB );
  2195. if ( pm->gent->client->NPC_class == CLASS_ALORA && !Q_irand( 0, 3 ) )
  2196. {//alora NPC
  2197. return LS_SPINATTACK_ALORA;
  2198. }
  2199. else
  2200. {
  2201. if ( pm->ps->dualSabers )
  2202. {
  2203. return LS_SPINATTACK_DUAL;
  2204. }
  2205. switch ( pm->ps->saberAnimLevel )
  2206. {
  2207. case SS_DUAL:
  2208. return LS_SPINATTACK_DUAL;
  2209. break;
  2210. case SS_STAFF:
  2211. return LS_SPINATTACK;
  2212. break;
  2213. default://normal lunge
  2214. if ( fallbackToNormalLunge )
  2215. {
  2216. vec3_t fwdAngles, jumpFwd;
  2217. VectorCopy( pm->ps->viewangles, fwdAngles );
  2218. fwdAngles[PITCH] = fwdAngles[ROLL] = 0;
  2219. //do the lunge
  2220. AngleVectors( fwdAngles, jumpFwd, NULL, NULL );
  2221. VectorScale( jumpFwd, 150, pm->ps->velocity );
  2222. pm->ps->velocity[2] = 50;
  2223. PM_AddEvent( EV_JUMP );
  2224. return LS_A_LUNGE;
  2225. }
  2226. break;
  2227. }
  2228. }
  2229. return LS_NONE;
  2230. }
  2231. qboolean PM_CheckLungeAttackMove( void )
  2232. {
  2233. if ( pm->ps->saberAnimLevel == SS_FAST//fast
  2234. || pm->ps->saberAnimLevel == SS_DUAL//dual
  2235. || pm->ps->saberAnimLevel == SS_STAFF //staff
  2236. || pm->ps->saberAnimLevel == SS_DESANN
  2237. || pm->ps->dualSabers )
  2238. {//alt+back+attack using fast, dual or staff attacks
  2239. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() )
  2240. {//NPC
  2241. if ( pm->cmd.upmove < 0 || (pm->ps->pm_flags&PMF_DUCKED) )
  2242. {//ducking
  2243. if ( pm->ps->legsAnim == BOTH_STAND2
  2244. || pm->ps->legsAnim == BOTH_SABERFAST_STANCE
  2245. || pm->ps->legsAnim == BOTH_SABERSLOW_STANCE
  2246. || pm->ps->legsAnim == BOTH_SABERSTAFF_STANCE
  2247. || pm->ps->legsAnim == BOTH_SABERDUAL_STANCE
  2248. || (level.time-pm->ps->lastStationary) <= 500 )
  2249. {//standing or just stopped standing
  2250. if ( pm->gent
  2251. && pm->gent->NPC //NPC
  2252. && pm->gent->NPC->rank >= RANK_LT_JG //high rank
  2253. && ( pm->gent->NPC->rank == RANK_LT_JG || Q_irand( -3, pm->gent->NPC->rank ) >= RANK_LT_JG )//Q_irand( 0, pm->gent->NPC->rank ) >= RANK_LT_JG )
  2254. && !Q_irand( 0, 3-g_spskill->integer ) )
  2255. {//only fencer and higher can do this
  2256. if ( pm->ps->saberAnimLevel == SS_DESANN )
  2257. {
  2258. if ( !Q_irand( 0, 4 ) )
  2259. {
  2260. return qtrue;
  2261. }
  2262. }
  2263. else
  2264. {
  2265. return qtrue;
  2266. }
  2267. }
  2268. }
  2269. }
  2270. }
  2271. else
  2272. {//player
  2273. if ( G_TryingLungeAttack( pm->gent, &pm->cmd )
  2274. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB )/*pm->ps->forcePower >= SABER_ALT_ATTACK_POWER_FB*/ )//have enough force power to pull it off
  2275. {
  2276. return qtrue;
  2277. }
  2278. }
  2279. }
  2280. return qfalse;
  2281. }
  2282. saberMoveName_t PM_SaberJumpForwardAttackMove( void )
  2283. {
  2284. G_DrainPowerForSpecialMove( pm->gent, FP_LEVITATION, SABER_ALT_ATTACK_POWER_FB );
  2285. if ( pm->ps->saberAnimLevel == SS_DUAL
  2286. || pm->ps->saberAnimLevel == SS_STAFF )
  2287. {
  2288. pm->cmd.upmove = 0;//no jump just yet
  2289. if ( pm->ps->saberAnimLevel == SS_STAFF )
  2290. {
  2291. if ( Q_irand(0, 1) )
  2292. {
  2293. return LS_JUMPATTACK_STAFF_LEFT;
  2294. }
  2295. else
  2296. {
  2297. return LS_JUMPATTACK_STAFF_RIGHT;
  2298. }
  2299. }
  2300. return LS_JUMPATTACK_DUAL;
  2301. }
  2302. else
  2303. {
  2304. vec3_t fwdAngles, jumpFwd;
  2305. VectorCopy( pm->ps->viewangles, fwdAngles );
  2306. fwdAngles[PITCH] = fwdAngles[ROLL] = 0;
  2307. AngleVectors( fwdAngles, jumpFwd, NULL, NULL );
  2308. VectorScale( jumpFwd, 200, pm->ps->velocity );
  2309. pm->ps->velocity[2] = 180;
  2310. pm->ps->forceJumpZStart = pm->ps->origin[2];//so we don't take damage if we land at same height
  2311. pm->ps->pm_flags |= PMF_JUMPING|PMF_SLOW_MO_FALL;
  2312. //FIXME: NPCs yell?
  2313. PM_AddEvent( EV_JUMP );
  2314. G_SoundOnEnt( pm->gent, CHAN_BODY, "sound/weapons/force/jump.wav" );
  2315. pm->cmd.upmove = 0;
  2316. return LS_A_JUMP_T__B_;
  2317. }
  2318. }
  2319. qboolean PM_CheckJumpForwardAttackMove( void )
  2320. {
  2321. if ( pm->ps->clientNum < MAX_CLIENTS
  2322. && PM_InSecondaryStyle() )
  2323. {
  2324. return qfalse;
  2325. }
  2326. if ( pm->cmd.forwardmove > 0 //going forward
  2327. && pm->ps->forceRageRecoveryTime < pm->cmd.serverTime //not in a force Rage recovery period
  2328. && pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_1 //can force jump
  2329. && pm->gent && !(pm->gent->flags&FL_LOCK_PLAYER_WEAPONS) // yes this locked weapons check also includes force powers, if we need a separate check later I'll make one
  2330. && (pm->ps->groundEntityNum != ENTITYNUM_NONE||level.time-pm->ps->lastOnGround<=250) //on ground or just jumped (if not player)
  2331. )
  2332. {
  2333. if ( pm->ps->saberAnimLevel == SS_DUAL
  2334. || pm->ps->saberAnimLevel == SS_STAFF )
  2335. {//dual and staff
  2336. if ( !PM_SaberInTransitionAny( pm->ps->saberMove ) //not going to/from/between an attack anim
  2337. && !PM_SaberInAttack( pm->ps->saberMove ) //not in attack anim
  2338. && pm->ps->weaponTime <= 0//not busy
  2339. && (pm->cmd.buttons&BUTTON_ATTACK) )//want to attack
  2340. {
  2341. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() )
  2342. {//NPC
  2343. if ( pm->cmd.upmove > 0 || (pm->ps->pm_flags&PMF_JUMPING) )//jumping NPC
  2344. {
  2345. if ( pm->gent
  2346. && pm->gent->NPC
  2347. && (pm->gent->NPC->rank==RANK_CREWMAN||pm->gent->NPC->rank>=RANK_LT) )
  2348. {
  2349. return qtrue;
  2350. }
  2351. }
  2352. }
  2353. else
  2354. {//PLAYER
  2355. if ( G_TryingJumpForwardAttack( pm->gent, &pm->cmd )
  2356. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB ) )//have enough power to attack
  2357. {
  2358. return qtrue;
  2359. }
  2360. }
  2361. }
  2362. }
  2363. //check strong
  2364. else if ( pm->ps->saberAnimLevel == SS_STRONG //strong style
  2365. || pm->ps->saberAnimLevel == SS_DESANN )//desann
  2366. {
  2367. if ( //&& !PM_InKnockDown( pm->ps )
  2368. !pm->ps->dualSabers
  2369. //&& (pm->ps->legsAnim == BOTH_STAND2||pm->ps->legsAnim == BOTH_SABERFAST_STANCE||pm->ps->legsAnim == BOTH_SABERSLOW_STANCE||level.time-pm->ps->lastStationary<=500)//standing or just started moving
  2370. )
  2371. {//strong attack: jump-hack
  2372. /*
  2373. if ( pm->ps->legsAnim == BOTH_STAND2
  2374. || pm->ps->legsAnim == BOTH_SABERFAST_STANCE
  2375. || pm->ps->legsAnim == BOTH_SABERSLOW_STANCE
  2376. || level.time-pm->ps->lastStationary <= 250 )//standing or just started moving
  2377. */
  2378. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() )
  2379. {//NPC
  2380. if ( pm->cmd.upmove > 0 || (pm->ps->pm_flags&PMF_JUMPING) )//NPC jumping
  2381. {
  2382. if ( pm->gent
  2383. && pm->gent->NPC
  2384. && (pm->gent->NPC->rank==RANK_CREWMAN||pm->gent->NPC->rank>=RANK_LT) )
  2385. {//only acrobat or boss and higher can do this
  2386. if ( pm->ps->legsAnim == BOTH_STAND2
  2387. || pm->ps->legsAnim == BOTH_SABERFAST_STANCE
  2388. || pm->ps->legsAnim == BOTH_SABERSLOW_STANCE
  2389. || level.time-pm->ps->lastStationary <= 250 )
  2390. {//standing or just started moving
  2391. if ( pm->gent->client
  2392. && pm->gent->client->NPC_class == CLASS_DESANN )
  2393. {
  2394. if ( !Q_irand( 0, 1 ) )
  2395. {
  2396. return qtrue;
  2397. }
  2398. }
  2399. else
  2400. {
  2401. return qtrue;
  2402. }
  2403. }
  2404. }
  2405. }
  2406. }
  2407. else
  2408. {//player
  2409. if ( G_TryingJumpForwardAttack( pm->gent, &pm->cmd )
  2410. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB ) )
  2411. {
  2412. return qtrue;
  2413. }
  2414. }
  2415. }
  2416. }
  2417. }
  2418. return qfalse;
  2419. }
  2420. saberMoveName_t PM_SaberFlipOverAttackMove( void )
  2421. {
  2422. //FIXME: check above for room enough to jump!
  2423. //FIXME: while in this jump, keep velocity[2] at a minimum until the end of the anim
  2424. vec3_t fwdAngles, jumpFwd;
  2425. VectorCopy( pm->ps->viewangles, fwdAngles );
  2426. fwdAngles[PITCH] = fwdAngles[ROLL] = 0;
  2427. AngleVectors( fwdAngles, jumpFwd, NULL, NULL );
  2428. VectorScale( jumpFwd, 150, pm->ps->velocity );
  2429. pm->ps->velocity[2] = 250;
  2430. //250 is normalized for a standing enemy at your z level, about 64 tall... adjust for actual maxs[2]-mins[2] of enemy and for zdiff in origins
  2431. if ( pm->gent && pm->gent->enemy )
  2432. { //go higher for taller enemies
  2433. pm->ps->velocity[2] *= (pm->gent->enemy->maxs[2]-pm->gent->enemy->mins[2])/64.0f;
  2434. //go higher for enemies higher than you, lower for those lower than you
  2435. float zDiff = pm->gent->enemy->currentOrigin[2] - pm->ps->origin[2];
  2436. pm->ps->velocity[2] += (zDiff)*1.5f;
  2437. //clamp to decent-looking values
  2438. //FIXME: still jump too low sometimes
  2439. if ( zDiff <= 0 && pm->ps->velocity[2] < 200 )
  2440. {//if we're on same level, don't let me jump so low, I clip into the ground
  2441. pm->ps->velocity[2] = 200;
  2442. }
  2443. else if ( pm->ps->velocity[2] < 50 )
  2444. {
  2445. pm->ps->velocity[2] = 50;
  2446. }
  2447. else if ( pm->ps->velocity[2] > 400 )
  2448. {
  2449. pm->ps->velocity[2] = 400;
  2450. }
  2451. }
  2452. pm->ps->forceJumpZStart = pm->ps->origin[2];//so we don't take damage if we land at same height
  2453. pm->ps->pm_flags |= PMF_JUMPING|PMF_SLOW_MO_FALL;
  2454. //FIXME: NPCs yell?
  2455. PM_AddEvent( EV_JUMP );
  2456. G_SoundOnEnt( pm->gent, CHAN_BODY, "sound/weapons/force/jump.wav" );
  2457. pm->cmd.upmove = 0;
  2458. //FIXME: don't allow this to land on other people
  2459. pm->gent->angle = pm->ps->viewangles[YAW];//so we know what yaw we started this at
  2460. G_DrainPowerForSpecialMove( pm->gent, FP_LEVITATION, SABER_ALT_ATTACK_POWER_FB );
  2461. if ( Q_irand( 0, 1 ) )
  2462. {
  2463. return LS_A_FLIP_STAB;
  2464. }
  2465. else
  2466. {
  2467. return LS_A_FLIP_SLASH;
  2468. }
  2469. }
  2470. qboolean PM_CheckFlipOverAttackMove( qboolean checkEnemy )
  2471. {
  2472. if ( pm->ps->clientNum < MAX_CLIENTS
  2473. && PM_InSecondaryStyle() )
  2474. {
  2475. return qfalse;
  2476. }
  2477. if ( (pm->ps->saberAnimLevel == SS_MEDIUM //medium
  2478. || pm->ps->saberAnimLevel == SS_TAVION )//tavion
  2479. && pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_1 //can force jump
  2480. && !(pm->gent->flags&FL_LOCK_PLAYER_WEAPONS) // yes this locked weapons check also includes force powers, if we need a separate check later I'll make one
  2481. && (pm->ps->groundEntityNum != ENTITYNUM_NONE||level.time-pm->ps->lastOnGround<=250) //on ground or just jumped
  2482. )
  2483. {
  2484. qboolean tryMove = qfalse;
  2485. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() )
  2486. {//NPC
  2487. if ( pm->cmd.upmove > 0//want to jump
  2488. || (pm->ps->pm_flags&PMF_JUMPING) )//jumping
  2489. {//flip over-forward down-attack
  2490. if ( (pm->gent->NPC
  2491. && (pm->gent->NPC->rank==RANK_CREWMAN||pm->gent->NPC->rank>=RANK_LT)
  2492. && !Q_irand(0, 2) ) )//NPC who can do this, 33% chance
  2493. {//only player or acrobat or boss and higher can do this
  2494. tryMove = qtrue;
  2495. }
  2496. }
  2497. }
  2498. else
  2499. {//player
  2500. if ( G_TryingJumpForwardAttack( pm->gent, &pm->cmd )
  2501. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB ) )//have enough power
  2502. {
  2503. if ( !pm->cmd.rightmove )
  2504. {
  2505. if ( pm->ps->legsAnim == BOTH_JUMP1
  2506. || pm->ps->legsAnim == BOTH_FORCEJUMP1
  2507. || pm->ps->legsAnim == BOTH_INAIR1
  2508. || pm->ps->legsAnim == BOTH_FORCEINAIR1 )
  2509. {//in a non-flip forward jump
  2510. tryMove = qtrue;
  2511. }
  2512. }
  2513. }
  2514. }
  2515. if ( tryMove )
  2516. {
  2517. if ( !checkEnemy )
  2518. {//based just on command input
  2519. return qtrue;
  2520. }
  2521. else
  2522. {//based on presence of enemy
  2523. if ( pm->gent->enemy )//have an enemy
  2524. {
  2525. vec3_t fwdAngles = {0,pm->ps->viewangles[YAW],0};
  2526. if ( pm->gent->enemy->health > 0
  2527. && pm->ps->forceRageRecoveryTime < pm->cmd.serverTime //not in a force Rage recovery period
  2528. && pm->gent->enemy->maxs[2] > 12
  2529. && (!pm->gent->enemy->client || !PM_InKnockDownOnGround( &pm->gent->enemy->client->ps ) )
  2530. && DistanceSquared( pm->gent->currentOrigin, pm->gent->enemy->currentOrigin ) < 10000
  2531. && InFront( pm->gent->enemy->currentOrigin, pm->gent->currentOrigin, fwdAngles, 0.3f ) )
  2532. {//enemy must be alive, not low to ground, close and in front
  2533. return qtrue;
  2534. }
  2535. }
  2536. return qfalse;
  2537. }
  2538. }
  2539. }
  2540. return qfalse;
  2541. }
  2542. saberMoveName_t PM_SaberBackflipAttackMove( void )
  2543. {
  2544. pm->cmd.upmove = 0;//no jump just yet
  2545. return LS_A_BACKFLIP_ATK;
  2546. }
  2547. qboolean PM_CheckBackflipAttackMove( void )
  2548. {
  2549. if ( pm->ps->clientNum < MAX_CLIENTS
  2550. && PM_InSecondaryStyle() )
  2551. {
  2552. return qfalse;
  2553. }
  2554. if ( pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_1 //can force jump
  2555. && pm->ps->forceRageRecoveryTime < pm->cmd.serverTime //not in a force Rage recovery period
  2556. && pm->gent && !(pm->gent->flags&FL_LOCK_PLAYER_WEAPONS) // yes this locked weapons check also includes force powers, if we need a separate check later I'll make one
  2557. //&& (pm->ps->legsAnim == BOTH_SABERSTAFF_STANCE || level.time-pm->ps->lastStationary<=250)//standing or just started moving
  2558. && (pm->ps->groundEntityNum != ENTITYNUM_NONE||level.time-pm->ps->lastOnGround<=250) )//on ground or just jumped (if not player)
  2559. {
  2560. if ( pm->cmd.forwardmove < 0 //moving backwards
  2561. && pm->ps->saberAnimLevel == SS_STAFF //using staff
  2562. && (pm->cmd.upmove > 0 || (pm->ps->pm_flags&PMF_JUMPING)) )//jumping
  2563. {//jumping backwards and using staff
  2564. if ( !PM_SaberInTransitionAny( pm->ps->saberMove ) //not going to/from/between an attack anim
  2565. && !PM_SaberInAttack( pm->ps->saberMove ) //not in attack anim
  2566. && pm->ps->weaponTime <= 0//not busy
  2567. && (pm->cmd.buttons&BUTTON_ATTACK) )//want to attack
  2568. {//not already attacking
  2569. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() )
  2570. {//NPC
  2571. if ( pm->gent
  2572. && pm->gent->NPC
  2573. && (pm->gent->NPC->rank==RANK_CREWMAN||pm->gent->NPC->rank>=RANK_LT) )
  2574. {//acrobat or boss and higher can do this
  2575. return qtrue;
  2576. }
  2577. }
  2578. else
  2579. {//player
  2580. return qtrue;
  2581. }
  2582. }
  2583. }
  2584. }
  2585. return qfalse;
  2586. }
  2587. saberMoveName_t PM_CheckDualSpinProtect( void )
  2588. {
  2589. if ( pm->ps->clientNum < MAX_CLIENTS
  2590. && PM_InSecondaryStyle() )
  2591. {
  2592. return LS_NONE;
  2593. }
  2594. if ( pm->ps->saberMove == LS_READY//ready
  2595. //&& (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer())//PLAYER ONLY...?
  2596. //&& pm->ps->viewangles[0] > 30 //looking down
  2597. && pm->ps->saberAnimLevel == SS_DUAL//using dual saber style
  2598. && pm->ps->saber[0].Active() && pm->ps->saber[1].Active()//both sabers on
  2599. //&& pm->ps->forcePowerLevel[FP_PUSH]>=FORCE_LEVEL_3//force push 3
  2600. //&& ((pm->ps->forcePowersActive&(1<<FP_PUSH))||pm->ps->forcePowerDebounce[FP_PUSH]>level.time)//force-pushing
  2601. && G_TryingKataAttack( pm->gent, &pm->cmd )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS)//holding focus
  2602. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER, qtrue )//pm->ps->forcePower >= SABER_ALT_ATTACK_POWER//DUAL_SPIN_PROTECT_POWER//force push 3
  2603. && (pm->cmd.buttons&BUTTON_ATTACK)//pressing attack
  2604. )
  2605. {//FIXME: some NPC logic to do this?
  2606. /*
  2607. if ( (pm->ps->pm_flags&PMF_DUCKED||pm->cmd.upmove<0)//crouching
  2608. && g_crosshairEntNum >= ENTITYNUM_WORLD )
  2609. */
  2610. {
  2611. if ( pm->gent )
  2612. {
  2613. G_DrainPowerForSpecialMove( pm->gent, FP_PUSH, SABER_ALT_ATTACK_POWER, qtrue );//drain the required force power
  2614. }
  2615. return LS_DUAL_SPIN_PROTECT;
  2616. }
  2617. }
  2618. return LS_NONE;
  2619. }
  2620. saberMoveName_t PM_CheckStaffKata( void )
  2621. {
  2622. if ( pm->ps->clientNum < MAX_CLIENTS
  2623. && PM_InSecondaryStyle() )
  2624. {
  2625. return LS_NONE;
  2626. }
  2627. if ( pm->ps->saberMove == LS_READY//ready
  2628. //&& (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer())//PLAYER ONLY...?
  2629. //&& pm->ps->viewangles[0] > 30 //looking down
  2630. && pm->ps->saberAnimLevel == SS_STAFF//using dual saber style
  2631. && pm->ps->saber[0].Active()//saber on
  2632. //&& pm->ps->forcePowerLevel[FP_PUSH]>=FORCE_LEVEL_3//force push 3
  2633. //&& ((pm->ps->forcePowersActive&(1<<FP_PUSH))||pm->ps->forcePowerDebounce[FP_PUSH]>level.time)//force-pushing
  2634. && G_TryingKataAttack( pm->gent, &pm->cmd )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS)//holding focus
  2635. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER, qtrue )//pm->ps->forcePower >= SABER_ALT_ATTACK_POWER//DUAL_SPIN_PROTECT_POWER//force push 3
  2636. && (pm->cmd.buttons&BUTTON_ATTACK)//pressing attack
  2637. )
  2638. {//FIXME: some NPC logic to do this?
  2639. /*
  2640. if ( (pm->ps->pm_flags&PMF_DUCKED||pm->cmd.upmove<0)//crouching
  2641. && g_crosshairEntNum >= ENTITYNUM_WORLD )
  2642. */
  2643. {
  2644. if ( pm->gent )
  2645. {
  2646. G_DrainPowerForSpecialMove( pm->gent, FP_LEVITATION, SABER_ALT_ATTACK_POWER, qtrue );//drain the required force power
  2647. }
  2648. return LS_STAFF_SOULCAL;
  2649. }
  2650. }
  2651. return LS_NONE;
  2652. }
  2653. extern qboolean WP_ForceThrowable( gentity_t *ent, gentity_t *forwardEnt, gentity_t *self, qboolean pull, float cone, float radius, vec3_t forward );
  2654. saberMoveName_t PM_CheckPullAttack( void )
  2655. {
  2656. if ( pm->ps->clientNum < MAX_CLIENTS
  2657. && PM_InSecondaryStyle() )
  2658. {
  2659. return LS_NONE;
  2660. }
  2661. if ( (pm->ps->saberMove == LS_READY||PM_SaberInReturn(pm->ps->saberMove)||PM_SaberInReflect(pm->ps->saberMove))//ready
  2662. //&& (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer())//PLAYER ONLY
  2663. && pm->ps->saberAnimLevel >= SS_FAST//single saber styles - FIXME: Tavion?
  2664. && pm->ps->saberAnimLevel <= SS_STRONG//single saber styles - FIXME: Tavion?
  2665. && G_TryingPullAttack( pm->gent, &pm->cmd, qfalse )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS)//holding focus
  2666. //&& pm->cmd.forwardmove<0//pulling back
  2667. && (pm->cmd.buttons&BUTTON_ATTACK)//attacking
  2668. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB )//pm->ps->forcePower >= SABER_ALT_ATTACK_POWER_FB//have enough power
  2669. )
  2670. {//FIXME: some NPC logic to do this?
  2671. qboolean doMove = g_saberNewControlScheme->integer?qtrue:qfalse;//in new control scheme, can always do this, even if there's no-one to do it to
  2672. if ( g_saberNewControlScheme->integer
  2673. || g_crosshairEntNum < ENTITYNUM_WORLD )//in old control scheme, there has to be someone there
  2674. {
  2675. saberMoveName_t pullAttackMove = LS_NONE;
  2676. if ( pm->ps->saberAnimLevel == SS_FAST )
  2677. {
  2678. pullAttackMove = LS_PULL_ATTACK_STAB;
  2679. }
  2680. else
  2681. {
  2682. pullAttackMove = LS_PULL_ATTACK_SWING;
  2683. }
  2684. if ( g_crosshairEntNum < ENTITYNUM_WORLD
  2685. && pm->gent && pm->gent->client )
  2686. {
  2687. gentity_t *targEnt = &g_entities[g_crosshairEntNum];
  2688. if ( targEnt->client
  2689. && targEnt->health > 0
  2690. //FIXME: check other things like in knockdown, saberlock, uninterruptable anims, etc.
  2691. && !PM_InOnGroundAnim( &targEnt->client->ps )
  2692. && !PM_LockedAnim( targEnt->client->ps.legsAnim )
  2693. && !PM_SuperBreakLoseAnim( targEnt->client->ps.legsAnim )
  2694. && !PM_SuperBreakWinAnim( targEnt->client->ps.legsAnim )
  2695. && targEnt->client->ps.saberLockTime <= 0
  2696. && WP_ForceThrowable( targEnt, targEnt, pm->gent, qtrue, 1.0f, 0.0f, NULL ) )
  2697. {
  2698. if ( !g_saberNewControlScheme->integer )
  2699. {//in old control scheme, make sure they're close or far enough away for the move we'll be doing
  2700. float targDist = Distance( targEnt->currentOrigin, pm->ps->origin );
  2701. if ( pullAttackMove == LS_PULL_ATTACK_STAB )
  2702. {//must be closer than 512
  2703. if ( targDist > 384.0f )
  2704. {
  2705. return LS_NONE;
  2706. }
  2707. }
  2708. else//if ( pullAttackMove == LS_PULL_ATTACK_SWING )
  2709. {//must be farther than 256
  2710. if ( targDist > 512.0f )
  2711. {
  2712. return LS_NONE;
  2713. }
  2714. if ( targDist < 192.0f )
  2715. {
  2716. return LS_NONE;
  2717. }
  2718. }
  2719. }
  2720. vec3_t targAngles = {0,targEnt->client->ps.viewangles[YAW],0};
  2721. if ( InFront( pm->ps->origin, targEnt->currentOrigin, targAngles ) )
  2722. {
  2723. NPC_SetAnim( targEnt, SETANIM_BOTH, BOTH_PULLED_INAIR_F, SETANIM_FLAG_OVERRIDE, SETANIM_FLAG_HOLD );
  2724. }
  2725. else
  2726. {
  2727. NPC_SetAnim( targEnt, SETANIM_BOTH, BOTH_PULLED_INAIR_B, SETANIM_FLAG_OVERRIDE, SETANIM_FLAG_HOLD );
  2728. }
  2729. //hold the anim until I'm with done pull anim
  2730. targEnt->client->ps.legsAnimTimer = targEnt->client->ps.torsoAnimTimer = PM_AnimLength( pm->gent->client->clientInfo.animFileIndex, (animNumber_t)saberMoveData[pullAttackMove].animToUse );
  2731. //set pullAttackTime
  2732. pm->gent->client->ps.pullAttackTime = targEnt->client->ps.pullAttackTime = level.time+targEnt->client->ps.legsAnimTimer;
  2733. //make us know about each other
  2734. pm->gent->client->ps.pullAttackEntNum = g_crosshairEntNum;
  2735. targEnt->client->ps.pullAttackEntNum = pm->ps->clientNum;
  2736. //do effect and sound on me
  2737. pm->ps->powerups[PW_FORCE_PUSH] = level.time + 1000;
  2738. if ( pm->gent )
  2739. {
  2740. G_Sound( pm->gent, G_SoundIndex( "sound/weapons/force/pull.wav" ) );
  2741. }
  2742. doMove = qtrue;
  2743. }
  2744. }
  2745. if ( doMove )
  2746. {
  2747. if ( pm->gent )
  2748. {
  2749. G_DrainPowerForSpecialMove( pm->gent, FP_PULL, SABER_ALT_ATTACK_POWER_FB );
  2750. }
  2751. return pullAttackMove;
  2752. }
  2753. }
  2754. }
  2755. return LS_NONE;
  2756. }
  2757. saberMoveName_t PM_CheckPlayerAttackFromParry( int curmove )
  2758. {
  2759. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() )
  2760. {
  2761. if ( curmove >= LS_PARRY_UP
  2762. && curmove <= LS_REFLECT_LL )
  2763. {//in a parry
  2764. switch ( saberMoveData[curmove].endQuad )
  2765. {
  2766. case Q_T:
  2767. return LS_A_T2B;
  2768. break;
  2769. case Q_TR:
  2770. return LS_A_TR2BL;
  2771. break;
  2772. case Q_TL:
  2773. return LS_A_TL2BR;
  2774. break;
  2775. case Q_BR:
  2776. return LS_A_BR2TL;
  2777. break;
  2778. case Q_BL:
  2779. return LS_A_BL2TR;
  2780. break;
  2781. //shouldn't be a parry that ends at L, R or B
  2782. }
  2783. }
  2784. }
  2785. return LS_NONE;
  2786. }
  2787. saberMoveName_t PM_SaberAttackForMovement( int forwardmove, int rightmove, int curmove )
  2788. {
  2789. qboolean noSpecials = qfalse;
  2790. if ( pm->ps->clientNum < MAX_CLIENTS
  2791. && PM_InSecondaryStyle() )
  2792. {
  2793. noSpecials = qtrue;
  2794. }
  2795. #ifdef _XBOX
  2796. if ( rightmove > 64 )
  2797. #else
  2798. if ( rightmove > 0 )
  2799. #endif // _XBOX
  2800. {//moving right
  2801. if ( !noSpecials
  2802. && (pm->ps->groundEntityNum != ENTITYNUM_NONE||level.time-pm->ps->lastOnGround<=250) //on ground or just jumped
  2803. && (pm->cmd.buttons&BUTTON_ATTACK)//hitting attack
  2804. && pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_0//have force jump 1 at least
  2805. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_LR )//pm->ps->forcePower >= SABER_ALT_ATTACK_POWER_LR//have enough power
  2806. && (((pm->ps->clientNum>=MAX_CLIENTS&&!PM_ControlledByPlayer())&&pm->cmd.upmove > 0)//jumping NPC
  2807. ||((pm->ps->clientNum<MAX_CLIENTS||PM_ControlledByPlayer())&&G_TryingCartwheel(pm->gent, &pm->cmd)/*(pm->cmd.buttons&BUTTON_FORCE_FOCUS)*/)) )//focus-holding player
  2808. {//cartwheel right
  2809. vec3_t right, fwdAngles = {0, pm->ps->viewangles[YAW], 0};
  2810. if ( pm->gent )
  2811. {
  2812. G_DrainPowerForSpecialMove( pm->gent, FP_LEVITATION, SABER_ALT_ATTACK_POWER_LR );
  2813. }
  2814. pm->cmd.upmove = 0;
  2815. if ( pm->ps->saberAnimLevel == SS_STAFF )
  2816. {
  2817. AngleVectors( fwdAngles, NULL, right, NULL );
  2818. pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
  2819. VectorMA( pm->ps->velocity, 190, right, pm->ps->velocity );
  2820. return LS_BUTTERFLY_RIGHT;
  2821. }
  2822. else
  2823. {
  2824. /*
  2825. if ( pm->ps->groundEntityNum != ENTITYNUM_NONE )
  2826. {//still on ground
  2827. VectorClear( pm->ps->velocity );
  2828. return LS_JUMPATTACK_CART_RIGHT;
  2829. }
  2830. else
  2831. */
  2832. {//in air
  2833. AngleVectors( fwdAngles, NULL, right, NULL );
  2834. pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
  2835. VectorMA( pm->ps->velocity, 190, right, pm->ps->velocity );
  2836. PM_SetJumped( JUMP_VELOCITY, qtrue );
  2837. return LS_JUMPATTACK_ARIAL_RIGHT;
  2838. }
  2839. }
  2840. }
  2841. else if ( pm->ps->legsAnim != BOTH_CARTWHEEL_RIGHT
  2842. && pm->ps->legsAnim != BOTH_ARIAL_RIGHT )
  2843. {//not in a cartwheel/arial
  2844. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  2845. {//player
  2846. if ( G_TryingSpecial(pm->gent, &pm->cmd)/*(pm->cmd.buttons&BUTTON_FORCE_FOCUS)*/ )//Holding focus
  2847. {//if no special worked, do nothing
  2848. return LS_NONE;
  2849. }
  2850. }
  2851. //checked all special attacks, if we're in a parry, attack from that move
  2852. saberMoveName_t parryAttackMove = PM_CheckPlayerAttackFromParry( curmove );
  2853. if ( parryAttackMove != LS_NONE )
  2854. {
  2855. return parryAttackMove;
  2856. }
  2857. //check regular attacks
  2858. if ( forwardmove > 0 )
  2859. {//forward right = TL2BR slash
  2860. return LS_A_TL2BR;
  2861. }
  2862. else if ( forwardmove < 0 )
  2863. {//backward right = BL2TR uppercut
  2864. return LS_A_BL2TR;
  2865. }
  2866. else
  2867. {//just right is a left slice
  2868. return LS_A_L2R;
  2869. }
  2870. }
  2871. }
  2872. #ifdef _XBOX
  2873. else if ( rightmove < -64 )
  2874. #else
  2875. else if ( rightmove < 0 )
  2876. #endif // _XBOX
  2877. {//moving left
  2878. if ( !noSpecials
  2879. && (pm->ps->groundEntityNum != ENTITYNUM_NONE||level.time-pm->ps->lastOnGround<=250) //on ground or just jumped
  2880. && (pm->cmd.buttons&BUTTON_ATTACK)//hitting attack
  2881. && pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_0//have force jump 1 at least
  2882. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_LR )//pm->ps->forcePower >= SABER_ALT_ATTACK_POWER_LR//have enough power
  2883. && (((pm->ps->clientNum>=MAX_CLIENTS&&!PM_ControlledByPlayer())&&pm->cmd.upmove > 0)//jumping NPC
  2884. ||((pm->ps->clientNum<MAX_CLIENTS||PM_ControlledByPlayer())&&G_TryingCartwheel(pm->gent, &pm->cmd)/*(pm->cmd.buttons&BUTTON_FORCE_FOCUS)*/)) )//focus-holding player
  2885. {//cartwheel left
  2886. vec3_t right, fwdAngles = {0, pm->ps->viewangles[YAW], 0};
  2887. if ( pm->gent )
  2888. {
  2889. G_DrainPowerForSpecialMove( pm->gent, FP_LEVITATION, SABER_ALT_ATTACK_POWER_LR );
  2890. }
  2891. pm->cmd.upmove = 0;
  2892. if ( pm->ps->saberAnimLevel == SS_STAFF )
  2893. {
  2894. AngleVectors( fwdAngles, NULL, right, NULL );
  2895. pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
  2896. VectorMA( pm->ps->velocity, -190, right, pm->ps->velocity );
  2897. return LS_BUTTERFLY_LEFT;
  2898. }
  2899. else
  2900. {
  2901. /*
  2902. if ( pm->ps->groundEntityNum != ENTITYNUM_NONE )
  2903. {//still on ground
  2904. VectorClear( pm->ps->velocity );
  2905. return LS_JUMPATTACK_ARIAL_LEFT;
  2906. }
  2907. else
  2908. */
  2909. {
  2910. AngleVectors( fwdAngles, NULL, right, NULL );
  2911. pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
  2912. VectorMA( pm->ps->velocity, -190, right, pm->ps->velocity );
  2913. PM_SetJumped( JUMP_VELOCITY, qtrue );
  2914. return LS_JUMPATTACK_CART_LEFT;
  2915. }
  2916. }
  2917. }
  2918. else if ( pm->ps->legsAnim != BOTH_CARTWHEEL_LEFT
  2919. && pm->ps->legsAnim != BOTH_ARIAL_LEFT )
  2920. {//not in a left cartwheel/arial
  2921. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  2922. {//player
  2923. if ( G_TryingSpecial(pm->gent, &pm->cmd)/*(pm->cmd.buttons&BUTTON_FORCE_FOCUS)*/ )//Holding focus
  2924. {//if no special worked, do nothing
  2925. return LS_NONE;
  2926. }
  2927. }
  2928. //checked all special attacks, if we're in a parry, attack from that move
  2929. saberMoveName_t parryAttackMove = PM_CheckPlayerAttackFromParry( curmove );
  2930. if ( parryAttackMove != LS_NONE )
  2931. {
  2932. return parryAttackMove;
  2933. }
  2934. //check regular attacks
  2935. if ( forwardmove > 0 )
  2936. {//forward left = TR2BL slash
  2937. return LS_A_TR2BL;
  2938. }
  2939. else if ( forwardmove < 0 )
  2940. {//backward left = BR2TL uppercut
  2941. return LS_A_BR2TL;
  2942. }
  2943. else
  2944. {//just left is a right slice
  2945. return LS_A_R2L;
  2946. }
  2947. }
  2948. }
  2949. else
  2950. {//not moving left or right
  2951. #ifdef _XBOX
  2952. if ( forwardmove > 64 )
  2953. #else
  2954. if ( forwardmove > 0 )
  2955. #endif // _XBOX
  2956. {//forward= T2B slash
  2957. saberMoveName_t stabDownMove = noSpecials?LS_NONE:PM_CheckStabDown();
  2958. if ( stabDownMove != LS_NONE )
  2959. {
  2960. return stabDownMove;
  2961. }
  2962. if ( ((pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg.renderingThirdPerson && !cg.zoomMode) )//player in third person, not zoomed in
  2963. {//player in thirdperson, not zoomed in
  2964. //flip-over attack logic
  2965. if ( !noSpecials && PM_CheckFlipOverAttackMove( qfalse ) )
  2966. {//flip over-forward down-attack
  2967. return PM_SaberFlipOverAttackMove();
  2968. }
  2969. //lunge attack logic
  2970. else if ( PM_CheckLungeAttackMove() )
  2971. {
  2972. return PM_SaberLungeAttackMove( qtrue );
  2973. }
  2974. //jump forward attack logic
  2975. else if ( !noSpecials && PM_CheckJumpForwardAttackMove() )
  2976. {
  2977. return PM_SaberJumpForwardAttackMove();
  2978. }
  2979. }
  2980. //player NPC with enemy: autoMove logic
  2981. if ( pm->gent
  2982. && pm->gent->enemy
  2983. && pm->gent->enemy->client )
  2984. {//I have an active enemy
  2985. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() )
  2986. {//a player who is running at an enemy
  2987. //if the enemy is not a jedi, don't use top-down, pick a diagonal or side attack
  2988. if ( pm->gent->enemy->s.weapon != WP_SABER
  2989. && pm->gent->enemy->client->NPC_class != CLASS_REMOTE//too small to do auto-aiming accurately
  2990. && pm->gent->enemy->client->NPC_class != CLASS_SEEKER//too small to do auto-aiming accurately
  2991. && pm->gent->enemy->client->NPC_class != CLASS_GONK//too short to do auto-aiming accurately
  2992. && pm->gent->enemy->client->NPC_class != CLASS_HOWLER//too short to do auto-aiming accurately
  2993. && g_saberAutoAim->integer )
  2994. {
  2995. saberMoveName_t autoMove = PM_AttackForEnemyPos( qfalse, (qboolean)(pm->ps->clientNum>=MAX_CLIENTS&&!PM_ControlledByPlayer()) );
  2996. if ( autoMove != LS_INVALID )
  2997. {
  2998. return autoMove;
  2999. }
  3000. }
  3001. }
  3002. if ( pm->ps->clientNum>=MAX_CLIENTS && !PM_ControlledByPlayer() ) //NPC ONLY
  3003. {//NPC
  3004. if ( PM_CheckFlipOverAttackMove( qtrue ) )
  3005. {
  3006. return PM_SaberFlipOverAttackMove();
  3007. }
  3008. }
  3009. }
  3010. //Regular NPCs
  3011. if ( pm->ps->clientNum >= MAX_CLIENTS && !PM_ControlledByPlayer() ) //NPC ONLY
  3012. {//NPC or player in third person, not zoomed in
  3013. //fwd jump attack logic
  3014. if ( PM_CheckJumpForwardAttackMove() )
  3015. {
  3016. return PM_SaberJumpForwardAttackMove();
  3017. }
  3018. //lunge attack logic
  3019. else if ( PM_CheckLungeAttackMove() )
  3020. {
  3021. return PM_SaberLungeAttackMove( qtrue );
  3022. }
  3023. }
  3024. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3025. {//player
  3026. if ( G_TryingSpecial(pm->gent,&pm->cmd) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3027. {//if no special worked, do nothing
  3028. return LS_NONE;
  3029. }
  3030. }
  3031. //checked all special attacks, if we're in a parry, attack from that move
  3032. saberMoveName_t parryAttackMove = PM_CheckPlayerAttackFromParry( curmove );
  3033. if ( parryAttackMove != LS_NONE )
  3034. {
  3035. return parryAttackMove;
  3036. }
  3037. //check regular attacks
  3038. return LS_A_T2B;
  3039. }
  3040. #ifdef _XBOX
  3041. else if ( forwardmove < -64 )
  3042. #else
  3043. else if ( forwardmove < 0 )
  3044. #endif // _XBOX
  3045. {//backward= T2B slash//B2T uppercut?
  3046. if ( g_saberNewControlScheme->integer )
  3047. {
  3048. saberMoveName_t pullAtk = PM_CheckPullAttack();
  3049. if ( pullAtk != LS_NONE )
  3050. {
  3051. return pullAtk;
  3052. }
  3053. }
  3054. if ( g_saberNewControlScheme->integer
  3055. && (pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer()) //PLAYER ONLY
  3056. && (pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus, trying special backwards attacks
  3057. {//player lunge attack logic
  3058. if ( ( pm->ps->dualSabers //or dual
  3059. || pm->ps->saberAnimLevel == SS_STAFF )//pm->ps->SaberStaff() )//or staff
  3060. && G_EnoughPowerForSpecialMove( pm->ps->forcePower, SABER_ALT_ATTACK_POWER_FB )/*pm->ps->forcePower >= SABER_ALT_ATTACK_POWER_FB*/ )//have enough force power to pull it off
  3061. {//alt+back+attack using fast, dual or staff attacks
  3062. PM_SaberLungeAttackMove( qfalse );
  3063. }
  3064. }
  3065. else if ( (pm->ps->clientNum&&!PM_ControlledByPlayer()) //NPC
  3066. || ((pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg.renderingThirdPerson && !cg.zoomMode) )//player in third person, not zooomed
  3067. {//NPC or player in third person, not zoomed
  3068. if ( PM_CheckBackflipAttackMove() )
  3069. {
  3070. return PM_SaberBackflipAttackMove();//backflip attack
  3071. }
  3072. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3073. {//player
  3074. if ( G_TryingSpecial(pm->gent,&pm->cmd) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3075. {//if no special worked, do nothing
  3076. return LS_NONE;
  3077. }
  3078. }
  3079. //if ( !PM_InKnockDown( pm->ps ) )
  3080. if ( pm->ps->groundEntityNum != ENTITYNUM_NONE )
  3081. {//only when on ground
  3082. if ( pm->gent && pm->gent->enemy )
  3083. {//FIXME: or just trace for a valid enemy standing behind me? And no enemy in front?
  3084. vec3_t enemyDir, faceFwd, facingAngles = {0, pm->ps->viewangles[YAW], 0};
  3085. AngleVectors( facingAngles, faceFwd, NULL, NULL );
  3086. VectorSubtract( pm->gent->enemy->currentOrigin, pm->ps->origin, enemyDir );
  3087. float dot = DotProduct( enemyDir, faceFwd );
  3088. if ( dot < 0 )
  3089. {//enemy is behind me
  3090. if ( dot < -0.75f
  3091. && DistanceSquared( pm->gent->currentOrigin, pm->gent->enemy->currentOrigin ) < 16384//128 squared
  3092. && (pm->ps->saberAnimLevel == SS_FAST || pm->ps->saberAnimLevel == SS_STAFF || (pm->gent->client &&(pm->gent->client->NPC_class == CLASS_TAVION||pm->gent->client->NPC_class == CLASS_ALORA)&&Q_irand(0,1))) )
  3093. {//fast attacks and Tavion
  3094. if ( !(pm->ps->pm_flags&PMF_DUCKED) && pm->cmd.upmove >= 0 )
  3095. {//can't do it while ducked?
  3096. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) || (pm->gent->NPC && pm->gent->NPC->rank >= RANK_LT_JG) )
  3097. {//only fencers and above can do this
  3098. return LS_A_BACKSTAB;
  3099. }
  3100. }
  3101. }
  3102. else if ( pm->ps->saberAnimLevel != SS_FAST
  3103. && pm->ps->saberAnimLevel != SS_STAFF )
  3104. {//medium and higher attacks
  3105. if ( (pm->ps->pm_flags&PMF_DUCKED) || pm->cmd.upmove < 0 )
  3106. {
  3107. return LS_A_BACK_CR;
  3108. }
  3109. else
  3110. {
  3111. return LS_A_BACK;
  3112. }
  3113. }
  3114. }
  3115. else
  3116. {//enemy in front
  3117. float enemyDistSq = DistanceSquared( pm->gent->currentOrigin, pm->gent->enemy->currentOrigin );
  3118. if ( (pm->ps->saberAnimLevel == FORCE_LEVEL_1||pm->ps->saberAnimLevel == SS_STAFF||pm->gent->client->NPC_class==CLASS_TAVION||pm->gent->client->NPC_class == CLASS_ALORA||(pm->gent->client->NPC_class==CLASS_DESANN&&!Q_irand(0,3))) && enemyDistSq > 16384 || pm->gent->enemy->health <= 0 )//128 squared
  3119. {//my enemy is pretty far in front of me and I'm using fast attacks
  3120. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) ||
  3121. ( pm->gent && pm->gent->client && pm->gent->NPC && pm->gent->NPC->rank >= RANK_LT_JG && Q_irand( 0, pm->gent->NPC->rank ) > RANK_ENSIGN ) )
  3122. {//only fencers and higher can do this, higher rank does it more
  3123. if ( PM_CheckEnemyInBack( 128 ) )
  3124. {
  3125. return PM_PickBackStab();
  3126. }
  3127. }
  3128. }
  3129. else if ( (pm->ps->saberAnimLevel >= FORCE_LEVEL_2 || pm->gent->client->NPC_class == CLASS_DESANN) && enemyDistSq > 40000 || pm->gent->enemy->health <= 0 )//200 squared
  3130. {//enemy is very faw away and I'm using medium/strong attacks
  3131. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) ||
  3132. ( pm->gent && pm->gent->client && pm->gent->NPC && pm->gent->NPC->rank >= RANK_LT_JG && Q_irand( 0, pm->gent->NPC->rank ) > RANK_ENSIGN ) )
  3133. {//only fencers and higher can do this, higher rank does it more
  3134. if ( PM_CheckEnemyInBack( 164 ) )
  3135. {
  3136. return PM_PickBackStab();
  3137. }
  3138. }
  3139. }
  3140. }
  3141. }
  3142. else
  3143. {//no current enemy
  3144. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->gent && pm->gent->client )
  3145. {//only player
  3146. if ( PM_CheckEnemyInBack( 128 ) )
  3147. {
  3148. return PM_PickBackStab();
  3149. }
  3150. }
  3151. }
  3152. }
  3153. }
  3154. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3155. {//player
  3156. if ( G_TryingSpecial( pm->gent, &pm->cmd ) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3157. {//if no special worked, do nothing
  3158. return LS_NONE;
  3159. }
  3160. }
  3161. //checked all special attacks, if we're in a parry, attack from that move
  3162. saberMoveName_t parryAttackMove = PM_CheckPlayerAttackFromParry( curmove );
  3163. if ( parryAttackMove != LS_NONE )
  3164. {
  3165. return parryAttackMove;
  3166. }
  3167. //check regular attacks
  3168. //else just swing down
  3169. return LS_A_T2B;
  3170. }
  3171. else
  3172. {//not moving in any direction
  3173. if ( PM_SaberInBounce( curmove ) )
  3174. {//bounces should go to their default attack if you don't specify a direction but are attacking
  3175. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3176. {//player
  3177. if ( G_TryingSpecial(pm->gent,&pm->cmd) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3178. {//if no special worked, do nothing
  3179. return LS_NONE;
  3180. }
  3181. }
  3182. saberMoveName_t newmove;
  3183. if ( pm->ps->clientNum && !PM_ControlledByPlayer() && Q_irand( 0, 3 ) )
  3184. {//use NPC random
  3185. newmove = PM_NPCSaberAttackFromQuad( saberMoveData[curmove].endQuad );
  3186. }
  3187. else
  3188. {//player uses chain-attack
  3189. newmove = saberMoveData[curmove].chain_attack;
  3190. }
  3191. if ( PM_SaberKataDone( curmove, newmove ) )
  3192. {
  3193. return saberMoveData[curmove].chain_idle;
  3194. }
  3195. else
  3196. {
  3197. return newmove;
  3198. }
  3199. }
  3200. else if ( PM_SaberInKnockaway( curmove ) )
  3201. {//bounces should go to their default attack if you don't specify a direction but are attacking
  3202. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3203. {//player
  3204. if ( G_TryingSpecial( pm->gent, &pm->cmd ) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3205. {//if no special worked, do nothing
  3206. return LS_NONE;
  3207. }
  3208. }
  3209. saberMoveName_t newmove;
  3210. if ( pm->ps->clientNum && !PM_ControlledByPlayer() && Q_irand( 0, 3 ) )
  3211. {//use NPC random
  3212. newmove = PM_NPCSaberAttackFromQuad( saberMoveData[curmove].endQuad );
  3213. }
  3214. else
  3215. {
  3216. if ( pm->ps->saberAnimLevel == SS_FAST ||
  3217. pm->ps->saberAnimLevel == SS_TAVION )
  3218. {//player is in fast attacks, so come right back down from the same spot
  3219. newmove = PM_AttackMoveForQuad( saberMoveData[curmove].endQuad );
  3220. }
  3221. else
  3222. {//use a transition to wrap to another attack from a different dir
  3223. newmove = saberMoveData[curmove].chain_attack;
  3224. }
  3225. }
  3226. if ( PM_SaberKataDone( curmove, newmove ) )
  3227. {
  3228. return saberMoveData[curmove].chain_idle;
  3229. }
  3230. else
  3231. {
  3232. return newmove;
  3233. }
  3234. }
  3235. else if ( curmove == LS_READY
  3236. || curmove == LS_A_FLIP_STAB
  3237. || curmove == LS_A_FLIP_SLASH
  3238. || ( curmove >= LS_PARRY_UP
  3239. && curmove <= LS_REFLECT_LL ) )
  3240. {//Not moving at all, not too busy to attack
  3241. //push + lookdown + attack + dual sabers = LS_DUAL_SPIN_PROTECT
  3242. if ( g_saberNewControlScheme->integer )
  3243. {
  3244. if ( PM_CheckDualSpinProtect() )
  3245. {
  3246. return LS_DUAL_SPIN_PROTECT;
  3247. }
  3248. if ( PM_CheckStaffKata() )
  3249. {
  3250. return LS_STAFF_SOULCAL;
  3251. }
  3252. }
  3253. if ( pm->ps->clientNum < MAX_CLIENTS || PM_ControlledByPlayer() ) //PLAYER ONLY
  3254. {//player
  3255. if ( G_TryingSpecial( pm->gent, &pm->cmd ) )//(pm->cmd.buttons&BUTTON_FORCE_FOCUS) )//Holding focus
  3256. {//if no special worked, do nothing
  3257. return LS_NONE;
  3258. }
  3259. }
  3260. //checked all special attacks, if we're in a parry, attack from that move
  3261. saberMoveName_t parryAttackMove = PM_CheckPlayerAttackFromParry( curmove );
  3262. if ( parryAttackMove != LS_NONE )
  3263. {
  3264. return parryAttackMove;
  3265. }
  3266. //check regular attacks
  3267. if ( pm->ps->clientNum || g_saberAutoAim->integer )
  3268. {//auto-aim
  3269. if ( pm->gent && pm->gent->enemy )
  3270. {//based on enemy position, pick a proper attack
  3271. saberMoveName_t autoMove = PM_AttackForEnemyPos( qtrue, (qboolean)(pm->ps->clientNum>=MAX_CLIENTS) );
  3272. if ( autoMove != LS_INVALID )
  3273. {
  3274. return autoMove;
  3275. }
  3276. }
  3277. else if ( fabs(pm->ps->viewangles[0]) > 30 )
  3278. {//looking far up or far down uses the top to bottom attack, presuming you want a vertical attack
  3279. return LS_A_T2B;
  3280. }
  3281. }
  3282. else
  3283. {//for now, just pick a random attack
  3284. return ((saberMoveName_t)Q_irand( LS_A_TL2BR, LS_A_T2B ));
  3285. }
  3286. }
  3287. }
  3288. }
  3289. //FIXME: pick a return?
  3290. return LS_NONE;
  3291. }
  3292. saberMoveName_t PM_SaberAnimTransitionMove( saberMoveName_t curmove, saberMoveName_t newmove )
  3293. {
  3294. //FIXME: take FP_SABER_OFFENSE into account here somehow?
  3295. int retmove = newmove;
  3296. if ( curmove == LS_READY )
  3297. {//just standing there
  3298. switch ( newmove )
  3299. {
  3300. case LS_A_TL2BR:
  3301. case LS_A_L2R:
  3302. case LS_A_BL2TR:
  3303. case LS_A_BR2TL:
  3304. case LS_A_R2L:
  3305. case LS_A_TR2BL:
  3306. case LS_A_T2B:
  3307. //transition is the start
  3308. retmove = LS_S_TL2BR + (newmove-LS_A_TL2BR);
  3309. break;
  3310. }
  3311. }
  3312. else
  3313. {
  3314. switch ( newmove )
  3315. {
  3316. //transitioning to ready pose
  3317. case LS_READY:
  3318. switch ( curmove )
  3319. {
  3320. //transitioning from an attack
  3321. case LS_A_TL2BR:
  3322. case LS_A_L2R:
  3323. case LS_A_BL2TR:
  3324. case LS_A_BR2TL:
  3325. case LS_A_R2L:
  3326. case LS_A_TR2BL:
  3327. case LS_A_T2B:
  3328. //transition is the return
  3329. retmove = LS_R_TL2BR + (newmove-LS_A_TL2BR);
  3330. break;
  3331. }
  3332. break;
  3333. //transitioning to an attack
  3334. case LS_A_TL2BR:
  3335. case LS_A_L2R:
  3336. case LS_A_BL2TR:
  3337. case LS_A_BR2TL:
  3338. case LS_A_R2L:
  3339. case LS_A_TR2BL:
  3340. case LS_A_T2B:
  3341. if ( newmove == curmove )
  3342. {//FIXME: need a spin or something or go to next level, but for now, just play the return
  3343. //going into another attack...
  3344. //allow endless chaining in level 1 attacks, several in level 2 and only one or a few in level 3
  3345. //FIXME: don't let strong attacks chain to an attack in the opposite direction ( > 45 degrees?)
  3346. if ( PM_SaberKataDone( curmove, newmove ) )
  3347. {//done with this kata, must return to ready before attack again
  3348. retmove = LS_R_TL2BR + (newmove-LS_A_TL2BR);
  3349. }
  3350. else
  3351. {//okay to chain to another attack
  3352. retmove = transitionMove[saberMoveData[curmove].endQuad][saberMoveData[newmove].startQuad];
  3353. }
  3354. }
  3355. else if ( saberMoveData[curmove].endQuad == saberMoveData[newmove].startQuad )
  3356. {//new move starts from same quadrant
  3357. retmove = newmove;
  3358. }
  3359. else
  3360. {
  3361. switch ( curmove )
  3362. {
  3363. //transitioning from an attack
  3364. case LS_A_TL2BR:
  3365. case LS_A_L2R:
  3366. case LS_A_BL2TR:
  3367. case LS_A_BR2TL:
  3368. case LS_A_R2L:
  3369. case LS_A_TR2BL:
  3370. case LS_A_T2B:
  3371. case LS_D1_BR:
  3372. case LS_D1__R:
  3373. case LS_D1_TR:
  3374. case LS_D1_T_:
  3375. case LS_D1_TL:
  3376. case LS_D1__L:
  3377. case LS_D1_BL:
  3378. case LS_D1_B_:
  3379. retmove = transitionMove[saberMoveData[curmove].endQuad][saberMoveData[newmove].startQuad];
  3380. break;
  3381. //transitioning from a return
  3382. case LS_R_TL2BR:
  3383. case LS_R_L2R:
  3384. case LS_R_BL2TR:
  3385. case LS_R_BR2TL:
  3386. case LS_R_R2L:
  3387. case LS_R_TR2BL:
  3388. case LS_R_T2B:
  3389. //transitioning from a bounce
  3390. /*
  3391. case LS_BOUNCE_UL2LL:
  3392. case LS_BOUNCE_LL2UL:
  3393. case LS_BOUNCE_L2LL:
  3394. case LS_BOUNCE_L2UL:
  3395. case LS_BOUNCE_UR2LR:
  3396. case LS_BOUNCE_LR2UR:
  3397. case LS_BOUNCE_R2LR:
  3398. case LS_BOUNCE_R2UR:
  3399. case LS_BOUNCE_TOP:
  3400. case LS_OVER_UR2UL:
  3401. case LS_OVER_UL2UR:
  3402. case LS_BOUNCE_UR:
  3403. case LS_BOUNCE_UL:
  3404. case LS_BOUNCE_LR:
  3405. case LS_BOUNCE_LL:
  3406. */
  3407. //transitioning from a parry/reflection/knockaway/broken parry
  3408. case LS_PARRY_UP:
  3409. case LS_PARRY_UR:
  3410. case LS_PARRY_UL:
  3411. case LS_PARRY_LR:
  3412. case LS_PARRY_LL:
  3413. case LS_REFLECT_UP:
  3414. case LS_REFLECT_UR:
  3415. case LS_REFLECT_UL:
  3416. case LS_REFLECT_LR:
  3417. case LS_REFLECT_LL:
  3418. case LS_K1_T_:
  3419. case LS_K1_TR:
  3420. case LS_K1_TL:
  3421. case LS_K1_BR:
  3422. case LS_K1_BL:
  3423. case LS_V1_BR:
  3424. case LS_V1__R:
  3425. case LS_V1_TR:
  3426. case LS_V1_T_:
  3427. case LS_V1_TL:
  3428. case LS_V1__L:
  3429. case LS_V1_BL:
  3430. case LS_V1_B_:
  3431. case LS_H1_T_:
  3432. case LS_H1_TR:
  3433. case LS_H1_TL:
  3434. case LS_H1_BR:
  3435. case LS_H1_BL:
  3436. retmove = transitionMove[saberMoveData[curmove].endQuad][saberMoveData[newmove].startQuad];
  3437. break;
  3438. //NB: transitioning from transitions is fine
  3439. }
  3440. }
  3441. break;
  3442. //transitioning to any other anim is not supported
  3443. }
  3444. }
  3445. if ( retmove == LS_NONE )
  3446. {
  3447. return newmove;
  3448. }
  3449. return ((saberMoveName_t)retmove);
  3450. }
  3451. /*
  3452. -------------------------
  3453. PM_LegsAnimForFrame
  3454. Returns animNumber for current frame
  3455. -------------------------
  3456. */
  3457. int PM_LegsAnimForFrame( gentity_t *ent, int legsFrame )
  3458. {
  3459. //Must be a valid client
  3460. if ( ent->client == NULL )
  3461. return -1;
  3462. //Must have a file index entry
  3463. if( ValidAnimFileIndex( ent->client->clientInfo.animFileIndex ) == qfalse )
  3464. return -1;
  3465. animation_t *animations = level.knownAnimFileSets[ent->client->clientInfo.animFileIndex].animations;
  3466. int glaIndex = gi.G2API_GetAnimIndex(&(ent->ghoul2[0]));
  3467. for ( int animation = 0; animation < BOTH_CIN_1; animation++ ) //first anim after last legs
  3468. {
  3469. if ( animation >= TORSO_DROPWEAP1 && animation < LEGS_TURN1 ) //first legs only anim
  3470. {//not a possible legs anim
  3471. continue;
  3472. }
  3473. if ( animations[animation].glaIndex != glaIndex )
  3474. {
  3475. continue;
  3476. }
  3477. if ( animations[animation].firstFrame > legsFrame )
  3478. {//This anim starts after this frame
  3479. continue;
  3480. }
  3481. if ( animations[animation].firstFrame + animations[animation].numFrames < legsFrame )
  3482. {//This anim ends before this frame
  3483. continue;
  3484. }
  3485. //else, must be in this anim!
  3486. return animation;
  3487. }
  3488. //Not in ANY torsoAnim? SHOULD NEVER HAPPEN
  3489. // assert(0);
  3490. return -1;
  3491. }
  3492. int PM_ValidateAnimRange( const int startFrame, const int endFrame, const float animSpeed )
  3493. {//given a startframe and endframe, see if that lines up with any known animation
  3494. animation_t *animations = level.knownAnimFileSets[0].animations;
  3495. for ( int anim = 0; anim < MAX_ANIMATIONS; anim++ )
  3496. {
  3497. if ( animSpeed < 0 )
  3498. {//playing backwards
  3499. if ( animations[anim].firstFrame == endFrame )
  3500. {
  3501. if ( animations[anim].numFrames + animations[anim].firstFrame == startFrame )
  3502. {
  3503. //Com_Printf( "valid reverse anim: %s\n", animTable[anim].name );
  3504. return anim;
  3505. }
  3506. }
  3507. }
  3508. else
  3509. {//playing forwards
  3510. if ( animations[anim].firstFrame == startFrame )
  3511. {//This anim starts on this frame
  3512. if ( animations[anim].firstFrame + animations[anim].numFrames == endFrame )
  3513. {//This anim ends on this frame
  3514. //Com_Printf( "valid forward anim: %s\n", animTable[anim].name );
  3515. return anim;
  3516. }
  3517. }
  3518. }
  3519. //else, must not be this anim!
  3520. }
  3521. //Not in ANY anim? SHOULD NEVER HAPPEN
  3522. Com_Printf( "invalid anim range %d to %d, speed %4.2f\n", startFrame, endFrame, animSpeed );
  3523. return -1;
  3524. }
  3525. /*
  3526. -------------------------
  3527. PM_TorsoAnimForFrame
  3528. Returns animNumber for current frame
  3529. -------------------------
  3530. */
  3531. int PM_TorsoAnimForFrame( gentity_t *ent, int torsoFrame )
  3532. {
  3533. //Must be a valid client
  3534. if ( ent->client == NULL )
  3535. return -1;
  3536. //Must have a file index entry
  3537. if( ValidAnimFileIndex( ent->client->clientInfo.animFileIndex ) == qfalse )
  3538. return -1;
  3539. animation_t *animations = level.knownAnimFileSets[ent->client->clientInfo.animFileIndex].animations;
  3540. int glaIndex = gi.G2API_GetAnimIndex(&(ent->ghoul2[0]));
  3541. for ( int animation = 0; animation < LEGS_TURN1; animation++ ) //first legs only anim
  3542. {
  3543. if ( animations[animation].glaIndex != glaIndex )
  3544. {
  3545. continue;
  3546. }
  3547. if ( animations[animation].firstFrame > torsoFrame )
  3548. {//This anim starts after this frame
  3549. continue;
  3550. }
  3551. if ( animations[animation].firstFrame + animations[animation].numFrames < torsoFrame )
  3552. {//This anim ends before this frame
  3553. continue;
  3554. }
  3555. //else, must be in this anim!
  3556. return animation;
  3557. }
  3558. //Not in ANY torsoAnim? SHOULD NEVER HAPPEN
  3559. // assert(0);
  3560. return -1;
  3561. }
  3562. qboolean PM_FinishedCurrentLegsAnim( gentity_t *self )
  3563. {
  3564. int junk, curFrame;
  3565. float currentFrame, animSpeed;
  3566. if ( !self->client )
  3567. {
  3568. return qtrue;
  3569. }
  3570. gi.G2API_GetBoneAnimIndex( &self->ghoul2[self->playerModel], self->rootBone, (cg.time?cg.time:level.time), &currentFrame, &junk, &junk, &junk, &animSpeed, NULL );
  3571. curFrame = floor( currentFrame );
  3572. int legsAnim = self->client->ps.legsAnim;
  3573. animation_t *animations = level.knownAnimFileSets[self->client->clientInfo.animFileIndex].animations;
  3574. if ( curFrame >= animations[legsAnim].firstFrame + (animations[legsAnim].numFrames - 2) )
  3575. {
  3576. return qtrue;
  3577. }
  3578. return qfalse;
  3579. }
  3580. /*
  3581. -------------------------
  3582. PM_HasAnimation
  3583. -------------------------
  3584. */
  3585. qboolean PM_HasAnimation( gentity_t *ent, int animation )
  3586. {
  3587. //Must be a valid client
  3588. if ( !ent || ent->client == NULL )
  3589. return qfalse;
  3590. //must be a valid anim number
  3591. if ( animation < 0 || animation >= MAX_ANIMATIONS )
  3592. {
  3593. return qfalse;
  3594. }
  3595. //Must have a file index entry
  3596. if( ValidAnimFileIndex( ent->client->clientInfo.animFileIndex ) == qfalse )
  3597. return qfalse;
  3598. animation_t *animations = level.knownAnimFileSets[ent->client->clientInfo.animFileIndex].animations;
  3599. //No frames, no anim
  3600. if ( animations[animation].numFrames == 0 )
  3601. return qfalse;
  3602. //Has the sequence
  3603. return qtrue;
  3604. }
  3605. int PM_PickAnim( gentity_t *self, int minAnim, int maxAnim )
  3606. {
  3607. int anim;
  3608. int count = 0;
  3609. if ( !self )
  3610. {
  3611. return Q_irand(minAnim, maxAnim);
  3612. }
  3613. do
  3614. {
  3615. anim = Q_irand(minAnim, maxAnim);
  3616. count++;
  3617. }
  3618. while ( !PM_HasAnimation( self, anim ) && count < 1000 );
  3619. return anim;
  3620. }
  3621. /*
  3622. -------------------------
  3623. PM_AnimLength
  3624. -------------------------
  3625. */
  3626. int PM_AnimLength( int index, animNumber_t anim )
  3627. {
  3628. if ( ValidAnimFileIndex( index ) == false )
  3629. return 0;
  3630. return level.knownAnimFileSets[index].animations[anim].numFrames * abs(level.knownAnimFileSets[index].animations[anim].frameLerp);
  3631. }
  3632. /*
  3633. -------------------------
  3634. PM_SetLegsAnimTimer
  3635. -------------------------
  3636. */
  3637. void PM_SetLegsAnimTimer( gentity_t *ent, int *legsAnimTimer, int time )
  3638. {
  3639. *legsAnimTimer = time;
  3640. if ( *legsAnimTimer < 0 && time != -1 )
  3641. {//Cap timer to 0 if was counting down, but let it be -1 if that was intentional
  3642. *legsAnimTimer = 0;
  3643. }
  3644. if ( !*legsAnimTimer && ent && Q3_TaskIDPending( ent, TID_ANIM_LOWER ) )
  3645. {//Waiting for legsAnimTimer to complete, and it just got set to zero
  3646. if ( !Q3_TaskIDPending( ent, TID_ANIM_BOTH) )
  3647. {//Not waiting for top
  3648. Q3_TaskIDComplete( ent, TID_ANIM_LOWER );
  3649. }
  3650. else
  3651. {//Waiting for both to finish before complete
  3652. Q3_TaskIDClear( &ent->taskID[TID_ANIM_LOWER] );//Bottom is done, regardless
  3653. if ( !Q3_TaskIDPending( ent, TID_ANIM_UPPER) )
  3654. {//top is done and we're done
  3655. Q3_TaskIDComplete( ent, TID_ANIM_BOTH );
  3656. }
  3657. }
  3658. }
  3659. }
  3660. /*
  3661. -------------------------
  3662. PM_SetTorsoAnimTimer
  3663. -------------------------
  3664. */
  3665. void PM_SetTorsoAnimTimer( gentity_t *ent, int *torsoAnimTimer, int time )
  3666. {
  3667. *torsoAnimTimer = time;
  3668. if ( *torsoAnimTimer < 0 && time != -1 )
  3669. {//Cap timer to 0 if was counting down, but let it be -1 if that was intentional
  3670. *torsoAnimTimer = 0;
  3671. }
  3672. if ( !*torsoAnimTimer && ent && Q3_TaskIDPending( ent, TID_ANIM_UPPER ) )
  3673. {//Waiting for torsoAnimTimer to complete, and it just got set to zero
  3674. if ( !Q3_TaskIDPending( ent, TID_ANIM_BOTH) )
  3675. {//Not waiting for bottom
  3676. Q3_TaskIDComplete( ent, TID_ANIM_UPPER );
  3677. }
  3678. else
  3679. {//Waiting for both to finish before complete
  3680. Q3_TaskIDClear( &ent->taskID[TID_ANIM_UPPER] );//Top is done, regardless
  3681. if ( !Q3_TaskIDPending( ent, TID_ANIM_LOWER) )
  3682. {//lower is done and we're done
  3683. Q3_TaskIDComplete( ent, TID_ANIM_BOTH );
  3684. }
  3685. }
  3686. }
  3687. }
  3688. extern qboolean PM_SpinningSaberAnim( int anim );
  3689. extern float saberAnimSpeedMod[NUM_FORCE_POWER_LEVELS];
  3690. void PM_SaberStartTransAnim( int saberAnimLevel, int anim, float *animSpeed, gentity_t *gent )
  3691. {
  3692. if ( g_saberAnimSpeed->value != 1.0f )
  3693. {
  3694. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_CROUCHATTACKBACK1 )
  3695. {
  3696. *animSpeed *= g_saberAnimSpeed->value;
  3697. }
  3698. }
  3699. if ( gent
  3700. && gent->client
  3701. && gent->client->ps.stats[STAT_WEAPONS]&(1<<WP_SCEPTER)
  3702. && gent->client->ps.dualSabers
  3703. && saberAnimLevel == SS_DUAL
  3704. && gent->weaponModel[1] )
  3705. {//using a scepter and dual style, slow down anims
  3706. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_H7_S7_BR )
  3707. {
  3708. *animSpeed *= 0.75;
  3709. }
  3710. }
  3711. if ( gent && gent->client && gent->client->ps.forceRageRecoveryTime > level.time )
  3712. {//rage recovery
  3713. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_H1_S1_BR )
  3714. {//animate slower
  3715. *animSpeed *= 0.75;
  3716. }
  3717. }
  3718. else if ( gent && gent->NPC && gent->NPC->rank == RANK_CIVILIAN )
  3719. {//grunt reborn
  3720. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_R1_TR_S1 )
  3721. {//his fast attacks are slower
  3722. if ( !PM_SpinningSaberAnim( anim ) )
  3723. {
  3724. *animSpeed *= 0.75;
  3725. }
  3726. return;
  3727. }
  3728. }
  3729. else if ( gent && gent->client )
  3730. {
  3731. if ( gent->client->ps.saber[0].type == SABER_LANCE || gent->client->ps.saber[0].type == SABER_TRIDENT )
  3732. {//FIXME: hack for now - these use the fast anims, but slowed down. Should have own style
  3733. if ( anim >= BOTH_A1_T__B_ && anim <= BOTH_R1_TR_S1 )
  3734. {//his fast attacks are slower
  3735. if ( !PM_SpinningSaberAnim( anim ) )
  3736. {
  3737. *animSpeed *= 0.75;
  3738. }
  3739. return;
  3740. }
  3741. }
  3742. }
  3743. if ( ( anim >= BOTH_T1_BR__R &&
  3744. anim <= BOTH_T1_BL_TL ) ||
  3745. ( anim >= BOTH_T3_BR__R &&
  3746. anim <= BOTH_T3_BL_TL ) ||
  3747. ( anim >= BOTH_T5_BR__R &&
  3748. anim <= BOTH_T5_BL_TL ) )
  3749. {
  3750. if ( saberAnimLevel == FORCE_LEVEL_1 || saberAnimLevel == FORCE_LEVEL_5 )
  3751. {//FIXME: should not be necc for FORCE_LEVEL_1's
  3752. *animSpeed *= 1.5;
  3753. }
  3754. else if ( saberAnimLevel == FORCE_LEVEL_3 )
  3755. {
  3756. *animSpeed *= 0.75;
  3757. }
  3758. }
  3759. }
  3760. /*
  3761. void PM_SaberStartTransAnim( int anim, int entNum, int saberOffenseLevel, float *animSpeed )
  3762. {
  3763. //check starts
  3764. if ( ( anim >= BOTH_S1_S1_T_ &&
  3765. anim <= BOTH_S1_S1_TR ) ||
  3766. ( anim >= BOTH_S1_S1_T_ &&
  3767. anim <= BOTH_S1_S1_TR ) ||
  3768. ( anim >= BOTH_S3_S1_T_ &&
  3769. anim <= BOTH_S3_S1_TR ) )
  3770. {
  3771. if ( entNum == 0 )
  3772. {
  3773. *animSpeed *= saberAnimSpeedMod[FORCE_LEVEL_3];
  3774. }
  3775. else
  3776. {
  3777. *animSpeed *= saberAnimSpeedMod[saberOffenseLevel];
  3778. }
  3779. }
  3780. //Check transitions
  3781. else if ( PM_SpinningSaberAnim( anim ) )
  3782. {//spins stay normal speed
  3783. return;
  3784. }
  3785. else if ( ( anim >= BOTH_T1_BR__R &&
  3786. anim <= BOTH_T1_BL_TL ) ||
  3787. ( anim >= BOTH_T2_BR__R &&
  3788. anim <= BOTH_T2_BL_TL ) ||
  3789. ( anim >= BOTH_T3_BR__R &&
  3790. anim <= BOTH_T3_BL_TL ) )
  3791. {//slow down the transitions
  3792. if ( entNum == 0 && saberOffenseLevel <= FORCE_LEVEL_2 )
  3793. {
  3794. *animSpeed *= saberAnimSpeedMod[saberOffenseLevel];
  3795. }
  3796. else
  3797. {
  3798. *animSpeed *= saberAnimSpeedMod[saberOffenseLevel]/2.0f;
  3799. }
  3800. }
  3801. return;
  3802. }
  3803. */
  3804. extern qboolean player_locked;
  3805. extern qboolean MatrixMode;
  3806. float PM_GetTimeScaleMod( gentity_t *gent )
  3807. {
  3808. if ( g_timescale->value )
  3809. {
  3810. if ( !MatrixMode
  3811. && gent->client->ps.legsAnim != BOTH_FORCELONGLEAP_START
  3812. && gent->client->ps.legsAnim != BOTH_FORCELONGLEAP_ATTACK
  3813. && gent->client->ps.legsAnim != BOTH_FORCELONGLEAP_LAND )
  3814. {
  3815. if ( gent && gent->s.clientNum == 0 && !player_locked && gent->client->ps.forcePowersActive&(1<<FP_SPEED) )
  3816. {
  3817. return (1.0 / g_timescale->value);
  3818. }
  3819. else if ( gent && gent->client && gent->client->ps.forcePowersActive&(1<<FP_SPEED) )
  3820. {
  3821. return (1.0 / g_timescale->value);
  3822. }
  3823. }
  3824. }
  3825. return 1.0f;
  3826. }
  3827. static inline qboolean PM_IsHumanoid( CGhoul2Info *ghlInfo )
  3828. {
  3829. char *GLAName;
  3830. GLAName = gi.G2API_GetGLAName( ghlInfo );
  3831. assert(GLAName);
  3832. if ( !Q_stricmp( "models/players/_humanoid/_humanoid", GLAName ) )
  3833. {
  3834. return qtrue;
  3835. }
  3836. return qfalse;
  3837. }
  3838. /*
  3839. -------------------------
  3840. PM_SetAnimFinal
  3841. -------------------------
  3842. */
  3843. #define G2_DEBUG_TIMING (0)
  3844. void PM_SetAnimFinal(int *torsoAnim,int *legsAnim,
  3845. int setAnimParts,int anim,int setAnimFlags,
  3846. int *torsoAnimTimer,int *legsAnimTimer,
  3847. gentity_t *gent,int blendTime) // default blendTime=350
  3848. {
  3849. // BASIC SETUP AND SAFETY CHECKING
  3850. //=================================
  3851. // If It Is A Busted Entity, Don't Do Anything Here.
  3852. //---------------------------------------------------
  3853. if (!gent || !gent->client)
  3854. {
  3855. return;
  3856. }
  3857. // Make Sure This Character Has Such An Anim And A Model
  3858. //-------------------------------------------------------
  3859. if (anim<0 || anim>=MAX_ANIMATIONS || !ValidAnimFileIndex(gent->client->clientInfo.animFileIndex))
  3860. {
  3861. #ifndef FINAL_BUILD
  3862. if (g_AnimWarning->integer)
  3863. {
  3864. if (anim<0 || anim>=MAX_ANIMATIONS)
  3865. {
  3866. gi.Printf(S_COLOR_RED"PM_SetAnimFinal: Invalid Anim Index (%d)!\n", anim);
  3867. }
  3868. else
  3869. {
  3870. gi.Printf(S_COLOR_RED"PM_SetAnimFinal: Invalid Anim File Index (%d)!\n", gent->client->clientInfo.animFileIndex);
  3871. }
  3872. }
  3873. #endif
  3874. return;
  3875. }
  3876. // Get Global Time Properties
  3877. //----------------------------
  3878. float timeScaleMod = PM_GetTimeScaleMod( gent );
  3879. const int actualTime = (cg.time?cg.time:level.time);
  3880. const animation_t* animations = level.knownAnimFileSets[gent->client->clientInfo.animFileIndex].animations;
  3881. const animation_t& curAnim = animations[anim];
  3882. // Make Sure This Character Has Such An Anim And A Model
  3883. //-------------------------------------------------------
  3884. if (animations[anim].numFrames==0)
  3885. {
  3886. static int LastAnimWarningNum=0;
  3887. #ifndef FINAL_BUILD
  3888. if (LastAnimWarningNum!=anim)
  3889. {
  3890. if ((cg_debugAnim.integer==3) || // 3 = do everyone
  3891. (cg_debugAnim.integer==1 && gent->s.number==0) || // 1 = only the player
  3892. (cg_debugAnim.integer==2 && gent->s.number!=0) || // 2 = only everyone else
  3893. (cg_debugAnim.integer==4 && gent->s.number!=cg_debugAnimTarget.integer) // 4 = specific entnum
  3894. )
  3895. {
  3896. gi.Printf(S_COLOR_RED"PM_SetAnimFinal: Anim %s does not exist in this model (%s)!\n", animTable[anim].name, gent->NPC_type );
  3897. }
  3898. }
  3899. LastAnimWarningNum = anim;
  3900. #endif
  3901. return;
  3902. }
  3903. // If It's Not A Ghoul 2 Model, Just Remember The Anims And Stop, Because Everything Beyond This Is Ghoul2
  3904. //---------------------------------------------------------------------------------------------------------
  3905. if (!gi.G2API_HaveWeGhoul2Models(gent->ghoul2))
  3906. {
  3907. if (setAnimParts&SETANIM_TORSO)
  3908. {
  3909. (*torsoAnim) = anim;
  3910. }
  3911. if (setAnimParts&SETANIM_LEGS)
  3912. {
  3913. (*legsAnim) = anim;
  3914. }
  3915. return;
  3916. }
  3917. // Lower Offensive Skill Slows Down The Saber Start Attack Animations
  3918. //--------------------------------------------------------------------
  3919. PM_SaberStartTransAnim( gent->client->ps.saberAnimLevel, anim, &timeScaleMod, gent );
  3920. // SETUP VALUES FOR INCOMMING ANIMATION
  3921. //======================================
  3922. const bool animFootMove = (PM_WalkingAnim(anim) || PM_RunningAnim(anim) || anim==BOTH_CROUCH1WALK || anim==BOTH_CROUCH1WALKBACK);
  3923. const bool animHoldless = (setAnimFlags&SETANIM_FLAG_HOLDLESS)!=0;
  3924. const bool animHold = (setAnimFlags&SETANIM_FLAG_HOLD)!=0;
  3925. const bool animRestart = (setAnimFlags&SETANIM_FLAG_RESTART)!=0;
  3926. const bool animOverride = (setAnimFlags&SETANIM_FLAG_OVERRIDE)!=0;
  3927. const bool animSync = (g_synchSplitAnims->integer!=0 && !animRestart);
  3928. float animCurrent = (-1.0f);
  3929. float animSpeed = (50.0f / curAnim.frameLerp * timeScaleMod); // animSpeed is 1.0 if the frameLerp (ms/frame) is 50 (20 fps).
  3930. const float animFPS = (fabsf(curAnim.frameLerp));
  3931. const int animDurMSec = (int)(((curAnim.numFrames - 1) * animFPS) / timeScaleMod);
  3932. const int animHoldMSec = ((animHoldless && timeScaleMod==1.0f)?((animDurMSec>1)?(animDurMSec-1):(animFPS)):(animDurMSec));
  3933. int animFlags = (curAnim.loopFrames!=-1)?(BONE_ANIM_OVERRIDE_LOOP):(BONE_ANIM_OVERRIDE_FREEZE);
  3934. int animStart = (curAnim.firstFrame);
  3935. int animEnd = (curAnim.firstFrame)+(animations[anim].numFrames);
  3936. // If We Have A Blend Timer, Add The Blend Flag
  3937. //----------------------------------------------
  3938. if (blendTime > 0)
  3939. {
  3940. animFlags |= BONE_ANIM_BLEND;
  3941. }
  3942. // If Animation Is Going Backwards, Swap Last And First Frames
  3943. //-------------------------------------------------------------
  3944. if (animSpeed<0.0f)
  3945. {
  3946. // #ifndef FINAL_BUILD
  3947. #if 0
  3948. if (g_AnimWarning->integer==1)
  3949. {
  3950. if (animFlags&BONE_ANIM_OVERRIDE_LOOP)
  3951. {
  3952. gi.Printf(S_COLOR_YELLOW"PM_SetAnimFinal: WARNING: Anim (%s) looping backwards!\n", animTable[anim].name);
  3953. }
  3954. }
  3955. #endif
  3956. int temp = animEnd;
  3957. animEnd = animStart;
  3958. animStart = temp;
  3959. blendTime = 0;
  3960. }
  3961. // If The Animation Is Walking Or Running, Attempt To Scale The Playback Speed To Match
  3962. //--------------------------------------------------------------------------------------
  3963. if (g_noFootSlide->integer
  3964. && animFootMove
  3965. && !(animSpeed<0.0f)
  3966. //FIXME: either read speed from animation.cfg or only do this for NPCs
  3967. // for whom we've specifically determined the proper numbers!
  3968. && gent->client->NPC_class != CLASS_HOWLER
  3969. && gent->client->NPC_class != CLASS_WAMPA
  3970. && gent->client->NPC_class != CLASS_GONK
  3971. && gent->client->NPC_class != CLASS_HOWLER
  3972. && gent->client->NPC_class != CLASS_MOUSE
  3973. && gent->client->NPC_class != CLASS_PROBE
  3974. && gent->client->NPC_class != CLASS_PROTOCOL
  3975. && gent->client->NPC_class != CLASS_R2D2
  3976. && gent->client->NPC_class != CLASS_R5D2
  3977. && gent->client->NPC_class != CLASS_SEEKER)
  3978. {
  3979. bool Walking = !!PM_WalkingAnim(anim);
  3980. bool HasDual = (gent->client->ps.saberAnimLevel==SS_DUAL);
  3981. bool HasStaff = (gent->client->ps.saberAnimLevel==SS_STAFF);
  3982. float moveSpeedOfAnim = 150.0f;//g_noFootSlideRunScale->value;
  3983. if (anim==BOTH_CROUCH1WALK || anim==BOTH_CROUCH1WALKBACK)
  3984. {
  3985. moveSpeedOfAnim = 75.0f;
  3986. }
  3987. else
  3988. {
  3989. if (gent->client->NPC_class == CLASS_HAZARD_TROOPER)
  3990. {
  3991. moveSpeedOfAnim = 50.0f;
  3992. }
  3993. else if (gent->client->NPC_class == CLASS_RANCOR)
  3994. {
  3995. moveSpeedOfAnim = 173.0f;
  3996. }
  3997. else
  3998. {
  3999. if (Walking)
  4000. {
  4001. if (HasDual || HasStaff)
  4002. {
  4003. moveSpeedOfAnim = 100.0f;
  4004. }
  4005. else
  4006. {
  4007. moveSpeedOfAnim = 50.0f;// g_noFootSlideWalkScale->value;
  4008. }
  4009. }
  4010. else
  4011. {
  4012. if (HasStaff)
  4013. {
  4014. moveSpeedOfAnim = 250.0f;
  4015. }
  4016. else
  4017. {
  4018. moveSpeedOfAnim = 150.0f;
  4019. }
  4020. }
  4021. }
  4022. }
  4023. animSpeed *= (gent->resultspeed/moveSpeedOfAnim);
  4024. if (animSpeed<0.01f)
  4025. {
  4026. animSpeed = 0.01f;
  4027. }
  4028. // Make Sure Not To Play Too Fast An Anim
  4029. //----------------------------------------
  4030. // float maxPlaybackSpeed = (1.5f * timeScaleMod);
  4031. float maxPlaybackSpeed = (1.5f * timeScaleMod) / 2.0f;
  4032. if (animSpeed>maxPlaybackSpeed)
  4033. {
  4034. animSpeed = maxPlaybackSpeed;
  4035. }
  4036. }
  4037. // GET VALUES FOR EXISTING BODY ANIMATION
  4038. //==========================================
  4039. float bodySpeed = 0.0f;
  4040. float bodyCurrent = 0.0f;
  4041. int bodyStart = 0;
  4042. int bodyEnd = 0;
  4043. int bodyFlags = 0;
  4044. int bodyAnim = (*legsAnim);
  4045. int bodyBone = (gent->rootBone);
  4046. bool bodyTimerOn = ((*legsAnimTimer>0) || (*legsAnimTimer)==-1);
  4047. bool bodyPlay = ((setAnimParts&SETANIM_LEGS) && (bodyBone!=-1) && (animOverride || !bodyTimerOn));
  4048. bool bodyAnimating = !!gi.G2API_GetBoneAnimIndex(&gent->ghoul2[gent->playerModel], bodyBone, actualTime, &bodyCurrent, &bodyStart, &bodyEnd, &bodyFlags, &bodySpeed, NULL);
  4049. bool bodyOnAnimNow = (bodyAnimating && bodyAnim==anim && bodyStart==animStart && bodyEnd==animEnd);
  4050. bool bodyMatchTorsFrame = false;
  4051. // GET VALUES FOR EXISTING TORSO ANIMATION
  4052. //===========================================
  4053. float torsSpeed = 0.0f;
  4054. float torsCurrent = 0.0f;
  4055. int torsStart = 0;
  4056. int torsEnd = 0;
  4057. int torsFlags = 0;
  4058. int torsAnim = (*torsoAnim);
  4059. int torsBone = (gent->lowerLumbarBone);
  4060. bool torsTimerOn = ((*torsoAnimTimer)>0 || (*torsoAnimTimer)==-1);
  4061. bool torsPlay = (gent->client->NPC_class!=CLASS_RANCOR && (setAnimParts&SETANIM_TORSO) && (torsBone!=-1) && (animOverride || !torsTimerOn));
  4062. bool torsAnimating = !!gi.G2API_GetBoneAnimIndex(&gent->ghoul2[gent->playerModel], torsBone, actualTime, &torsCurrent, &torsStart, &torsEnd, &torsFlags, &torsSpeed, NULL);
  4063. bool torsOnAnimNow = (torsAnimating && torsAnim==anim && torsStart==animStart && torsEnd==animEnd);
  4064. bool torsMatchBodyFrame = false;
  4065. // APPLY SYNC TO TORSO
  4066. //=====================
  4067. if (animSync && torsPlay && !bodyPlay && bodyOnAnimNow && (!torsOnAnimNow || torsCurrent!=bodyCurrent))
  4068. {
  4069. torsMatchBodyFrame = true;
  4070. animCurrent = bodyCurrent;
  4071. }
  4072. if (animSync && bodyPlay && !torsPlay && torsOnAnimNow && (!bodyOnAnimNow || bodyCurrent!=torsCurrent))
  4073. {
  4074. bodyMatchTorsFrame = true;
  4075. animCurrent = torsCurrent;
  4076. }
  4077. // If Already Doing These Exact Parameters, Then Don't Play
  4078. //----------------------------------------------------------
  4079. if (!animRestart)
  4080. {
  4081. torsPlay &= !(torsOnAnimNow && torsSpeed==animSpeed && !torsMatchBodyFrame);
  4082. bodyPlay &= !(bodyOnAnimNow && bodySpeed==animSpeed && !bodyMatchTorsFrame);
  4083. }
  4084. #ifndef FINAL_BUILD
  4085. if ((cg_debugAnim.integer==3) || // 3 = do everyone
  4086. (cg_debugAnim.integer==1 && gent->s.number==0) || // 1 = only the player
  4087. (cg_debugAnim.integer==2 && gent->s.number!=0) || // 2 = only everyone else
  4088. (cg_debugAnim.integer==4 && gent->s.number!=cg_debugAnimTarget.integer) // 4 = specific entnum
  4089. )
  4090. {
  4091. if (bodyPlay || torsPlay)
  4092. {
  4093. char* entName = gent->targetname;
  4094. char* location;
  4095. // Select Entity Name
  4096. //--------------------
  4097. if (!entName || !entName[0])
  4098. {
  4099. entName = gent->NPC_targetname;
  4100. }
  4101. if (!entName || !entName[0])
  4102. {
  4103. entName = gent->NPC_type;
  4104. }
  4105. if (!entName || !entName[0])
  4106. {
  4107. entName = gent->classname;
  4108. }
  4109. if (!entName || !entName[0])
  4110. {
  4111. entName = "UNKNOWN";
  4112. }
  4113. // Select Play Location
  4114. //----------------------
  4115. if (bodyPlay && torsPlay)
  4116. {
  4117. location = "BOTH ";
  4118. }
  4119. else if (bodyPlay)
  4120. {
  4121. location = "LEGS ";
  4122. }
  4123. else
  4124. {
  4125. location = "TORSO";
  4126. }
  4127. // Print It!
  4128. //-----------
  4129. Com_Printf("[%10d] ent[%3d-%18s] %s anim[%3d] - %s\n",
  4130. actualTime,
  4131. gent->s.number,
  4132. entName,
  4133. location,
  4134. anim,
  4135. animTable[anim].name );
  4136. }
  4137. }
  4138. #endif
  4139. // PLAY ON THE TORSO
  4140. //========================
  4141. if (torsPlay)
  4142. {
  4143. *torsoAnim = anim;
  4144. float oldAnimCurrent = animCurrent;
  4145. if (animCurrent!=bodyCurrent && torsOnAnimNow && !animRestart && !torsMatchBodyFrame)
  4146. {
  4147. animCurrent = torsCurrent;
  4148. }
  4149. gi.G2API_SetAnimIndex(&gent->ghoul2[gent->playerModel], curAnim.glaIndex);
  4150. gi.G2API_SetBoneAnimIndex(&gent->ghoul2[gent->playerModel], torsBone,
  4151. animStart,
  4152. animEnd,
  4153. (torsOnAnimNow && !animRestart)?(animFlags&~BONE_ANIM_BLEND):(animFlags),
  4154. animSpeed,
  4155. actualTime,
  4156. animCurrent,
  4157. blendTime);
  4158. if (gent->motionBone!=-1)
  4159. {
  4160. gi.G2API_SetBoneAnimIndex(&gent->ghoul2[gent->playerModel], gent->motionBone,
  4161. animStart,
  4162. animEnd,
  4163. (torsOnAnimNow && !animRestart)?(animFlags&~BONE_ANIM_BLEND):(animFlags),
  4164. animSpeed,
  4165. actualTime,
  4166. animCurrent,
  4167. blendTime);
  4168. }
  4169. animCurrent = oldAnimCurrent;
  4170. // If This Animation Is To Be Locked And Held, Calculate The Duration And Set The Timer
  4171. //--------------------------------------------------------------------------------------
  4172. if (animHold || animHoldless)
  4173. {
  4174. PM_SetTorsoAnimTimer(gent, torsoAnimTimer, animHoldMSec);
  4175. }
  4176. }
  4177. // PLAY ON THE WHOLE BODY
  4178. //========================
  4179. if (bodyPlay)
  4180. {
  4181. *legsAnim = anim;
  4182. if (bodyOnAnimNow && !animRestart && !bodyMatchTorsFrame)
  4183. {
  4184. animCurrent = bodyCurrent;
  4185. }
  4186. gi.G2API_SetAnimIndex(&gent->ghoul2[gent->playerModel], curAnim.glaIndex);
  4187. gi.G2API_SetBoneAnimIndex(&gent->ghoul2[gent->playerModel], bodyBone,
  4188. animStart,
  4189. animEnd,
  4190. (bodyOnAnimNow && !animRestart)?(animFlags&~BONE_ANIM_BLEND):(animFlags),
  4191. animSpeed,
  4192. actualTime,
  4193. animCurrent,
  4194. blendTime);
  4195. // If This Animation Is To Be Locked And Held, Calculate The Duration And Set The Timer
  4196. //--------------------------------------------------------------------------------------
  4197. if (animHold || animHoldless)
  4198. {
  4199. PM_SetLegsAnimTimer(gent, legsAnimTimer, animHoldMSec);
  4200. }
  4201. }
  4202. // PRINT SOME DEBUG TEXT OF EXISTING VALUES
  4203. //==========================================
  4204. if (false)
  4205. {
  4206. gi.Printf("PLAYANIM: (%3d) Speed(%4.2f) ", anim, animSpeed);
  4207. if (bodyAnimating)
  4208. {
  4209. gi.Printf("BODY: (%4.2f) (%4.2f) ", bodyCurrent, bodySpeed);
  4210. }
  4211. else
  4212. {
  4213. gi.Printf(" ");
  4214. }
  4215. if (torsAnimating)
  4216. {
  4217. gi.Printf("TORS: (%4.2f) (%4.2f)\n", torsCurrent, torsSpeed);
  4218. }
  4219. else
  4220. {
  4221. gi.Printf("\n");
  4222. }
  4223. }
  4224. }
  4225. void PM_SetAnim(pmove_t *pm,int setAnimParts,int anim,int setAnimFlags, int blendTime)
  4226. { // FIXME : once torsoAnim and legsAnim are in the same structure for NPC and Players
  4227. // rename PM_SetAnimFinal to PM_SetAnim and have both NPC and Players call PM_SetAnim
  4228. if ( pm->ps->pm_type >= PM_DEAD )
  4229. {//FIXME: sometimes we'll want to set anims when your dead... twitches, impacts, etc.
  4230. return;
  4231. }
  4232. if ( pm->gent == NULL )
  4233. {
  4234. return;
  4235. }
  4236. if ( !pm->gent || pm->gent->health > 0 )
  4237. {//don't lock anims if the guy is dead
  4238. if ( pm->ps->torsoAnimTimer
  4239. && PM_LockedAnim( pm->ps->torsoAnim )
  4240. && !PM_LockedAnim( anim ) )
  4241. {//nothing can override these special anims
  4242. setAnimParts &= ~SETANIM_TORSO;
  4243. }
  4244. if ( pm->ps->legsAnimTimer
  4245. && PM_LockedAnim( pm->ps->legsAnim )
  4246. && !PM_LockedAnim( anim ) )
  4247. {//nothing can override these special anims
  4248. setAnimParts &= ~SETANIM_LEGS;
  4249. }
  4250. }
  4251. if ( !setAnimParts )
  4252. {
  4253. return;
  4254. }
  4255. if (setAnimFlags&SETANIM_FLAG_OVERRIDE)
  4256. {
  4257. // pm->ps->animationTimer = 0;
  4258. if (setAnimParts & SETANIM_TORSO)
  4259. {
  4260. if( (setAnimFlags & SETANIM_FLAG_RESTART) || pm->ps->torsoAnim != anim )
  4261. {
  4262. PM_SetTorsoAnimTimer( pm->gent, &pm->ps->torsoAnimTimer, 0 );
  4263. }
  4264. }
  4265. if (setAnimParts & SETANIM_LEGS)
  4266. {
  4267. if( (setAnimFlags & SETANIM_FLAG_RESTART) || pm->ps->legsAnim != anim )
  4268. {
  4269. PM_SetLegsAnimTimer( pm->gent, &pm->ps->legsAnimTimer, 0 );
  4270. }
  4271. }
  4272. }
  4273. PM_SetAnimFinal(&pm->ps->torsoAnim,&pm->ps->legsAnim,setAnimParts,anim,setAnimFlags,&pm->ps->torsoAnimTimer,&pm->ps->legsAnimTimer,&g_entities[pm->ps->clientNum],blendTime);//was pm->gent
  4274. }
  4275. bool TorsoAgainstWindTest( gentity_t* ent )
  4276. {
  4277. if (ent&&//valid ent
  4278. ent->client&&//a client
  4279. (ent->client->ps.weapon!=WP_SABER||ent->client->ps.saberMove==LS_READY)&&//either not holding a saber or the saber is in the ready pose
  4280. (ent->s.number<MAX_CLIENTS||G_ControlledByPlayer(ent)) &&
  4281. gi.WE_GetWindGusting(ent->currentOrigin) &&
  4282. gi.WE_IsOutside(ent->currentOrigin) )
  4283. {
  4284. if (Q_stricmp(level.mapname, "t2_wedge")!=0)
  4285. {
  4286. vec3_t fwd;
  4287. vec3_t windDir;
  4288. if (gi.WE_GetWindVector(windDir, ent->currentOrigin))
  4289. {
  4290. VectorScale(windDir, -1.0f, windDir);
  4291. AngleVectors(pm->gent->currentAngles, fwd, 0, 0);
  4292. if (DotProduct(fwd, windDir)>0.65f)
  4293. {
  4294. if (ent->client && ent->client->ps.torsoAnim!=BOTH_WIND)
  4295. {
  4296. NPC_SetAnim(ent, SETANIM_TORSO, BOTH_WIND, SETANIM_FLAG_NORMAL, 400);
  4297. }
  4298. return true;
  4299. }
  4300. }
  4301. }
  4302. }
  4303. return false;
  4304. }
  4305. /*
  4306. -------------------------
  4307. PM_TorsoAnimLightsaber
  4308. -------------------------
  4309. */
  4310. // Note that this function is intended to set the animation for the player, but
  4311. // only does idle-ish anims. Anything that has a timer associated, such as attacks and blocks,
  4312. // are set by PM_WeaponLightsaber()
  4313. extern Vehicle_t *G_IsRidingVehicle( gentity_t *pEnt );
  4314. extern qboolean PM_LandingAnim( int anim );
  4315. extern qboolean PM_JumpingAnim( int anim );
  4316. qboolean PM_InCartwheel( int anim );
  4317. void PM_TorsoAnimLightsaber()
  4318. {
  4319. // *********************************************************
  4320. // WEAPON_READY
  4321. // *********************************************************
  4322. if ( pm->ps->forcePowersActive&(1<<FP_GRIP) && pm->ps->forcePowerLevel[FP_GRIP] > FORCE_LEVEL_1 )
  4323. {//holding an enemy aloft with force-grip
  4324. return;
  4325. }
  4326. if ( pm->ps->forcePowersActive&(1<<FP_LIGHTNING) && pm->ps->forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_1 )
  4327. {//lightning
  4328. return;
  4329. }
  4330. if ( pm->ps->forcePowersActive&(1<<FP_DRAIN) )
  4331. {//drain
  4332. return;
  4333. }
  4334. if ( pm->ps->saber[0].blade[0].active
  4335. && pm->ps->saber[0].blade[0].length < 3
  4336. && !(pm->ps->saberEventFlags&SEF_HITWALL)
  4337. && pm->ps->weaponstate == WEAPON_RAISING )
  4338. {
  4339. if (!G_IsRidingVehicle(pm->gent))
  4340. {
  4341. PM_SetSaberMove(LS_DRAW);
  4342. }
  4343. return;
  4344. }
  4345. else if ( !pm->ps->SaberActive() && pm->ps->SaberLength() )
  4346. {
  4347. if (!G_IsRidingVehicle(pm->gent))
  4348. {
  4349. PM_SetSaberMove(LS_PUTAWAY);
  4350. }
  4351. return;
  4352. }
  4353. if (pm->ps->weaponTime > 0)
  4354. { // weapon is already busy.
  4355. if ( pm->ps->torsoAnim == BOTH_TOSS1
  4356. || pm->ps->torsoAnim == BOTH_TOSS2 )
  4357. {//in toss
  4358. if ( !pm->ps->torsoAnimTimer )
  4359. {//weird, get out of it, I guess
  4360. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4361. }
  4362. }
  4363. return;
  4364. }
  4365. if ( pm->ps->weaponstate == WEAPON_READY ||
  4366. pm->ps->weaponstate == WEAPON_CHARGING ||
  4367. pm->ps->weaponstate == WEAPON_CHARGING_ALT )
  4368. {//ready
  4369. if ( pm->ps->weapon == WP_SABER && (pm->ps->SaberLength()) )
  4370. {//saber is on
  4371. // Select the proper idle Lightsaber attack move from the chart.
  4372. if (pm->ps->saberMove > LS_READY && pm->ps->saberMove < LS_MOVE_MAX)
  4373. {
  4374. PM_SetSaberMove(saberMoveData[pm->ps->saberMove].chain_idle);
  4375. }
  4376. else
  4377. {
  4378. if ( PM_JumpingAnim( pm->ps->legsAnim )
  4379. || PM_LandingAnim( pm->ps->legsAnim )
  4380. || PM_InCartwheel( pm->ps->legsAnim )
  4381. || PM_FlippingAnim( pm->ps->legsAnim ))
  4382. {
  4383. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4384. }
  4385. else
  4386. {
  4387. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  4388. {//using something
  4389. if ( !pm->ps->useTime )
  4390. {//stopped holding it, release
  4391. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4392. }//else still holding, leave it as it is
  4393. }
  4394. else
  4395. {
  4396. if ( (PM_RunningAnim( pm->ps->legsAnim )
  4397. || pm->ps->legsAnim == BOTH_WALK_STAFF
  4398. || pm->ps->legsAnim == BOTH_WALK_DUAL
  4399. || pm->ps->legsAnim == BOTH_WALKBACK_STAFF
  4400. || pm->ps->legsAnim == BOTH_WALKBACK_DUAL )
  4401. && pm->ps->saberBlockingTime < cg.time )
  4402. {//running w/1-handed weapon uses full-body anim
  4403. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4404. }
  4405. else
  4406. {
  4407. PM_SetSaberMove(LS_READY);
  4408. }
  4409. }
  4410. }
  4411. }
  4412. /*
  4413. if ( PM_JumpingAnim( pm->ps->legsAnim )
  4414. || PM_LandingAnim( pm->ps->legsAnim )
  4415. || PM_InCartwheel( pm->ps->legsAnim )
  4416. || PM_FlippingAnim( pm->ps->legsAnim ))
  4417. {//jumping, landing cartwheel, flipping
  4418. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4419. }
  4420. else
  4421. {
  4422. PM_SetSaberMove( LS_READY );
  4423. }
  4424. */
  4425. }
  4426. else if (TorsoAgainstWindTest(pm->gent))
  4427. {
  4428. }
  4429. else if( pm->ps->legsAnim == BOTH_RUN1 )
  4430. {
  4431. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN1,SETANIM_FLAG_NORMAL);
  4432. pm->ps->saberMove = LS_READY;
  4433. }
  4434. else if( pm->ps->legsAnim == BOTH_RUN2 )//&& pm->ps->saberAnimLevel != SS_STAFF )
  4435. {
  4436. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN2,SETANIM_FLAG_NORMAL);
  4437. pm->ps->saberMove = LS_READY;
  4438. }
  4439. else if( pm->ps->legsAnim == BOTH_RUN_STAFF )
  4440. {
  4441. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN_STAFF,SETANIM_FLAG_NORMAL);
  4442. pm->ps->saberMove = LS_READY;
  4443. }
  4444. else if( pm->ps->legsAnim == BOTH_RUN_DUAL )
  4445. {
  4446. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN_DUAL,SETANIM_FLAG_NORMAL);
  4447. pm->ps->saberMove = LS_READY;
  4448. }
  4449. else if( pm->ps->legsAnim == BOTH_WALK1 )
  4450. {
  4451. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK1,SETANIM_FLAG_NORMAL);
  4452. pm->ps->saberMove = LS_READY;
  4453. }
  4454. else if( pm->ps->legsAnim == BOTH_WALK2 )
  4455. {
  4456. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK2,SETANIM_FLAG_NORMAL);
  4457. pm->ps->saberMove = LS_READY;
  4458. }
  4459. else if( pm->ps->legsAnim == BOTH_WALK_STAFF )
  4460. {
  4461. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK_STAFF,SETANIM_FLAG_NORMAL);
  4462. pm->ps->saberMove = LS_READY;
  4463. }
  4464. else if( pm->ps->legsAnim == BOTH_WALK_DUAL )
  4465. {
  4466. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK_DUAL,SETANIM_FLAG_NORMAL);
  4467. pm->ps->saberMove = LS_READY;
  4468. }
  4469. else if( pm->ps->legsAnim == BOTH_CROUCH1IDLE && pm->ps->clientNum != 0 )//player falls through
  4470. {
  4471. //??? Why nothing? What if you were running???
  4472. //PM_SetAnim(pm,SETANIM_TORSO,BOTH_CROUCH1IDLE,SETANIM_FLAG_NORMAL);
  4473. pm->ps->saberMove = LS_READY;
  4474. }
  4475. else if( pm->ps->legsAnim == BOTH_JUMP1 )
  4476. {
  4477. PM_SetAnim(pm,SETANIM_TORSO,BOTH_JUMP1,SETANIM_FLAG_NORMAL);
  4478. pm->ps->saberMove = LS_READY;
  4479. }
  4480. else
  4481. {//Used to default to both_stand1 which is an arms-down anim
  4482. // PM_SetAnim(pm,SETANIM_TORSO,BOTH_ATTACK1,SETANIM_FLAG_NORMAL);//TORSO_WEAPONREADY1
  4483. // Select the next proper pose for the lightsaber assuming that there are no attacks.
  4484. if (pm->ps->saberMove > LS_READY && pm->ps->saberMove < LS_MOVE_MAX)
  4485. {
  4486. PM_SetSaberMove(saberMoveData[pm->ps->saberMove].chain_idle);
  4487. }
  4488. else
  4489. {
  4490. if ( PM_JumpingAnim( pm->ps->legsAnim )
  4491. || PM_LandingAnim( pm->ps->legsAnim )
  4492. || PM_InCartwheel( pm->ps->legsAnim )
  4493. || PM_FlippingAnim( pm->ps->legsAnim ))
  4494. {
  4495. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4496. }
  4497. else
  4498. {
  4499. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  4500. {//using something
  4501. if ( !pm->ps->useTime )
  4502. {//stopped holding it, release
  4503. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4504. }//else still holding, leave it as it is
  4505. }
  4506. else
  4507. {
  4508. PM_SetSaberMove(LS_READY);
  4509. }
  4510. }
  4511. }
  4512. }
  4513. }
  4514. // *********************************************************
  4515. // WEAPON_IDLE
  4516. // *********************************************************
  4517. else if ( pm->ps->weaponstate == WEAPON_IDLE )
  4518. {
  4519. if (TorsoAgainstWindTest(pm->gent))
  4520. {
  4521. }
  4522. else if( pm->ps->legsAnim == BOTH_GUARD_LOOKAROUND1 )
  4523. {
  4524. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUARD_LOOKAROUND1,SETANIM_FLAG_NORMAL);
  4525. pm->ps->saberMove = LS_READY;
  4526. }
  4527. else if( pm->ps->legsAnim == BOTH_GUARD_IDLE1 )
  4528. {
  4529. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUARD_IDLE1,SETANIM_FLAG_NORMAL);
  4530. pm->ps->saberMove = LS_READY;
  4531. }
  4532. else if( pm->ps->legsAnim == BOTH_STAND1IDLE1
  4533. || pm->ps->legsAnim == BOTH_STAND2IDLE1
  4534. || pm->ps->legsAnim == BOTH_STAND2IDLE2
  4535. || pm->ps->legsAnim == BOTH_STAND3IDLE1
  4536. || pm->ps->legsAnim == BOTH_STAND5IDLE1 )
  4537. {
  4538. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4539. pm->ps->saberMove = LS_READY;
  4540. }
  4541. else if( pm->ps->legsAnim == BOTH_STAND2TO4 )
  4542. {
  4543. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND2TO4,SETANIM_FLAG_NORMAL);
  4544. pm->ps->saberMove = LS_READY;
  4545. }
  4546. else if( pm->ps->legsAnim == BOTH_STAND4TO2 )
  4547. {
  4548. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND4TO2,SETANIM_FLAG_NORMAL);
  4549. pm->ps->saberMove = LS_READY;
  4550. }
  4551. else if( pm->ps->legsAnim == BOTH_STAND4 )
  4552. {
  4553. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND4,SETANIM_FLAG_NORMAL);
  4554. pm->ps->saberMove = LS_READY;
  4555. }
  4556. else
  4557. {
  4558. // This is now set in SetSaberMove.
  4559. // Idle for Lightsaber
  4560. if ( pm->gent && pm->gent->client )
  4561. {
  4562. // pm->gent->client->saberTrail.inAction = qfalse;
  4563. }
  4564. qboolean saberInAir = qtrue;
  4565. if ( pm->ps->saberInFlight )
  4566. {//guiding saber
  4567. if ( PM_SaberInBrokenParry( pm->ps->saberMove ) || pm->ps->saberBlocked == BLOCKED_PARRY_BROKEN || PM_DodgeAnim( pm->ps->torsoAnim ) )
  4568. {//we're stuck in a broken parry
  4569. saberInAir = qfalse;
  4570. }
  4571. if ( pm->ps->saberEntityNum < ENTITYNUM_NONE && pm->ps->saberEntityNum > 0 )//player is 0
  4572. {//
  4573. if ( &g_entities[pm->ps->saberEntityNum] != NULL && g_entities[pm->ps->saberEntityNum].s.pos.trType == TR_STATIONARY )
  4574. {//fell to the ground and we're not trying to pull it back
  4575. saberInAir = qfalse;
  4576. }
  4577. }
  4578. }
  4579. if ( pm->ps->saberInFlight
  4580. && saberInAir
  4581. && (!pm->ps->dualSabers || !pm->ps->saber[1].Active()))
  4582. {
  4583. if ( !PM_ForceAnim( pm->ps->torsoAnim )
  4584. || pm->ps->torsoAnimTimer < 300 )
  4585. {//don't interrupt a force power anim
  4586. if ( pm->ps->torsoAnim != BOTH_LOSE_SABER
  4587. || !pm->ps->torsoAnimTimer )
  4588. {
  4589. PM_SetAnim( pm, SETANIM_TORSO,BOTH_SABERPULL,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4590. }
  4591. }
  4592. }
  4593. else
  4594. {//saber is on
  4595. // Idle for Lightsaber
  4596. if ( pm->gent && pm->gent->client )
  4597. {
  4598. if ( !G_InCinematicSaberAnim( pm->gent ) )
  4599. {
  4600. pm->gent->client->ps.SaberDeactivateTrail( 0 );
  4601. }
  4602. }
  4603. // Idle for idle/ready Lightsaber
  4604. // PM_SetAnim(pm,SETANIM_TORSO,BOTH_ATTACK1,SETANIM_FLAG_NORMAL);//TORSO_WEAPONIDLE1
  4605. // Select the proper idle Lightsaber attack move from the chart.
  4606. if (pm->ps->saberMove > LS_READY && pm->ps->saberMove < LS_MOVE_MAX)
  4607. {
  4608. PM_SetSaberMove(saberMoveData[pm->ps->saberMove].chain_idle);
  4609. }
  4610. else
  4611. {
  4612. if ( PM_JumpingAnim( pm->ps->legsAnim )
  4613. || PM_LandingAnim( pm->ps->legsAnim )
  4614. || PM_InCartwheel( pm->ps->legsAnim )
  4615. || PM_FlippingAnim( pm->ps->legsAnim ))
  4616. {
  4617. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4618. }
  4619. else
  4620. {
  4621. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  4622. {//using something
  4623. if ( !pm->ps->useTime )
  4624. {//stopped holding it, release
  4625. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4626. }//else still holding, leave it as it is
  4627. }
  4628. else
  4629. {
  4630. if ( (PM_RunningAnim( pm->ps->legsAnim )
  4631. || pm->ps->legsAnim == BOTH_WALK_STAFF
  4632. || pm->ps->legsAnim == BOTH_WALK_DUAL
  4633. || pm->ps->legsAnim == BOTH_WALKBACK_STAFF
  4634. || pm->ps->legsAnim == BOTH_WALKBACK_DUAL )
  4635. && pm->ps->saberBlockingTime < cg.time )
  4636. {//running w/1-handed weapon uses full-body anim
  4637. int setFlags = SETANIM_FLAG_NORMAL;
  4638. if ( PM_LandingAnim( pm->ps->torsoAnim ) )
  4639. {
  4640. setFlags = SETANIM_FLAG_OVERRIDE;
  4641. }
  4642. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,setFlags);
  4643. }
  4644. else
  4645. {
  4646. PM_SetSaberMove(LS_READY);
  4647. }
  4648. }
  4649. }
  4650. }
  4651. }
  4652. }
  4653. }
  4654. }
  4655. /*
  4656. -------------------------
  4657. PM_TorsoAnimation
  4658. -------------------------
  4659. */
  4660. void PM_TorsoAnimation( void )
  4661. {//FIXME: Write a much smarter and more appropriate anim picking routine logic...
  4662. // int oldAnim;
  4663. if ( PM_InKnockDown( pm->ps ) || PM_InRoll( pm->ps ))
  4664. {//in knockdown
  4665. return;
  4666. }
  4667. if ( (pm->ps->eFlags&EF_HELD_BY_WAMPA) )
  4668. {
  4669. return;
  4670. }
  4671. if ( (pm->ps->eFlags&EF_FORCE_DRAINED) )
  4672. {//being drained
  4673. //PM_SetAnim( pm, SETANIM_TORSO, BOTH_HUGGEE1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4674. return;
  4675. }
  4676. if ( (pm->ps->forcePowersActive&(1<<FP_DRAIN))
  4677. && pm->ps->forceDrainEntityNum < ENTITYNUM_WORLD )
  4678. {//draining
  4679. //PM_SetAnim( pm, SETANIM_TORSO, BOTH_HUGGER1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4680. return;
  4681. }
  4682. if( pm->gent && pm->gent->NPC && (pm->gent->NPC->scriptFlags & SCF_FORCED_MARCH) )
  4683. {
  4684. return;
  4685. }
  4686. if(pm->gent != NULL && pm->gent->client)
  4687. {
  4688. pm->gent->client->renderInfo.torsoFpsMod = 1.0f;
  4689. }
  4690. if ( pm->gent && pm->ps && pm->ps->eFlags & EF_LOCKED_TO_WEAPON )
  4691. {
  4692. if ( pm->gent->owner && pm->gent->owner->e_UseFunc == useF_emplaced_gun_use )//ugly way to tell, but...
  4693. {//full body
  4694. PM_SetAnim(pm,SETANIM_BOTH,BOTH_GUNSIT1,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4695. }
  4696. else
  4697. {//torso
  4698. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUNSIT1,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4699. }
  4700. return;
  4701. }
  4702. /* else if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_VEHICLE && pm->ps->clientNum < MAX_CLIENTS && (m_pVehicleInfo[((CVehicleNPC *)pm->gent->NPC)->m_iVehicleTypeID].numHands == 2 || g_speederControlScheme->value == 2) )
  4703. {//can't look around
  4704. PM_SetAnim(pm,SETANIM_TORSO,m_pVehicleInfo[((CVehicleNPC *)pm->gent->NPC)->m_iVehicleTypeID].riderAnim,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);
  4705. return;
  4706. }*/
  4707. if ( pm->ps->taunting > level.time )
  4708. {
  4709. if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_ALORA )
  4710. {
  4711. PM_SetAnim(pm,SETANIM_BOTH,BOTH_ALORA_TAUNT,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4712. }
  4713. else if ( pm->ps->weapon == WP_SABER && pm->ps->saberAnimLevel == SS_DUAL && PM_HasAnimation( pm->gent, BOTH_DUAL_TAUNT ) )
  4714. {
  4715. PM_SetAnim(pm,SETANIM_BOTH,BOTH_DUAL_TAUNT,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4716. }
  4717. else if ( pm->ps->weapon == WP_SABER
  4718. && pm->ps->saberAnimLevel == SS_STAFF )//pm->ps->saber[0].type == SABER_STAFF )
  4719. {//turn on the blades
  4720. if ( PM_HasAnimation( pm->gent, BOTH_STAFF_TAUNT ) )
  4721. {
  4722. PM_SetAnim(pm,SETANIM_BOTH,BOTH_STAFF_TAUNT,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4723. }
  4724. /*
  4725. else
  4726. {
  4727. if ( !pm->ps->saber[0].blade[0].active )
  4728. {//first blade is off
  4729. //turn it on
  4730. pm->ps->SaberBladeActivate( 0, 0, qtrue );
  4731. if ( !pm->ps->saber[0].blade[1].active )
  4732. {//second blade is also off, extend time of this taunt so we have enough time to turn them both on
  4733. pm->ps->taunting = level.time + 3000;
  4734. }
  4735. }
  4736. else if ( (pm->ps->taunting - level.time) < 1500 )
  4737. {//only 1500ms left in taunt
  4738. if ( !pm->ps->saber[0].blade[1].active )
  4739. {//second blade is off
  4740. //turn it on
  4741. pm->ps->SaberBladeActivate( 0, 1, qtrue );
  4742. }
  4743. }
  4744. //pose
  4745. PM_SetAnim(pm,SETANIM_BOTH,BOTH_SABERSTAFF_STANCE,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);
  4746. pm->ps->torsoAnimTimer = pm->ps->legsAnimTimer = (pm->ps->taunting - level.time);
  4747. }
  4748. */
  4749. }
  4750. else if ( PM_HasAnimation( pm->gent, BOTH_GESTURE1 ) )
  4751. {
  4752. PM_SetAnim(pm,SETANIM_BOTH,BOTH_GESTURE1,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD);//SETANIM_FLAG_NORMAL
  4753. pm->gent->client->ps.SaberActivateTrail( 100 );
  4754. //FIXME: will this reset?
  4755. //FIXME: force-control (yellow glow) effect on hand and saber?
  4756. }
  4757. else
  4758. {
  4759. //PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE1,SETANIM_FLAG_NORMAL);
  4760. }
  4761. return;
  4762. }
  4763. if (pm->ps->weapon == WP_SABER ) // WP_LIGHTSABER
  4764. {
  4765. qboolean saberInAir = qfalse;
  4766. if ( pm->ps->SaberLength() && !pm->ps->saberInFlight )
  4767. {
  4768. PM_TorsoAnimLightsaber();
  4769. }
  4770. else
  4771. {
  4772. if ( pm->ps->forcePowersActive&(1<<FP_GRIP) && pm->ps->forcePowerLevel[FP_GRIP] > FORCE_LEVEL_1 )
  4773. {//holding an enemy aloft with force-grip
  4774. return;
  4775. }
  4776. if ( pm->ps->forcePowersActive&(1<<FP_LIGHTNING) && pm->ps->forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_1 )
  4777. {//lightning
  4778. return;
  4779. }
  4780. if ( pm->ps->forcePowersActive&(1<<FP_DRAIN) )
  4781. {//drain
  4782. return;
  4783. }
  4784. saberInAir = qtrue;
  4785. if ( PM_SaberInBrokenParry( pm->ps->saberMove ) || pm->ps->saberBlocked == BLOCKED_PARRY_BROKEN || PM_DodgeAnim( pm->ps->torsoAnim ) )
  4786. {//we're stuck in a broken parry
  4787. PM_TorsoAnimLightsaber();
  4788. }
  4789. else
  4790. {
  4791. if ( pm->ps->saberEntityNum < ENTITYNUM_NONE && pm->ps->saberEntityNum > 0 )//player is 0
  4792. {//
  4793. if ( &g_entities[pm->ps->saberEntityNum] != NULL && g_entities[pm->ps->saberEntityNum].s.pos.trType == TR_STATIONARY )
  4794. {//fell to the ground and we're not trying to pull it back
  4795. saberInAir = qfalse;
  4796. }
  4797. }
  4798. if ( pm->ps->saberInFlight
  4799. && saberInAir
  4800. && (!pm->ps->dualSabers //not using 2 sabers
  4801. || !pm->ps->saber[1].Active() //left one off
  4802. || pm->ps->torsoAnim == BOTH_SABERDUAL_STANCE//not attacking
  4803. || pm->ps->torsoAnim == BOTH_SABERPULL//not attacking
  4804. || pm->ps->torsoAnim == BOTH_STAND1//not attacking
  4805. || PM_RunningAnim( pm->ps->torsoAnim ) //not attacking
  4806. || PM_WalkingAnim( pm->ps->torsoAnim ) //not attacking
  4807. || PM_JumpingAnim( pm->ps->torsoAnim )//not attacking
  4808. || PM_SwimmingAnim( pm->ps->torsoAnim ) )//not attacking
  4809. )
  4810. {
  4811. if ( !PM_ForceAnim( pm->ps->torsoAnim ) || pm->ps->torsoAnimTimer < 300 )
  4812. {//don't interrupt a force power anim
  4813. if ( pm->ps->torsoAnim != BOTH_LOSE_SABER
  4814. || !pm->ps->torsoAnimTimer )
  4815. {
  4816. PM_SetAnim( pm, SETANIM_TORSO,BOTH_SABERPULL,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4817. }
  4818. }
  4819. }
  4820. else
  4821. {
  4822. if ( PM_InSlopeAnim( pm->ps->legsAnim ) )
  4823. {//HMM... this probably breaks the saber putaway and select anims
  4824. if ( pm->ps->SaberLength() > 0 )
  4825. {
  4826. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND2,SETANIM_FLAG_NORMAL);
  4827. }
  4828. else
  4829. {
  4830. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND1,SETANIM_FLAG_NORMAL);
  4831. }
  4832. }
  4833. else
  4834. {
  4835. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  4836. {//using something
  4837. if ( !pm->ps->useTime )
  4838. {//stopped holding it, release
  4839. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4840. }//else still holding, leave it as it is
  4841. }
  4842. else
  4843. {
  4844. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  4845. }
  4846. }
  4847. }
  4848. }
  4849. }
  4850. if (pm->ps->weaponTime<= 0 && (pm->ps->saberMove==LS_READY || pm->ps->SaberLength()==0) && !saberInAir)
  4851. {
  4852. TorsoAgainstWindTest(pm->gent);
  4853. }
  4854. return;
  4855. }
  4856. if ( PM_ForceAnim( pm->ps->torsoAnim )
  4857. && pm->ps->torsoAnimTimer > 0 )
  4858. {//in a force anim, don't do a stand anim
  4859. return;
  4860. }
  4861. qboolean weaponBusy = qfalse;
  4862. if ( pm->ps->weapon == WP_NONE )
  4863. {
  4864. weaponBusy = qfalse;
  4865. }
  4866. else if ( pm->ps->weaponstate == WEAPON_FIRING || pm->ps->weaponstate == WEAPON_CHARGING || pm->ps->weaponstate == WEAPON_CHARGING_ALT )
  4867. {
  4868. weaponBusy = qtrue;
  4869. }
  4870. else if ( pm->ps->lastShotTime > level.time - 3000 )
  4871. {
  4872. weaponBusy = qtrue;
  4873. }
  4874. else if ( pm->ps->weaponTime > 0 )
  4875. {
  4876. weaponBusy = qtrue;
  4877. }
  4878. else if ( pm->gent && pm->gent->client->fireDelay > 0 )
  4879. {
  4880. weaponBusy = qtrue;
  4881. }
  4882. else if ( TorsoAgainstWindTest(pm->gent) )
  4883. {
  4884. return;
  4885. }
  4886. else if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg.zoomTime > cg.time - 5000 )
  4887. {//if we used binoculars recently, aim weapon
  4888. weaponBusy = qtrue;
  4889. pm->ps->weaponstate = WEAPON_IDLE;
  4890. }
  4891. else if ( pm->ps->pm_flags & PMF_DUCKED )
  4892. {//ducking is considered on alert... plus looks stupid to have arms hanging down when crouched
  4893. weaponBusy = qtrue;
  4894. }
  4895. if ( pm->ps->weapon == WP_NONE ||
  4896. pm->ps->weaponstate == WEAPON_READY ||
  4897. pm->ps->weaponstate == WEAPON_CHARGING ||
  4898. pm->ps->weaponstate == WEAPON_CHARGING_ALT )
  4899. {
  4900. if ( pm->ps->weapon == WP_SABER && pm->ps->SaberLength() )
  4901. {
  4902. PM_SetAnim(pm,SETANIM_TORSO,BOTH_ATTACK1,SETANIM_FLAG_NORMAL);//TORSO_WEAPONREADY1
  4903. }
  4904. else if( pm->ps->legsAnim == BOTH_RUN1 && !weaponBusy )
  4905. {
  4906. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN1,SETANIM_FLAG_NORMAL);
  4907. }
  4908. else if( pm->ps->legsAnim == BOTH_RUN2 && !weaponBusy )//&& pm->ps->saberAnimLevel != SS_STAFF )
  4909. {
  4910. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN2,SETANIM_FLAG_NORMAL);
  4911. }
  4912. else if( pm->ps->legsAnim == BOTH_RUN4 && !weaponBusy )//&& pm->ps->saberAnimLevel != SS_STAFF )
  4913. {
  4914. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN4,SETANIM_FLAG_NORMAL);
  4915. }
  4916. else if( pm->ps->legsAnim == BOTH_RUN_STAFF && !weaponBusy )
  4917. {
  4918. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN_STAFF,SETANIM_FLAG_NORMAL);
  4919. }
  4920. else if( pm->ps->legsAnim == BOTH_RUN_DUAL && !weaponBusy )
  4921. {
  4922. PM_SetAnim(pm,SETANIM_TORSO,BOTH_RUN_DUAL,SETANIM_FLAG_NORMAL);
  4923. }
  4924. else if( pm->ps->legsAnim == BOTH_WALK1 && !weaponBusy )
  4925. {
  4926. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK1,SETANIM_FLAG_NORMAL);
  4927. }
  4928. else if( pm->ps->legsAnim == BOTH_WALK2 && !weaponBusy )
  4929. {
  4930. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK2,SETANIM_FLAG_NORMAL);
  4931. }
  4932. else if( pm->ps->legsAnim == BOTH_WALK_STAFF && !weaponBusy )
  4933. {
  4934. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK_STAFF,SETANIM_FLAG_NORMAL);
  4935. }
  4936. else if( pm->ps->legsAnim == BOTH_WALK_DUAL&& !weaponBusy )
  4937. {
  4938. PM_SetAnim(pm,SETANIM_TORSO,BOTH_WALK_DUAL,SETANIM_FLAG_NORMAL);
  4939. }
  4940. else if( pm->ps->legsAnim == BOTH_CROUCH1IDLE && pm->ps->clientNum != 0 )//player falls through
  4941. {
  4942. //??? Why nothing? What if you were running???
  4943. //PM_SetAnim(pm,SETANIM_TORSO,BOTH_CROUCH1IDLE,SETANIM_FLAG_NORMAL);
  4944. }
  4945. else if( pm->ps->legsAnim == BOTH_JUMP1 && !weaponBusy )
  4946. {
  4947. PM_SetAnim(pm,SETANIM_TORSO,BOTH_JUMP1,SETANIM_FLAG_NORMAL, 100); // Only blend over 100ms
  4948. }
  4949. else if( pm->ps->legsAnim == BOTH_SWIM_IDLE1 && !weaponBusy )
  4950. {
  4951. PM_SetAnim(pm,SETANIM_TORSO,BOTH_SWIM_IDLE1,SETANIM_FLAG_NORMAL);
  4952. }
  4953. else if( pm->ps->legsAnim == BOTH_SWIMFORWARD && !weaponBusy )
  4954. {
  4955. PM_SetAnim(pm,SETANIM_TORSO,BOTH_SWIMFORWARD,SETANIM_FLAG_NORMAL);
  4956. }
  4957. else if ( pm->ps->weapon == WP_NONE )
  4958. {
  4959. int legsAnim = pm->ps->legsAnim;
  4960. /*
  4961. if ( PM_RollingAnim( legsAnim ) ||
  4962. PM_FlippingAnim( legsAnim ) ||
  4963. PM_JumpingAnim( legsAnim ) ||
  4964. PM_PainAnim( legsAnim ) ||
  4965. PM_SwimmingAnim( legsAnim ) )
  4966. */
  4967. {
  4968. PM_SetAnim(pm, SETANIM_TORSO, legsAnim, SETANIM_FLAG_NORMAL );
  4969. }
  4970. }
  4971. else
  4972. {//Used to default to both_stand1 which is an arms-down anim
  4973. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  4974. {//using something
  4975. if ( !pm->ps->useTime )
  4976. {//stopped holding it, release
  4977. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  4978. }//else still holding, leave it as it is
  4979. }
  4980. else if ( pm->gent != NULL
  4981. && (pm->gent->s.number<MAX_CLIENTS||G_ControlledByPlayer(pm->gent))
  4982. && pm->ps->weaponstate != WEAPON_CHARGING
  4983. && pm->ps->weaponstate != WEAPON_CHARGING_ALT )
  4984. {//PLayer- temp hack for weapon frame
  4985. if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_RANCOR )
  4986. {//ignore
  4987. }
  4988. else if ( pm->ps->weapon == WP_MELEE )
  4989. {//hehe
  4990. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND6,SETANIM_FLAG_NORMAL);
  4991. }
  4992. else
  4993. {
  4994. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND1,SETANIM_FLAG_NORMAL);
  4995. }
  4996. }
  4997. else if ( PM_InSpecialJump( pm->ps->legsAnim ) )
  4998. {//use legs anim
  4999. //FIXME: or just use whatever's currently playing?
  5000. //PM_SetAnim( pm, SETANIM_TORSO, pm->ps->legsAnim, SETANIM_FLAG_NORMAL );
  5001. }
  5002. else
  5003. {
  5004. switch(pm->ps->weapon)
  5005. {
  5006. // ********************************************************
  5007. case WP_SABER: // WP_LIGHTSABER
  5008. // Ready pose for Lightsaber
  5009. // PM_SetAnim(pm,SETANIM_TORSO,BOTH_ATTACK1,SETANIM_FLAG_NORMAL);//TORSO_WEAPONREADY1
  5010. // Select the next proper pose for the lightsaber assuming that there are no attacks.
  5011. if (pm->ps->saberMove > LS_NONE && pm->ps->saberMove < LS_MOVE_MAX)
  5012. {
  5013. PM_SetSaberMove(saberMoveData[pm->ps->saberMove].chain_idle);
  5014. }
  5015. break;
  5016. // ********************************************************
  5017. case WP_BRYAR_PISTOL:
  5018. //FIXME: if recently fired, hold the ready!
  5019. if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT || weaponBusy )
  5020. {
  5021. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5022. }
  5023. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5024. || PM_WalkingAnim( pm->ps->legsAnim )
  5025. || PM_JumpingAnim( pm->ps->legsAnim )
  5026. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5027. {//running w/1-handed weapon uses full-body anim
  5028. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5029. }
  5030. else
  5031. {
  5032. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5033. }
  5034. break;
  5035. case WP_BLASTER_PISTOL:
  5036. if ( pm->gent
  5037. && pm->gent->weaponModel[1] > 0 )
  5038. {//dual pistols
  5039. if ( weaponBusy )
  5040. {
  5041. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUNSIT1,SETANIM_FLAG_NORMAL);
  5042. }
  5043. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5044. || PM_WalkingAnim( pm->ps->legsAnim )
  5045. || PM_JumpingAnim( pm->ps->legsAnim )
  5046. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5047. {//running w/1-handed weapon uses full-body anim
  5048. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5049. }
  5050. else
  5051. {
  5052. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND6,SETANIM_FLAG_NORMAL);
  5053. }
  5054. }
  5055. else
  5056. {//single pistols
  5057. if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT || weaponBusy )
  5058. {
  5059. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5060. }
  5061. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5062. || PM_WalkingAnim( pm->ps->legsAnim )
  5063. || PM_JumpingAnim( pm->ps->legsAnim )
  5064. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5065. {//running w/1-handed weapon uses full-body anim
  5066. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5067. }
  5068. else
  5069. {
  5070. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5071. }
  5072. }
  5073. break;
  5074. case WP_NONE:
  5075. //NOTE: should never get here
  5076. break;
  5077. case WP_MELEE:
  5078. if ( PM_RunningAnim( pm->ps->legsAnim )
  5079. || PM_WalkingAnim( pm->ps->legsAnim )
  5080. || PM_JumpingAnim( pm->ps->legsAnim )
  5081. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5082. {//running w/1-handed weapon uses full-body anim
  5083. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5084. }
  5085. else
  5086. {
  5087. if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_RANCOR )
  5088. {//ignore
  5089. }
  5090. else if ( pm->gent && pm->gent->client && !PM_DroidMelee( pm->gent->client->NPC_class ) )
  5091. {
  5092. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND6,SETANIM_FLAG_NORMAL);
  5093. }
  5094. else
  5095. {
  5096. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND1,SETANIM_FLAG_NORMAL);
  5097. }
  5098. }
  5099. break;
  5100. case WP_TUSKEN_STAFF:
  5101. if ( PM_RunningAnim( pm->ps->legsAnim )
  5102. || PM_WalkingAnim( pm->ps->legsAnim )
  5103. || PM_JumpingAnim( pm->ps->legsAnim )
  5104. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5105. {//running w/1-handed weapon uses full-body anim
  5106. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5107. }
  5108. else
  5109. {
  5110. PM_SetAnim(pm, SETANIM_TORSO, BOTH_STAND3, SETANIM_FLAG_NORMAL);
  5111. }
  5112. break;
  5113. case WP_NOGHRI_STICK:
  5114. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5115. //PM_SetAnim(pm,SETANIM_LEGS,BOTH_ATTACK2,SETANIM_FLAG_NORMAL);
  5116. break;
  5117. case WP_BLASTER:
  5118. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5119. //PM_SetAnim(pm,SETANIM_LEGS,BOTH_ATTACK2,SETANIM_FLAG_NORMAL);
  5120. break;
  5121. case WP_DISRUPTOR:
  5122. case WP_TUSKEN_RIFLE:
  5123. if ( (pm->ps->weaponstate != WEAPON_FIRING
  5124. && pm->ps->weaponstate != WEAPON_CHARGING
  5125. && pm->ps->weaponstate != WEAPON_CHARGING_ALT)
  5126. || PM_RunningAnim( pm->ps->legsAnim )
  5127. || PM_WalkingAnim( pm->ps->legsAnim )
  5128. || PM_JumpingAnim( pm->ps->legsAnim )
  5129. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5130. {//running sniper weapon uses normal ready
  5131. if ( pm->ps->clientNum )
  5132. {
  5133. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY3, SETANIM_FLAG_NORMAL );
  5134. }
  5135. else
  5136. {
  5137. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY3, SETANIM_FLAG_NORMAL );
  5138. }
  5139. }
  5140. else
  5141. {
  5142. if ( pm->ps->clientNum )
  5143. {
  5144. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY4, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );//TORSO_WEAPONREADY4//SETANIM_FLAG_RESTART|
  5145. }
  5146. else
  5147. {
  5148. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY4, SETANIM_FLAG_NORMAL );
  5149. }
  5150. }
  5151. break;
  5152. case WP_BOT_LASER:
  5153. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE2,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_RESTART|SETANIM_FLAG_HOLD);
  5154. break;
  5155. case WP_THERMAL:
  5156. if ( pm->ps->weaponstate != WEAPON_FIRING
  5157. && pm->ps->weaponstate != WEAPON_CHARGING
  5158. && pm->ps->weaponstate != WEAPON_CHARGING_ALT
  5159. && (PM_RunningAnim( pm->ps->legsAnim )
  5160. || PM_WalkingAnim( pm->ps->legsAnim )
  5161. || PM_JumpingAnim( pm->ps->legsAnim )
  5162. || PM_SwimmingAnim( pm->ps->legsAnim )) )
  5163. {//running w/1-handed weapon uses full-body anim
  5164. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5165. }
  5166. else
  5167. {
  5168. if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && (pm->ps->weaponstate == WEAPON_CHARGING || pm->ps->weaponstate == WEAPON_CHARGING_ALT) )
  5169. {//player pulling back to throw
  5170. if ( PM_StandingAnim( pm->ps->legsAnim ) )
  5171. {
  5172. PM_SetAnim( pm, SETANIM_LEGS, BOTH_THERMAL_READY, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  5173. }
  5174. else if ( pm->ps->legsAnim == BOTH_THERMAL_READY )
  5175. {//sigh... hold it so pm_footsteps doesn't override
  5176. if ( pm->ps->legsAnimTimer < 100 )
  5177. {
  5178. pm->ps->legsAnimTimer = 100;
  5179. }
  5180. }
  5181. PM_SetAnim( pm, SETANIM_TORSO, BOTH_THERMAL_READY, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  5182. }
  5183. else
  5184. {
  5185. if ( weaponBusy )
  5186. {
  5187. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY10, SETANIM_FLAG_NORMAL );
  5188. }
  5189. else
  5190. {
  5191. PM_SetAnim( pm, SETANIM_TORSO, BOTH_STAND1, SETANIM_FLAG_NORMAL );
  5192. }
  5193. }
  5194. }
  5195. break;
  5196. case WP_REPEATER:
  5197. if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_GALAKMECH )
  5198. {//
  5199. if ( pm->gent->alt_fire )
  5200. {
  5201. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5202. }
  5203. else
  5204. {
  5205. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY1,SETANIM_FLAG_NORMAL);
  5206. }
  5207. }
  5208. else
  5209. {
  5210. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5211. }
  5212. break;
  5213. case WP_TRIP_MINE:
  5214. case WP_DET_PACK:
  5215. if ( PM_RunningAnim( pm->ps->legsAnim )
  5216. || PM_WalkingAnim( pm->ps->legsAnim )
  5217. || PM_JumpingAnim( pm->ps->legsAnim )
  5218. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5219. {//running w/1-handed weapon uses full-body anim
  5220. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5221. }
  5222. else
  5223. {
  5224. if ( weaponBusy )
  5225. {
  5226. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY3, SETANIM_FLAG_NORMAL );
  5227. }
  5228. else
  5229. {
  5230. PM_SetAnim( pm, SETANIM_TORSO, BOTH_STAND1, SETANIM_FLAG_NORMAL );
  5231. }
  5232. }
  5233. break;
  5234. default:
  5235. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5236. break;
  5237. }
  5238. }
  5239. }
  5240. }
  5241. else if ( pm->ps->weaponstate == WEAPON_IDLE )
  5242. {
  5243. if( pm->ps->legsAnim == BOTH_GUARD_LOOKAROUND1 )
  5244. {
  5245. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUARD_LOOKAROUND1,SETANIM_FLAG_NORMAL);
  5246. }
  5247. else if( pm->ps->legsAnim == BOTH_GUARD_IDLE1 )
  5248. {
  5249. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUARD_IDLE1,SETANIM_FLAG_NORMAL);
  5250. }
  5251. else if( pm->ps->legsAnim == BOTH_STAND1IDLE1
  5252. || pm->ps->legsAnim == BOTH_STAND2IDLE1
  5253. || pm->ps->legsAnim == BOTH_STAND2IDLE2
  5254. || pm->ps->legsAnim == BOTH_STAND3IDLE1
  5255. || pm->ps->legsAnim == BOTH_STAND5IDLE1 )
  5256. {
  5257. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5258. pm->ps->saberMove = LS_READY;
  5259. }
  5260. else if( pm->ps->legsAnim == BOTH_STAND2TO4 )
  5261. {
  5262. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND2TO4,SETANIM_FLAG_NORMAL);
  5263. }
  5264. else if( pm->ps->legsAnim == BOTH_STAND4TO2 )
  5265. {
  5266. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND4TO2,SETANIM_FLAG_NORMAL);
  5267. }
  5268. else if( pm->ps->legsAnim == BOTH_STAND4 )
  5269. {
  5270. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND4,SETANIM_FLAG_NORMAL);
  5271. }
  5272. else if( pm->ps->legsAnim == BOTH_SWIM_IDLE1 )
  5273. {
  5274. PM_SetAnim(pm,SETANIM_TORSO,BOTH_SWIM_IDLE1,SETANIM_FLAG_NORMAL);
  5275. }
  5276. else if( pm->ps->legsAnim == BOTH_SWIMFORWARD )
  5277. {
  5278. PM_SetAnim(pm,SETANIM_TORSO,BOTH_SWIMFORWARD,SETANIM_FLAG_NORMAL);
  5279. }
  5280. else if ( PM_InSpecialJump( pm->ps->legsAnim ) )
  5281. {//use legs anim
  5282. //FIXME: or just use whatever's currently playing?
  5283. //PM_SetAnim( pm, SETANIM_TORSO, pm->ps->legsAnim, SETANIM_FLAG_NORMAL );
  5284. }
  5285. else if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && pm->ps->torsoAnim == BOTH_BUTTON_HOLD )
  5286. {//using something
  5287. if ( !pm->ps->useTime )
  5288. {//stopped holding it, release
  5289. PM_SetAnim( pm, SETANIM_TORSO, BOTH_BUTTON_RELEASE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
  5290. }//else still holding, leave it as it is
  5291. }
  5292. else
  5293. {
  5294. if ( !weaponBusy
  5295. && pm->ps->weapon != WP_BOWCASTER
  5296. && pm->ps->weapon != WP_REPEATER
  5297. && pm->ps->weapon != WP_FLECHETTE
  5298. && pm->ps->weapon != WP_ROCKET_LAUNCHER
  5299. && pm->ps->weapon != WP_CONCUSSION
  5300. && ( PM_RunningAnim( pm->ps->legsAnim )
  5301. || (PM_WalkingAnim( pm->ps->legsAnim ) && (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()))
  5302. || PM_JumpingAnim( pm->ps->legsAnim )
  5303. || PM_SwimmingAnim( pm->ps->legsAnim ) ) )
  5304. {//running w/1-handed or light 2-handed weapon uses full-body anim if you're not using the weapon right now
  5305. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5306. }
  5307. else
  5308. {
  5309. switch ( pm->ps->weapon )
  5310. {
  5311. // ********************************************************
  5312. case WP_SABER: // WP_LIGHTSABER
  5313. // Shouldn't get here, should go to TorsoAnimLightsaber
  5314. break;
  5315. // ********************************************************
  5316. case WP_BRYAR_PISTOL:
  5317. if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT || weaponBusy )
  5318. {
  5319. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5320. }
  5321. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5322. || PM_WalkingAnim( pm->ps->legsAnim )
  5323. || PM_JumpingAnim( pm->ps->legsAnim )
  5324. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5325. {//running w/1-handed weapon uses full-body anim
  5326. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5327. }
  5328. else
  5329. {
  5330. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE2,SETANIM_FLAG_NORMAL);
  5331. }
  5332. break;
  5333. case WP_BLASTER_PISTOL:
  5334. if ( pm->gent
  5335. && pm->gent->weaponModel[1] > 0 )
  5336. {//dual pistols
  5337. if ( weaponBusy )
  5338. {
  5339. PM_SetAnim(pm,SETANIM_TORSO,BOTH_GUNSIT1,SETANIM_FLAG_NORMAL);
  5340. }
  5341. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5342. || PM_WalkingAnim( pm->ps->legsAnim )
  5343. || PM_JumpingAnim( pm->ps->legsAnim )
  5344. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5345. {//running w/1-handed weapon uses full-body anim
  5346. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5347. }
  5348. else
  5349. {
  5350. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND1,SETANIM_FLAG_NORMAL);
  5351. }
  5352. }
  5353. else
  5354. {//single pistols
  5355. if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT || weaponBusy )
  5356. {
  5357. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY2,SETANIM_FLAG_NORMAL);
  5358. }
  5359. else if ( PM_RunningAnim( pm->ps->legsAnim )
  5360. || PM_WalkingAnim( pm->ps->legsAnim )
  5361. || PM_JumpingAnim( pm->ps->legsAnim )
  5362. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5363. {//running w/1-handed weapon uses full-body anim
  5364. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5365. }
  5366. else
  5367. {
  5368. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE2,SETANIM_FLAG_NORMAL);
  5369. }
  5370. }
  5371. break;
  5372. case WP_NONE:
  5373. //NOTE: should never get here
  5374. break;
  5375. case WP_MELEE:
  5376. if ( PM_RunningAnim( pm->ps->legsAnim )
  5377. || PM_WalkingAnim( pm->ps->legsAnim )
  5378. || PM_JumpingAnim( pm->ps->legsAnim )
  5379. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5380. {//running w/1-handed weapon uses full-body anim
  5381. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5382. }
  5383. else
  5384. {
  5385. if ( pm->gent && pm->gent->client && pm->gent->client->NPC_class == CLASS_RANCOR )
  5386. {//ignore
  5387. }
  5388. else if ( pm->gent && pm->gent->client && !PM_DroidMelee( pm->gent->client->NPC_class ) )
  5389. {
  5390. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND6,SETANIM_FLAG_NORMAL);
  5391. }
  5392. else
  5393. {
  5394. PM_SetAnim(pm,SETANIM_TORSO,BOTH_STAND1,SETANIM_FLAG_NORMAL);
  5395. }
  5396. }
  5397. break;
  5398. case WP_TUSKEN_STAFF:
  5399. if ( PM_RunningAnim( pm->ps->legsAnim )
  5400. || PM_WalkingAnim( pm->ps->legsAnim )
  5401. || PM_JumpingAnim( pm->ps->legsAnim )
  5402. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5403. {//running w/1-handed weapon uses full-body anim
  5404. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5405. }
  5406. else
  5407. {
  5408. PM_SetAnim(pm, SETANIM_TORSO, BOTH_STAND3, SETANIM_FLAG_NORMAL);
  5409. }
  5410. break;
  5411. case WP_NOGHRI_STICK:
  5412. if ( weaponBusy )
  5413. {
  5414. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5415. }
  5416. else
  5417. {
  5418. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE3,SETANIM_FLAG_NORMAL);
  5419. }
  5420. break;
  5421. case WP_BLASTER:
  5422. if ( weaponBusy )
  5423. {
  5424. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5425. }
  5426. else
  5427. {
  5428. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE3,SETANIM_FLAG_NORMAL);
  5429. }
  5430. break;
  5431. case WP_DISRUPTOR:
  5432. case WP_TUSKEN_RIFLE:
  5433. if ( (pm->ps->weaponstate != WEAPON_FIRING
  5434. && pm->ps->weaponstate != WEAPON_CHARGING
  5435. && pm->ps->weaponstate != WEAPON_CHARGING_ALT)
  5436. || PM_RunningAnim( pm->ps->legsAnim )
  5437. || PM_WalkingAnim( pm->ps->legsAnim )
  5438. || PM_JumpingAnim( pm->ps->legsAnim )
  5439. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5440. {//running sniper weapon uses normal ready
  5441. if ( pm->ps->clientNum )
  5442. {
  5443. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY3, SETANIM_FLAG_NORMAL );
  5444. }
  5445. else
  5446. {
  5447. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY3, SETANIM_FLAG_NORMAL );
  5448. }
  5449. }
  5450. else
  5451. {
  5452. if ( pm->ps->clientNum )
  5453. {
  5454. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY4, SETANIM_FLAG_NORMAL );
  5455. }
  5456. else
  5457. {
  5458. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONREADY4, SETANIM_FLAG_NORMAL );
  5459. }
  5460. }
  5461. break;
  5462. case WP_BOT_LASER:
  5463. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE2,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_RESTART|SETANIM_FLAG_HOLD);
  5464. break;
  5465. case WP_THERMAL:
  5466. if ( PM_RunningAnim( pm->ps->legsAnim )
  5467. || PM_WalkingAnim( pm->ps->legsAnim )
  5468. || PM_JumpingAnim( pm->ps->legsAnim )
  5469. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5470. {//running w/1-handed weapon uses full-body anim
  5471. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5472. }
  5473. else
  5474. {
  5475. if ( weaponBusy )
  5476. {
  5477. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONIDLE10, SETANIM_FLAG_NORMAL );
  5478. }
  5479. else
  5480. {
  5481. PM_SetAnim( pm, SETANIM_TORSO, BOTH_STAND1, SETANIM_FLAG_NORMAL );
  5482. }
  5483. }
  5484. break;
  5485. case WP_REPEATER:
  5486. if ( weaponBusy )
  5487. {
  5488. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5489. }
  5490. else
  5491. {
  5492. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE3,SETANIM_FLAG_NORMAL);
  5493. }
  5494. break;
  5495. case WP_TRIP_MINE:
  5496. case WP_DET_PACK:
  5497. if ( PM_RunningAnim( pm->ps->legsAnim )
  5498. || PM_WalkingAnim( pm->ps->legsAnim )
  5499. || PM_JumpingAnim( pm->ps->legsAnim )
  5500. || PM_SwimmingAnim( pm->ps->legsAnim ) )
  5501. {//running w/1-handed weapon uses full-body anim
  5502. PM_SetAnim(pm,SETANIM_TORSO,pm->ps->legsAnim,SETANIM_FLAG_NORMAL);
  5503. }
  5504. else
  5505. {
  5506. if ( weaponBusy )
  5507. {
  5508. PM_SetAnim( pm, SETANIM_TORSO, TORSO_WEAPONIDLE3, SETANIM_FLAG_NORMAL );
  5509. }
  5510. else
  5511. {
  5512. PM_SetAnim( pm, SETANIM_TORSO, BOTH_STAND1, SETANIM_FLAG_NORMAL );
  5513. }
  5514. }
  5515. break;
  5516. default:
  5517. if ( weaponBusy )
  5518. {
  5519. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONREADY3,SETANIM_FLAG_NORMAL);
  5520. }
  5521. else
  5522. {
  5523. PM_SetAnim(pm,SETANIM_TORSO,TORSO_WEAPONIDLE3,SETANIM_FLAG_NORMAL);
  5524. }
  5525. break;
  5526. }
  5527. }
  5528. }
  5529. }
  5530. }
  5531. //=========================================================================
  5532. // Anim checking utils
  5533. //=========================================================================
  5534. int PM_GetTurnAnim( gentity_t *gent, int anim )
  5535. {
  5536. if ( !gent )
  5537. {
  5538. return -1;
  5539. }
  5540. switch( anim )
  5541. {
  5542. case BOTH_STAND1: //# Standing idle: no weapon: hands down
  5543. case BOTH_STAND1IDLE1: //# Random standing idle
  5544. case BOTH_STAND2: //# Standing idle with a weapon
  5545. case BOTH_SABERFAST_STANCE:
  5546. case BOTH_SABERSLOW_STANCE:
  5547. case BOTH_STAND2IDLE1: //# Random standing idle
  5548. case BOTH_STAND2IDLE2: //# Random standing idle
  5549. case BOTH_STAND3: //# Standing hands behind back: at ease: etc.
  5550. case BOTH_STAND3IDLE1: //# Random standing idle
  5551. case BOTH_STAND4: //# two handed: gun down: relaxed stand
  5552. case BOTH_STAND5: //# standing idle, no weapon, hand down, back straight
  5553. case BOTH_STAND5IDLE1: //# Random standing idle
  5554. case BOTH_STAND6: //# one handed: gun at side: relaxed stand
  5555. case BOTH_STAND2TO4: //# Transition from stand2 to stand4
  5556. case BOTH_STAND4TO2: //# Transition from stand4 to stand2
  5557. case BOTH_GESTURE1: //# Generic gesture: non-specific
  5558. case BOTH_GESTURE2: //# Generic gesture: non-specific
  5559. case BOTH_TALK1: //# Generic talk anim
  5560. case BOTH_TALK2: //# Generic talk anim
  5561. if ( PM_HasAnimation( gent, LEGS_TURN1 ) )
  5562. {
  5563. return LEGS_TURN1;
  5564. }
  5565. else
  5566. {
  5567. return -1;
  5568. }
  5569. break;
  5570. case BOTH_ATTACK1: //# Attack with generic 1-handed weapon
  5571. case BOTH_ATTACK2: //# Attack with generic 2-handed weapon
  5572. case BOTH_ATTACK3: //# Attack with heavy 2-handed weapon
  5573. case BOTH_ATTACK4: //# Attack with ???
  5574. case BOTH_MELEE1: //# First melee attack
  5575. case BOTH_MELEE2: //# Second melee attack
  5576. case BOTH_GUARD_LOOKAROUND1: //# Cradling weapon and looking around
  5577. case BOTH_GUARD_IDLE1: //# Cradling weapon and standing
  5578. if ( PM_HasAnimation( gent, LEGS_TURN2 ) )
  5579. {
  5580. return LEGS_TURN2;
  5581. }
  5582. else
  5583. {
  5584. return -1;
  5585. }
  5586. break;
  5587. default:
  5588. return -1;
  5589. break;
  5590. }
  5591. }
  5592. int PM_TurnAnimForLegsAnim( gentity_t *gent, int anim )
  5593. {
  5594. if ( !gent )
  5595. {
  5596. return -1;
  5597. }
  5598. switch( anim )
  5599. {
  5600. case BOTH_STAND1: //# Standing idle: no weapon: hands down
  5601. case BOTH_STAND1IDLE1: //# Random standing idle
  5602. if ( PM_HasAnimation( gent, BOTH_TURNSTAND1 ) )
  5603. {
  5604. return BOTH_TURNSTAND1;
  5605. }
  5606. else
  5607. {
  5608. return -1;
  5609. }
  5610. break;
  5611. case BOTH_STAND2: //# Standing idle with a weapon
  5612. case BOTH_SABERFAST_STANCE:
  5613. case BOTH_SABERSLOW_STANCE:
  5614. case BOTH_STAND2IDLE1: //# Random standing idle
  5615. case BOTH_STAND2IDLE2: //# Random standing idle
  5616. if ( PM_HasAnimation( gent, BOTH_TURNSTAND2 ) )
  5617. {
  5618. return BOTH_TURNSTAND2;
  5619. }
  5620. else
  5621. {
  5622. return -1;
  5623. }
  5624. break;
  5625. case BOTH_STAND3: //# Standing hands behind back: at ease: etc.
  5626. case BOTH_STAND3IDLE1: //# Random standing idle
  5627. if ( PM_HasAnimation( gent, BOTH_TURNSTAND3 ) )
  5628. {
  5629. return BOTH_TURNSTAND3;
  5630. }
  5631. else
  5632. {
  5633. return -1;
  5634. }
  5635. break;
  5636. case BOTH_STAND4: //# two handed: gun down: relaxed stand
  5637. if ( PM_HasAnimation( gent, BOTH_TURNSTAND4 ) )
  5638. {
  5639. return BOTH_TURNSTAND4;
  5640. }
  5641. else
  5642. {
  5643. return -1;
  5644. }
  5645. break;
  5646. case BOTH_STAND5: //# standing idle, no weapon, hand down, back straight
  5647. case BOTH_STAND5IDLE1: //# Random standing idle
  5648. if ( PM_HasAnimation( gent, BOTH_TURNSTAND5 ) )
  5649. {
  5650. return BOTH_TURNSTAND5;
  5651. }
  5652. else
  5653. {
  5654. return -1;
  5655. }
  5656. break;
  5657. case BOTH_CROUCH1: //# Transition from standing to crouch
  5658. case BOTH_CROUCH1IDLE: //# Crouching idle
  5659. /*
  5660. case BOTH_UNCROUCH1: //# Transition from crouch to standing
  5661. case BOTH_CROUCH2TOSTAND1: //# going from crouch2 to stand1
  5662. case BOTH_CROUCH3: //# Desann crouching down to Kyle (cin 9)
  5663. case BOTH_UNCROUCH3: //# Desann uncrouching down to Kyle (cin 9)
  5664. case BOTH_CROUCH4: //# Slower version of crouch1 for cinematics
  5665. case BOTH_UNCROUCH4: //# Slower version of uncrouch1 for cinematics
  5666. */
  5667. if ( PM_HasAnimation( gent, BOTH_TURNCROUCH1 ) )
  5668. {
  5669. return BOTH_TURNCROUCH1;
  5670. }
  5671. else
  5672. {
  5673. return -1;
  5674. }
  5675. break;
  5676. default:
  5677. return -1;
  5678. break;
  5679. }
  5680. }
  5681. qboolean PM_InOnGroundAnim ( playerState_t *ps )
  5682. {
  5683. switch( ps->legsAnim )
  5684. {
  5685. case BOTH_DEAD1:
  5686. case BOTH_DEAD2:
  5687. case BOTH_DEAD3:
  5688. case BOTH_DEAD4:
  5689. case BOTH_DEAD5:
  5690. case BOTH_DEADFORWARD1:
  5691. case BOTH_DEADBACKWARD1:
  5692. case BOTH_DEADFORWARD2:
  5693. case BOTH_DEADBACKWARD2:
  5694. case BOTH_LYINGDEATH1:
  5695. case BOTH_LYINGDEAD1:
  5696. case BOTH_SLEEP1: //# laying on back-rknee up-rhand on torso
  5697. return qtrue;
  5698. break;
  5699. case BOTH_KNOCKDOWN1: //#
  5700. case BOTH_KNOCKDOWN2: //#
  5701. case BOTH_KNOCKDOWN3: //#
  5702. case BOTH_KNOCKDOWN4: //#
  5703. case BOTH_KNOCKDOWN5: //#
  5704. case BOTH_LK_DL_ST_T_SB_1_L:
  5705. case BOTH_RELEASED:
  5706. if ( ps->legsAnimTimer < 500 )
  5707. {//pretty much horizontal by this point
  5708. return qtrue;
  5709. }
  5710. break;
  5711. case BOTH_PLAYER_PA_3_FLY:
  5712. if ( ps->legsAnimTimer < 300 )
  5713. {//pretty much horizontal by this point
  5714. return qtrue;
  5715. }
  5716. /*
  5717. else if ( ps->clientNum < MAX_CLIENTS
  5718. && ps->legsAnimTimer < 300 + PLAYER_KNOCKDOWN_HOLD_EXTRA_TIME )
  5719. {
  5720. return qtrue;
  5721. }
  5722. */
  5723. break;
  5724. case BOTH_GETUP1:
  5725. case BOTH_GETUP2:
  5726. case BOTH_GETUP3:
  5727. case BOTH_GETUP4:
  5728. case BOTH_GETUP5:
  5729. case BOTH_GETUP_CROUCH_F1:
  5730. case BOTH_GETUP_CROUCH_B1:
  5731. case BOTH_FORCE_GETUP_F1:
  5732. case BOTH_FORCE_GETUP_F2:
  5733. case BOTH_FORCE_GETUP_B1:
  5734. case BOTH_FORCE_GETUP_B2:
  5735. case BOTH_FORCE_GETUP_B3:
  5736. case BOTH_FORCE_GETUP_B4:
  5737. case BOTH_FORCE_GETUP_B5:
  5738. case BOTH_FORCE_GETUP_B6:
  5739. if ( ps->legsAnimTimer > PM_AnimLength( g_entities[ps->clientNum].client->clientInfo.animFileIndex, (animNumber_t)ps->legsAnim )-400 )
  5740. {//still pretty much horizontal at this point
  5741. return qtrue;
  5742. }
  5743. break;
  5744. }
  5745. return qfalse;
  5746. }
  5747. qboolean PM_InSpecialDeathAnim( int anim )
  5748. {
  5749. switch( pm->ps->legsAnim )
  5750. {
  5751. case BOTH_DEATH_ROLL: //# Death anim from a roll
  5752. case BOTH_DEATH_FLIP: //# Death anim from a flip
  5753. case BOTH_DEATH_SPIN_90_R: //# Death anim when facing 90 degrees right
  5754. case BOTH_DEATH_SPIN_90_L: //# Death anim when facing 90 degrees left
  5755. case BOTH_DEATH_SPIN_180: //# Death anim when facing backwards
  5756. case BOTH_DEATH_LYING_UP: //# Death anim when lying on back
  5757. case BOTH_DEATH_LYING_DN: //# Death anim when lying on front
  5758. case BOTH_DEATH_FALLING_DN: //# Death anim when falling on face
  5759. case BOTH_DEATH_FALLING_UP: //# Death anim when falling on back
  5760. case BOTH_DEATH_CROUCHED: //# Death anim when crouched
  5761. return qtrue;
  5762. break;
  5763. default:
  5764. return qfalse;
  5765. break;
  5766. }
  5767. }
  5768. qboolean PM_InDeathAnim ( void )
  5769. {//Purposely does not cover stumbledeath and falldeath...
  5770. switch( pm->ps->legsAnim )
  5771. {
  5772. case BOTH_DEATH1: //# First Death anim
  5773. case BOTH_DEATH2: //# Second Death anim
  5774. case BOTH_DEATH3: //# Third Death anim
  5775. case BOTH_DEATH4: //# Fourth Death anim
  5776. case BOTH_DEATH5: //# Fifth Death anim
  5777. case BOTH_DEATH6: //# Sixth Death anim
  5778. case BOTH_DEATH7: //# Seventh Death anim
  5779. case BOTH_DEATH8: //#
  5780. case BOTH_DEATH9: //#
  5781. case BOTH_DEATH10: //#
  5782. case BOTH_DEATH11: //#
  5783. case BOTH_DEATH12: //#
  5784. case BOTH_DEATH13: //#
  5785. case BOTH_DEATH14: //#
  5786. case BOTH_DEATH14_UNGRIP: //# Desann's end death (cin #35)
  5787. case BOTH_DEATH14_SITUP: //# Tavion sitting up after having been thrown (cin #23)
  5788. case BOTH_DEATH15: //#
  5789. case BOTH_DEATH16: //#
  5790. case BOTH_DEATH17: //#
  5791. case BOTH_DEATH18: //#
  5792. case BOTH_DEATH19: //#
  5793. case BOTH_DEATH20: //#
  5794. case BOTH_DEATH21: //#
  5795. case BOTH_DEATH22: //#
  5796. case BOTH_DEATH23: //#
  5797. case BOTH_DEATH24: //#
  5798. case BOTH_DEATH25: //#
  5799. case BOTH_DEATHFORWARD1: //# First Death in which they get thrown forward
  5800. case BOTH_DEATHFORWARD2: //# Second Death in which they get thrown forward
  5801. case BOTH_DEATHFORWARD3: //# Tavion's falling in cin# 23
  5802. case BOTH_DEATHBACKWARD1: //# First Death in which they get thrown backward
  5803. case BOTH_DEATHBACKWARD2: //# Second Death in which they get thrown backward
  5804. case BOTH_DEATH1IDLE: //# Idle while close to death
  5805. case BOTH_LYINGDEATH1: //# Death to play when killed lying down
  5806. case BOTH_STUMBLEDEATH1: //# Stumble forward and fall face first death
  5807. case BOTH_FALLDEATH1: //# Fall forward off a high cliff and splat death - start
  5808. case BOTH_FALLDEATH1INAIR: //# Fall forward off a high cliff and splat death - loop
  5809. case BOTH_FALLDEATH1LAND: //# Fall forward off a high cliff and splat death - hit bottom
  5810. //# #sep case BOTH_ DEAD POSES # Should be last frame of corresponding previous anims
  5811. case BOTH_DEAD1: //# First Death finished pose
  5812. case BOTH_DEAD2: //# Second Death finished pose
  5813. case BOTH_DEAD3: //# Third Death finished pose
  5814. case BOTH_DEAD4: //# Fourth Death finished pose
  5815. case BOTH_DEAD5: //# Fifth Death finished pose
  5816. case BOTH_DEAD6: //# Sixth Death finished pose
  5817. case BOTH_DEAD7: //# Seventh Death finished pose
  5818. case BOTH_DEAD8: //#
  5819. case BOTH_DEAD9: //#
  5820. case BOTH_DEAD10: //#
  5821. case BOTH_DEAD11: //#
  5822. case BOTH_DEAD12: //#
  5823. case BOTH_DEAD13: //#
  5824. case BOTH_DEAD14: //#
  5825. case BOTH_DEAD15: //#
  5826. case BOTH_DEAD16: //#
  5827. case BOTH_DEAD17: //#
  5828. case BOTH_DEAD18: //#
  5829. case BOTH_DEAD19: //#
  5830. case BOTH_DEAD20: //#
  5831. case BOTH_DEAD21: //#
  5832. case BOTH_DEAD22: //#
  5833. case BOTH_DEAD23: //#
  5834. case BOTH_DEAD24: //#
  5835. case BOTH_DEAD25: //#
  5836. case BOTH_DEADFORWARD1: //# First thrown forward death finished pose
  5837. case BOTH_DEADFORWARD2: //# Second thrown forward death finished pose
  5838. case BOTH_DEADBACKWARD1: //# First thrown backward death finished pose
  5839. case BOTH_DEADBACKWARD2: //# Second thrown backward death finished pose
  5840. case BOTH_LYINGDEAD1: //# Killed lying down death finished pose
  5841. case BOTH_STUMBLEDEAD1: //# Stumble forward death finished pose
  5842. case BOTH_FALLDEAD1LAND: //# Fall forward and splat death finished pose
  5843. //# #sep case BOTH_ DEAD TWITCH/FLOP # React to being shot from death poses
  5844. case BOTH_DEADFLOP1: //# React to being shot from First Death finished pose
  5845. case BOTH_DEADFLOP2: //# React to being shot from Second Death finished pose
  5846. case BOTH_DISMEMBER_HEAD1: //#
  5847. case BOTH_DISMEMBER_TORSO1: //#
  5848. case BOTH_DISMEMBER_LLEG: //#
  5849. case BOTH_DISMEMBER_RLEG: //#
  5850. case BOTH_DISMEMBER_RARM: //#
  5851. case BOTH_DISMEMBER_LARM: //#
  5852. return qtrue;
  5853. break;
  5854. default:
  5855. return PM_InSpecialDeathAnim( pm->ps->legsAnim );
  5856. break;
  5857. }
  5858. }
  5859. qboolean PM_InCartwheel( int anim )
  5860. {
  5861. switch ( anim )
  5862. {
  5863. case BOTH_ARIAL_LEFT:
  5864. case BOTH_ARIAL_RIGHT:
  5865. case BOTH_ARIAL_F1:
  5866. case BOTH_CARTWHEEL_LEFT:
  5867. case BOTH_CARTWHEEL_RIGHT:
  5868. return qtrue;
  5869. break;
  5870. }
  5871. return qfalse;
  5872. }
  5873. qboolean PM_InButterfly( int anim )
  5874. {
  5875. switch ( anim )
  5876. {
  5877. case BOTH_BUTTERFLY_LEFT:
  5878. case BOTH_BUTTERFLY_RIGHT:
  5879. case BOTH_BUTTERFLY_FL1:
  5880. case BOTH_BUTTERFLY_FR1:
  5881. return qtrue;
  5882. break;
  5883. }
  5884. return qfalse;
  5885. }
  5886. qboolean PM_StandingAnim( int anim )
  5887. {//NOTE: does not check idles or special (cinematic) stands
  5888. switch ( anim )
  5889. {
  5890. case BOTH_STAND1:
  5891. case BOTH_STAND2:
  5892. case BOTH_STAND3:
  5893. case BOTH_STAND4:
  5894. case BOTH_ATTACK3:
  5895. return qtrue;
  5896. break;
  5897. }
  5898. return qfalse;
  5899. }
  5900. qboolean PM_InAirKickingAnim( int anim )
  5901. {
  5902. switch ( anim )
  5903. {
  5904. case BOTH_A7_KICK_F_AIR:
  5905. case BOTH_A7_KICK_B_AIR:
  5906. case BOTH_A7_KICK_R_AIR:
  5907. case BOTH_A7_KICK_L_AIR:
  5908. return qtrue;
  5909. }
  5910. return qfalse;
  5911. }
  5912. qboolean PM_KickingAnim( int anim )
  5913. {
  5914. switch ( anim )
  5915. {
  5916. case BOTH_A7_KICK_F:
  5917. case BOTH_A7_KICK_B:
  5918. case BOTH_A7_KICK_R:
  5919. case BOTH_A7_KICK_L:
  5920. case BOTH_A7_KICK_S:
  5921. case BOTH_A7_KICK_BF:
  5922. case BOTH_A7_KICK_RL:
  5923. //NOT a kick, but acts like one:
  5924. case BOTH_A7_HILT:
  5925. //NOT kicks, but do kick traces anyway
  5926. case BOTH_GETUP_BROLL_B:
  5927. case BOTH_GETUP_BROLL_F:
  5928. case BOTH_GETUP_FROLL_B:
  5929. case BOTH_GETUP_FROLL_F:
  5930. return qtrue;
  5931. break;
  5932. default:
  5933. return PM_InAirKickingAnim( anim );
  5934. break;
  5935. }
  5936. //return qfalse;
  5937. }
  5938. qboolean PM_StabDownAnim( int anim )
  5939. {
  5940. switch ( anim )
  5941. {
  5942. case BOTH_STABDOWN:
  5943. case BOTH_STABDOWN_STAFF:
  5944. case BOTH_STABDOWN_DUAL:
  5945. return qtrue;
  5946. }
  5947. return qfalse;
  5948. }
  5949. qboolean PM_GoingToAttackDown( playerState_t *ps )
  5950. {
  5951. if ( PM_StabDownAnim( ps->torsoAnim )//stabbing downward
  5952. || ps->saberMove == LS_A_LUNGE//lunge
  5953. || ps->saberMove == LS_A_JUMP_T__B_//death from above
  5954. || ps->saberMove == LS_A_T2B//attacking top to bottom
  5955. || ps->saberMove == LS_S_T2B//starting at attack downward
  5956. || (PM_SaberInTransition( ps->saberMove ) && saberMoveData[ps->saberMove].endQuad == Q_T) )//transitioning to a top to bottom attack
  5957. {
  5958. return qtrue;
  5959. }
  5960. return qfalse;
  5961. }
  5962. qboolean PM_ForceUsingSaberAnim( int anim )
  5963. {//saber/acrobatic anims that should prevent you from recharging force power while you're in them...
  5964. switch ( anim )
  5965. {
  5966. case BOTH_JUMPFLIPSLASHDOWN1:
  5967. case BOTH_JUMPFLIPSTABDOWN:
  5968. case BOTH_FORCELEAP2_T__B_:
  5969. case BOTH_JUMPATTACK6:
  5970. case BOTH_JUMPATTACK7:
  5971. case BOTH_FORCELONGLEAP_START:
  5972. case BOTH_FORCELONGLEAP_ATTACK:
  5973. case BOTH_FORCEWALLRUNFLIP_START:
  5974. case BOTH_FORCEWALLRUNFLIP_END:
  5975. case BOTH_FORCEWALLRUNFLIP_ALT:
  5976. case BOTH_FORCEWALLREBOUND_FORWARD:
  5977. case BOTH_FORCEWALLREBOUND_LEFT:
  5978. case BOTH_FORCEWALLREBOUND_BACK:
  5979. case BOTH_FORCEWALLREBOUND_RIGHT:
  5980. case BOTH_FLIP_ATTACK7:
  5981. case BOTH_FLIP_HOLD7:
  5982. case BOTH_FLIP_LAND:
  5983. case BOTH_PULL_IMPALE_STAB:
  5984. case BOTH_PULL_IMPALE_SWING:
  5985. case BOTH_A6_SABERPROTECT:
  5986. case BOTH_A7_SOULCAL:
  5987. case BOTH_A1_SPECIAL:
  5988. case BOTH_A2_SPECIAL:
  5989. case BOTH_A3_SPECIAL:
  5990. case BOTH_ARIAL_LEFT:
  5991. case BOTH_ARIAL_RIGHT:
  5992. case BOTH_CARTWHEEL_LEFT:
  5993. case BOTH_CARTWHEEL_RIGHT:
  5994. case BOTH_FLIP_LEFT:
  5995. case BOTH_FLIP_BACK1:
  5996. case BOTH_FLIP_BACK2:
  5997. case BOTH_FLIP_BACK3:
  5998. case BOTH_ALORA_FLIP_B:
  5999. case BOTH_BUTTERFLY_LEFT:
  6000. case BOTH_BUTTERFLY_RIGHT:
  6001. case BOTH_BUTTERFLY_FL1:
  6002. case BOTH_BUTTERFLY_FR1:
  6003. case BOTH_WALL_RUN_RIGHT:
  6004. case BOTH_WALL_RUN_RIGHT_FLIP:
  6005. case BOTH_WALL_RUN_RIGHT_STOP:
  6006. case BOTH_WALL_RUN_LEFT:
  6007. case BOTH_WALL_RUN_LEFT_FLIP:
  6008. case BOTH_WALL_RUN_LEFT_STOP:
  6009. case BOTH_WALL_FLIP_RIGHT:
  6010. case BOTH_WALL_FLIP_LEFT:
  6011. case BOTH_FORCEJUMP1:
  6012. case BOTH_FORCEINAIR1:
  6013. case BOTH_FORCELAND1:
  6014. case BOTH_FORCEJUMPBACK1:
  6015. case BOTH_FORCEINAIRBACK1:
  6016. case BOTH_FORCELANDBACK1:
  6017. case BOTH_FORCEJUMPLEFT1:
  6018. case BOTH_FORCEINAIRLEFT1:
  6019. case BOTH_FORCELANDLEFT1:
  6020. case BOTH_FORCEJUMPRIGHT1:
  6021. case BOTH_FORCEINAIRRIGHT1:
  6022. case BOTH_FORCELANDRIGHT1:
  6023. case BOTH_FLIP_F:
  6024. case BOTH_FLIP_B:
  6025. case BOTH_FLIP_L:
  6026. case BOTH_FLIP_R:
  6027. case BOTH_ALORA_FLIP_1:
  6028. case BOTH_ALORA_FLIP_2:
  6029. case BOTH_ALORA_FLIP_3:
  6030. case BOTH_DODGE_FL:
  6031. case BOTH_DODGE_FR:
  6032. case BOTH_DODGE_BL:
  6033. case BOTH_DODGE_BR:
  6034. case BOTH_DODGE_L:
  6035. case BOTH_DODGE_R:
  6036. case BOTH_DODGE_HOLD_FL:
  6037. case BOTH_DODGE_HOLD_FR:
  6038. case BOTH_DODGE_HOLD_BL:
  6039. case BOTH_DODGE_HOLD_BR:
  6040. case BOTH_DODGE_HOLD_L:
  6041. case BOTH_DODGE_HOLD_R:
  6042. case BOTH_FORCE_GETUP_F1:
  6043. case BOTH_FORCE_GETUP_F2:
  6044. case BOTH_FORCE_GETUP_B1:
  6045. case BOTH_FORCE_GETUP_B2:
  6046. case BOTH_FORCE_GETUP_B3:
  6047. case BOTH_FORCE_GETUP_B4:
  6048. case BOTH_FORCE_GETUP_B5:
  6049. case BOTH_FORCE_GETUP_B6:
  6050. case BOTH_GETUP_BROLL_B:
  6051. case BOTH_GETUP_BROLL_F:
  6052. case BOTH_GETUP_BROLL_L:
  6053. case BOTH_GETUP_BROLL_R:
  6054. case BOTH_GETUP_FROLL_B:
  6055. case BOTH_GETUP_FROLL_F:
  6056. case BOTH_GETUP_FROLL_L:
  6057. case BOTH_GETUP_FROLL_R:
  6058. case BOTH_WALL_FLIP_BACK1:
  6059. case BOTH_WALL_FLIP_BACK2:
  6060. case BOTH_SPIN1:
  6061. case BOTH_FJSS_TR_BL:
  6062. case BOTH_FJSS_TL_BR:
  6063. case BOTH_DEFLECTSLASH__R__L_FIN:
  6064. case BOTH_ARIAL_F1:
  6065. return qtrue;
  6066. }
  6067. return qfalse;
  6068. }
  6069. qboolean G_HasKnockdownAnims( gentity_t *ent )
  6070. {
  6071. if ( PM_HasAnimation( ent, BOTH_KNOCKDOWN1 )
  6072. && PM_HasAnimation( ent, BOTH_KNOCKDOWN2 )
  6073. && PM_HasAnimation( ent, BOTH_KNOCKDOWN3 )
  6074. && PM_HasAnimation( ent, BOTH_KNOCKDOWN4 )
  6075. && PM_HasAnimation( ent, BOTH_KNOCKDOWN5 ) )
  6076. {
  6077. return qtrue;
  6078. }
  6079. return qfalse;
  6080. }
  6081. qboolean PM_InAttackRoll( int anim )
  6082. {
  6083. switch ( anim )
  6084. {
  6085. case BOTH_GETUP_BROLL_B:
  6086. case BOTH_GETUP_BROLL_F:
  6087. case BOTH_GETUP_FROLL_B:
  6088. case BOTH_GETUP_FROLL_F:
  6089. return qtrue;
  6090. }
  6091. return qfalse;
  6092. }
  6093. qboolean PM_LockedAnim( int anim )
  6094. {//anims that can *NEVER* be overridden, regardless
  6095. switch ( anim )
  6096. {
  6097. case BOTH_KYLE_PA_1:
  6098. case BOTH_KYLE_PA_2:
  6099. case BOTH_KYLE_PA_3:
  6100. case BOTH_PLAYER_PA_1:
  6101. case BOTH_PLAYER_PA_2:
  6102. case BOTH_PLAYER_PA_3:
  6103. case BOTH_PLAYER_PA_3_FLY:
  6104. case BOTH_TAVION_SCEPTERGROUND:
  6105. case BOTH_TAVION_SWORDPOWER:
  6106. case BOTH_SCEPTER_START:
  6107. case BOTH_SCEPTER_HOLD:
  6108. case BOTH_SCEPTER_STOP:
  6109. //grabbed by wampa
  6110. case BOTH_GRABBED: //#
  6111. case BOTH_RELEASED: //# when Wampa drops player, transitions into fall on back
  6112. case BOTH_HANG_IDLE: //#
  6113. case BOTH_HANG_ATTACK: //#
  6114. case BOTH_HANG_PAIN: //#
  6115. return qtrue;
  6116. }
  6117. return qfalse;
  6118. }
  6119. qboolean PM_SuperBreakLoseAnim( int anim )
  6120. {
  6121. switch ( anim )
  6122. {
  6123. case BOTH_LK_S_DL_S_SB_1_L: //super break I lost
  6124. case BOTH_LK_S_DL_T_SB_1_L: //super break I lost
  6125. case BOTH_LK_S_ST_S_SB_1_L: //super break I lost
  6126. case BOTH_LK_S_ST_T_SB_1_L: //super break I lost
  6127. case BOTH_LK_S_S_S_SB_1_L: //super break I lost
  6128. case BOTH_LK_S_S_T_SB_1_L: //super break I lost
  6129. case BOTH_LK_DL_DL_S_SB_1_L: //super break I lost
  6130. case BOTH_LK_DL_DL_T_SB_1_L: //super break I lost
  6131. case BOTH_LK_DL_ST_S_SB_1_L: //super break I lost
  6132. case BOTH_LK_DL_ST_T_SB_1_L: //super break I lost
  6133. case BOTH_LK_DL_S_S_SB_1_L: //super break I lost
  6134. case BOTH_LK_DL_S_T_SB_1_L: //super break I lost
  6135. case BOTH_LK_ST_DL_S_SB_1_L: //super break I lost
  6136. case BOTH_LK_ST_DL_T_SB_1_L: //super break I lost
  6137. case BOTH_LK_ST_ST_S_SB_1_L: //super break I lost
  6138. case BOTH_LK_ST_ST_T_SB_1_L: //super break I lost
  6139. case BOTH_LK_ST_S_S_SB_1_L: //super break I lost
  6140. case BOTH_LK_ST_S_T_SB_1_L: //super break I lost
  6141. return qtrue;
  6142. break;
  6143. }
  6144. return qfalse;
  6145. }
  6146. qboolean PM_SuperBreakWinAnim( int anim )
  6147. {
  6148. switch ( anim )
  6149. {
  6150. case BOTH_LK_S_DL_S_SB_1_W: //super break I won
  6151. case BOTH_LK_S_DL_T_SB_1_W: //super break I won
  6152. case BOTH_LK_S_ST_S_SB_1_W: //super break I won
  6153. case BOTH_LK_S_ST_T_SB_1_W: //super break I won
  6154. case BOTH_LK_S_S_S_SB_1_W: //super break I won
  6155. case BOTH_LK_S_S_T_SB_1_W: //super break I won
  6156. case BOTH_LK_DL_DL_S_SB_1_W: //super break I won
  6157. case BOTH_LK_DL_DL_T_SB_1_W: //super break I won
  6158. case BOTH_LK_DL_ST_S_SB_1_W: //super break I won
  6159. case BOTH_LK_DL_ST_T_SB_1_W: //super break I won
  6160. case BOTH_LK_DL_S_S_SB_1_W: //super break I won
  6161. case BOTH_LK_DL_S_T_SB_1_W: //super break I won
  6162. case BOTH_LK_ST_DL_S_SB_1_W: //super break I won
  6163. case BOTH_LK_ST_DL_T_SB_1_W: //super break I won
  6164. case BOTH_LK_ST_ST_S_SB_1_W: //super break I won
  6165. case BOTH_LK_ST_ST_T_SB_1_W: //super break I won
  6166. case BOTH_LK_ST_S_S_SB_1_W: //super break I won
  6167. case BOTH_LK_ST_S_T_SB_1_W: //super break I won
  6168. return qtrue;
  6169. break;
  6170. }
  6171. return qfalse;
  6172. }
  6173. qboolean PM_SaberLockBreakAnim( int anim )
  6174. {
  6175. switch ( anim )
  6176. {
  6177. case BOTH_BF1BREAK:
  6178. case BOTH_BF2BREAK:
  6179. case BOTH_CWCIRCLEBREAK:
  6180. case BOTH_CCWCIRCLEBREAK:
  6181. case BOTH_LK_S_DL_S_B_1_L: //normal break I lost
  6182. case BOTH_LK_S_DL_S_B_1_W: //normal break I won
  6183. case BOTH_LK_S_DL_T_B_1_L: //normal break I lost
  6184. case BOTH_LK_S_DL_T_B_1_W: //normal break I won
  6185. case BOTH_LK_S_ST_S_B_1_L: //normal break I lost
  6186. case BOTH_LK_S_ST_S_B_1_W: //normal break I won
  6187. case BOTH_LK_S_ST_T_B_1_L: //normal break I lost
  6188. case BOTH_LK_S_ST_T_B_1_W: //normal break I won
  6189. case BOTH_LK_S_S_S_B_1_L: //normal break I lost
  6190. case BOTH_LK_S_S_S_B_1_W: //normal break I won
  6191. case BOTH_LK_S_S_T_B_1_L: //normal break I lost
  6192. case BOTH_LK_S_S_T_B_1_W: //normal break I won
  6193. case BOTH_LK_DL_DL_S_B_1_L: //normal break I lost
  6194. case BOTH_LK_DL_DL_S_B_1_W: //normal break I won
  6195. case BOTH_LK_DL_DL_T_B_1_L: //normal break I lost
  6196. case BOTH_LK_DL_DL_T_B_1_W: //normal break I won
  6197. case BOTH_LK_DL_ST_S_B_1_L: //normal break I lost
  6198. case BOTH_LK_DL_ST_S_B_1_W: //normal break I won
  6199. case BOTH_LK_DL_ST_T_B_1_L: //normal break I lost
  6200. case BOTH_LK_DL_ST_T_B_1_W: //normal break I won
  6201. case BOTH_LK_DL_S_S_B_1_L: //normal break I lost
  6202. case BOTH_LK_DL_S_S_B_1_W: //normal break I won
  6203. case BOTH_LK_DL_S_T_B_1_L: //normal break I lost
  6204. case BOTH_LK_DL_S_T_B_1_W: //normal break I won
  6205. case BOTH_LK_ST_DL_S_B_1_L: //normal break I lost
  6206. case BOTH_LK_ST_DL_S_B_1_W: //normal break I won
  6207. case BOTH_LK_ST_DL_T_B_1_L: //normal break I lost
  6208. case BOTH_LK_ST_DL_T_B_1_W: //normal break I won
  6209. case BOTH_LK_ST_ST_S_B_1_L: //normal break I lost
  6210. case BOTH_LK_ST_ST_S_B_1_W: //normal break I won
  6211. case BOTH_LK_ST_ST_T_B_1_L: //normal break I lost
  6212. case BOTH_LK_ST_ST_T_B_1_W: //normal break I won
  6213. case BOTH_LK_ST_S_S_B_1_L: //normal break I lost
  6214. case BOTH_LK_ST_S_S_B_1_W: //normal break I won
  6215. case BOTH_LK_ST_S_T_B_1_L: //normal break I lost
  6216. case BOTH_LK_ST_S_T_B_1_W: //normal break I won
  6217. return (PM_SuperBreakLoseAnim(anim)||PM_SuperBreakWinAnim(anim));
  6218. break;
  6219. }
  6220. return qfalse;
  6221. }
  6222. qboolean PM_GetupAnimNoMove( int legsAnim )
  6223. {
  6224. switch( legsAnim )
  6225. {
  6226. case BOTH_GETUP1:
  6227. case BOTH_GETUP2:
  6228. case BOTH_GETUP3:
  6229. case BOTH_GETUP4:
  6230. case BOTH_GETUP5:
  6231. case BOTH_GETUP_CROUCH_F1:
  6232. case BOTH_GETUP_CROUCH_B1:
  6233. case BOTH_FORCE_GETUP_F1:
  6234. case BOTH_FORCE_GETUP_F2:
  6235. case BOTH_FORCE_GETUP_B1:
  6236. case BOTH_FORCE_GETUP_B2:
  6237. case BOTH_FORCE_GETUP_B3:
  6238. case BOTH_FORCE_GETUP_B4:
  6239. case BOTH_FORCE_GETUP_B5:
  6240. case BOTH_FORCE_GETUP_B6:
  6241. return qtrue;
  6242. }
  6243. return qfalse;
  6244. }
  6245. qboolean PM_KnockDownAnim( int anim )
  6246. {
  6247. switch ( anim )
  6248. {
  6249. case BOTH_KNOCKDOWN1:
  6250. case BOTH_KNOCKDOWN2:
  6251. case BOTH_KNOCKDOWN3:
  6252. case BOTH_KNOCKDOWN4:
  6253. case BOTH_KNOCKDOWN5:
  6254. /*
  6255. //special anims:
  6256. case BOTH_RELEASED:
  6257. case BOTH_LK_DL_ST_T_SB_1_L:
  6258. case BOTH_PLAYER_PA_3_FLY:
  6259. */
  6260. return qtrue;
  6261. break;
  6262. /*
  6263. default:
  6264. return PM_InGetUp( ps );
  6265. break;
  6266. */
  6267. }
  6268. return qfalse;
  6269. }
  6270. qboolean PM_KnockDownAnimExtended( int anim )
  6271. {
  6272. switch ( anim )
  6273. {
  6274. case BOTH_KNOCKDOWN1:
  6275. case BOTH_KNOCKDOWN2:
  6276. case BOTH_KNOCKDOWN3:
  6277. case BOTH_KNOCKDOWN4:
  6278. case BOTH_KNOCKDOWN5:
  6279. //special anims:
  6280. case BOTH_RELEASED:
  6281. case BOTH_LK_DL_ST_T_SB_1_L:
  6282. case BOTH_PLAYER_PA_3_FLY:
  6283. return qtrue;
  6284. break;
  6285. /*
  6286. default:
  6287. return PM_InGetUp( ps );
  6288. break;
  6289. */
  6290. }
  6291. return qfalse;
  6292. }
  6293. qboolean PM_SaberInKata( saberMoveName_t saberMove )
  6294. {
  6295. switch ( saberMove )
  6296. {
  6297. case LS_A1_SPECIAL:
  6298. case LS_A2_SPECIAL:
  6299. case LS_A3_SPECIAL:
  6300. case LS_DUAL_SPIN_PROTECT:
  6301. case LS_STAFF_SOULCAL:
  6302. return qtrue;
  6303. }
  6304. return qfalse;
  6305. }
  6306. qboolean PM_CanRollFromSoulCal( playerState_t *ps )
  6307. {
  6308. if ( ps->legsAnim == BOTH_A7_SOULCAL
  6309. && ps->legsAnimTimer < 700
  6310. && ps->legsAnimTimer > 250 )
  6311. {
  6312. return qtrue;
  6313. }
  6314. return qfalse;
  6315. }
  6316. qboolean BG_FullBodyTauntAnim( int anim )
  6317. {
  6318. switch ( anim )
  6319. {
  6320. case BOTH_GESTURE1:
  6321. case BOTH_DUAL_TAUNT:
  6322. case BOTH_STAFF_TAUNT:
  6323. case BOTH_BOW:
  6324. case BOTH_MEDITATE:
  6325. case BOTH_SHOWOFF_FAST:
  6326. case BOTH_SHOWOFF_MEDIUM:
  6327. case BOTH_SHOWOFF_STRONG:
  6328. case BOTH_SHOWOFF_DUAL:
  6329. case BOTH_SHOWOFF_STAFF:
  6330. case BOTH_VICTORY_FAST:
  6331. case BOTH_VICTORY_MEDIUM:
  6332. case BOTH_VICTORY_STRONG:
  6333. case BOTH_VICTORY_DUAL:
  6334. case BOTH_VICTORY_STAFF:
  6335. return qtrue;
  6336. break;
  6337. }
  6338. return qfalse;
  6339. }