ACTIONS.CPP 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177
  1. /******************************************************************************
  2. *******************************************************************************
  3. Player action routines...
  4. ******************************************************************************
  5. *****************************************************************************/
  6. #include "global.h"
  7. #include "3deng.h"
  8. #include "data.h"
  9. #include "ball.dta"
  10. #include "defines.h"
  11. #include "externs.h"
  12. #include "audio.h" // Kev's audio calls.
  13. #include "front.h"
  14. #include "eurofrnt\euro_int.h"
  15. extern team_info game_data[];
  16. extern setup_info setup;
  17. extern stad_info stadlist[];
  18. extern match_data match_info;
  19. extern short get_there_time(int p_num,float x,float y);
  20. /******************************************************************************
  21. *****************************************************************************/
  22. // Converts Statistical speed to actual game speed (takes possession of ball into account!)...
  23. float full_spd(match_player *p)
  24. {
  25. float a;
  26. if (p->int_move==I_CELEB)
  27. a=MC_CELEB_SPD;
  28. else
  29. a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  30. return(a);
  31. }
  32. /******************************************************************************
  33. *****************************************************************************/
  34. // Converts Statistical speed to actual game speed (takes possession of ball into account!)...
  35. float actual_spd(match_player *p)
  36. {
  37. float a;
  38. if (p->int_move==I_CELEB)
  39. a=MC_CELEB_SPD;
  40. else
  41. if (p->int_move==I_INTERCEPT && p->int_cnt)
  42. // Chasing Ball (must run)...
  43. a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  44. else
  45. if (p->go_step)
  46. // Side stepping...
  47. a=((float)pitch_len)/((24.-(((float)(p->tm_rate)/64)*4))*20);
  48. else
  49. if (ball_poss==p->tm_player)
  50. // Avg runs pitch length in 14 secs.
  51. // Top run in 10 secs.
  52. {
  53. if (ball_in_hands && (p->tm_player==KP_A || p->tm_player==KP_B))
  54. // Keeper with ball in his hands...(slow)
  55. a=((float)pitch_len)/((28.-(((float)(p->tm_rate)/64)*4))*20);
  56. else
  57. a=((float)pitch_len)/((20.-(((float)(p->tm_rate)/64)*4))*20);
  58. }
  59. else
  60. // Avg runs pitch length in 16 secs.
  61. // Top run in 12 secs.
  62. if (user_controlled && burst_timer[user_controlled-1]>0)
  63. a=((float)pitch_len)/(((18.-(float)burst_timer[user_controlled-1]/5)-(((float)(p->tm_rate)/64)*4))*20);
  64. else
  65. a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  66. return(a);
  67. }
  68. /******************************************************************************
  69. *****************************************************************************/
  70. void init_officials()
  71. {
  72. refs[0].x=cntspot_x;
  73. refs[1].x=cntspot_x;
  74. refs[2].x=cntspot_x;
  75. refs[0].goto_x=cntspot_x;
  76. refs[1].goto_x=cntspot_x;
  77. refs[2].goto_x=cntspot_x;
  78. refs[0].y=cntspot_y;
  79. refs[0].goto_y=cntspot_y;
  80. refs[1].y=-(prat*2);
  81. refs[1].goto_y=-(prat*2);
  82. refs[2].y=pitch_wid+(prat*2);
  83. refs[2].goto_y=pitch_wid+(prat*2);
  84. refs[0].z=0;
  85. refs[1].z=0;
  86. refs[2].z=0;
  87. refs[0].dir_x=0;
  88. refs[1].dir_x=0;
  89. refs[2].dir_x=0;
  90. refs[0].dir_y=1;
  91. refs[1].dir_y=1;
  92. refs[2].dir_y=-1;
  93. refs[0].anim=MC_PLEAD;
  94. refs[1].anim=MC_STAND;
  95. refs[2].anim=MC_STAND;
  96. refs[0].fstep=MC_PLEAD_FS;
  97. refs[1].fstep=MC_STAND_FS;
  98. refs[2].fstep=MC_STAND_FS;
  99. refs[0].frm=0.6;
  100. refs[1].frm=0;
  101. refs[2].frm=0;
  102. refs[0].act=0;
  103. refs[1].act=0;
  104. refs[2].act=0;
  105. refs[0].target=0;
  106. refs[1].target=0;
  107. refs[2].target=0;
  108. refs[0].go=0;
  109. refs[1].go=0;
  110. refs[2].go=0;
  111. refs[0].newanim=TRUE;
  112. refs[1].newanim=TRUE;
  113. refs[2].newanim=TRUE;
  114. }
  115. /******************************************************************************
  116. *****************************************************************************/
  117. void check_practice()
  118. {
  119. if (match_info.CompetitionType==PRACTICE)
  120. practice=1;
  121. else
  122. practice=0;
  123. switch(practice)
  124. {
  125. case(0):
  126. team_a_on=TRUE;
  127. team_b_on=TRUE;
  128. break;
  129. case(1):
  130. team_a_on=TRUE;
  131. team_b_on=FALSE;
  132. break;
  133. case(-1):
  134. team_a_on=FALSE;
  135. team_b_on=TRUE;
  136. break;
  137. }
  138. }
  139. /******************************************************************************
  140. *****************************************************************************/
  141. void init_team()
  142. {
  143. int i;
  144. check_practice();
  145. for (i=1; i<=22; i++)
  146. {
  147. init_player_stats(i);
  148. if (i==2)
  149. {
  150. teams[i-1].tm_rate=120;
  151. teams[i-1].tm_pow=120;
  152. teams[i-1].tm_cont=120;
  153. teams[i-1].tm_flair=120;
  154. teams[i-1].tm_vis=120;
  155. teams[i-1].tm_ac=120;
  156. teams[i-1].tm_stam=120;
  157. teams[i-1].tm_disc=120;
  158. }
  159. }
  160. for (i=0; i<(players/2); i++)
  161. {
  162. if (team_a_on)
  163. {
  164. teams[i].tm_player=i+1;
  165. teams[i].tm_x=cntspot_x-prat*2;
  166. teams[i].tm_y=(cntspot_y+10*24)-(i*24);
  167. teams[i].tm_z=0;
  168. teams[i].tm_xdis=1;
  169. teams[i].tm_ydis=0;
  170. teams[i].tm_zdis=0;
  171. teams[i].mface=0;
  172. teams[i].tm_dist=50;
  173. teams[i].tm_pos=1;
  174. teams[i].tm_limbo=0;
  175. teams[i].guy_on=TRUE;
  176. teams[i].control=0;
  177. teams[i].tm_srng=0;
  178. teams[i].tm_off=0;
  179. teams[i].tm_stopped=0;
  180. teams[i].tm_trap=0;
  181. teams[i].special=0;
  182. teams[i].tm_strike=0;
  183. teams[i].tm_stime=0;
  184. teams[i].tm_ftime=0;
  185. teams[i].ball_state=0;
  186. teams[i].tm_fpass_type=0;
  187. teams[i].tm_fpass_to=0;
  188. teams[i].draw_me=TRUE;
  189. teams[i].shirt=i+1;
  190. teams[i].tm_book=0;
  191. teams[i].tm_fouls=0;
  192. teams[i].tm_tacks=0;
  193. teams[i].tm_twon=0;
  194. teams[i].tm_shots=0;
  195. teams[i].tm_saved=0;
  196. teams[i].tm_goals=0;
  197. teams[i].tm_pass=0;
  198. teams[i].tm_pwon=0;
  199. teams[i].tm_inj=0;
  200. teams[i].tm_posst=0;
  201. teams[i].tm_work=0;
  202. teams[i].tm_kpsaves=0;
  203. teams[i].tm_ogs=0;
  204. teams[i].tm_time=0;
  205. teams[i].turn_dir=0;
  206. teams[i].face_dir=0;
  207. teams[i].dir_mode=0;
  208. teams[i].tm_frm=0;
  209. teams[i].tm_fstep=MC_STAND_FS; // For intitialisation purposes.
  210. teams[i].tm_anim=MC_STAND;
  211. teams[i].tm_hcol=0;
  212. teams[i].tm_htype=0;
  213. teams[i].tm_mcspd=(float)(teams[i].tm_flair+teams[i].tm_rate)/128;
  214. teams[i].ls_anim=0;
  215. teams[i].ls_frm=0;
  216. teams[i].contact=-1;
  217. teams[i].tm_newanim=1;
  218. teams[i].tm_barge=0;
  219. teams[i].tm_act=0;
  220. teams[i].tm_poss=0;
  221. teams[i].tm_wall=0;
  222. teams[i].tm_leave=0;
  223. teams[i].tm_mark=0;
  224. teams[i].go_dist=0;
  225. teams[i].go_cnt=0;
  226. teams[i].go_txdis=0;
  227. teams[i].go_tydis=0;
  228. teams[i].go_tx=teams[i].tm_x;
  229. teams[i].go_ty=teams[i].tm_y;
  230. teams[i].go_xoff=0;
  231. teams[i].go_yoff=0;
  232. teams[i].tm_jump=PLAYER_HEIGHT+6+(teams[i].tm_pow/10);
  233. teams[i].go_stop=0;
  234. teams[i].go_step=0;
  235. teams[i].tm_notme=0;
  236. teams[i].int_move=0;
  237. teams[i].int_cnt=0;
  238. teams[i].mess_num=0;
  239. teams[i].mess_cnt=0;
  240. teams[i].tm_comm=0;
  241. teams[i].tm_ccnt=0;
  242. }
  243. else
  244. teams[i].guy_on=FALSE;
  245. }
  246. for (i=11; i<players; i++)
  247. {
  248. if (team_b_on || i==11)
  249. // if (team_b_on)
  250. {
  251. teams[i].tm_player=i+1;
  252. teams[i].tm_x=cntspot_x+prat*2;
  253. teams[i].tm_y=(cntspot_y+10*24)-((i-11)*24);
  254. teams[i].tm_z=0;
  255. teams[i].tm_xdis=-1;
  256. teams[i].tm_ydis=0;
  257. teams[i].tm_zdis=0;
  258. teams[i].mface=0;
  259. teams[i].tm_dist=50;
  260. teams[i].tm_pos=1;
  261. teams[i].tm_limbo=0;
  262. teams[i].guy_on=TRUE;
  263. teams[i].control=0;
  264. teams[i].tm_srng=0;
  265. teams[i].tm_off=0;
  266. teams[i].tm_stopped=0;
  267. teams[i].tm_trap=0;
  268. teams[i].special=0;
  269. teams[i].tm_strike=0;
  270. teams[i].tm_stime=0;
  271. teams[i].tm_ftime=0;
  272. teams[i].ball_state=0;
  273. teams[i].tm_fpass_type=0;
  274. teams[i].tm_fpass_to=0;
  275. teams[i].draw_me=TRUE;
  276. teams[i].shirt=i-10;
  277. teams[i].tm_book=0;
  278. teams[i].tm_fouls=0;
  279. teams[i].tm_tacks=0;
  280. teams[i].tm_twon=0;
  281. teams[i].tm_shots=0;
  282. teams[i].tm_saved=0;
  283. teams[i].tm_goals=0;
  284. teams[i].tm_pass=0;
  285. teams[i].tm_pwon=0;
  286. teams[i].tm_inj=0;
  287. teams[i].tm_posst=0;
  288. teams[i].turn_dir=0;
  289. teams[i].face_dir=0;
  290. teams[i].dir_mode=0;
  291. teams[i].tm_frm=0;
  292. teams[i].tm_fstep=MC_STAND_FS; // For intitialisation purposes.
  293. teams[i].tm_anim=MC_STAND;
  294. teams[i].tm_hcol=0;
  295. teams[i].tm_htype=0;
  296. teams[i].tm_mcspd=(float)(teams[i].tm_flair+teams[i].tm_rate)/128;
  297. teams[i].ls_anim=0;
  298. teams[i].ls_frm=0;
  299. teams[i].contact=-1;
  300. teams[i].tm_newanim=1;
  301. teams[i].tm_barge=0;
  302. teams[i].tm_act=0;
  303. teams[i].tm_poss=0;
  304. teams[i].tm_wall=0;
  305. teams[i].tm_leave=0;
  306. teams[i].tm_mark=0;
  307. teams[i].go_dist=0;
  308. teams[i].go_cnt=0;
  309. teams[i].go_txdis=0;
  310. teams[i].go_tydis=0;
  311. teams[i].go_tx=teams[i].tm_x;
  312. teams[i].go_ty=teams[i].tm_y;
  313. teams[i].go_xoff=0;
  314. teams[i].go_yoff=0;
  315. teams[i].tm_jump=PLAYER_HEIGHT+6+(teams[i].tm_pow/10);
  316. teams[i].go_stop=0;
  317. teams[i].go_step=0;
  318. teams[i].tm_notme=0;
  319. teams[i].int_move=0;
  320. teams[i].int_cnt=0;
  321. teams[i].mess_num=0;
  322. teams[i].mess_cnt=0;
  323. teams[i].tm_comm=0;
  324. teams[i].tm_ccnt=0;
  325. }
  326. else
  327. teams[i].guy_on=FALSE;
  328. }
  329. reset_all_ideas();
  330. interceptor_a=0;
  331. interceptor_b=0;
  332. }
  333. /******************************************************************************
  334. *****************************************************************************/
  335. void taker_pass_f(float xp,float yp)
  336. {
  337. short t;
  338. float dif,x,y,d,nx,ny;
  339. t=(setp_taker<12 ? 10:21); // team-mates!
  340. pass_type=0;
  341. for (short i=t; i>t-11; i--)
  342. {
  343. if (setp_taker!=i+1)
  344. // Not man on ball!
  345. {
  346. if ((teams[i].tm_act<=TURN_ACT) && (teams[i].guy_on>0))
  347. // Not Busy!
  348. {
  349. x=teams[i].tm_x-ballx;
  350. y=teams[i].tm_y-bally;
  351. d=calc_dist(x,y);
  352. dif=((x*xp)+(y*yp))/d;
  353. if (dif>FACING_ANGLE)
  354. {
  355. pass_type=in_kicking_range(&teams[setp_taker-1],x,y);
  356. }
  357. if (pass_type)
  358. {
  359. make_pass(&teams[setp_taker-1],i+1,FALSE);
  360. ready_set_kick();
  361. break;
  362. }
  363. }
  364. }
  365. }
  366. if (!pass_type)
  367. {
  368. setp_kick_x=xp;
  369. setp_kick_y=yp;
  370. must_pass=10;
  371. nx=(xp*teams[setp_taker-1].tm_xdis)+(yp*teams[setp_taker-1].tm_ydis);
  372. ny=(yp*teams[setp_taker-1].tm_xdis)-(xp*teams[setp_taker-1].tm_ydis);
  373. pass_type=(1+get_dir(nx,ny));
  374. make_pass(&teams[setp_taker-1],0,FALSE);
  375. ready_set_kick();
  376. }
  377. }
  378. /******************************************************************************
  379. *****************************************************************************/
  380. void taker_pass_h(float xp,float yp)
  381. {
  382. chip_pass=TRUE;
  383. short t;
  384. float dif,x,y,d,nx,ny;
  385. t=(setp_taker<12 ? 10:21); // team-mates!
  386. pass_type=0;
  387. for (short i=t; i>t-11; i--)
  388. {
  389. if (setp_taker!=i+1)
  390. // Not man on ball!
  391. {
  392. if ((teams[i].tm_act<=TURN_ACT) && (teams[i].guy_on>0))
  393. // Not Busy!
  394. {
  395. x=teams[i].tm_x-ballx;
  396. y=teams[i].tm_y-bally;
  397. d=calc_dist(x,y);
  398. dif=((x*xp)+(y*yp))/d;
  399. if (dif>FACING_ANGLE)
  400. {
  401. pass_type=in_kicking_range(&teams[setp_taker-1],x,y);
  402. if (pass_type!=5 && pass_type!=-1)
  403. pass_type=0;
  404. else
  405. pass_type=-1;
  406. }
  407. if (pass_type)
  408. {
  409. make_pass(&teams[setp_taker-1],i+1,FALSE);
  410. ready_set_kick();
  411. break;
  412. }
  413. }
  414. }
  415. }
  416. if (!pass_type)
  417. {
  418. setp_kick_x=teams[setp_taker-1].tm_xdis;
  419. setp_kick_y=teams[setp_taker-1].tm_ydis;
  420. must_pass=TRUE;
  421. pass_type=-1;
  422. make_pass(&teams[setp_taker-1],0,FALSE);
  423. ready_set_kick();
  424. }
  425. }
  426. /******************************************************************************
  427. *****************************************************************************/
  428. void taker_tee_up(float x,float y)
  429. {
  430. taker_pass_f(x,y);
  431. must_shoot=TRUE;
  432. must_punt=TRUE;
  433. }
  434. /******************************************************************************
  435. *****************************************************************************/
  436. void taker_kick(float x,float y)
  437. {
  438. if (teams[setp_taker-1].tm_srng)
  439. {
  440. // In shooting range...
  441. if (spec_kick_type==SPACT_DRIVE)
  442. drive_shot=TRUE;
  443. pass_type=-1;
  444. make_shoot(&teams[setp_taker-1]);
  445. ready_set_kick();
  446. }
  447. else
  448. {
  449. make_punt(&teams[setp_taker-1]);
  450. ready_set_kick();
  451. }
  452. }
  453. /******************************************************************************
  454. *****************************************************************************/
  455. void taker_chip(float x,float y)
  456. {
  457. setp_kick_x=teams[setp_taker-1].tm_xdis;
  458. setp_kick_y=teams[setp_taker-1].tm_ydis;
  459. chip_pass=TRUE;
  460. must_pass=TRUE;
  461. pass_type=-1;
  462. make_pass(&teams[setp_taker-1],0,FALSE);
  463. ready_set_kick();
  464. }
  465. /******************************************************************************
  466. *****************************************************************************/
  467. void taker_grnd(float x,float y)
  468. {
  469. setp_kick_x=teams[setp_taker-1].tm_xdis;
  470. setp_kick_y=teams[setp_taker-1].tm_ydis;
  471. chip_pass=FALSE;
  472. must_pass=TRUE;
  473. pass_type=5;
  474. make_pass(&teams[setp_taker-1],0,FALSE);
  475. ready_set_kick();
  476. }
  477. /******************************************************************************
  478. *****************************************************************************/
  479. #ifdef SUPPORT_LP
  480. #define ROTATE_ANG (0.16)
  481. void rotate_lp(match_player *player)
  482. {
  483. float ox=player->tm_xdis;
  484. float oy=player->tm_ydis;
  485. float rot=0;
  486. short fire=users_dir[user_controlled-1].f;
  487. if (!(fire&LP_L && fire&LP_R))
  488. {
  489. // Not both shoulder buttons...
  490. if (fire&LP_L)
  491. rot=-ROTATE_ANG;
  492. if (fire&LP_R)
  493. rot=ROTATE_ANG;
  494. player->tm_xdis=(ox*cos(rot))-(oy*sin(rot));
  495. player->tm_ydis=(oy*cos(rot))+(ox*sin(rot));
  496. player->tm_x=ballx-(player->tm_xdis*8);
  497. player->tm_y=bally-(player->tm_ydis*8);
  498. }
  499. }
  500. #endif
  501. /******************************************************************************
  502. *****************************************************************************/
  503. void rotate_around_ball(match_player *player)
  504. {
  505. if (um)
  506. {
  507. float x=ballx-(ux*8);
  508. float y=bally-(uy*8);
  509. player->tm_x=x;
  510. player->tm_y=y;
  511. player->tm_xdis=ux;
  512. player->tm_ydis=uy;
  513. }
  514. }
  515. /******************************************************************************
  516. *****************************************************************************/
  517. void taker_nkick()
  518. {
  519. newk_shot=TRUE;
  520. teams[setp_taker-1].tm_xdis=setp_kick_x;
  521. teams[setp_taker-1].tm_ydis=setp_kick_y;
  522. pass_type=-1;
  523. make_shoot(&teams[setp_taker-1]);
  524. ready_set_kick();
  525. }
  526. /******************************************************************************
  527. *****************************************************************************/
  528. void draw_tracker(short mp,float x,float y)
  529. {
  530. static float fract=0;
  531. float bspeed=get_power();
  532. ballxdis=x*bspeed;
  533. ballydis=y*bspeed;
  534. ballzdis=get_traj();
  535. ball_inair=TRUE;
  536. ball_poss=FALSE;
  537. predict_ball();
  538. ballxdis=0;
  539. ballydis=0;
  540. ballzdis=0;
  541. ball_inair=FALSE;
  542. ball_poss=setp_taker;
  543. float xp,yp,zp;
  544. // Draw tracker...
  545. for (short i=0; (i<first_bounce || i<mp); i++)
  546. {
  547. // Marker...
  548. xp=ball_pred_tab[i][0];
  549. yp=ball_pred_tab[i][1];
  550. zp=ball_pred_tab[i][2];
  551. xp=xp+(fract*(ball_pred_tab[i+1][0]-xp));
  552. yp=yp+(fract*(ball_pred_tab[i+1][1]-yp));
  553. zp=zp+(fract*(ball_pred_tab[i+1][2]-zp));
  554. // Dot...
  555. add_pitch_sprite(xp,yp,zp,0);
  556. // Shadow...
  557. add_pitch_sprite(xp,yp,0,1);
  558. }
  559. fract+=0.2;
  560. if (fract>=1)
  561. fract=0;
  562. }
  563. /******************************************************************************
  564. *****************************************************************************/
  565. void init_runup_act(match_player *player)
  566. {
  567. init_run_act(player,ballx,bally,TRUE);
  568. player->int_move=I_RUNUP;
  569. player->int_cnt=player->go_cnt;
  570. if (player->int_cnt>0)
  571. player->int_cnt--;
  572. }
  573. /******************************************************************************
  574. *****************************************************************************/
  575. void user_runup(match_player *player)
  576. {
  577. if (!player->int_cnt--)
  578. {
  579. // End of runup...
  580. spec_kick_type=SPACT_NEWK;
  581. taker_nkick();
  582. }
  583. else
  584. {
  585. go_forward(player);
  586. }
  587. }
  588. /******************************************************************************
  589. *****************************************************************************/
  590. #define ROT_SPEED (0.05)
  591. void new_user_spec_kick(match_player *player)
  592. {
  593. if (player->int_move==I_RUNUP)
  594. {
  595. user_runup(player);
  596. }
  597. else
  598. {
  599. float x=setp_kick_x;
  600. float y=setp_kick_y;
  601. // Player's maximum power of shot...
  602. short max_pow=(player->tm_pow/6)+8;
  603. float xd;
  604. short yd;
  605. // Read unvectored user controls...
  606. if (users_dir[user_controlled-1].f&8)
  607. xd=-ROT_SPEED*((max_pow)/(setp_power+6));
  608. else
  609. if (users_dir[user_controlled-1].f&4)
  610. xd=ROT_SPEED*((max_pow)/(setp_power+6));
  611. else
  612. xd=0;
  613. if (users_dir[user_controlled-1].f&32)
  614. yd=1;
  615. else
  616. if (users_dir[user_controlled-1].f&16)
  617. yd=-1;
  618. else
  619. yd=0;
  620. if (!uf2)
  621. {
  622. // Not trying pass...
  623. // Rotate player based on (left,right action)...
  624. setp_kick_x=(x*cos(xd))-(y*sin(xd));
  625. setp_kick_y=(y*cos(xd))+(x*sin(xd));
  626. float d=calc_dist(setp_kick_x,setp_kick_y);
  627. setp_kick_x=setp_kick_x/d;
  628. setp_kick_y=setp_kick_y/d;
  629. // Adjust run-up based on (up,down action)...
  630. setp_power+=yd;
  631. if (setp_power<0)
  632. setp_power=0;
  633. else
  634. if (setp_power>max_pow)
  635. setp_power=max_pow;
  636. }
  637. // Where should he be...
  638. setp_x=ballx-(setp_kick_x*(setp_power+2)*2);
  639. setp_y=bally-(setp_kick_y*(setp_power+2)*2);
  640. init_run_act(player,setp_x,setp_y,TRUE);
  641. if (player->tm_act==RUN_ACT)
  642. go_forward(player);
  643. else
  644. {
  645. player->tm_x=setp_x;
  646. player->tm_y=setp_y;
  647. player->tm_xdis=setp_kick_x;
  648. player->tm_ydis=setp_kick_y;
  649. }
  650. if (uf1)
  651. {
  652. // Shoot button held...
  653. if (++setp_hgt>30)
  654. setp_hgt--;
  655. }
  656. else
  657. {
  658. if (setp_hgt)
  659. // Shoot button has been released...
  660. init_runup_act(player);
  661. if (uf2)
  662. {
  663. if (setp_power || calc_dist(player->tm_x-setp_x,player->tm_y-setp_y)>1)
  664. setp_power=0;
  665. else
  666. {
  667. // At ball... Ready to pass...
  668. if (!f2_down)
  669. {
  670. f2_down=1;
  671. }
  672. }
  673. }
  674. else
  675. {
  676. if (f2_down)
  677. {
  678. // uf2 released...
  679. if (um)
  680. {
  681. // (uf2 + d)...
  682. if (uf1)
  683. spec_kick_type=SPACT_TEE_UP; // Tee up for shot or punt!
  684. else
  685. spec_kick_type=SPACT_DPASS; // Disguised Pass!
  686. }
  687. else
  688. spec_kick_type=SPACT_FPASS; // Pass to feet!
  689. }
  690. }
  691. }
  692. if (!f2_down && setp_power)
  693. draw_tracker(max_pow/2,setp_kick_x,setp_kick_y);
  694. switch(spec_kick_type)
  695. {
  696. case(SPACT_FPASS):
  697. taker_pass_f(player->tm_xdis,player->tm_ydis);
  698. break;
  699. case(SPACT_HPASS):
  700. taker_pass_h(player->tm_xdis,player->tm_ydis);
  701. break;
  702. case(SPACT_TEE_UP):
  703. taker_tee_up(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  704. break;
  705. case(SPACT_DPASS):
  706. taker_pass_f(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  707. break;
  708. case(SPACT_GRND):
  709. taker_grnd(player->tm_xdis,player->tm_ydis);
  710. break;
  711. case(SPACT_CHIP):
  712. taker_chip(player->tm_xdis,player->tm_ydis);
  713. break;
  714. case(SPACT_DRIVE):
  715. taker_kick(player->tm_xdis,player->tm_ydis);
  716. break;
  717. case(SPACT_KICK):
  718. taker_kick(player->tm_xdis,player->tm_ydis);
  719. break;
  720. case(SPACT_NEWK):
  721. taker_nkick();
  722. break;
  723. }
  724. }
  725. }
  726. /******************************************************************************
  727. *****************************************************************************/
  728. void user_pen_kick(match_player *player,char user_guy)
  729. {
  730. float ydif,racc;
  731. if (player->int_move==I_RUNUP)
  732. {
  733. user_runup(player);
  734. }
  735. else
  736. {
  737. if (player->tm_player<12)
  738. setp_bxd=pitch_len;
  739. else
  740. setp_bxd=0;
  741. float x,y,d;
  742. float acc=(128.-player->tm_ac)/4;
  743. float skill=(160.-player->tm_flair)/16;
  744. setp_power=(player->tm_pow/8)+10;
  745. if (f2_down<0)
  746. {
  747. setp_byd-=skill;
  748. if (setp_byd<(top_post_y-acc))
  749. f2_down=1;
  750. }
  751. else
  752. {
  753. setp_byd+=skill;
  754. if (setp_byd>(bot_post_y+acc))
  755. f2_down=-1;
  756. }
  757. // Derive vector from point on goal-line...
  758. x=setp_bxd-ballx;
  759. y=setp_byd-bally;
  760. d=calc_dist(x,y);
  761. setp_kick_x=x/d;
  762. setp_kick_y=y/d;
  763. if (!user_guy)
  764. {
  765. // Computer intelligence...
  766. if (!f1_down)
  767. {
  768. // Not started kick yet...
  769. af_randomize();
  770. if (seed>(92+((128-player->tm_flair)/8)))
  771. {
  772. // Decides to kick...
  773. af_randomize();
  774. if (seed>(player->tm_flair/2))
  775. {
  776. // Aim low... (not very spectacular)
  777. setp_bzd=4;
  778. }
  779. else
  780. {
  781. // Aim High... (Spectacular attempt)
  782. setp_bzd=16;
  783. }
  784. if (f2_down<0)
  785. {
  786. // Targeter moving upward...
  787. ydif=setp_byd-(top_post_y+(ball_diam*2)+skill);
  788. }
  789. else
  790. {
  791. // Targeter moving downward...
  792. ydif=(bot_post_y-(ball_diam*2)-skill)-setp_byd;
  793. }
  794. if (ABS((ydif/skill)-setp_bzd)<1)
  795. {
  796. uf1=TRUE;
  797. af_randomize();
  798. setp_bzd+=((acc-(acc*seed/64)))/2;
  799. if (setp_bzd<1)
  800. setp_bzd=1;
  801. }
  802. }
  803. }
  804. else
  805. {
  806. if (f1_down>(setp_bzd-1))
  807. uf1=FALSE;
  808. else
  809. uf1=TRUE;
  810. }
  811. }
  812. // Under user control...
  813. if (uf1)
  814. {
  815. if ((++f1_down)>30)
  816. {
  817. f1_down=30;
  818. }
  819. setp_hgt=f1_down;
  820. }
  821. else
  822. {
  823. if (f1_down)
  824. {
  825. init_runup_act(player);
  826. penalty_shot=TRUE;
  827. }
  828. }
  829. draw_tracker(setp_power/2,setp_kick_x,setp_kick_y);
  830. }
  831. }
  832. /******************************************************************************
  833. *****************************************************************************/
  834. void user_spec_kick(match_player *player)
  835. {
  836. setp_taker=player->tm_player;
  837. if (uf1 && uf2)
  838. {
  839. // Both buttons held...
  840. if (um && !f1_down && !f2_down)
  841. {
  842. // Both pressed together...(take F1!)
  843. spec_kick_type=SPACT_DRIVE; // Driving shot or punt!
  844. }
  845. }
  846. else
  847. {
  848. if (f2_down && f1_down)
  849. {
  850. // Both buttons held...
  851. if (!uf1)
  852. {
  853. // Both buttons were held but f1 released...
  854. if (um)
  855. {
  856. // Direction selected...
  857. spec_kick_type=SPACT_TEE_UP; // Tee up for shot or punt!
  858. }
  859. else
  860. {
  861. // No Direction...
  862. spec_kick_type=SPACT_CHIP; // Power Chip into air!
  863. }
  864. }
  865. else
  866. {
  867. if (!uf2)
  868. {
  869. // Both buttons were held but f2 released...
  870. if (um)
  871. {
  872. // Direction selected...
  873. spec_kick_type=SPACT_DPASS; // Disguised pass!
  874. }
  875. else
  876. {
  877. // No Direction...
  878. spec_kick_type=SPACT_HPASS; // Pass to head!
  879. }
  880. }
  881. }
  882. }
  883. else
  884. {
  885. if (f1_down)
  886. {
  887. // F1 held down only...
  888. if (!uf1)
  889. {
  890. // F1 now released...
  891. if (um)
  892. {
  893. // Direction selected...
  894. spec_kick_type=SPACT_TEE_UP; // Tee up for shot or punt!
  895. }
  896. else
  897. {
  898. // No Direction...
  899. spec_kick_type=SPACT_DRIVE; // Driving shot or punt(no swerve)!
  900. }
  901. }
  902. }
  903. else
  904. {
  905. if (f2_down)
  906. {
  907. // F2 held down only...
  908. if (!uf2)
  909. {
  910. // F2 now released...
  911. if (um)
  912. {
  913. // Direction selected...
  914. spec_kick_type=SPACT_DPASS; // Disguised Pass!
  915. }
  916. else
  917. {
  918. // No Direction...
  919. spec_kick_type=SPACT_GRND; // Power kick along ground!
  920. }
  921. }
  922. }
  923. else
  924. {
  925. // No buttons held...
  926. if (uf1 && um)
  927. {
  928. // F1 pressed initialy with dir...
  929. spec_kick_type=SPACT_KICK; // Shoot or punt!
  930. }
  931. else
  932. {
  933. if (uf2 && um)
  934. {
  935. // F2 pressed initialy with dir...
  936. spec_kick_type=SPACT_FPASS; // Pass to feet!
  937. }
  938. }
  939. }
  940. }
  941. }
  942. }
  943. if (!um)
  944. {
  945. if (uf2)
  946. {
  947. if (!f2_down && f1_down)
  948. f2_down=1;
  949. if (++f2_down>30)
  950. f2_down=30;
  951. }
  952. if (uf1)
  953. {
  954. if (!f1_down && f2_down)
  955. f2_down=1;
  956. if (++f1_down>30)
  957. f1_down=30;
  958. }
  959. if (f1_down)
  960. setp_power=f1_down;
  961. else
  962. setp_power=f2_down;
  963. setp_bxd=(player->tm_xdis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  964. setp_byd=(player->tm_ydis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  965. setp_bzd=(setp_power/4)+4;
  966. #ifdef SUPPORT_LP
  967. if (!uf1 && !uf2 && !f1_down && !f2_down && set_piece_on)
  968. rotate_lp(player);
  969. #endif
  970. }
  971. else
  972. {
  973. if (!uf1 && !uf2 && !f1_down && !f2_down && set_piece_on)
  974. rotate_around_ball(player);
  975. }
  976. switch(spec_kick_type)
  977. {
  978. case(SPACT_FPASS):
  979. taker_pass_f(player->tm_xdis,player->tm_ydis);
  980. break;
  981. case(SPACT_HPASS):
  982. taker_pass_h(player->tm_xdis,player->tm_ydis);
  983. break;
  984. case(SPACT_TEE_UP):
  985. taker_tee_up(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  986. break;
  987. case(SPACT_DPASS):
  988. taker_pass_f(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  989. break;
  990. case(SPACT_GRND):
  991. taker_grnd(player->tm_xdis,player->tm_ydis);
  992. break;
  993. case(SPACT_CHIP):
  994. taker_chip(player->tm_xdis,player->tm_ydis);
  995. break;
  996. case(SPACT_DRIVE):
  997. taker_kick(player->tm_xdis,player->tm_ydis);
  998. break;
  999. case(SPACT_KICK):
  1000. taker_kick(player->tm_xdis,player->tm_ydis);
  1001. break;
  1002. }
  1003. }
  1004. /******************************************************************************
  1005. *****************************************************************************/
  1006. void user_limited_kick(match_player *player)
  1007. {
  1008. // Limited for penalty...
  1009. setp_taker=player->tm_player;
  1010. if (um)
  1011. {
  1012. // Directional...
  1013. if (uf1)
  1014. {
  1015. spec_kick_type=SPACT_KICK; // Shoot!
  1016. }
  1017. }
  1018. else
  1019. {
  1020. if (uf1)
  1021. {
  1022. spec_kick_type=SPACT_DRIVE; // Driving shot!
  1023. }
  1024. }
  1025. setp_power=(player->tm_pow/6)+8;
  1026. setp_bxd=(player->tm_xdis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1027. setp_byd=(player->tm_ydis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1028. setp_bzd=(setp_power/4)+4;
  1029. if (!uf1 && !f1_down && set_piece_on)
  1030. rotate_around_ball(player);
  1031. switch(spec_kick_type)
  1032. {
  1033. case(SPACT_DRIVE):
  1034. penalty_shot=TRUE;
  1035. taker_kick(player->tm_xdis,player->tm_ydis);
  1036. break;
  1037. case(SPACT_KICK):
  1038. penalty_shot=TRUE;
  1039. taker_kick(player->tm_xdis,player->tm_ydis);
  1040. break;
  1041. }
  1042. }
  1043. /******************************************************************************
  1044. *****************************************************************************/
  1045. void comp_set_piece(match_player *player)
  1046. {
  1047. if (refs[0].act==2)
  1048. user_pen_kick(player,FALSE);
  1049. }
  1050. /******************************************************************************
  1051. *****************************************************************************/
  1052. void user_set_piece(match_player *player)
  1053. {
  1054. user_conts(&teams[player_num-1]);
  1055. #ifdef STOP_TIME_WASTING
  1056. if (ref_wait<0)
  1057. {
  1058. // Force strike on ball (Time-up)...
  1059. uf1=TRUE;
  1060. uf2=TRUE;
  1061. um=TRUE;
  1062. ux=player->tm_xdis;
  1063. uy=player->tm_ydis;
  1064. }
  1065. #endif
  1066. if (ref_wait)
  1067. {
  1068. switch(match_mode)
  1069. {
  1070. case(IF_KICK_A):
  1071. case(IF_KICK_B):
  1072. case(DF_KICK_A):
  1073. case(DF_KICK_B):
  1074. case(CORNER_TL):
  1075. case(CORNER_BL):
  1076. case(CORNER_TR):
  1077. case(CORNER_BR):
  1078. case(GOAL_KICK_TL):
  1079. case(GOAL_KICK_BL):
  1080. case(GOAL_KICK_TR):
  1081. case(GOAL_KICK_BR):
  1082. case(CENTRE_A):
  1083. case(CENTRE_B):
  1084. #ifndef EURO96
  1085. user_spec_kick(player);
  1086. #else
  1087. new_user_spec_kick(player);
  1088. #endif
  1089. break;
  1090. case(PEN_KICK_A):
  1091. case(PEN_KICK_B):
  1092. #ifdef EURO96
  1093. user_pen_kick(player,TRUE);
  1094. #else
  1095. user_limited_kick(player);
  1096. #endif
  1097. break; }
  1098. }
  1099. }
  1100. /******************************************************************************
  1101. *****************************************************************************/
  1102. void init_throw_act(match_player *player)
  1103. {
  1104. last_touch=player->tm_player;
  1105. player->tm_anim=MC_THROWL;
  1106. player->tm_newanim=TRUE;
  1107. player->tm_frm=0;
  1108. player->tm_fstep=MC_THROWL_FS;
  1109. player->dir_mode=2;
  1110. player->go_txdis=0;
  1111. player->go_tydis=0;
  1112. player->tm_act=THROW_ACT;
  1113. player->tm_xdis=0;
  1114. if (player->tm_player<12)
  1115. player->turn_dir=1;
  1116. else
  1117. player->turn_dir=-1;
  1118. if (bally<cntspot_y)
  1119. player->tm_ydis=1;
  1120. else
  1121. player->tm_ydis=-1;
  1122. throw_cnt=90;
  1123. support_me=TRUE;
  1124. }
  1125. /******************************************************************************
  1126. *****************************************************************************/
  1127. void init_get_up(match_player *player,float fs)
  1128. {
  1129. player->int_cnt=1+(1.0/fs);
  1130. player->int_move=I_GET_UP;
  1131. player->dir_mode=2; // Don't turn!
  1132. }
  1133. /******************************************************************************
  1134. *****************************************************************************/
  1135. void init_pickup_act(match_player *player)
  1136. {
  1137. reset_ideas(player);
  1138. player->tm_act=PICKUP_ACT;
  1139. init_anim(player,MC_PICKBALL);
  1140. player->int_move=I_GET_UP; // Look like he is busy!
  1141. player->int_cnt=1/MC_PICKBALL_FS;
  1142. }
  1143. /******************************************************************************
  1144. *****************************************************************************/
  1145. void pickup_action(match_player *player)
  1146. {
  1147. if (!player->int_cnt)
  1148. {
  1149. // end of animation...
  1150. if (player->tm_anim==MC_PICKBALL)
  1151. {
  1152. init_anim(player,MC_STANDB);
  1153. ball_in_hands=TRUE;
  1154. if (player->tm_player==KP_A || player->tm_player==KP_B)
  1155. {
  1156. player->dir_mode=2;
  1157. init_kphold_act(player);
  1158. }
  1159. }
  1160. }
  1161. }
  1162. /******************************************************************************
  1163. *****************************************************************************/
  1164. void init_taunt_act(match_player *player)
  1165. {
  1166. // Stationary taunt...
  1167. player->tm_act=CELEB_ACT;
  1168. player->go_txdis=0;
  1169. player->go_tydis=0;
  1170. player->dir_mode=2;
  1171. if (player->tm_player==goal_scorer)
  1172. {
  1173. scorer_running=FALSE;
  1174. // Choose Taunt...
  1175. af_randomize();
  1176. if (seed&2)
  1177. {
  1178. // Knee slide...
  1179. init_anim(player,MC_KNEE);
  1180. player->go_txdis=player->tm_xdis*3;
  1181. player->go_tydis=player->tm_ydis*3;
  1182. player->go_cnt=1/MC_KNEE_FS;
  1183. }
  1184. else
  1185. {
  1186. // Taunt...
  1187. af_randomize();
  1188. short r=0;
  1189. if (user_scorer)
  1190. {
  1191. // User selects celebration...
  1192. while(((users_dir[user_scorer-1].f)>>2)&(1<<r));
  1193. r--;
  1194. }
  1195. else
  1196. // Computer is random...
  1197. r=rand_range(4);
  1198. switch(rand_range(4))
  1199. {
  1200. case(0):
  1201. init_anim(player,MC_REEVES);
  1202. break;
  1203. case(1):
  1204. init_anim(player,MC_BABY);
  1205. break;
  1206. case(2):
  1207. init_anim(player,MC_PUMP);
  1208. break;
  1209. case(3):
  1210. init_anim(player,MC_MILLER);
  1211. break;
  1212. }
  1213. }
  1214. }
  1215. else
  1216. {
  1217. // Do whatever goal scorer is doing...
  1218. if (teams[goal_scorer-1].tm_anim==MC_KNEE || teams[goal_scorer-1].tm_anim==MC_DUCK)
  1219. {
  1220. init_anim(player,MC_KNEE);
  1221. player->go_txdis=player->tm_xdis*3;
  1222. player->go_tydis=player->tm_ydis*3;
  1223. player->go_cnt=1/MC_KNEE_FS;
  1224. }
  1225. else
  1226. if (teams[goal_scorer-1].tm_anim>=MC_KNEE && teams[goal_scorer-1].tm_anim<=MC_REEVES)
  1227. {
  1228. init_anim(player,teams[goal_scorer-1].tm_anim);
  1229. if (player->tm_anim==MC_MOON)
  1230. {
  1231. player->go_txdis=-player->tm_xdis;
  1232. player->go_tydis=-player->tm_ydis;
  1233. }
  1234. }
  1235. else
  1236. init_anim(player,MC_CELEB);
  1237. }
  1238. }
  1239. /******************************************************************************
  1240. *****************************************************************************/
  1241. void init_run_celeb(match_player *player,float tx,float ty)
  1242. {
  1243. // Moving celebration...
  1244. player->int_move=I_CELEB;
  1245. init_run_act(player,tx,ty,TRUE);
  1246. if (player->tm_act!=RUN_ACT)
  1247. init_taunt_act(player);
  1248. else
  1249. {
  1250. af_randomize();
  1251. if (player->tm_player==goal_scorer)
  1252. {
  1253. scorer_running=TRUE;
  1254. switch(seed&1)
  1255. {
  1256. case(0):
  1257. init_anim(player,MC_FINGER);
  1258. break;
  1259. case(1):
  1260. init_anim(player,MC_PLANE);
  1261. break;
  1262. }
  1263. }
  1264. else
  1265. init_anim(player,MC_FINGER);
  1266. player->int_cnt=player->go_cnt+1;
  1267. }
  1268. }
  1269. /******************************************************************************
  1270. *****************************************************************************/
  1271. void init_stationary_celeb(match_player *player)
  1272. {
  1273. // Stationary celebration...
  1274. player->tm_act=CELEB_ACT;
  1275. player->go_txdis=player->tm_xdis;
  1276. player->go_tydis=player->tm_ydis;
  1277. player->go_txdis=0;
  1278. player->go_tydis=0;
  1279. player->dir_mode=2;
  1280. }
  1281. /******************************************************************************
  1282. *****************************************************************************/
  1283. #define CELEB_RUN_DIST (13*prat)
  1284. void init_celeb_act(match_player *player)
  1285. {
  1286. reset_ideas(player); // Stop interception etc.
  1287. short celeb=seed&1;
  1288. #ifndef EURO96
  1289. init_anim(player,MC_CELEB);
  1290. #endif
  1291. if (player->tm_anim==MC_CELEB)
  1292. {
  1293. init_stationary_celeb(player);
  1294. }
  1295. else
  1296. {
  1297. if (player->tm_player==goal_scorer ||
  1298. (player->tm_player!=goal_scorer && teams[goal_scorer-1].tm_act==RUN_ACT))
  1299. {
  1300. if (player->tm_player!=goal_scorer)
  1301. {
  1302. // Run towards goal scorer...
  1303. float x=teams[goal_scorer-1].tm_x;
  1304. float y=teams[goal_scorer-1].tm_y;
  1305. af_randomize();
  1306. x+=(seed-64)/2;
  1307. af_randomize();
  1308. y+=(seed-64)/2;
  1309. init_run_celeb(player,x,y);
  1310. }
  1311. else
  1312. {
  1313. float a,b;
  1314. float x=player->tm_x;
  1315. float y=player->tm_y;
  1316. af_randomize();
  1317. random_vector(a,b);
  1318. x+=(a*CELEB_RUN_DIST);
  1319. y+=(b*CELEB_RUN_DIST);
  1320. if (x<0)
  1321. if (x<-CELEB_RUN_DIST)
  1322. init_anim(player,MC_CELEB);
  1323. else
  1324. x=player->tm_x+(player->tm_x-x);
  1325. if (x>pitch_len)
  1326. if (x>(CELEB_RUN_DIST+pitch_len))
  1327. init_anim(player,MC_CELEB);
  1328. else
  1329. x=player->tm_x+(player->tm_x-x);
  1330. if (y<0)
  1331. if (y<-CELEB_RUN_DIST)
  1332. init_anim(player,MC_CELEB);
  1333. else
  1334. y=player->tm_y+(player->tm_y-y);
  1335. if (y>pitch_wid)
  1336. if (y>(CELEB_RUN_DIST+pitch_wid))
  1337. init_anim(player,MC_CELEB);
  1338. else
  1339. y=player->tm_y+(player->tm_y-y);
  1340. if (player->tm_anim==MC_CELEB)
  1341. init_taunt_act(player);
  1342. else
  1343. init_run_celeb(player,x,y);
  1344. }
  1345. }
  1346. else
  1347. {
  1348. // Goal scorer will be doing his party piece! (follow suit)...
  1349. init_taunt_act(player);
  1350. }
  1351. }
  1352. }
  1353. /******************************************************************************
  1354. *****************************************************************************/
  1355. void celeb_action(match_player *player)
  1356. {
  1357. player->tm_x+=player->go_txdis;
  1358. player->tm_y+=player->go_tydis;
  1359. if (player->tm_anim==MC_KNEE)
  1360. {
  1361. player->go_txdis*=0.94;
  1362. player->go_tydis*=0.94;
  1363. if ((--player->go_cnt)<1)
  1364. {
  1365. // Do the Duck!!!
  1366. init_anim(player,MC_DUCK);
  1367. player->go_txdis=player->tm_xdis*MC_DUCK_SPD;
  1368. player->go_tydis=player->tm_ydis*MC_DUCK_SPD;
  1369. }
  1370. }
  1371. if (!just_scored)
  1372. init_stand_act(player);
  1373. }
  1374. /******************************************************************************
  1375. *****************************************************************************/
  1376. void init_stand_act(match_player *player)
  1377. {
  1378. player->contact=-1;
  1379. int ac=player->tm_act;
  1380. if (ac==SAVE_ACT)
  1381. keep_dive=FALSE;
  1382. reset_ideas(player); // Stop interception etc.
  1383. player->ls_anim=ABS(player->tm_anim); // last anim stored!
  1384. player->ls_frm=player->tm_frm-player->tm_fstep;
  1385. player->tm_act=STAND_ACT;
  1386. player->go_txdis=player->tm_xdis;
  1387. player->go_tydis=player->tm_ydis;
  1388. player->go_txdis=0;
  1389. player->go_tydis=0;
  1390. player->dir_mode=1;
  1391. if (player->tm_player==KP_A || player->tm_player==KP_B)
  1392. {
  1393. if (keeper_down && ac==SAVE_ACT)
  1394. {
  1395. // This keeper is on ground...
  1396. if (ball_in_hands && ball_poss==player->tm_player)
  1397. {
  1398. // Guy has ball in hands...
  1399. if (keeper_down<0)
  1400. // Keeper lying left...
  1401. {
  1402. init_anim(player,MC_STOSBL);
  1403. player->tm_fstep*=(keeper_spd*2);
  1404. init_kphold_act(player);
  1405. init_get_up(player,player->tm_fstep);
  1406. }
  1407. else
  1408. {
  1409. if (keeper_down==1)
  1410. {
  1411. // Keeper lying right...
  1412. init_anim(player,MC_STOSBR);
  1413. player->tm_fstep*=(keeper_spd*2);
  1414. init_kphold_act(player);
  1415. init_get_up(player,player->tm_fstep);
  1416. }
  1417. else
  1418. {
  1419. // Keeper forward crouched...
  1420. init_anim(player,MC_CRTOSTB);
  1421. player->tm_fstep*=(keeper_spd*2);
  1422. init_kphold_act(player);
  1423. init_get_up(player,player->tm_fstep);
  1424. }
  1425. }
  1426. }
  1427. else
  1428. {
  1429. // Doesn't have ball...
  1430. if (keeper_down<0)
  1431. // Keeper lying left...
  1432. {
  1433. init_anim(player,MC_STOSL);
  1434. player->tm_fstep*=(keeper_spd*2);
  1435. init_get_up(player,player->tm_fstep);
  1436. }
  1437. else
  1438. {
  1439. // Keeper lying right...
  1440. init_anim(player,MC_STOSR);
  1441. player->tm_fstep*=(keeper_spd*2);
  1442. init_get_up(player,player->tm_fstep);
  1443. }
  1444. }
  1445. keeper_down=0;
  1446. }
  1447. else
  1448. {
  1449. // Keeper standing up...
  1450. if (ball_in_hands && ball_poss==player->tm_player)
  1451. {
  1452. // Has ball...
  1453. init_anim(player,MC_STANDB);
  1454. init_kphold_act(player);
  1455. }
  1456. else
  1457. {
  1458. // Doesn't have ball...
  1459. if (match_mode==PEN_KICK_A || match_mode==PEN_KICK_B)
  1460. init_anim(player,MC_PENALTY);
  1461. else
  1462. init_anim(player,MC_STAND);
  1463. }
  1464. }
  1465. }
  1466. else
  1467. {
  1468. init_anim(player,MC_STAND);
  1469. }
  1470. }
  1471. /******************************************************************************
  1472. *****************************************************************************/
  1473. void init_steal_act(match_player *player)
  1474. {
  1475. player->tm_act=STEAL_ACT;
  1476. player->go_txdis=player->tm_xdis;
  1477. player->go_tydis=player->tm_ydis;
  1478. player->dir_mode=1;
  1479. init_anim(player,MC_PASSL);
  1480. reset_ideas(player); // Stop interception etc.
  1481. }
  1482. /******************************************************************************
  1483. *****************************************************************************/
  1484. void init_kphold_act(match_player *player)
  1485. {
  1486. keep_timer=6*REAL_SPEED;
  1487. player->tm_act=KPHOLD_ACT;
  1488. player->dir_mode=3;
  1489. reset_ideas(player); // Stop interception etc.
  1490. keeper_steps=(1./MC_RUNWITHB_FS);
  1491. }
  1492. /******************************************************************************
  1493. *****************************************************************************/
  1494. float angle_to_target(match_player *player)
  1495. {
  1496. float x=player->go_xoff;
  1497. float y=player->go_yoff;
  1498. float d=calc_dist(x,y);
  1499. // get new normalised vector.
  1500. float nx=x/d;
  1501. float ny=y/d;
  1502. float ox=player->tm_xdis;
  1503. float oy=player->tm_ydis;
  1504. // get difference (cos a).
  1505. float dif=((nx*ox)+(ny*oy));
  1506. if (dif>1.0)
  1507. dif=1;
  1508. if (dif<-1.0)
  1509. dif=-1;
  1510. return(dif);
  1511. }
  1512. /******************************************************************************
  1513. *****************************************************************************/
  1514. float angle_to_xy(float a,float b,float x,float y)
  1515. {
  1516. float d=calc_dist(a,b);
  1517. // get new normalised vector.
  1518. float nx=a/d;
  1519. float ny=b/d;
  1520. d=calc_dist(x,y);
  1521. float ox=x/d;
  1522. float oy=y/d;
  1523. // get difference (cos a).
  1524. float dif=((nx*ox)+(ny*oy));
  1525. if (dif>1.0)
  1526. dif=1;
  1527. if (dif<-1.0)
  1528. dif=-1;
  1529. return(dif);
  1530. }
  1531. /******************************************************************************
  1532. *****************************************************************************/
  1533. void init_stand_anims(match_player *player)
  1534. {
  1535. short p=player->tm_player;
  1536. if (p==KP_A || p==KP_B)
  1537. {
  1538. // Goal-keeper...
  1539. if (ball_in_hands && ball_poss==p)
  1540. {
  1541. // In keeper's hands...
  1542. init_anim(player,MC_STANDB);
  1543. }
  1544. else
  1545. init_anim(player,MC_STAND);
  1546. }
  1547. else
  1548. init_anim(player,MC_STAND);
  1549. }
  1550. /******************************************************************************
  1551. *****************************************************************************/
  1552. void init_trot_anims(match_player *player)
  1553. {
  1554. init_anim(player,MC_TROTA);
  1555. }
  1556. /******************************************************************************
  1557. *****************************************************************************/
  1558. void init_run_anims(match_player *player)
  1559. {
  1560. short p=player->tm_player;
  1561. if (p==KP_A || p==KP_B)
  1562. {
  1563. // Goal-keeper...
  1564. if (ball_in_hands && ball_poss==p)
  1565. {
  1566. // In keeper's hands...
  1567. init_anim(player,MC_RUNWITHB);
  1568. }
  1569. else
  1570. init_anim(player,MC_RUN);
  1571. }
  1572. else
  1573. init_anim(player,MC_RUN);
  1574. }
  1575. /******************************************************************************
  1576. *****************************************************************************/
  1577. void init_run_act(match_player *player,float tx,float ty,char s)
  1578. {
  1579. player->mface=FALSE;
  1580. // Setup target coords...
  1581. player->go_tx=tx;
  1582. player->go_ty=ty;
  1583. // Setup target offset...
  1584. float x=tx-player->tm_x;
  1585. float y=ty-player->tm_y;
  1586. player->go_xoff=x;
  1587. player->go_yoff=y;
  1588. float d=calc_dist(x,y); // How far is target!
  1589. if (d<IM_THERE_DIST)
  1590. {
  1591. // He is there already...
  1592. player->tm_x=tx;
  1593. player->tm_y=ty;
  1594. init_stand_act(player);
  1595. }
  1596. else
  1597. {
  1598. // Got to travel...
  1599. // Angle facing towards target...
  1600. float a=angle_to_xy(x,y,player->tm_xdis,player->tm_ydis);
  1601. if (a>=cos(MAX_TURN))
  1602. {
  1603. // He is facing target??? (no need to side step!)
  1604. player->go_step=FALSE;
  1605. if (s)
  1606. s=2;
  1607. }
  1608. // Now! Should he be side-stepping???
  1609. if (s && ((player->go_step && d<STEP_RANGE*2) || (!player->go_step && d<STEP_RANGE)))
  1610. {
  1611. // Jog now!
  1612. player->go_stop=FALSE;
  1613. player->go_step=TRUE;
  1614. player->go_cnt=d/actual_spd(player)+1;
  1615. player->go_txdis=x/player->go_cnt;
  1616. player->go_tydis=y/player->go_cnt;
  1617. init_trot_anims(player);
  1618. if (s==TRUE)
  1619. player->dir_mode=1; // Face ball.
  1620. else
  1621. player->dir_mode=0; // Face target.
  1622. }
  1623. else
  1624. {
  1625. // Run now!
  1626. player->go_step=FALSE;
  1627. player->go_cnt=get_there_time(player->tm_player,tx,ty);
  1628. if (player->go_cnt>=2000)
  1629. init_stand_act(player);
  1630. else
  1631. player->go_cnt-=must_face_time;
  1632. player->mface_x=x_face;
  1633. player->mface_y=y_face; // Direction he will be facing at target point!
  1634. if (must_face)
  1635. {
  1636. // Must get to a target and then face in a certain dir...
  1637. player->mface=TRUE;
  1638. player->mface_time=must_face_time;
  1639. }
  1640. if (stop_and_face)
  1641. {
  1642. // Quickest way to get to target is to stop and turn then run straight...
  1643. player->go_stop=TRUE;
  1644. short tt=ABS(acos(a)/MAX_TURN); // time to turn!
  1645. // Displacement vectors after turning...
  1646. player->go_txdis=x/(player->go_cnt-tt);
  1647. player->go_tydis=y/(player->go_cnt-tt);
  1648. init_stand_anims(player);
  1649. }
  1650. else
  1651. {
  1652. player->go_stop=FALSE;
  1653. // Displacement points to target... (not current though!)
  1654. player->go_txdis=x/player->go_cnt;
  1655. player->go_tydis=y/player->go_cnt;
  1656. init_run_anims(player);
  1657. }
  1658. player->dir_mode=0; // Face target.
  1659. if (user_controlled && uf2)
  1660. {
  1661. // Run Fast (user only!)...
  1662. player->go_txdis=player->go_txdis*1.2;
  1663. player->go_tydis=player->go_tydis*1.2;
  1664. }
  1665. }
  1666. player->tm_act=RUN_ACT;
  1667. }
  1668. }
  1669. /*
  1670. // How long to get there...
  1671. player->go_cnt=get_there_time(player->tm_player,tx,ty);
  1672. // Face target coords mode...
  1673. player->dir_mode=0;
  1674. if ((ABS(x)<=.1) && (ABS(y)<=.1))
  1675. {
  1676. if ((user_controlled) && (ball_poss==player->tm_player))
  1677. init_stand_act(player);
  1678. else
  1679. init_stand_act(player);
  1680. }
  1681. else
  1682. {
  1683. if (player->tm_player==3)
  1684. player->tm_player=3;
  1685. if (!shall_i_turn(player,x,y,s)) // Turn if need be (maybe step)!
  1686. {
  1687. float dist=calc_dist(x,y);
  1688. player->go_dist=(int)dist;
  1689. if (!player->go_step)
  1690. {
  1691. // Player not trotting...
  1692. if ((!ball_in_hands) && ((player->int_move==I_INTERCEPT) || (user_controlled) ||
  1693. ((dist>MUST_RUN_DIST) && (ABS(player->tm_anim)==MC_RUN)) ||
  1694. ((dist>(MUST_RUN_DIST*2)) && (ABS(player->tm_anim)!=MC_RUN)) ||
  1695. (player->tm_player==ball_poss && !ball_in_hands) ||
  1696. (plr_facing(x,y,player))))
  1697. {
  1698. player->go_cnt=((dist)/actual_spd(player)); //No. of steps till target.
  1699. init_anim(player,MC_RUN);
  1700. }
  1701. else
  1702. {
  1703. if ((player->tm_player==KP_A) || (player->tm_player==KP_B))
  1704. {
  1705. if (ball_in_hands && ball_poss==player->tm_player)
  1706. {
  1707. // kickout run up...
  1708. player->go_cnt=((dist)/(actual_spd(player)/4)); //No. of steps till target.
  1709. init_anim(player,MC_RUNWITHB);
  1710. }
  1711. else
  1712. {
  1713. player->go_cnt=((dist)/(actual_spd(player)/2)); //No. of steps till target.
  1714. init_anim(player,MC_JOG);
  1715. }
  1716. }
  1717. else
  1718. {
  1719. player->go_cnt=dist/(actual_spd(player)/2); //half speed.
  1720. init_anim(player,MC_JOG);
  1721. }
  1722. }
  1723. }
  1724. else
  1725. {
  1726. // Trot away...
  1727. player->go_cnt=dist/(actual_spd(player)); //half speed.
  1728. init_anim(player,MC_TROTA);
  1729. player->dir_mode=1; // Face ball.
  1730. }
  1731. player->go_cnt++;
  1732. player->go_txdis=x/player->go_cnt;
  1733. player->go_tydis=y/player->go_cnt;
  1734. player->tm_act=RUN_ACT;
  1735. if (user_controlled && uf2)
  1736. {
  1737. // Run Fast (user only!)...
  1738. player->go_txdis=player->go_txdis*1.2;
  1739. player->go_tydis=player->go_tydis*1.2;
  1740. }
  1741. }
  1742. }
  1743. }
  1744. */
  1745. /******************************************************************************
  1746. *****************************************************************************/
  1747. void init_fall(match_player *player)
  1748. {
  1749. reset_ideas(player);
  1750. if (ball_poss==player->tm_player)
  1751. holder_lose_ball();
  1752. // get_face_xy(player->face_dir,x,y);
  1753. player->go_txdis=(player->tm_xdis*FALL_RATE);
  1754. player->go_tydis=(player->tm_ydis*FALL_RATE);
  1755. player->go_tx=player->tm_x+(player->go_txdis*100);
  1756. player->go_ty=player->tm_y+(player->go_tydis*100);
  1757. player->tm_z=0;
  1758. player->go_cnt=(1/MC_FALLR_FS)-1;
  1759. player->tm_act=FALL_ACT;
  1760. player->dir_mode=0;
  1761. init_anim(player,MC_FALLR);
  1762. action="Fall";
  1763. }
  1764. /******************************************************************************
  1765. *****************************************************************************/
  1766. void init_jump_act(match_player *player,char dir,char ride)
  1767. {
  1768. float t;
  1769. reset_ideas(player);
  1770. if (dir)
  1771. {
  1772. if (ride)
  1773. // Ride tackle... set zdis to length of animation...
  1774. {
  1775. player->dir_mode=0;
  1776. player->tm_act=JUMP_ACT;
  1777. action="Jump";
  1778. init_anim(player,MC_RIDEL);
  1779. player->tm_zdis=(((1.0-player->tm_frm)/player->tm_fstep)-2)*gravity/2;
  1780. }
  1781. else
  1782. // Jump as high as poss...
  1783. {
  1784. player->tm_zdis=1.0+(float)(player->tm_pow)/32;
  1785. player->dir_mode=0;
  1786. player->tm_act=JUMP_ACT;
  1787. action="Jump";
  1788. t=((player->tm_zdis/gravity)*2)+1;
  1789. init_anim(player,MC_J_HEAD);
  1790. player->tm_fstep=(float)1/t;
  1791. }
  1792. }
  1793. else
  1794. {
  1795. if (player->tm_zdis!=0)
  1796. {
  1797. player->dir_mode=1;
  1798. player->tm_act=JUMP_ACT;
  1799. action="Header";
  1800. player->go_txdis=0;
  1801. player->go_tydis=0;
  1802. t=((player->tm_zdis/gravity)*2)+1;
  1803. init_anim(player,MC_J_HEAD);
  1804. player->tm_fstep=(float)1/t;
  1805. }
  1806. }
  1807. }
  1808. /******************************************************************************
  1809. *****************************************************************************/
  1810. void jump_action(match_player *player)
  1811. {
  1812. player->tm_z+=player->tm_zdis;
  1813. player->tm_zdis-=gravity;
  1814. go_toward_target(player);
  1815. if (player->tm_z<=0)
  1816. {
  1817. player->tm_z=0;
  1818. player->tm_zdis=0;
  1819. init_stand_act(player);
  1820. }
  1821. }
  1822. /******************************************************************************
  1823. *****************************************************************************/
  1824. void user_init_tackle(match_player *player)
  1825. {
  1826. if (um)
  1827. {
  1828. // if (camera!=6)
  1829. // Flat mode!
  1830. init_tackle_act(player,player->tm_x+(ux*256),player->tm_y+(uy*256));
  1831. /*
  1832. else
  1833. // Follow mode!
  1834. {
  1835. if (player->tm_act==RUN_ACT)
  1836. init_tackle_act(player,player->tm_x+(player->tm_xdis*256)
  1837. ,player->tm_y+(player->tm_ydis*256));
  1838. else
  1839. {
  1840. float x,y;
  1841. forward_joystick(player,x,y);
  1842. init_tackle_act(player,player->tm_x+(x*256),player->tm_y+(y*256));
  1843. }
  1844. }
  1845. */
  1846. }
  1847. else
  1848. {
  1849. float x,y;
  1850. // get_face_xy(player->face_dir,x,y);
  1851. x=player->tm_xdis;
  1852. y=player->tm_ydis;
  1853. init_tackle_act(player,player->tm_x+(x*256),player->tm_y+(y*256));
  1854. }
  1855. }
  1856. /******************************************************************************
  1857. *****************************************************************************/
  1858. void init_tackle_act(match_player *player,float tx,float ty)
  1859. {
  1860. float x,y,d;
  1861. x=tx-player->tm_x;
  1862. y=ty-player->tm_y;
  1863. d=calc_dist(x,y);
  1864. player->go_tx=player->tm_x+(x/d*30*prat);
  1865. player->go_ty=player->tm_y+(y/d*30*prat);
  1866. x=tx-player->tm_x;
  1867. y=ty-player->tm_y;
  1868. player->go_xoff=x;
  1869. player->go_yoff=y;
  1870. float a=angle_to_xy(x,y,player->tm_xdis,player->tm_ydis);
  1871. if (a>=cos(MAX_TURN))
  1872. {
  1873. inc_tack(player->tm_player);
  1874. float d=calc_dist(x,y);
  1875. player->go_cnt=(TACKLE_TURNS); //no. of steps till target.
  1876. player->go_txdis=((x)*((player->tm_rate+player->tm_pow+32)/20)/d);
  1877. player->go_tydis=((y)*((player->tm_rate+player->tm_pow+32)/20)/d);
  1878. player->tm_act=TACKLE_ACT;
  1879. action="Tackle";
  1880. player->dir_mode=0;
  1881. init_anim(player,MC_S_TACKLE);
  1882. player->go_cnt=1/MC_S_TACKLE_FS; //no. of steps till target.
  1883. play_fx(PS_SLIDING,player->tm_x,player->tm_y);
  1884. }
  1885. }
  1886. /******************************************************************************
  1887. *****************************************************************************/
  1888. void rotate_offs(int an,float &x,float &y,float &z,float nx,float ny)
  1889. {
  1890. float d=calc_dist(nx,ny);
  1891. nx=nx/d;
  1892. ny=ny/d;
  1893. // Calculate contact offsets with rotation in direction of facing...
  1894. x=save_offs[((an-MC_AFOOTB)*3)]; //x
  1895. y=-save_offs[((an-MC_AFOOTB)*3)+1]; //y
  1896. z=save_offs[((an-MC_AFOOTB)*3)+2]; //z
  1897. // Normal of offset...
  1898. float dof=calc_dist(x,y);
  1899. if (dof>1)
  1900. {
  1901. // Is there any offset present???
  1902. x=x/dof;
  1903. y=y/dof;
  1904. // get angle of rotation.
  1905. float nsx=(x*nx)-(y*ny);
  1906. float nsy=(y*nx)+(x*ny);
  1907. x=nsx*dof;
  1908. y=nsy*dof;
  1909. }
  1910. else
  1911. {
  1912. x=0;
  1913. y=0;
  1914. z=0;
  1915. }
  1916. }
  1917. /******************************************************************************
  1918. *****************************************************************************/
  1919. void init_save_act(match_player *player,int tx,int ty,int tz,int an,int zone,int bp,int cont)
  1920. {
  1921. float nx,ny,acc,cacc,sacc;
  1922. if (!user_controlled && penalty_shot)
  1923. {
  1924. // Penalty shot... (computer keeper can sometimes dive in wrong direction!)
  1925. af_randomize();
  1926. if (seed>(32+((player->tm_flair+player->tm_vis)/3)))
  1927. ty=player->tm_y-(ty-player->tm_y);
  1928. }
  1929. keeper_down=0;
  1930. // Accuracy of 64 gives range of (20 to -20 degrees)...
  1931. acc=((float)((rand_range(128-player->tm_ac))*(seed&1 ? 1:-1)))/183;
  1932. // acc=0;
  1933. cacc=cos(acc);
  1934. sacc=sin(acc);
  1935. af_randomize();
  1936. float x=tx-player->tm_x;
  1937. float y=ty-player->tm_y;
  1938. // Horz. vector to target...
  1939. float d=calc_dist(x,y);
  1940. x=x/d;
  1941. y=y/d;
  1942. // Add inaccuracy based on stats...
  1943. nx=(x*cacc)-(y*sacc);
  1944. ny=(y*cacc)+(x*sacc);
  1945. newdx=ny;
  1946. newdy=nx;
  1947. if ((an>MC_AJUMPC) && (an<=MC_CJUMPBR))
  1948. {
  1949. // Is he going left or right???
  1950. if ((nx*(player->tm_y-bally))>(ny*(player->tm_x-ballx)))
  1951. {
  1952. newdy=-newdy;
  1953. an++;
  1954. }
  1955. else
  1956. newdx=-newdx;
  1957. }
  1958. // Face Ball...
  1959. newdx=ballx-player->tm_x;
  1960. newdy=bally-player->tm_y;
  1961. float nd=calc_dist(newdx,newdy);
  1962. newdx=newdx/nd;
  1963. newdy=newdy/nd;
  1964. if (an==MC_AFOOTC)
  1965. keeper_down=2;
  1966. if ((an>=MC_BFOOTCL && an<=MC_BBODYCR) || (an>=MC_CFOOTBL && an<=MC_CBODYCR))
  1967. {
  1968. // Keeper will hit ground...
  1969. if (an&1)
  1970. // Going right...
  1971. keeper_down=1;
  1972. else
  1973. keeper_down=-1;
  1974. }
  1975. // Calculate current mcap offsets for given direction (newdx,newdy)!
  1976. float sx,sy,sz;
  1977. rotate_offs(an,sx,sy,sz,newdx,newdy);
  1978. // rotate_offs(an,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  1979. save_xoff=sx;
  1980. save_yoff=sy;
  1981. save_zoff=sz;
  1982. // Get horz. distance offset from target point to centre of body,
  1983. // based on motion capture animation...
  1984. /*WAIT for mcap data...*/
  1985. x=(nx*d)-save_xoff;
  1986. y=(ny*d)-save_yoff;
  1987. reset_ideas(player);
  1988. player->tm_act=SAVE_ACT;
  1989. player->go_cnt=1/player->tm_fstep;
  1990. if (keeper_on_grnd)
  1991. // Stay down for a bit after save...
  1992. if (save_block)
  1993. player->int_cnt=4+((128-player->tm_rate)/12)+1/player->tm_fstep; // Time to get up!
  1994. else
  1995. player->int_cnt=18+1/player->tm_fstep; // Time to get up!
  1996. else
  1997. player->int_cnt=2+1/player->tm_fstep;
  1998. player->int_move=I_SAVE_WAIT;
  1999. action="Save";
  2000. init_anim(player,an);
  2001. player->dir_mode=5;
  2002. // player->dir_mode=2;
  2003. player->go_tx=player->tm_x+x;
  2004. player->go_ty=player->tm_y+y;
  2005. player->go_xoff=x;
  2006. player->go_yoff=y;
  2007. if (keeper_will_save)
  2008. {
  2009. player->go_txdis=x/bp;
  2010. player->go_tydis=y/bp;
  2011. }
  2012. else
  2013. {
  2014. player->go_txdis=x/cont;
  2015. player->go_tydis=y/cont;
  2016. }
  2017. d=calc_dist(player->go_txdis,player->go_tydis);
  2018. if (d>(actual_spd(player)))
  2019. {
  2020. player->go_txdis=player->go_txdis*actual_spd(player)/d;
  2021. player->go_tydis=player->go_tydis*actual_spd(player)/d;
  2022. }
  2023. player->tm_zdis=0;
  2024. }
  2025. /******************************************************************************
  2026. *****************************************************************************/
  2027. void go_toward_target(match_player *player)
  2028. {
  2029. player->tm_x+=(player->go_txdis);
  2030. player->tm_y+=(player->go_tydis);
  2031. }
  2032. /******************************************************************************
  2033. *****************************************************************************/
  2034. void go_forward(match_player *player)
  2035. {
  2036. float rate=actual_spd(player);
  2037. if (player->go_step)
  2038. {
  2039. // Player is trotting facing ball...
  2040. player->tm_x+=(player->go_txdis);
  2041. player->tm_y+=(player->go_tydis);
  2042. inc_work(player->tm_player);
  2043. }
  2044. else
  2045. {
  2046. // Player is aiming to run straight at target...
  2047. if (player->go_stop)
  2048. {
  2049. // Player must wait until he faces target before moving on...
  2050. float a=angle_to_xy(player->go_txdis,player->go_tydis,player->tm_xdis,player->tm_ydis);
  2051. if (a>=cos(MAX_TURN))
  2052. {
  2053. // Now facing target... (can move forward!)
  2054. player->go_stop=FALSE;
  2055. player->tm_x+=(player->go_txdis);
  2056. player->tm_y+=(player->go_tydis);
  2057. inc_work(player->tm_player);
  2058. init_run_anims(player);
  2059. }
  2060. else
  2061. {
  2062. // Stand on the spot...
  2063. }
  2064. }
  2065. else
  2066. {
  2067. // Run forward in present dir at turn speed...
  2068. float a=angle_to_xy(player->go_tx-player->tm_x,player->go_ty-player->tm_y,player->tm_xdis,player->tm_ydis);
  2069. float turn_spd=(1.0+a)/2;
  2070. player->go_txdis=player->tm_xdis*turn_spd*rate;
  2071. player->go_tydis=player->tm_ydis*turn_spd*rate;
  2072. player->tm_x+=(player->go_txdis);
  2073. player->tm_y+=(player->go_tydis);
  2074. inc_work(player->tm_player);
  2075. }
  2076. }
  2077. }
  2078. /******************************************************************************
  2079. *****************************************************************************/
  2080. void scorer_go(match_player *player)
  2081. {
  2082. init_celeb_act(player);
  2083. }
  2084. /*
  2085. float xoff=cntspot_x-player->tm_x;
  2086. float yoff=cntspot_y-player->tm_y;
  2087. xoff+=64-seed;
  2088. af_randomize();
  2089. yoff+=64-seed;
  2090. float step=(calc_dist(xoff,yoff)/actual_spd(player));
  2091. player->go_txdis=xoff/step;
  2092. player->go_tydis=yoff/step;
  2093. init_jump_act(player,TRUE);
  2094. }
  2095. */
  2096. /******************************************************************************
  2097. *****************************************************************************/
  2098. void player_shame(match_player *player)
  2099. {
  2100. init_anim(player,MC_SHAME);
  2101. init_get_up(player,MC_SHAME_FS);
  2102. }
  2103. /******************************************************************************
  2104. *****************************************************************************/
  2105. void go_to_scorer(match_player *player)
  2106. {
  2107. int gs=goal_scorer;
  2108. if (player->tm_act<TURN_ACT)
  2109. {
  2110. float x=teams[gs-1].tm_x;
  2111. float y=teams[gs-1].tm_y;
  2112. float d=calc_dist(x-player->tm_x,y-player->tm_y);
  2113. short dp=(player->tm_player>11 ? (player->tm_player-11):(player->tm_player));
  2114. dp=dp*6;
  2115. if (d<8+dp)
  2116. init_celeb_act(player);
  2117. else
  2118. {
  2119. init_run_act(player,x,y,TRUE);
  2120. {
  2121. if (player->tm_act==RUN_ACT)
  2122. {
  2123. go_forward(player);
  2124. player->go_cnt=0;
  2125. }
  2126. }
  2127. }
  2128. }
  2129. }
  2130. /******************************************************************************
  2131. *****************************************************************************/
  2132. void someone_has_scored(match_player *player)
  2133. {
  2134. if (player->int_move!=I_CELEB && (goal_scorer==player->tm_player || (player->tm_player!=KP_A && player->tm_player!=KP_B)))
  2135. {
  2136. if (last_goal==1)
  2137. {
  2138. // Goal for team A...
  2139. if (goal_scorer<12)
  2140. {
  2141. // Celebrate...
  2142. if (goal_scorer==player->tm_player)
  2143. // He scored!
  2144. scorer_go(player);
  2145. else
  2146. if (player->tm_player<12)
  2147. // His team-mate
  2148. go_to_scorer(player);
  2149. else
  2150. init_stand_act(player);
  2151. }
  2152. else
  2153. {
  2154. // Own goal( Shame! )
  2155. if (goal_scorer==player->tm_player)
  2156. // He scored!
  2157. player_shame(player);
  2158. else
  2159. init_stand_act(player);
  2160. }
  2161. }
  2162. else
  2163. {
  2164. // Goal for team B...
  2165. if (goal_scorer>11)
  2166. {
  2167. // Celebrate...
  2168. if (goal_scorer==player->tm_player)
  2169. // He scored!
  2170. scorer_go(player);
  2171. else
  2172. if (player->tm_player>11)
  2173. // His team-mate
  2174. go_to_scorer(player);
  2175. else
  2176. init_stand_act(player);
  2177. }
  2178. else
  2179. {
  2180. // Own goal( Shame! )
  2181. if (goal_scorer==player->tm_player)
  2182. // He scored!
  2183. player_shame(player);
  2184. else
  2185. init_stand_act(player);
  2186. }
  2187. }
  2188. }
  2189. else
  2190. if (player->int_move!=I_CELEB)
  2191. init_stand_act(player);
  2192. }
  2193. /******************************************************************************
  2194. *****************************************************************************/
  2195. void dont_run_off(match_player *player)
  2196. {
  2197. if ((ballx<16) || (ballx>pitch_len-16) ||
  2198. (bally<16) || (bally>pitch_wid-16))
  2199. init_stand_act(player);
  2200. }
  2201. /******************************************************************************
  2202. *****************************************************************************/
  2203. void user_stand(match_player *player)
  2204. {
  2205. // if (camera!=6)
  2206. // Flat mode!
  2207. if (!f1_down && !f2_down)
  2208. // Not doing special...
  2209. if (game_action==-1)
  2210. // Should take up zonal position...
  2211. find_zonal_target(player,player->tm_x,player->tm_y); //players x,y for comparison.
  2212. else
  2213. init_run_act(player,player->tm_x+ux*256,player->tm_y+uy*256,FALSE);
  2214. /*
  2215. else
  2216. // Follow mode!
  2217. {
  2218. float x,y;
  2219. forward_joystick(player,x,y);
  2220. if (uy<0)
  2221. if (!match_mode && game_action==1)
  2222. // Should take up zonal position...
  2223. find_zonal_target(player,player->tm_x,player->tm_y); //players x,y for comparison.
  2224. else
  2225. init_run_act(player,player->tm_x+x*256,player->tm_y+y*256,FALSE);
  2226. else
  2227. {
  2228. player->go_txdis=x;
  2229. player->go_tydis=y;
  2230. }
  2231. }
  2232. */
  2233. player->go_cnt=1;
  2234. }
  2235. /******************************************************************************
  2236. *****************************************************************************/
  2237. /*
  2238. void check_for_header(match_player *player)
  2239. {
  2240. if ((ball_inair) && (!ball_poss))
  2241. // && (player->int_move==I_INTERCEPT) && (player->int_cnt))
  2242. {
  2243. int meet=200;
  2244. prev_d=5000;
  2245. for (int i=0; i<24; i++)
  2246. {
  2247. x=ball_pred_tab[i][0];
  2248. y=ball_pred_tab[i][1];
  2249. z=ball_pred_tab[i][2];
  2250. d=calc_dist(x-player->tm_x,y-player->tm_y);
  2251. // Volley???
  2252. if (ballx>
  2253. if (ballz>
  2254. if (d<min_d)
  2255. {
  2256. min_d=d;
  2257. meet=i;
  2258. }
  2259. else
  2260. i=21; // end loop (not getting closer to ball)
  2261. prev_d=d;
  2262. }
  2263. if (meet!=200)
  2264. {
  2265. // Ball has a closest point...
  2266. x=ball_pred_tab[meet][0];
  2267. y=ball_pred_tab[meet][1];
  2268. z=ball_pred_tab[meet][2];
  2269. z=z-PLAYER_HEIGHT+5;
  2270. // float zd=sqrt(z)-(gravity*gravity); // Take-off speed for given max height!
  2271. float zd=sqrt(2*z*gravity)-(gravity*gravity); // Max. Height
  2272. int jt=gravity+zd/gravity; // Time to reach max height.
  2273. jt=meet-jt;
  2274. if (jt>=0)
  2275. {
  2276. reset_ideas(player);
  2277. player->int_cnt=jt;
  2278. player->int_move=I_HEADER; // Wait for header.
  2279. player->tm_zdis=zd;
  2280. }
  2281. }
  2282. }
  2283. }
  2284. */
  2285. /******************************************************************************
  2286. *****************************************************************************/
  2287. void kick_strike(match_player *player)
  2288. {
  2289. if (player->tm_srng)
  2290. {
  2291. // In Shooting Range!
  2292. shoot_ball(player);
  2293. }
  2294. else
  2295. {
  2296. punt_ball(player);
  2297. }
  2298. }
  2299. /******************************************************************************
  2300. *****************************************************************************/
  2301. void overhead_strike(match_player *player)
  2302. {
  2303. player->tm_xdis=-player->tm_xdis;
  2304. player->tm_ydis=-player->tm_ydis; // Facing backwards...
  2305. int p=player->tm_pow;
  2306. player->tm_pow=p*2/3; // 2 3rds power of kick!
  2307. if (player->tm_srng)
  2308. {
  2309. // In Shooting Range!
  2310. shoot_ball(player);
  2311. }
  2312. else
  2313. {
  2314. punt_ball(player);
  2315. }
  2316. player->tm_xdis=-player->tm_xdis;
  2317. player->tm_ydis=-player->tm_ydis;
  2318. player->tm_pow=p;
  2319. }
  2320. /******************************************************************************
  2321. *****************************************************************************/
  2322. void chip_strike(match_player *player)
  2323. {
  2324. pass_type=player->tm_fpass_type;
  2325. receiver=player->tm_fpass_to;
  2326. pass_ball(receiver,FALSE);
  2327. }
  2328. /******************************************************************************
  2329. *****************************************************************************/
  2330. void head_strike(match_player *player)
  2331. {
  2332. heading_ball=TRUE;
  2333. if (player->tm_fpass_type)
  2334. {
  2335. pass_type=player->tm_fpass_type;
  2336. receiver=player->tm_fpass_to;
  2337. pass_ball(receiver,FALSE);
  2338. }
  2339. else
  2340. {
  2341. int p=player->tm_pow;
  2342. player->tm_pow=p/2; // Half power of kick!
  2343. if (player->tm_srng)
  2344. {
  2345. // In Shooting Range!
  2346. if (user_controlled)
  2347. {
  2348. if (uf1) // Head down!
  2349. heading_ball=3;
  2350. }
  2351. else
  2352. if (seed<player->tm_ac)
  2353. heading_ball=3;
  2354. shoot_ball(player);
  2355. }
  2356. else
  2357. {
  2358. punt_ball(player);
  2359. }
  2360. player->tm_pow=p;
  2361. }
  2362. heading_ball=FALSE;
  2363. }
  2364. /******************************************************************************
  2365. *****************************************************************************/
  2366. void dvhead_strike(match_player *player)
  2367. {
  2368. int p=player->tm_pow;
  2369. player->tm_pow=p/2; // Half power of kick!
  2370. heading_ball=2;
  2371. short ps=pass_decide(player,FALSE);
  2372. if (ps && pass_type>=3)
  2373. {
  2374. pass_ball(ps,FALSE);
  2375. }
  2376. else
  2377. {
  2378. if (player->tm_srng)
  2379. {
  2380. // In Shooting Range!
  2381. shoot_ball(player);
  2382. }
  2383. else
  2384. {
  2385. punt_ball(player);
  2386. }
  2387. }
  2388. player->tm_pow=p;
  2389. heading_ball=FALSE;
  2390. }
  2391. /******************************************************************************
  2392. *****************************************************************************/
  2393. void strike_ball_off(match_player *player)
  2394. {
  2395. add_comp_pass(player->tm_player);
  2396. player->tm_ftime=-1;
  2397. last_touch=player->tm_player;
  2398. if (last_touch!=KP_A && last_touch!=KP_B)
  2399. pre_kp_touch=last_touch;
  2400. ball_poss=player->tm_player;
  2401. int a=player->tm_anim;
  2402. switch(a)
  2403. {
  2404. case(MC_OVERHEAD):
  2405. overhead_strike(player);
  2406. break;
  2407. case(MC_DV_HEAD):
  2408. dvhead_strike(player);
  2409. break;
  2410. case(MC_J_HEAD):
  2411. case(MC_S_HEAD):
  2412. head_strike(player);
  2413. break;
  2414. case(MC_CHIPL):
  2415. case(MC_CHIPR):
  2416. chip_strike(player);
  2417. break;
  2418. case(MC_SHOOTL):
  2419. case(MC_SHOOTR):
  2420. case(MC_VOLLEYL):
  2421. case(MC_VOLLEYR):
  2422. kick_strike(player);
  2423. break;
  2424. }
  2425. standard_fstep(player);
  2426. }
  2427. /******************************************************************************
  2428. *****************************************************************************/
  2429. void fire_ball_off()
  2430. {
  2431. reset_shot();
  2432. if (kick_type==KT_PUNT)
  2433. {
  2434. // Punt...
  2435. punt_ball(&teams[ball_poss-1]);
  2436. }
  2437. else
  2438. {
  2439. if (kick_type==KT_SHOOT)
  2440. {
  2441. // Shoot...
  2442. shoot_ball(&teams[ball_poss-1]);
  2443. }
  2444. else
  2445. {
  2446. pass_ball(receiver,cross_now);
  2447. cross_now=FALSE;
  2448. chip_pass=FALSE;
  2449. action="Pass";
  2450. }
  2451. }
  2452. float sp;
  2453. int fx;
  2454. sp=calc_dist(ballxdis,ballydis);
  2455. sp=calc_dist(sp,ballzdis);
  2456. if (sp<10)
  2457. fx=PS_SOFTKICK;
  2458. else
  2459. if (sp<14)
  2460. fx=PS_MEDKICK;
  2461. else
  2462. fx=PS_HARDKICK;
  2463. play_fx(fx,ballx,bally);
  2464. // process_ball();
  2465. }
  2466. /******************************************************************************
  2467. *****************************************************************************/
  2468. void init_kick_act(match_player *player,int mc,float pc)
  2469. {
  2470. init_anim(player,mc);
  2471. player->tm_fstep=player->tm_fstep*player->tm_mcspd;
  2472. player->contact=pc;
  2473. if (!set_piece_on)
  2474. player->dir_mode=0;
  2475. else
  2476. player->dir_mode=2;
  2477. reset_ideas(player); // Stop interception etc.
  2478. player->int_move=I_KICKED;
  2479. player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  2480. rotate_offs(ABS(player->tm_anim),b_xoff,b_yoff,b_zoff,teams[ball_poss-1].tm_xdis,teams[ball_poss-1].tm_ydis);
  2481. player->go_txdis=MC_PASS_DIST*player->tm_fstep*player->tm_xdis;
  2482. player->go_tydis=MC_PASS_DIST*player->tm_fstep*player->tm_ydis;
  2483. player->go_tx=player->tm_x+player->tm_xdis*100;
  2484. player->go_ty=player->tm_y+player->tm_ydis*100;
  2485. player->tm_act=KICK_ACT;
  2486. }
  2487. /******************************************************************************
  2488. *****************************************************************************/
  2489. void kick_action(match_player *player)
  2490. {
  2491. if (player->tm_frm+player->tm_fstep>=1)
  2492. {
  2493. // Finished kick animation...
  2494. init_stand_act(player);
  2495. player->contact=-1;
  2496. }
  2497. if (player->tm_frm>=player->contact && ball_poss==player->tm_player)
  2498. {
  2499. // Contacted ball (release it)...
  2500. fire_ball_off();
  2501. }
  2502. if (ball_poss!=player->tm_player && player->tm_frm<player->contact)
  2503. {
  2504. // Ball stolen before kick!
  2505. init_stand_act(player);
  2506. player->contact=-1;
  2507. }
  2508. else
  2509. go_toward_target(player);
  2510. }
  2511. /******************************************************************************
  2512. *****************************************************************************/
  2513. void steal_action(match_player *player)
  2514. {
  2515. if (player->tm_frm<1.0)
  2516. {
  2517. if ((player->tm_frm>0.4) && (player->tm_frm<0.6)
  2518. && (ballz<1) && (ball_poss!=player->tm_player))
  2519. // Foot out frames...
  2520. {
  2521. // Get foot coords...
  2522. float x=player->tm_x+(player->tm_xdis*prat);
  2523. float y=player->tm_y+(player->tm_ydis*prat);
  2524. x=ballx-x;
  2525. y=bally-y;
  2526. float d=calc_dist(x,y);
  2527. if (d<=STEAL_FOOT_DIST)
  2528. {
  2529. holder_lose_ball();
  2530. collect_ball(player);
  2531. }
  2532. }
  2533. }
  2534. else
  2535. {
  2536. init_stand_act(player);
  2537. }
  2538. }
  2539. /******************************************************************************
  2540. *****************************************************************************/
  2541. void stand_action(match_player *player)
  2542. {
  2543. if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  2544. {
  2545. // Waiting for first touch...
  2546. if (--player->go_cnt<=0)
  2547. // Begin first touch animation...
  2548. init_strike_act(player);
  2549. }
  2550. else
  2551. {
  2552. if (ABS(player->tm_anim)==MC_SOCKSL || ABS(player->tm_anim)==MC_SOCKSR)
  2553. // Pulling his socks up just now...
  2554. {
  2555. if (player->tm_frm>0.99)
  2556. init_anim(player,MC_STAND);
  2557. }
  2558. player->ls_anim=ABS(player->tm_anim); // Do not use last anim!
  2559. player->ls_frm=player->tm_frm; // Do not use last anim!
  2560. if ((user_controlled) && (!match_mode)
  2561. && (!((player->tm_player==KP_A || player->tm_player==KP_B)
  2562. && ABS(player->tm_anim)>=MC_STOSL && ABS(player->tm_anim)<=MC_STOSBR)))
  2563. user_stand(player);
  2564. else
  2565. {
  2566. if (ABS(player->tm_anim)>=MC_STOSL && ABS(player->tm_anim)<=MC_STOSBR)
  2567. {
  2568. // Keeper getting up!
  2569. if (!player->int_cnt)
  2570. {
  2571. if (ball_in_hands)
  2572. init_anim(player,MC_STANDB);
  2573. else
  2574. init_anim(player,MC_STAND);
  2575. }
  2576. }
  2577. else
  2578. {
  2579. if (just_scored>0)
  2580. someone_has_scored(player);
  2581. else
  2582. {
  2583. // if (player->int_move!=I_HEADER)
  2584. // check_for_header(player);
  2585. // else
  2586. if (player->int_move==I_HEADER)
  2587. {
  2588. if (player->int_cnt<=1)
  2589. {
  2590. player->int_cnt=-1;
  2591. init_jump_act(player,FALSE); // Jump straight up!
  2592. }
  2593. }
  2594. else
  2595. {
  2596. if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  2597. || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  2598. || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  2599. {
  2600. // Make sure that keeper isn't waiting to make save!
  2601. if ((player->tm_act==STAND_ACT) && (!player->tm_stopped))
  2602. find_zonal_target(player,player->tm_x,player->tm_y); //players x,y for comparison.
  2603. }
  2604. }
  2605. }
  2606. }
  2607. }
  2608. if (ABS(player->tm_anim)==MC_STAND && player->tm_dist>(prat*50))
  2609. {
  2610. // Standing far away from ball...
  2611. if ((ball_poss>11 && player->tm_player>11) || (ball_poss
  2612. && ball_poss<12 && player->tm_player<12))
  2613. // Team-mate has ball (safe!)...
  2614. {
  2615. if (seed<SOCKS_PROB)
  2616. {
  2617. if (seed&1)
  2618. init_anim(player,MC_SOCKSL);
  2619. else
  2620. init_anim(player,MC_SOCKSR);
  2621. // Busy now...
  2622. init_get_up(player,MC_SOCKS_FS);
  2623. }
  2624. }
  2625. }
  2626. }
  2627. }
  2628. /******************************************************************************
  2629. *****************************************************************************/
  2630. void user_throw(match_player *player)
  2631. {
  2632. char high=FALSE;
  2633. float x,y;
  2634. if (um)
  2635. // Joystick_dir...
  2636. {
  2637. if (bally>cntspot_y)
  2638. // Bottom line...
  2639. {
  2640. x=ux;
  2641. y=uy;
  2642. if (uy>0)
  2643. {
  2644. high=TRUE;
  2645. y=-uy;
  2646. }
  2647. else
  2648. high=FALSE;
  2649. }
  2650. else
  2651. // Top line...
  2652. {
  2653. x=ux;
  2654. y=uy;
  2655. if (uy<0)
  2656. {
  2657. high=TRUE;
  2658. y=-uy;
  2659. }
  2660. else
  2661. high=FALSE;
  2662. }
  2663. player->tm_xdis=x;
  2664. player->tm_ydis=y;
  2665. if (uf2)
  2666. // Pass to nearest team-mate...
  2667. {
  2668. must_pass=TRUE;
  2669. throw_cnt=1;
  2670. if (high)
  2671. chip_pass=TRUE;
  2672. int p=pass_decide(player,FALSE);
  2673. make_pass(player,p,FALSE);
  2674. dead_ball_cnt=0;
  2675. game_action=0;
  2676. just_thrown=20;
  2677. match_mode=0;
  2678. arrow_on=FALSE;
  2679. already_there=FALSE;
  2680. stop_clock=FALSE;
  2681. }
  2682. if (uf1)
  2683. // Throw straight...
  2684. {
  2685. float sx,sy,sz;
  2686. float power=5+(player->tm_pow/16);
  2687. ballxdis=player->tm_xdis*power;
  2688. ballydis=player->tm_ydis*power;
  2689. ballzdis=(high ? power:power/2);
  2690. init_anim(player,MC_THROWL);
  2691. // Point at which ball leaves hand!
  2692. // Calculate current mcap offsets for given direction (newdx,newdy)!
  2693. rotate_offs(MC_THROWL,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  2694. ballx=player->tm_x+sx;
  2695. bally=player->tm_y+sy;
  2696. ballz=player->tm_z+sz;
  2697. ball_limbo(player->tm_player,MCC_THROWL);
  2698. player->tm_limbo=1/MC_THROWL_FS;
  2699. ball_inair=TRUE;
  2700. holder_lose_ball();
  2701. dead_ball_cnt=0;
  2702. game_action=0;
  2703. just_thrown=20;
  2704. match_mode=0;
  2705. arrow_on=FALSE;
  2706. already_there=FALSE;
  2707. stop_clock=FALSE;
  2708. launch_ball(1); // Set up spin vector.
  2709. }
  2710. }
  2711. }
  2712. /******************************************************************************
  2713. *****************************************************************************/
  2714. void throw_action(match_player *player)
  2715. {
  2716. // Lmen normal...
  2717. refs[1].act=0;
  2718. refs[2].act=0;
  2719. if (refs[0].act!=2)
  2720. {
  2721. // Referee wait for kick mode...
  2722. refs[0].act=2;
  2723. ktaker=player->tm_player;
  2724. ref_wait=(160-ref_strictness)*REAL_SPEED/8;
  2725. play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  2726. }
  2727. if (user_controlled)
  2728. user_throw(player);
  2729. else
  2730. {
  2731. if (player->dir_mode==2)
  2732. {
  2733. // Scan in all directions for team-mate...
  2734. float ang_add,nx,ny;
  2735. float ox=player->go_txdis;
  2736. float oy=player->go_tydis;
  2737. if (player->turn_dir>0)
  2738. ang_add=0.1047198; // 6 degrees (radians)
  2739. else
  2740. ang_add=-0.1047198;
  2741. nx=(ox*cos(ang_add))-(oy*sin(ang_add));
  2742. ny=(oy*cos(ang_add))+(ox*sin(ang_add));
  2743. if (ny>1)
  2744. {
  2745. ny=1;
  2746. nx=0;
  2747. }
  2748. if (ny<-1)
  2749. {
  2750. ny=-1;
  2751. nx=0;
  2752. }
  2753. if ((bally<cntspot_y) && (ny<=0))
  2754. {
  2755. player->turn_dir=-player->turn_dir;
  2756. ny=0;
  2757. if (nx>0)
  2758. nx=1;
  2759. else
  2760. nx=-1;
  2761. }
  2762. if ((bally>cntspot_y) && (ny>=0))
  2763. {
  2764. player->turn_dir=-player->turn_dir;
  2765. ny=0;
  2766. if (nx>0)
  2767. nx=1;
  2768. else
  2769. nx=-1;
  2770. }
  2771. player->go_txdis=nx;
  2772. player->go_tydis=ny;
  2773. if (!(--throw_cnt))
  2774. // Looked around long enough must pass now.
  2775. {
  2776. must_pass=TRUE;
  2777. throw_cnt=1;
  2778. }
  2779. float tx=player->tm_xdis;
  2780. float ty=player->tm_ydis;
  2781. player->tm_xdis=player->go_txdis;
  2782. player->tm_ydis=player->go_tydis;
  2783. float x,y,d;
  2784. int p=pass_decide(player,FALSE);
  2785. if (p)
  2786. {
  2787. player->dir_mode=0; // Face in move dir.
  2788. player->turn_dir=p; // store receiver.
  2789. x=teams[p-1].tm_x-player->tm_x;
  2790. y=teams[p-1].tm_y-player->tm_y;
  2791. d=calc_dist(x,y);
  2792. player->go_txdis=x/d;
  2793. player->go_tydis=y/d;
  2794. player->go_tx=teams[p-1].tm_x;
  2795. player->go_ty=teams[p-1].tm_y;
  2796. already_there=FALSE;
  2797. stop_clock=FALSE;
  2798. }
  2799. player->tm_xdis=tx;
  2800. player->tm_ydis=ty;
  2801. }
  2802. else
  2803. {
  2804. // Wait for thrower to rotate to pass direction...
  2805. float ox=player->tm_xdis;
  2806. float oy=player->tm_ydis;
  2807. float dif=((player->go_txdis*ox)+(player->go_tydis*oy));
  2808. if (ABS(dif)>0.95)
  2809. {
  2810. // He's facing receiver...
  2811. make_pass(player,player->turn_dir,FALSE);
  2812. dead_ball_cnt=0;
  2813. game_action=0;
  2814. just_thrown=20;
  2815. match_mode=0;
  2816. launch_ball(1); // Set up spin vector.
  2817. already_there=FALSE;
  2818. stop_clock=FALSE;
  2819. }
  2820. }
  2821. }
  2822. }
  2823. /******************************************************************************
  2824. *****************************************************************************/
  2825. // Moves player on journey to target (x,y).
  2826. void user_run(match_player *player)
  2827. {
  2828. float px=player->tm_x;
  2829. float py=player->tm_y;
  2830. if ((px<-(prat*2) && ux<0)
  2831. || (px>pitch_len+(prat*2) && ux>0))
  2832. {
  2833. ux=0;
  2834. if (ABS(uy)<0.05)
  2835. init_stand_act(player);
  2836. else
  2837. if (uy>0)
  2838. uy=1;
  2839. else
  2840. uy=-1;
  2841. }
  2842. if ((py<-(prat*2) && uy<0)
  2843. || (py>pitch_wid+(prat*2) && uy>0))
  2844. {
  2845. uy=0;
  2846. if (ABS(ux)<0.05)
  2847. init_stand_act(player);
  2848. else
  2849. if (ux>0)
  2850. ux=1;
  2851. else
  2852. ux=-1;
  2853. }
  2854. /*
  2855. if (camera==6)
  2856. // Follow mode!
  2857. {
  2858. float x,y;
  2859. forward_joystick(player,x,y);
  2860. if (uy<0)
  2861. init_run_act(player,player->tm_x+x*256,player->tm_y+y*256,FALSE);
  2862. else
  2863. {
  2864. init_stand_act(player);
  2865. user_stand(player);
  2866. }
  2867. }
  2868. else
  2869. */
  2870. init_run_act(player,player->tm_x+ux*256,player->tm_y+uy*256,FALSE);
  2871. go_forward(player);
  2872. player->go_cnt=0;
  2873. }
  2874. /*****************************************************************************
  2875. *****************************************************************************/
  2876. // Keeper (holding ball) faces out then throws or kicks ball.
  2877. #define TOO_CLOSE_TO_GOAL (prat)
  2878. void kphold_action(match_player *player)
  2879. {
  2880. int p=player->tm_player;
  2881. game_action=-1; // Force players to keep away!
  2882. if (!player->int_cnt)
  2883. {
  2884. player->dir_mode=3;
  2885. // Added... Make keeper kick ball out if close to own goal line!
  2886. char kickit=FALSE;
  2887. if ((player->tm_player==KP_A && player->tm_x<TOO_CLOSE_TO_GOAL)
  2888. || (player->tm_player==KP_B && player->tm_x>(pitch_len-TOO_CLOSE_TO_GOAL)))
  2889. kickit=TRUE;
  2890. init_anim(player,MC_STANDB);
  2891. if (keep_timer)
  2892. keep_timer--;
  2893. if (!opp_around(ballx,bally,player->tm_player) || !keep_timer)
  2894. {
  2895. // No opposition near!
  2896. if (seed&1 && seed&8 && !kickit)
  2897. {
  2898. // Bounce the ball...
  2899. init_anim(player,MC_BOUNCE);
  2900. player->int_move=I_KP_BUSY;
  2901. player->int_cnt=(1./MC_BOUNCE_FS);
  2902. }
  2903. else
  2904. {
  2905. if (seed&2 && seed&8 && !kickit)
  2906. {
  2907. // Wave team-mates up-field...
  2908. init_anim(player,MC_WAVEUP);
  2909. player->int_move=I_KP_BUSY;
  2910. player->int_cnt=(1./MC_WAVEUP_FS);
  2911. }
  2912. else
  2913. {
  2914. if (seed&4 && seed&8 && !kickit)
  2915. {
  2916. // Stand for a bit...
  2917. player->int_move=I_KP_BUSY;
  2918. player->int_cnt=20;
  2919. }
  2920. else
  2921. {
  2922. // Just run...
  2923. if ((p==KP_A) && (player->tm_xdis>=0.95))
  2924. {
  2925. init_run_act(player,player->tm_x+(prat*15),player->tm_y,FALSE);
  2926. }
  2927. if ((p==KP_B) && (player->tm_xdis<=-0.95))
  2928. {
  2929. init_run_act(player,player->tm_x-(prat*15),player->tm_y,FALSE);
  2930. }
  2931. if (ABS(player->tm_anim)==MC_RUN)
  2932. init_anim(player,MC_RUNWITHB);
  2933. }
  2934. }
  2935. }
  2936. }
  2937. }
  2938. }
  2939. /******************************************************************************
  2940. *****************************************************************************/
  2941. void wait_action(match_player *player)
  2942. {
  2943. if ((player->ball_state<0 && !ball_poss)
  2944. || (player->ball_state>0 && player->ball_state!=last_touch))
  2945. // Ball has changed trajectory!
  2946. init_stand_act(player);
  2947. else
  2948. {
  2949. if (!(--player->tm_ftime))
  2950. // No more waiting!
  2951. {
  2952. player->tm_strike=-player->tm_strike;
  2953. init_strike_act(player);
  2954. }
  2955. else
  2956. {
  2957. player->tm_x+=player->go_txdis;
  2958. player->tm_y+=player->go_tydis;
  2959. }
  2960. }
  2961. }
  2962. /******************************************************************************
  2963. *****************************************************************************/
  2964. void stop_action(match_player *player)
  2965. {
  2966. if (player->int_move==I_INTERCEPT)
  2967. {
  2968. float a=angle_to_xy(player->go_xoff,player->go_yoff,player->tm_xdis,player->tm_ydis);
  2969. if (a>cos(MAX_TURN))
  2970. {
  2971. // Facing target now...
  2972. init_run_act(player,player->go_tx,player->go_ty,FALSE);
  2973. go_toward_target(player);
  2974. }
  2975. }
  2976. else
  2977. init_stand_act(player);
  2978. }
  2979. /******************************************************************************
  2980. *****************************************************************************/
  2981. void init_stop_act(match_player *player,float x,float y)
  2982. {
  2983. player->dir_mode=0;
  2984. player->tm_act=STOP_ACT;
  2985. player->go_tx=x;
  2986. player->go_ty=y;
  2987. player->go_xoff=x-player->tm_x;
  2988. player->go_yoff=y-player->tm_y;
  2989. init_anim(player,MC_STAND);
  2990. }
  2991. /******************************************************************************
  2992. *****************************************************************************/
  2993. void init_wait_act(match_player *player,float x,float y)
  2994. {
  2995. player->dir_mode=2;
  2996. player->tm_act=WAIT_ACT;
  2997. player->go_step=TRUE; // Side step if needed!
  2998. short m=player->int_move;
  2999. player->int_move=0;
  3000. float rate=actual_spd(player);
  3001. player->int_move=m;
  3002. float d=calc_dist(x,y);
  3003. x=x/d;
  3004. y=y/d;
  3005. short t=player->tm_ftime;
  3006. d=d/t; // Magnitude of displacement!
  3007. if (d>(rate+(player->tm_stime-1)))
  3008. init_stand_act(player);
  3009. else
  3010. {
  3011. player->tm_strike=-player->tm_strike;
  3012. player->go_txdis=x*d;
  3013. player->go_tydis=y*d;
  3014. // player->go_tx=player->go_tx-player->tm_x+(player->go_txdis*(t+1));
  3015. // player->go_ty=player->go_ty-player->tm_y+(player->go_tydis*(t+1));
  3016. if (d>.5)
  3017. init_anim(player,MC_TROTA);
  3018. else
  3019. init_anim(player,MC_STAND);
  3020. player->int_cnt=player->tm_ftime+1;
  3021. player->tm_x+=player->go_txdis;
  3022. player->tm_y+=player->go_tydis;
  3023. }
  3024. }
  3025. /******************************************************************************
  3026. *****************************************************************************/
  3027. void control_action(match_player *player)
  3028. {
  3029. if (player->tm_frm>=1)
  3030. {
  3031. // end of animation...
  3032. ballz=0;
  3033. init_stand_act(player);
  3034. player->tm_ftime=-2;
  3035. hold_ball(player);
  3036. ball_limbo_on=FALSE;
  3037. }
  3038. else
  3039. {
  3040. if (player->tm_frm>=player->contact && ball_poss!=player->tm_player && player->tm_ftime>=0)
  3041. // Player should have ball now but doesn't....
  3042. {
  3043. init_stand_act(player);
  3044. }
  3045. else
  3046. {
  3047. player->tm_x+=player->go_txdis;
  3048. player->tm_y+=player->go_tydis;
  3049. }
  3050. }
  3051. }
  3052. /******************************************************************************
  3053. *****************************************************************************/
  3054. void get_closest_pred(match_player *player,float &rt,float &x,float &y,float &z,float &d)
  3055. {
  3056. float sx,sy,sz;
  3057. rotate_offs(player->tm_anim,sx,sy,sz,player->mface_x,player->mface_y);
  3058. x=ball_pred_tab[(int)(rt)][0]-sx;
  3059. y=ball_pred_tab[(int)(rt)][1]-sy;
  3060. z=ball_pred_tab[(int)(rt)][2]-sz;
  3061. x=x-player->tm_x;
  3062. y=y-player->tm_y;
  3063. z=z-player->tm_z;
  3064. d=calc_dist(x,y);
  3065. d=calc_dist(z,d);
  3066. float best_rt=rt;
  3067. float min_d=d;
  3068. float best_x=x;
  3069. float best_y=y;
  3070. float best_z=z;
  3071. // Check one forward...
  3072. if (rt<49)
  3073. {
  3074. rt++;
  3075. x=ball_pred_tab[(int)(rt)][0]-sx;
  3076. y=ball_pred_tab[(int)(rt)][1]-sy;
  3077. z=ball_pred_tab[(int)(rt)][2]-sz;
  3078. x=x-player->tm_x;
  3079. y=y-player->tm_y;
  3080. z=z-player->tm_z;
  3081. d=calc_dist(x,y);
  3082. d=calc_dist(z,d);
  3083. if (d<min_d)
  3084. {
  3085. min_d=d;
  3086. best_rt=rt;
  3087. best_x=x;
  3088. best_y=y;
  3089. best_z=z;
  3090. }
  3091. }
  3092. // Check one back...
  3093. if (rt>=1)
  3094. {
  3095. rt-=2;
  3096. x=ball_pred_tab[(int)(rt)][0]-sx;
  3097. y=ball_pred_tab[(int)(rt)][1]-sy;
  3098. z=ball_pred_tab[(int)(rt)][2]-sz;
  3099. x=x-player->tm_x;
  3100. y=y-player->tm_y;
  3101. z=z-player->tm_z;
  3102. d=calc_dist(x,y);
  3103. d=calc_dist(z,d);
  3104. if (d<min_d)
  3105. {
  3106. min_d=d;
  3107. best_rt=rt;
  3108. best_x=x;
  3109. best_y=y;
  3110. best_z=z;
  3111. }
  3112. }
  3113. d=min_d;
  3114. x=best_x;
  3115. y=best_y;
  3116. z=best_z;
  3117. rt=best_rt;
  3118. }
  3119. /******************************************************************************
  3120. *****************************************************************************/
  3121. void init_control_act(match_player *player)
  3122. {
  3123. float x,y,z,d,rt;
  3124. switch(player->tm_strike)
  3125. {
  3126. case(1):
  3127. init_anim(player,MC_TRAPL);
  3128. player->contact=MCC_TRAP;
  3129. z=save_offs[(MC_TRAPL*3)+2];
  3130. break;
  3131. case(2):
  3132. init_anim(player,MC_CHEST);
  3133. player->contact=MCC_CHEST;
  3134. z=save_offs[(MC_CHEST*3)+2];
  3135. break;
  3136. case(3):
  3137. init_anim(player,MC_D_HEAD);
  3138. player->contact=MCC_D_HEAD;
  3139. z=save_offs[(MC_D_HEAD*3)+2];
  3140. break;
  3141. }
  3142. // Real contact point with offset...
  3143. float old_rt=player->tm_stime+player->tm_ftime;
  3144. rt=old_rt;
  3145. get_closest_pred(player,rt,x,y,z,d);
  3146. player->tm_ftime+=rt-old_rt; // Add difference in timing.
  3147. if (player->tm_ftime>0)
  3148. {
  3149. // Some free time... (lets stand and wait!)
  3150. init_wait_act(player,x,y);
  3151. }
  3152. else
  3153. {
  3154. // Need to run animation...
  3155. player->tm_ftime=0;
  3156. short ts=player->tm_strike;
  3157. reset_ideas(player);
  3158. if (player->tm_player>11)
  3159. interceptor_b=player->tm_player;
  3160. else
  3161. interceptor_a=player->tm_player;
  3162. player->tm_strike=ts;
  3163. player->tm_act=CONTROL_ACT;
  3164. player->int_move=I_RECEIVE;
  3165. player->tm_fstep=player->contact/rt;
  3166. player->tm_frm=player->tm_fstep+0.01;
  3167. player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  3168. d=calc_dist(x,y);
  3169. if (d/rt>1)
  3170. // Ball has changed direction... (cannot meet!)
  3171. init_stand_act(player);
  3172. else
  3173. {
  3174. if (abs(z)>prat)
  3175. // Ball has changed direction... (cannot meet!)
  3176. init_stand_act(player);
  3177. else
  3178. {
  3179. // set displacement to meet ball at contact point!
  3180. player->go_txdis=x/rt;
  3181. player->go_tydis=y/rt;
  3182. // keep facing same direction!
  3183. player->dir_mode=2;
  3184. }
  3185. player->tm_strike=-player->tm_strike;
  3186. }
  3187. }
  3188. }
  3189. /******************************************************************************
  3190. *****************************************************************************/
  3191. #define JUMP_POINT (0.1)
  3192. void strike_action(match_player *player)
  3193. {
  3194. if (player->tm_frm+player->tm_fstep>=1)
  3195. {
  3196. // end of animation...
  3197. player->tm_ftime=-2;
  3198. if (player->tm_anim==MC_OVERHEAD)
  3199. {
  3200. // On the ground must get up ( on his back )...
  3201. player->tm_limbo=1/MC_GETUP_FS;
  3202. init_anim(player,MC_GETUP);
  3203. }
  3204. else
  3205. {
  3206. if (player->tm_anim==MC_DV_HEAD)
  3207. {
  3208. // On the ground must get up ( on his front )...
  3209. player->tm_limbo=1/MC_GETUPF_FS;
  3210. init_anim(player,MC_GETUPF);
  3211. }
  3212. else
  3213. init_stand_act(player);
  3214. }
  3215. }
  3216. else
  3217. {
  3218. if (player->tm_anim==MC_J_HEAD)
  3219. {
  3220. // Jumping header...
  3221. if (player->tm_frm>JUMP_POINT)
  3222. {
  3223. player->tm_z+=player->tm_zdis;
  3224. if (player->tm_z<0)
  3225. player->tm_z=0;
  3226. else
  3227. player->tm_zdis-=gravity;
  3228. }
  3229. }
  3230. if (player->tm_frm>=player->contact)
  3231. // Player can slow down now...
  3232. {
  3233. player->go_txdis=player->go_txdis*SAVE_DECEL;
  3234. player->go_tydis=player->go_tydis*SAVE_DECEL;
  3235. }
  3236. player->tm_x+=player->go_txdis;
  3237. player->tm_y+=player->go_tydis;
  3238. }
  3239. }
  3240. /******************************************************************************
  3241. *****************************************************************************/
  3242. void init_first_time_act(match_player *player,int mc,float pc)
  3243. {
  3244. float x,y,z,d,rt;
  3245. init_anim(player,mc);
  3246. player->tm_frm=0;
  3247. // Real contact point with offset...
  3248. float old_rt=player->tm_stime+player->tm_ftime;
  3249. rt=old_rt;
  3250. get_closest_pred(player,rt,x,y,z,d);
  3251. player->tm_ftime+=rt-old_rt; // Add difference in timing.
  3252. if (player->tm_ftime>0)
  3253. {
  3254. // Some free time... (lets stand and wait!)
  3255. init_wait_act(player,x,y);
  3256. }
  3257. else
  3258. {
  3259. // Need to speed up animation...
  3260. player->tm_ftime=0;
  3261. short ts=player->tm_strike;
  3262. reset_ideas(player); // Stop interception etc.
  3263. if (player->tm_player>11)
  3264. interceptor_b=player->tm_player;
  3265. else
  3266. interceptor_a=player->tm_player;
  3267. player->tm_strike=ts;
  3268. player->tm_act=STRIKE_ACT;
  3269. player->int_move=I_RECEIVE;
  3270. player->contact=pc;
  3271. float fs=player->tm_fstep;
  3272. player->tm_fstep=player->contact/rt;
  3273. player->tm_frm=player->tm_fstep+0.01;
  3274. player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  3275. if (mc==MC_J_HEAD)
  3276. player->tm_zdis=(gravity*((player->int_cnt-1)*.6)/2);
  3277. d=calc_dist(x,y);
  3278. if (d/rt>2)
  3279. // Ball has changed direction... (cannot meet!)
  3280. init_stand_act(player);
  3281. else
  3282. {
  3283. if (abs(z)>prat)
  3284. // Ball has changed direction... (cannot meet!)
  3285. init_stand_act(player);
  3286. else
  3287. {
  3288. // set displacement to meet ball at contact point!
  3289. player->go_txdis=x/rt;
  3290. player->go_tydis=y/rt;
  3291. // keep facing same direction!
  3292. player->dir_mode=2;
  3293. }
  3294. player->tm_strike=-player->tm_strike;
  3295. }
  3296. }
  3297. }
  3298. /******************************************************************************
  3299. *****************************************************************************/
  3300. void oinit_first_time_act(match_player *player,int mc,float pc)
  3301. {
  3302. float x,y,z,d;
  3303. init_anim(player,mc);
  3304. float sx,sy,sz;
  3305. rotate_offs(mc,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  3306. // Real contact point with offset...
  3307. float rt=player->tm_stime+player->tm_ftime;
  3308. x=ball_pred_tab[(int)(rt)][0]-sx;
  3309. y=ball_pred_tab[(int)(rt)][1]-sy;
  3310. z=ball_pred_tab[(int)(rt)][2]-sz;
  3311. x=x-player->tm_x;
  3312. y=y-player->tm_y;
  3313. z=z-player->tm_z;
  3314. if (player->tm_ftime)
  3315. {
  3316. // Some free time... (lets stand and wait!)
  3317. init_wait_act(player,x,y);
  3318. }
  3319. else
  3320. {
  3321. player->tm_strike=-player->tm_strike;
  3322. float fs=player->tm_fstep; // Standard anim speed fstep!
  3323. player->contact=pc;
  3324. player->tm_fstep=(pc-player->tm_frm)/(player->tm_stime+player->tm_ftime);
  3325. player->dir_mode=2;
  3326. reset_ideas(player); // Stop interception etc.
  3327. player->int_move=I_RECEIVE;
  3328. player->int_cnt=((pc-player->tm_frm)/player->tm_fstep)+(1-pc/fs)+1;
  3329. player->tm_act=STRIKE_ACT;
  3330. float d=calc_dist(x,y);
  3331. if (d/rt>1)
  3332. // Ball has changed direction... (cannot meet!)
  3333. init_stand_act(player);
  3334. else
  3335. {
  3336. if (abs(z)>prat)
  3337. // Ball has changed direction... (cannot meet!)
  3338. init_stand_act(player);
  3339. else
  3340. {
  3341. // set displacement to meet ball at contact point!
  3342. player->go_txdis=x/rt;
  3343. player->go_tydis=y/rt;
  3344. }
  3345. }
  3346. }
  3347. }
  3348. /******************************************************************************
  3349. *****************************************************************************/
  3350. void init_strike_act(match_player *player)
  3351. {
  3352. short s;
  3353. switch(player->tm_strike)
  3354. {
  3355. case(1):
  3356. case(2):
  3357. case(3):
  3358. init_control_act(player);
  3359. break;
  3360. case(4):
  3361. init_first_time_act(player,MC_OVERHEAD,MCC_OVERHEAD);
  3362. headed_ball=FALSE;
  3363. break;
  3364. case(5):
  3365. init_first_time_act(player,MC_VOLLEYL,MCC_VOLLEY);
  3366. headed_ball=FALSE;
  3367. break;
  3368. case(6):
  3369. init_first_time_act(player,MC_DV_HEAD,MCC_DV_HEAD);
  3370. headed_ball=TRUE;
  3371. break;
  3372. case(7):
  3373. init_first_time_act(player,MC_J_HEAD,MCC_J_HEAD);
  3374. headed_ball=TRUE;
  3375. break;
  3376. case(8):
  3377. init_first_time_act(player,MC_SHOOTL,MCC_SHOOT);
  3378. headed_ball=FALSE;
  3379. break;
  3380. case(9):
  3381. init_first_time_act(player,MC_S_HEAD,MCC_S_HEAD);
  3382. headed_ball=TRUE;
  3383. break;
  3384. case(10):
  3385. init_first_time_act(player,MC_CHIPL,MCC_CHIP);
  3386. headed_ball=FALSE;
  3387. break;
  3388. }
  3389. }
  3390. /******************************************************************************
  3391. *****************************************************************************/
  3392. // Moves player on journey to target (x,y).
  3393. void orun_action(match_player *player)
  3394. {
  3395. if ((player->tm_comm==SAY_PASS || player->tm_comm==SAY_CROSS)
  3396. && !player->tm_ccnt)
  3397. // He's asking for ball!
  3398. go_toward_target(player);
  3399. else
  3400. {
  3401. int player_ref=player->tm_player;
  3402. if ((ball_poss || (!ball_poss && player->int_move!=I_INTERCEPT)) && (user_controlled) && (!match_mode))
  3403. user_run(player);
  3404. else
  3405. {
  3406. if (ball_poss!=player_ref)
  3407. {
  3408. if (sender_1_2!=player_ref)
  3409. {
  3410. if (player->tm_strike>0 && player->int_move==I_INTERCEPT
  3411. && ((player->ball_state<0 && !ball_poss)
  3412. || (player->ball_state>0 && player->ball_state!=last_touch)))
  3413. init_stand_act(player);
  3414. else
  3415. {
  3416. --player->go_cnt;
  3417. if (player->go_cnt<=0)
  3418. {
  3419. player->go_cnt=0;
  3420. if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  3421. // Begin first touch animation...
  3422. {
  3423. go_toward_target(player);
  3424. init_strike_act(player);
  3425. }
  3426. else
  3427. {
  3428. if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  3429. || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  3430. || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  3431. {
  3432. // Make sure that keeper isn't waiting to make save!
  3433. find_zonal_target(player,player->tm_x,player->tm_y); //players x,y for comparison.
  3434. if ((player->go_cnt) && (player->tm_act==RUN_ACT))
  3435. {
  3436. go_toward_target(player);
  3437. }
  3438. else
  3439. {
  3440. if (player->tm_act!=TURN_ACT)
  3441. init_stand_act(player);
  3442. }
  3443. }
  3444. else
  3445. {
  3446. // Keeper waiting to make save!
  3447. init_stand_act(player);
  3448. }
  3449. }
  3450. }
  3451. else
  3452. {
  3453. if (just_scored>0)
  3454. someone_has_scored(player); // Target is goal scorer!
  3455. else
  3456. {
  3457. go_toward_target(player);
  3458. }
  3459. }
  3460. }
  3461. }
  3462. }
  3463. else
  3464. // Running with ball!
  3465. {
  3466. --player->go_cnt;
  3467. if (player->go_cnt<=0)
  3468. {
  3469. player->go_cnt=0;
  3470. init_stand_act(player);
  3471. }
  3472. else
  3473. {
  3474. go_toward_target(player);
  3475. if (ball_in_hands)
  3476. {
  3477. if (player->tm_player==KP_A)
  3478. {
  3479. // Keeper A...
  3480. if (keeper_a_in_box)
  3481. {
  3482. // Can only take three steps...
  3483. if (!(--keeper_steps))
  3484. must_punt=TRUE;
  3485. }
  3486. else
  3487. {
  3488. must_punt=TRUE;
  3489. }
  3490. }
  3491. else
  3492. {
  3493. if (player->tm_player==KP_B)
  3494. // Keeper B...
  3495. {
  3496. if (keeper_b_in_box)
  3497. {
  3498. if (!(--keeper_steps))
  3499. must_punt=TRUE;
  3500. // Can only take three steps...
  3501. }
  3502. else
  3503. {
  3504. must_punt=TRUE;
  3505. }
  3506. }
  3507. }
  3508. }
  3509. }
  3510. }
  3511. }
  3512. }
  3513. }
  3514. /******************************************************************************
  3515. *****************************************************************************/
  3516. // Moves player on journey to target (x,y).
  3517. void run_action(match_player *player)
  3518. {
  3519. if ((player->tm_comm==SAY_PASS || player->tm_comm==SAY_CROSS)
  3520. && !player->tm_ccnt)
  3521. // He's asking for ball!
  3522. go_forward(player);
  3523. else
  3524. {
  3525. int player_ref=player->tm_player;
  3526. if (user_controlled && game_action!=-1 && !match_mode && (ball_poss || (!ball_poss && player->int_move!=I_INTERCEPT)))
  3527. user_run(player);
  3528. else
  3529. {
  3530. if (ball_poss!=player_ref)
  3531. {
  3532. // Doesn't have ball...
  3533. if (sender_1_2!=player_ref)
  3534. {
  3535. // Not part of 1-2 move...
  3536. if (player->tm_strike>0 && player->int_move==I_INTERCEPT
  3537. && ((player->ball_state<0 && !ball_poss)
  3538. || (player->ball_state>0 && player->ball_state!=last_touch)))
  3539. // Can't continue first touch action! (Ball trajectory has changed!)
  3540. init_stand_act(player);
  3541. else
  3542. {
  3543. if (user_controlled && player->int_move==I_INTERCEPT && player->int_cnt
  3544. && !player->tm_strike && (uf1 || uf2))
  3545. go_to_path(player->tm_player); // Forced to try special move next cycle...
  3546. if (player->go_cnt && player->dir_mode!=6)
  3547. go_forward(player);
  3548. if (player->tm_trap && player_ref==player_on_off
  3549. && player->go_cnt<12)
  3550. player->draw_me=FALSE;
  3551. --player->go_cnt;
  3552. if (player->go_cnt<=0)
  3553. {
  3554. // Should be at target now!
  3555. player->go_cnt=0;
  3556. if (player->int_move==I_CELEB)
  3557. {
  3558. // Celebration run finished...
  3559. init_taunt_act(player);
  3560. }
  3561. if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  3562. // Begin first touch animation...
  3563. {
  3564. if (player->mface && player->dir_mode!=6)
  3565. {
  3566. player->dir_mode=6;
  3567. player->go_cnt=player->mface_time;
  3568. init_anim(player,MC_STAND);
  3569. }
  3570. else
  3571. init_strike_act(player);
  3572. }
  3573. else
  3574. {
  3575. if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  3576. || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  3577. || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  3578. {
  3579. // Make sure that keeper isn't waiting to make save!
  3580. if (just_scored)
  3581. someone_has_scored(player);
  3582. else
  3583. if (player->int_move==I_OFF)
  3584. {
  3585. player->tm_x=player->go_tx;
  3586. player->tm_y=player->go_ty;
  3587. init_stand_act(player);
  3588. }
  3589. else
  3590. {
  3591. if (player->int_cnt)
  3592. init_stand_act(player);
  3593. else
  3594. find_zonal_target(player,player->tm_x,player->tm_y); //players x,y for comparison.
  3595. }
  3596. }
  3597. else
  3598. {
  3599. // Keeper waiting to make save!
  3600. init_stand_act(player);
  3601. }
  3602. }
  3603. }
  3604. else
  3605. {
  3606. if (just_scored>0 && player->int_move!=I_CELEB)
  3607. someone_has_scored(player); // Target is goal scorer!
  3608. }
  3609. }
  3610. }
  3611. }
  3612. else
  3613. // Running with ball!
  3614. {
  3615. if (player->go_cnt)
  3616. go_forward(player);
  3617. --player->go_cnt;
  3618. if (player->go_cnt<=0)
  3619. {
  3620. player->go_cnt=0;
  3621. init_stand_act(player);
  3622. }
  3623. else
  3624. {
  3625. if (ball_in_hands)
  3626. {
  3627. if (player->tm_player==KP_A)
  3628. {
  3629. // Keeper A...
  3630. if (keeper_a_in_box)
  3631. {
  3632. // Can only take three steps...
  3633. if (!(--keeper_steps))
  3634. {
  3635. game_action=0;
  3636. must_punt=TRUE;
  3637. }
  3638. }
  3639. else
  3640. {
  3641. game_action=0;
  3642. must_punt=TRUE;
  3643. }
  3644. }
  3645. else
  3646. {
  3647. if (player->tm_player==KP_B)
  3648. // Keeper B...
  3649. {
  3650. if (keeper_b_in_box)
  3651. {
  3652. if (!(--keeper_steps))
  3653. {
  3654. game_action=0;
  3655. must_punt=TRUE;
  3656. }
  3657. // Can only take three steps...
  3658. }
  3659. else
  3660. {
  3661. game_action=0;
  3662. must_punt=TRUE;
  3663. }
  3664. }
  3665. }
  3666. }
  3667. }
  3668. }
  3669. }
  3670. }
  3671. }
  3672. /******************************************************************************
  3673. *****************************************************************************/
  3674. void tackle_action(match_player *player)
  3675. {
  3676. go_toward_target(player);
  3677. player->go_txdis*=TACKLE_DECEL;
  3678. player->go_tydis*=TACKLE_DECEL;
  3679. if (!player->go_cnt--)
  3680. init_stand_act(player);
  3681. }
  3682. /******************************************************************************
  3683. *****************************************************************************/
  3684. void save_action(match_player *player)
  3685. {
  3686. if ((player->tm_player==KP_A && keeper_a_in_box)
  3687. || (player->tm_player==KP_B && keeper_b_in_box))
  3688. {
  3689. player->tm_x+=player->go_txdis;
  3690. player->tm_y+=player->go_tydis;
  3691. }
  3692. else
  3693. {
  3694. seconds++;
  3695. }
  3696. if (player->tm_anim>=MC_AFOOTB && player->tm_anim<=MC_AJUMPC && player->tm_frm>keeper_contact)
  3697. {
  3698. // Slow him down after ball contact in zone A...
  3699. player->go_txdis=player->go_txdis*SAVE_DECEL;
  3700. player->go_tydis=player->go_tydis*SAVE_DECEL;
  3701. }
  3702. /*WAIT for mcap data*/
  3703. /* If keeper lands on ground slow him down...*/
  3704. if (!player->go_cnt--)
  3705. {
  3706. player->go_txdis=player->go_txdis*SAVE_DECEL;
  3707. player->go_tydis=player->go_tydis*SAVE_DECEL;
  3708. player->go_cnt=0;
  3709. player->tm_fstep=0;
  3710. player->tm_frm=.9999;
  3711. if ((!keeper_on_grnd) || (keeper_on_grnd && player->int_cnt<=1))
  3712. {
  3713. shot_acknowledged=FALSE;
  3714. player->go_cnt=0;
  3715. init_stand_act(player);
  3716. }
  3717. }
  3718. }
  3719. /******************************************************************************
  3720. *****************************************************************************/
  3721. void fall_action(match_player *player)
  3722. {
  3723. go_toward_target(player);
  3724. player->go_txdis*=TACKLE_DECEL;
  3725. player->go_tydis*=TACKLE_DECEL;
  3726. player->go_cnt--;
  3727. if (player->go_cnt==1)
  3728. {
  3729. init_anim(player,MC_GETUPF);
  3730. player->tm_fstep*=((float)(player->tm_rate+128)/128);
  3731. player->tm_limbo=1/player->tm_fstep;
  3732. }
  3733. else
  3734. if (!player->go_cnt)
  3735. init_stand_act(player);
  3736. }
  3737. /******************************************************************************
  3738. *****************************************************************************/
  3739. void init_tussles()
  3740. {
  3741. tussle_ptr=&tussle_tab[0];
  3742. *tussle_ptr=0;
  3743. }
  3744. /******************************************************************************
  3745. *****************************************************************************/
  3746. void tussle_collision(match_player *p1,match_player *p2)
  3747. {
  3748. float xoff,yoff,dist;
  3749. xoff=(p2->tm_x)-(p1->tm_x);
  3750. yoff=(p2->tm_y)-(p1->tm_y);
  3751. dist=calc_dist(xoff,yoff);
  3752. if (dist<prat*0.7)
  3753. {
  3754. // Sub vectors to get force of collision!
  3755. float ef_xd=((p1->tm_pow*p1->go_txdis)-(p2->tm_pow*p2->go_txdis));
  3756. float ef_yd=((p1->tm_pow*p1->go_tydis)-(p2->tm_pow*p2->go_tydis));
  3757. int force=ABS(ef_xd)+ABS(ef_yd);
  3758. // Add averaged vector!
  3759. ef_xd=(p1->go_txdis)+(p2->go_txdis);
  3760. ef_yd=(p1->go_tydis)+(p2->go_tydis);
  3761. int power=(p1->tm_pow+(p1->tm_act==STEAL_ACT ? 32:0)+(p1->tm_act==SAVE_ACT ? 500:0))
  3762. -(p2->tm_pow+(p2->tm_act==STEAL_ACT ? 32:0)+(p2->tm_act==SAVE_ACT ? 500:0));
  3763. if (power+(seed/2)-32<0)
  3764. // Player 1 is shoved!
  3765. {
  3766. if (p2->tm_anim==MC_RUN)
  3767. {
  3768. // Player 2 can barge run!
  3769. init_anim(p2,MC_BARGE);
  3770. p2->tm_barge=20;
  3771. }
  3772. if (p2->tm_player==KP_B)
  3773. force*=2;
  3774. if (p2->tm_act==SAVE_ACT)
  3775. force+=128*16;
  3776. // Update current movement!
  3777. if (force/16>seed && (!(seed&3) || p2->tm_act==SAVE_ACT))
  3778. {
  3779. float d=calc_dist(ef_xd,ef_yd);
  3780. p1->tm_xdis=ef_xd/d;
  3781. p1->tm_ydis=ef_yd/d;
  3782. init_fall(p1);
  3783. if (p2->tm_act==SAVE_ACT && (p2->tm_poss+2)*32<((float)seed*ref_strictness/128))
  3784. {
  3785. man_down=TRUE;
  3786. init_foul(p2->tm_player,TRUE); // pass no. of fouler.
  3787. }
  3788. else
  3789. {
  3790. p1->tm_x+=(ef_xd);
  3791. p1->tm_y+=(ef_yd);
  3792. if ((p1->tm_act==RUN_ACT) || (p1->tm_act==JUMP_ACT))
  3793. {
  3794. p1->tm_x-=(p1->go_txdis);
  3795. p1->tm_y-=(p1->go_tydis);
  3796. }
  3797. }
  3798. }
  3799. else
  3800. {
  3801. p1->tm_x+=(ef_xd);
  3802. p1->tm_y+=(ef_yd);
  3803. if ((p1->tm_act==RUN_ACT) || (p1->tm_act==JUMP_ACT))
  3804. {
  3805. p1->tm_x-=(p1->go_txdis);
  3806. p1->tm_y-=(p1->go_tydis);
  3807. }
  3808. }
  3809. }
  3810. else
  3811. // Player 2 is shoved!
  3812. {
  3813. if (p1->tm_anim==MC_RUN)
  3814. {
  3815. // Player 1 can barge run!
  3816. init_anim(p1,MC_BARGE);
  3817. p1->tm_barge=20;
  3818. }
  3819. // Update current movement!
  3820. if (force/16>seed && (!(seed&3) || p2->tm_act==SAVE_ACT))
  3821. {
  3822. float d=calc_dist(ef_xd,ef_yd);
  3823. p2->tm_xdis=ef_xd/d;
  3824. p2->tm_ydis=ef_yd/d;
  3825. init_fall(p2);
  3826. if (p1->tm_act==SAVE_ACT && (p1->tm_poss+2)*32<((float)seed*ref_strictness/128))
  3827. {
  3828. man_down=TRUE;
  3829. init_foul(p1->tm_player,TRUE); // pass no. of fouler.
  3830. }
  3831. }
  3832. else
  3833. {
  3834. p2->tm_x+=(ef_xd);
  3835. p2->tm_y+=(ef_yd);
  3836. if ((p2->tm_act==RUN_ACT) || (p2->tm_act==JUMP_ACT))
  3837. {
  3838. p2->tm_x-=(p2->go_txdis);
  3839. p2->tm_y-=(p2->go_tydis);
  3840. }
  3841. }
  3842. }
  3843. }
  3844. }
  3845. /******************************************************************************
  3846. *****************************************************************************/
  3847. void player_tussles()
  3848. {
  3849. int p=0;
  3850. int p1,p2,op;
  3851. char same_team=FALSE;
  3852. while ((tussle_ptr!=&tussle_tab[p]) && (!same_team))
  3853. {
  3854. p1=tussle_tab[p++];
  3855. op=p;
  3856. same_team=TRUE;
  3857. while (tussle_ptr!=&tussle_tab[op])
  3858. {
  3859. p2=tussle_tab[op++];
  3860. if (((p1<12) && (p2>11)) || ((p1>11) && (p2<12)))
  3861. {
  3862. same_team=FALSE;
  3863. tussle_collision(&teams[p1-1],&teams[p2-1]);
  3864. }
  3865. }
  3866. }
  3867. }
  3868. /******************************************************************************
  3869. *****************************************************************************/
  3870. void inline add_to_tussle_list(int pnum)
  3871. {
  3872. *tussle_ptr++=pnum;
  3873. }
  3874. /******************************************************************************
  3875. *****************************************************************************/
  3876. void do_action()
  3877. {
  3878. switch(teams[player_num-1].tm_act)
  3879. {
  3880. case STAND_ACT:
  3881. stand_action(&teams[player_num-1]);
  3882. break;
  3883. case RUN_ACT:
  3884. run_action(&teams[player_num-1]);
  3885. break;
  3886. /*
  3887. case TURN_ACT:
  3888. turn_action(&teams[player_num-1]);
  3889. break;
  3890. */
  3891. case TACKLE_ACT:
  3892. tackle_action(&teams[player_num-1]);
  3893. break;
  3894. case FALL_ACT:
  3895. fall_action(&teams[player_num-1]);
  3896. break;
  3897. case JUMP_ACT:
  3898. jump_action(&teams[player_num-1]);
  3899. break;
  3900. case SAVE_ACT:
  3901. save_action(&teams[player_num-1]);
  3902. break;
  3903. case THROW_ACT:
  3904. throw_action(&teams[player_num-1]);
  3905. break;
  3906. case KPHOLD_ACT:
  3907. kphold_action(&teams[player_num-1]);
  3908. break;
  3909. case STEAL_ACT:
  3910. steal_action(&teams[player_num-1]);
  3911. break;
  3912. case KICK_ACT:
  3913. kick_action(&teams[player_num-1]);
  3914. break;
  3915. case CELEB_ACT:
  3916. celeb_action(&teams[player_num-1]);
  3917. break;
  3918. case CONTROL_ACT:
  3919. control_action(&teams[player_num-1]);
  3920. break;
  3921. case STRIKE_ACT:
  3922. strike_action(&teams[player_num-1]);
  3923. break;
  3924. case WAIT_ACT:
  3925. wait_action(&teams[player_num-1]);
  3926. break;
  3927. case PICKUP_ACT:
  3928. pickup_action(&teams[player_num-1]);
  3929. break;
  3930. case STOP_ACT:
  3931. stop_action(&teams[player_num-1]);
  3932. break;
  3933. }
  3934. }
  3935. /******************************************************************************
  3936. *****************************************************************************/
  3937. void new_dir(match_player *player,float x,float y)
  3938. {
  3939. float d=calc_dist(x,y);
  3940. float max;
  3941. // get maximum turn.
  3942. max=MAX_TURN;
  3943. // get new normalised vector.
  3944. float nx=x/d;
  3945. float ny=y/d;
  3946. float ox=player->tm_xdis;
  3947. float oy=player->tm_ydis;
  3948. // get difference (cos a).
  3949. float dif=((nx*ox)+(ny*oy));
  3950. if (dif<cos(max))
  3951. {
  3952. // Which way to turn?
  3953. if ((nx*oy)>(ny*ox))
  3954. max=-max;
  3955. nx=(ox*cos(max))-(oy*sin(max));
  3956. ny=(oy*cos(max))+(ox*sin(max));
  3957. // Error Correction...
  3958. d=calc_dist(nx,ny);
  3959. nx=nx/d;
  3960. ny=ny/d;
  3961. if (ny>1)
  3962. {
  3963. ny=1;
  3964. nx=0;
  3965. }
  3966. if (ny<-1)
  3967. {
  3968. ny=-1;
  3969. nx=0;
  3970. }
  3971. if (nx>1)
  3972. {
  3973. nx=1;
  3974. ny=0;
  3975. }
  3976. if (nx<-1)
  3977. {
  3978. nx=-1;
  3979. ny=0;
  3980. }
  3981. }
  3982. player->tm_xdis=nx;
  3983. player->tm_ydis=ny;
  3984. player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  3985. }
  3986. /******************************************************************************
  3987. *****************************************************************************/
  3988. void dir_movement(match_player *player)
  3989. {
  3990. float x,y;
  3991. if (user_controlled && !player->tm_act && player->tm_player==ball_poss)
  3992. {
  3993. x=player->tm_xdis*10;
  3994. y=player->tm_ydis*10;
  3995. }
  3996. else
  3997. {
  3998. x=player->go_tx-player->tm_x;
  3999. y=player->go_ty-player->tm_y;
  4000. }
  4001. if ((x!=0) || (y!=0))
  4002. new_dir(player,x,y);
  4003. }
  4004. /******************************************************************************
  4005. *****************************************************************************/
  4006. void dir_ball(match_player *player)
  4007. {
  4008. float x=ballx-player->tm_x;
  4009. float y=bally-player->tm_y;
  4010. if ((x!=0) || (y!=0))
  4011. new_dir(player,x,y);
  4012. }
  4013. /******************************************************************************
  4014. *****************************************************************************/
  4015. void dir_new_d(match_player *player)
  4016. {
  4017. new_dir(player,newdx,newdy);
  4018. }
  4019. /******************************************************************************
  4020. *****************************************************************************/
  4021. void dir_must_face(match_player *player)
  4022. {
  4023. new_dir(player,player->mface_x,player->mface_y);
  4024. }
  4025. /******************************************************************************
  4026. *****************************************************************************/
  4027. void dir_away(match_player *player)
  4028. {
  4029. float x;
  4030. float y=0;
  4031. if (player->tm_player<12)
  4032. x=1;
  4033. else
  4034. x=-1;
  4035. new_dir(player,x,y);
  4036. }
  4037. /******************************************************************************
  4038. *****************************************************************************/
  4039. void select_hlite(match_player *player,short u)
  4040. {
  4041. player->tm_hcol=u-1; // Highlight colour.
  4042. if (ball_poss==player->tm_player)
  4043. {
  4044. if (in_cross_area)
  4045. player->tm_htype=HLITE_CROSS;
  4046. else
  4047. if (player->tm_srng)
  4048. player->tm_htype=HLITE_SHOOT;
  4049. else
  4050. player->tm_htype=HLITE_BALL;
  4051. }
  4052. else
  4053. {
  4054. if (player->special>0 && player->int_move==I_INTERCEPT)
  4055. player->tm_htype=HLITE_SPECIAL;
  4056. else
  4057. if (player->special<0 && player->int_move==I_INTERCEPT)
  4058. player->tm_htype=HLITE_STAR;
  4059. else
  4060. player->tm_htype=HLITE_NORM;
  4061. }
  4062. }
  4063. /******************************************************************************
  4064. *****************************************************************************/
  4065. void user_conts(match_player *player)
  4066. {
  4067. short u=player->control;
  4068. if (u)
  4069. {
  4070. ux=users_dir[u-1].x;
  4071. uy=users_dir[u-1].y;
  4072. um=users_dir[u-1].m;
  4073. if (users_dir[u-1].f&1)
  4074. {
  4075. uf1=TRUE;
  4076. if (player->tm_player==KP_B)
  4077. uf1++;
  4078. }
  4079. else
  4080. uf1=FALSE;
  4081. if (users_dir[u-1].f&2)
  4082. {
  4083. uf2=TRUE;
  4084. }
  4085. else
  4086. {
  4087. uf2=FALSE;
  4088. }
  4089. if (uf1 || uf2)
  4090. {
  4091. // Any fire buttons pressed?
  4092. if (users[u-1].chng)
  4093. // Just been selected... wait for release of buttons...
  4094. {
  4095. uf1=FALSE;
  4096. uf2=FALSE;
  4097. }
  4098. }
  4099. else
  4100. {
  4101. if (users[u-1].chng)
  4102. // Buttons released...
  4103. users[u-1].chng=FALSE;
  4104. }
  4105. #ifdef FORCE_SELECT
  4106. #ifdef EURO96
  4107. if (uf2 && uf1 && player->tm_dist>FSELECT_DIST && users[u-1].type<0)
  4108. #endif
  4109. #ifndef EURO96
  4110. if (uf2 && player->tm_dist>FSELECT_DIST && users[u-1].type<0)
  4111. #endif
  4112. {
  4113. uf1=FALSE;
  4114. uf2=FALSE;
  4115. if ((forced>>(u-1))&1)
  4116. forced-=1<<(u-1);
  4117. else
  4118. forced+=1<<(u-1);
  4119. }
  4120. else
  4121. if ((forced>>(u-1))&1)
  4122. forced-=1<<(u-1);
  4123. #endif
  4124. }
  4125. }
  4126. /******************************************************************************
  4127. *****************************************************************************/
  4128. void process_dir(match_player *player)
  4129. {
  4130. switch(player->dir_mode)
  4131. {
  4132. case(0):
  4133. dir_movement(player);
  4134. break;
  4135. case(-1):
  4136. dir_movement(player);
  4137. player->dir_mode=1;
  4138. break;
  4139. case(1):
  4140. dir_ball(player);
  4141. break;
  4142. case(2):
  4143. player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  4144. break;
  4145. case(3):
  4146. dir_away(player);
  4147. break;
  4148. case(4):
  4149. player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  4150. player->dir_mode=0;
  4151. break;
  4152. case(5):
  4153. dir_new_d(player);
  4154. break;
  4155. case(6):
  4156. dir_must_face(player);
  4157. break;
  4158. };
  4159. }
  4160. /******************************************************************************
  4161. *****************************************************************************/
  4162. void init_stand_anim(match_player *player)
  4163. {
  4164. player->tm_anim=MC_STAND;
  4165. player->tm_newanim=TRUE;
  4166. player->tm_frm=0;
  4167. player->tm_fstep=MC_STAND_FS;
  4168. }
  4169. /******************************************************************************
  4170. *****************************************************************************/
  4171. void init_penalty_anim(match_player *player)
  4172. {
  4173. if (player->tm_anim!=MC_PENALTY)
  4174. {
  4175. player->tm_anim=MC_PENALTY;
  4176. player->tm_newanim=TRUE;
  4177. player->tm_frm=0;
  4178. player->tm_fstep=MC_PENALTY_FS;
  4179. }
  4180. }
  4181. /******************************************************************************
  4182. *****************************************************************************/
  4183. void init_shame_anim(match_player *player)
  4184. {
  4185. player->tm_anim=MC_SHAMEW;
  4186. player->tm_newanim=TRUE;
  4187. player->tm_frm=0;
  4188. player->tm_fstep=MC_SHAMEW_FS;
  4189. }
  4190. /******************************************************************************
  4191. *****************************************************************************/
  4192. void init_standb_anim(match_player *player)
  4193. {
  4194. player->tm_anim=MC_STANDB;
  4195. player->tm_newanim=TRUE;
  4196. player->tm_frm=0;
  4197. player->tm_fstep=MC_STANDB_FS;
  4198. }
  4199. /******************************************************************************
  4200. *****************************************************************************/
  4201. void init_barge_anim(match_player *player)
  4202. {
  4203. // Always go from run animation to barge!
  4204. player->tm_anim=MC_BARGE;
  4205. player->tm_fstep=MC_BARGE_FS*(actual_spd(player)/MC_RUN_SPD);
  4206. player->tm_frm+=0.5;
  4207. }
  4208. /******************************************************************************
  4209. *****************************************************************************/
  4210. void init_run_anim(match_player *player)
  4211. {
  4212. if (!player->tm_barge || player->tm_anim!=MC_BARGE)
  4213. {
  4214. // Not barging!!!
  4215. if (user_controlled && uf2)
  4216. player->tm_fstep=(MC_RUN_FS*(actual_spd(player)/MC_RUN_SPD))*1.2;
  4217. else
  4218. player->tm_fstep=MC_RUN_FS*(actual_spd(player)/MC_RUN_SPD);
  4219. if (ABS((int)player->tm_anim)==MC_JOG)
  4220. {
  4221. // Tween to run from jog....
  4222. player->tm_anim=MC_RUN;
  4223. player->tm_frm+=0.4;
  4224. }
  4225. else
  4226. {
  4227. if (ABS((int)player->tm_anim)!=MC_RUN)
  4228. {
  4229. player->tm_anim=MC_RUN;
  4230. player->tm_newanim=TRUE;
  4231. player->tm_frm=0;
  4232. }
  4233. }
  4234. }
  4235. }
  4236. /******************************************************************************
  4237. *****************************************************************************/
  4238. void init_jog_anim(match_player *player)
  4239. {
  4240. player->tm_fstep=MC_JOG_FS*((actual_spd(player)/2)/MC_JOG_SPD);
  4241. if (ABS((int)player->tm_anim)==MC_RUN)
  4242. {
  4243. // Tween to jog from run....
  4244. player->tm_anim=MC_JOG;
  4245. player->tm_frm+=0.7;
  4246. }
  4247. else
  4248. {
  4249. if (ABS((int)player->tm_anim)==MC_BARGE)
  4250. {
  4251. player->tm_anim=MC_JOG;
  4252. }
  4253. else
  4254. {
  4255. if (ABS((int)player->tm_anim)!=MC_JOG)
  4256. {
  4257. player->tm_anim=MC_JOG;
  4258. player->tm_newanim=TRUE;
  4259. player->tm_frm=0;
  4260. }
  4261. }
  4262. }
  4263. }
  4264. /******************************************************************************
  4265. *****************************************************************************/
  4266. void init_shoot_anim(match_player *player)
  4267. {
  4268. player->tm_fstep=MC_SHOOT_FS;
  4269. double n;
  4270. if ((AFEQS(player->tm_anim,MC_RUN)) ||
  4271. (AFEQS(player->tm_anim,MC_JOG)))
  4272. {
  4273. if (modf(player->tm_frm,&n)>0.5)
  4274. {
  4275. // Left Footed Shot...
  4276. player->tm_anim=MC_SHOOTL;
  4277. player->tm_newanim=TRUE;
  4278. player->tm_frm-=0.5;
  4279. }
  4280. else
  4281. {
  4282. // Right Footed Shot...
  4283. player->tm_anim=MC_SHOOTR;
  4284. player->tm_newanim=TRUE;
  4285. }
  4286. }
  4287. else
  4288. {
  4289. // Right Footed Shot...
  4290. player->tm_anim=MC_SHOOTR;
  4291. player->tm_newanim=TRUE;
  4292. player->tm_frm=0;
  4293. }
  4294. }
  4295. /******************************************************************************
  4296. *****************************************************************************/
  4297. void init_kick_anim(match_player *player,int a)
  4298. {
  4299. int an=a;
  4300. double n;
  4301. float t;
  4302. float f;
  4303. if (AFEQS(player->tm_anim,MC_RUN))
  4304. t=modf(player->tm_frm,&n);
  4305. else
  4306. if (AFEQS(player->tm_anim,MC_JOG) || AFEQS(player->tm_anim,MC_BARGE))
  4307. t=modf((player->tm_frm+0.5),&n);
  4308. if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)) || (AFEQS(player->tm_anim,MC_BARGE)))
  4309. {
  4310. switch(a)
  4311. {
  4312. case(MC_PASSL):
  4313. case(MC_CHIPL):
  4314. case(MC_BACKHEELL):
  4315. if (t>=0.3 && t<0.8)
  4316. {
  4317. // Right Footed...
  4318. t=(t-0.3);
  4319. an-=1;
  4320. }
  4321. else
  4322. {
  4323. // Left Footed...
  4324. if (t<0.3)
  4325. t=(t+0.2);
  4326. else
  4327. t=(t-0.8);
  4328. }
  4329. switch(a)
  4330. {
  4331. case(MC_TOEL):
  4332. f=0.7;
  4333. break;
  4334. default:
  4335. f=0.8;
  4336. break;
  4337. }
  4338. player->tm_anim=ABS(an);
  4339. player->tm_newanim=TRUE;
  4340. player->tm_frm=(t*f);
  4341. break;
  4342. case(MC_SHOOTL):
  4343. case(MC_CROSSL):
  4344. if (t>=0.25 && t<0.75)
  4345. {
  4346. // Right Footed...
  4347. t=(t-0.25);
  4348. an-=1;
  4349. }
  4350. else
  4351. {
  4352. // Left Footed...
  4353. if (t<0.25)
  4354. t=(t+0.25);
  4355. else
  4356. t=(t-0.75);
  4357. }
  4358. switch(a)
  4359. {
  4360. case(MC_SHOOTL):
  4361. f=0.6;
  4362. break;
  4363. case(MC_CROSSL):
  4364. f=0.5;
  4365. break;
  4366. }
  4367. player->tm_anim=ABS(an);
  4368. player->tm_newanim=TRUE;
  4369. player->tm_frm=(t*f);
  4370. break;
  4371. }
  4372. }
  4373. else
  4374. {
  4375. // Right Footed...
  4376. player->tm_anim=ABS(an);
  4377. player->tm_newanim=TRUE;
  4378. player->tm_frm=0;
  4379. }
  4380. switch(a)
  4381. {
  4382. case(MC_PASSL):
  4383. player->tm_fstep=MC_PASS_FS;
  4384. break;
  4385. case(MC_CHIPL):
  4386. player->tm_fstep=MC_CHIP_FS;
  4387. break;
  4388. case(MC_BACKHEELL):
  4389. player->tm_fstep=MC_BACKHEEL_FS;
  4390. break;
  4391. case(MC_SHOOTL):
  4392. player->tm_fstep=MC_SHOOT_FS;
  4393. break;
  4394. case(MC_CROSSL):
  4395. player->tm_fstep=MC_CROSS_FS;
  4396. break;
  4397. }
  4398. }
  4399. /******************************************************************************
  4400. *****************************************************************************/
  4401. void init_kick_l_anim(match_player *player,int a)
  4402. {
  4403. int an=a;
  4404. double n;
  4405. float t;
  4406. if (AFEQS(player->tm_anim,MC_RUN))
  4407. t=modf(player->tm_frm,&n);
  4408. else
  4409. if (AFEQS(player->tm_anim,MC_JOG))
  4410. t=modf((player->tm_frm+0.5),&n);
  4411. if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  4412. {
  4413. // Left Footed...
  4414. if (t<0.3)
  4415. t=(t+0.2);
  4416. else
  4417. if (t>0.8)
  4418. t=(t-0.8);
  4419. else
  4420. t=0;
  4421. player->tm_frm=(t*0.8);
  4422. }
  4423. else
  4424. player->tm_frm=0;
  4425. player->tm_anim=ABS(an);
  4426. player->tm_newanim=TRUE;
  4427. switch(an)
  4428. {
  4429. case(MC_DIAGPASSL):
  4430. player->tm_fstep=MC_DIAGPASS_FS;
  4431. break;
  4432. case(MC_DIAGBACKL):
  4433. player->tm_fstep=MC_DIAGBACK_FS;
  4434. break;
  4435. case(MC_SIDEPASSL):
  4436. player->tm_fstep=MC_SIDEPASS_FS;
  4437. break;
  4438. }
  4439. }
  4440. /******************************************************************************
  4441. *****************************************************************************/
  4442. void init_kick_r_anim(match_player *player,int a)
  4443. {
  4444. int an=a;
  4445. double n;
  4446. float t;
  4447. if (AFEQS(player->tm_anim,MC_RUN))
  4448. t=modf(player->tm_frm,&n);
  4449. else
  4450. if (AFEQS(player->tm_anim,MC_JOG))
  4451. t=modf((player->tm_frm+0.5),&n);
  4452. if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  4453. {
  4454. if (t>=0.3 && t<0.8)
  4455. {
  4456. // Right Footed...
  4457. t=(t-0.3);
  4458. }
  4459. else
  4460. t=0;
  4461. player->tm_frm=(t*0.8);
  4462. }
  4463. else
  4464. player->tm_frm=0;
  4465. player->tm_anim=ABS(an);
  4466. player->tm_newanim=TRUE;
  4467. switch(an)
  4468. {
  4469. case(MC_DIAGPASSR):
  4470. player->tm_fstep=MC_DIAGPASS_FS;
  4471. break;
  4472. case(MC_DIAGBACKR):
  4473. player->tm_fstep=MC_DIAGBACK_FS;
  4474. break;
  4475. case(MC_SIDEPASSR):
  4476. player->tm_fstep=MC_SIDEPASS_FS;
  4477. break;
  4478. }
  4479. }
  4480. /******************************************************************************
  4481. *****************************************************************************/
  4482. void init_trap_anim(match_player *player)
  4483. {
  4484. player->tm_fstep=MC_TRAP_FS*fstep_factor(player->tm_cont);
  4485. player->tm_frm=0;
  4486. player->tm_newanim=TRUE;
  4487. double n;
  4488. if (AFEQS(player->tm_anim,MC_RUN))
  4489. {
  4490. if (modf(player->tm_frm,&n)>=0.4 && modf(player->tm_frm,&n)<0.9)
  4491. {
  4492. // Left Footed Trap...
  4493. player->tm_anim=MC_TRAPL;
  4494. }
  4495. else
  4496. {
  4497. // Right Footed Trap...
  4498. player->tm_anim=MC_TRAPR;
  4499. }
  4500. }
  4501. else
  4502. {
  4503. // Right Footed Trap...
  4504. player->tm_anim=MC_TRAPR;
  4505. }
  4506. }
  4507. /******************************************************************************
  4508. *****************************************************************************/
  4509. void init_ride_anim(match_player *player)
  4510. {
  4511. double n;
  4512. float t;
  4513. if (AFEQS(player->tm_anim,MC_RUN))
  4514. t=modf(player->tm_frm,&n);
  4515. else
  4516. if (AFEQS(player->tm_anim,MC_JOG))
  4517. t=modf((player->tm_frm+0.5),&n);
  4518. if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  4519. {
  4520. if (t>=0.35 && t<0.85)
  4521. {
  4522. // Left Footed...
  4523. player->tm_anim=MC_RIDEL;
  4524. player->tm_newanim=TRUE;
  4525. t=(t-0.35);
  4526. }
  4527. else
  4528. {
  4529. // Right Footed...
  4530. player->tm_anim=MC_RIDER;
  4531. player->tm_newanim=TRUE;
  4532. if (t>=0.85)
  4533. t=t-0.85;
  4534. else
  4535. t=t+0.15;
  4536. }
  4537. player->tm_frm=(t*2/5);
  4538. }
  4539. else
  4540. {
  4541. player->tm_frm=0;
  4542. player->tm_anim=MC_RIDEL;
  4543. player->tm_newanim=TRUE;
  4544. }
  4545. // Player's speed and flair determine how fast he rides tackle...
  4546. float f=(player->tm_flair+player->tm_rate)/2;
  4547. f=MC_RIDE_FS+(0.000536*f);
  4548. player->tm_fstep=f;
  4549. }
  4550. /******************************************************************************
  4551. *****************************************************************************/
  4552. void init_tack_anim(match_player *player)
  4553. {
  4554. player->tm_fstep=MC_S_TACKLE_FS;
  4555. player->tm_anim=MC_S_TACKLE;
  4556. player->tm_newanim=TRUE;
  4557. player->tm_frm=0;
  4558. }
  4559. /******************************************************************************
  4560. *****************************************************************************/
  4561. void init_shdr_anim(match_player *player)
  4562. {
  4563. if ((ABS((int)player->tm_anim)!=MC_S_HEAD) && (ABS((int)player->tm_anim)!=MC_J_HEAD))
  4564. {
  4565. player->tm_fstep=MC_S_HEAD_FS*fstep_factor(player->tm_flair);
  4566. player->tm_anim=MC_S_HEAD;
  4567. player->tm_newanim=TRUE;
  4568. player->tm_frm=0;
  4569. }
  4570. }
  4571. /******************************************************************************
  4572. *****************************************************************************/
  4573. void init_jhdr_anim(match_player *player)
  4574. {
  4575. player->tm_fstep=MC_J_HEAD_FS*fstep_factor(player->tm_flair);
  4576. player->tm_anim=MC_J_HEAD;
  4577. player->tm_newanim=TRUE;
  4578. player->tm_frm=0;
  4579. }
  4580. /******************************************************************************
  4581. *****************************************************************************/
  4582. void init_dhdr_anim(match_player *player)
  4583. {
  4584. player->tm_fstep=MC_DV_HEAD_FS*fstep_factor(player->tm_flair);
  4585. player->tm_anim=MC_DV_HEAD;
  4586. player->tm_newanim=TRUE;
  4587. player->tm_frm=0;
  4588. }
  4589. /******************************************************************************
  4590. *****************************************************************************/
  4591. void init_ohd_anim(match_player *player)
  4592. {
  4593. player->tm_fstep=MC_OVERHEAD_FS*fstep_factor(player->tm_flair);
  4594. player->tm_anim=MC_OVERHEAD;
  4595. player->tm_newanim=TRUE;
  4596. player->tm_frm=0;
  4597. }
  4598. /******************************************************************************
  4599. *****************************************************************************/
  4600. void init_voll_anim(match_player *player)
  4601. {
  4602. player->tm_fstep=MC_VOLLEY_FS*fstep_factor(player->tm_flair);
  4603. player->tm_anim=MC_VOLLEYL;
  4604. player->tm_newanim=TRUE;
  4605. player->tm_frm=0;
  4606. }
  4607. /******************************************************************************
  4608. *****************************************************************************/
  4609. void init_fallr_anim(match_player *player)
  4610. {
  4611. player->tm_fstep=MC_FALLR_FS;
  4612. player->tm_anim=MC_FALLR;
  4613. player->tm_newanim=TRUE;
  4614. player->tm_frm=0;
  4615. }
  4616. /******************************************************************************
  4617. *****************************************************************************/
  4618. void init_chest_anim(match_player *player)
  4619. {
  4620. player->tm_fstep=MC_CHEST_FS*fstep_factor(player->tm_cont);
  4621. player->tm_anim=MC_CHEST;
  4622. player->tm_newanim=TRUE;
  4623. player->tm_frm=0;
  4624. }
  4625. /******************************************************************************
  4626. *****************************************************************************/
  4627. void init_dnhead_anim(match_player *player)
  4628. {
  4629. player->tm_fstep=MC_D_HEAD_FS*fstep_factor(player->tm_cont);
  4630. player->tm_anim=MC_D_HEAD;
  4631. player->tm_newanim=TRUE;
  4632. player->tm_frm=0;
  4633. }
  4634. /******************************************************************************
  4635. *****************************************************************************/
  4636. void init_getupf_anim(match_player *player)
  4637. {
  4638. player->tm_fstep=MC_GETUPF_FS;
  4639. player->tm_anim=MC_GETUPF;
  4640. player->tm_newanim=TRUE;
  4641. player->tm_frm=0;
  4642. }
  4643. /******************************************************************************
  4644. *****************************************************************************/
  4645. void init_getup_anim(match_player *player)
  4646. {
  4647. player->tm_fstep=MC_GETUP_FS;
  4648. player->tm_anim=MC_GETUP;
  4649. player->tm_newanim=TRUE;
  4650. player->tm_frm=0;
  4651. }
  4652. /******************************************************************************
  4653. *****************************************************************************/
  4654. void init_save_anim(match_player *player,int an)
  4655. {
  4656. player->tm_anim=ABS(an);
  4657. player->tm_newanim=TRUE;
  4658. player->tm_frm=0;
  4659. }
  4660. /******************************************************************************
  4661. *****************************************************************************/
  4662. void init_bounce_anim(match_player *player)
  4663. {
  4664. player->tm_anim=MC_BOUNCE;
  4665. player->tm_newanim=TRUE;
  4666. player->tm_frm=0;
  4667. player->tm_fstep=MC_BOUNCE_FS;
  4668. }
  4669. /******************************************************************************
  4670. *****************************************************************************/
  4671. void init_kout_anim(match_player *player)
  4672. {
  4673. player->tm_anim=MC_KICKOUT;
  4674. player->tm_newanim=TRUE;
  4675. player->tm_frm=0;
  4676. player->tm_fstep=MC_KICKOUT_FS;
  4677. }
  4678. /******************************************************************************
  4679. *****************************************************************************/
  4680. void init_hvoll_anim(match_player *player)
  4681. {
  4682. player->tm_anim=MC_HALFVOLL;
  4683. player->tm_newanim=TRUE;
  4684. player->tm_frm=0;
  4685. player->tm_fstep=MC_HALFVOLL_FS;
  4686. }
  4687. /******************************************************************************
  4688. *****************************************************************************/
  4689. void init_throw_anim(match_player *player)
  4690. {
  4691. player->tm_anim=MC_THROW;
  4692. player->tm_newanim=TRUE;
  4693. player->tm_frm=0;
  4694. player->tm_fstep=MC_THROW_FS;
  4695. }
  4696. /******************************************************************************
  4697. *****************************************************************************/
  4698. void init_roll_anim(match_player *player)
  4699. {
  4700. player->tm_anim=MC_ROLL;
  4701. player->tm_newanim=TRUE;
  4702. player->tm_frm=0;
  4703. player->tm_fstep=MC_ROLL_FS;
  4704. }
  4705. /******************************************************************************
  4706. *****************************************************************************/
  4707. void init_runb_anim(match_player *player)
  4708. {
  4709. player->tm_anim=MC_RUNWITHB;
  4710. player->tm_newanim=TRUE;
  4711. player->tm_frm=0;
  4712. player->tm_fstep=MC_RUNWITHB_FS;
  4713. }
  4714. /******************************************************************************
  4715. *****************************************************************************/
  4716. void init_waveup_anim(match_player *player)
  4717. {
  4718. player->tm_anim=MC_WAVEUP;
  4719. player->tm_newanim=TRUE;
  4720. player->tm_frm=0;
  4721. player->tm_fstep=MC_WAVEUP_FS;
  4722. }
  4723. /******************************************************************************
  4724. *****************************************************************************/
  4725. void init_throwl_anim(match_player *player)
  4726. {
  4727. player->tm_anim=MC_THROWL;
  4728. player->tm_newanim=TRUE;
  4729. player->tm_frm=0.02;
  4730. player->tm_fstep=MC_THROWL_FS;
  4731. }
  4732. /******************************************************************************
  4733. *****************************************************************************/
  4734. void init_throws_anim(match_player *player)
  4735. {
  4736. player->tm_anim=MC_THROWS;
  4737. player->tm_newanim=TRUE;
  4738. player->tm_frm=0.02;
  4739. player->tm_fstep=MC_THROWS_FS;
  4740. }
  4741. /******************************************************************************
  4742. *****************************************************************************/
  4743. void init_crtostb_anim(match_player *player)
  4744. {
  4745. player->tm_anim=MC_CRTOSTB;
  4746. player->tm_newanim=TRUE;
  4747. player->tm_frm=0;
  4748. player->tm_fstep=MC_CRTOSTB_FS;
  4749. }
  4750. /******************************************************************************
  4751. *****************************************************************************/
  4752. void init_crl_anim(match_player *player)
  4753. {
  4754. player->tm_anim=MC_CROSSL;
  4755. player->tm_newanim=TRUE;
  4756. player->tm_frm=0;
  4757. player->tm_fstep=MC_CROSS_FS;
  4758. }
  4759. /******************************************************************************
  4760. *****************************************************************************/
  4761. void init_crr_anim(match_player *player)
  4762. {
  4763. player->tm_anim=MC_CROSSR;
  4764. player->tm_newanim=TRUE;
  4765. player->tm_frm=0;
  4766. player->tm_fstep=MC_CROSS_FS;
  4767. }
  4768. /******************************************************************************
  4769. *****************************************************************************/
  4770. void init_tostand_anim(match_player *player,int an)
  4771. {
  4772. player->tm_anim=ABS(an);
  4773. player->tm_newanim=TRUE;
  4774. player->tm_frm=0;
  4775. player->tm_fstep=MC_STOS_FS;
  4776. }
  4777. /******************************************************************************
  4778. *****************************************************************************/
  4779. void init_tostandb_anim(match_player *player,int an)
  4780. {
  4781. player->tm_anim=ABS(an);
  4782. player->tm_newanim=TRUE;
  4783. player->tm_frm=0;
  4784. player->tm_fstep=MC_STOSB_FS;
  4785. }
  4786. /******************************************************************************
  4787. *****************************************************************************/
  4788. void init_socks_anim(match_player *player,int an)
  4789. {
  4790. player->tm_anim=ABS(an);
  4791. player->tm_newanim=TRUE;
  4792. player->tm_frm=0;
  4793. player->tm_fstep=MC_SOCKS_FS;
  4794. }
  4795. /******************************************************************************
  4796. *****************************************************************************/
  4797. void init_celeb_anim(match_player *player,int an)
  4798. {
  4799. player->tm_anim=ABS(an);
  4800. player->tm_newanim=TRUE;
  4801. player->tm_frm=0;
  4802. switch(an)
  4803. {
  4804. case(MC_CELEB):
  4805. player->tm_fstep=MC_CELEB_FS;
  4806. break;
  4807. case(MC_PUMP):
  4808. player->tm_fstep=MC_PUMP_FS;
  4809. break;
  4810. case(MC_BABY):
  4811. player->tm_fstep=MC_BABY_FS;
  4812. break;
  4813. case(MC_REEVES):
  4814. player->tm_fstep=MC_REEVES_FS;
  4815. break;
  4816. case(MC_MILLER):
  4817. player->tm_fstep=MC_MILLER_FS;
  4818. break;
  4819. case(MC_PLANE):
  4820. player->tm_fstep=MC_PLANE_FS;
  4821. break;
  4822. case(MC_FINGER):
  4823. player->tm_fstep=MC_FINGER_FS;
  4824. break;
  4825. case(MC_KNEE):
  4826. player->tm_fstep=MC_KNEE_FS;
  4827. break;
  4828. case(MC_MOON):
  4829. player->tm_fstep=MC_MOON_FS;
  4830. break;
  4831. case(MC_DUCK):
  4832. player->tm_fstep=MC_DUCK_FS;
  4833. break;
  4834. }
  4835. }
  4836. /******************************************************************************
  4837. *****************************************************************************/
  4838. void init_pickup_anim(match_player *player)
  4839. {
  4840. player->tm_anim=MC_PICKBALL;
  4841. player->tm_newanim=TRUE;
  4842. player->tm_frm=0;
  4843. player->tm_fstep=MC_PICKBALL_FS;
  4844. }
  4845. /******************************************************************************
  4846. *****************************************************************************/
  4847. void init_trot_anim(match_player *player)
  4848. {
  4849. float x=player->go_tx-player->tm_x;
  4850. float y=player->go_ty-player->tm_y;
  4851. float d=calc_dist(x,y);
  4852. // d is effective speed!
  4853. player->tm_fstep=actual_spd(player)*MC_TROTA_FS/2;
  4854. x=x/d;
  4855. y=y/d;
  4856. float nx=(x*player->tm_xdis)+(y*player->tm_ydis);
  4857. float ny=(y*player->tm_xdis)-(x*player->tm_ydis);
  4858. if (player->tm_anim<MC_TROTB || player->tm_anim>MC_TROTE)
  4859. // Not currently in trot animation...
  4860. {
  4861. player->tm_frm=0;
  4862. player->tm_newanim=TRUE;
  4863. }
  4864. switch((1+get_dir(nx,ny)))
  4865. {
  4866. case(8):
  4867. player->tm_anim=MC_TROTF;
  4868. break;
  4869. case(7):
  4870. player->tm_anim=MC_TROTG;
  4871. break;
  4872. case(6):
  4873. player->tm_anim=MC_TROTH;
  4874. break;
  4875. case(5):
  4876. player->tm_anim=MC_TROTA;
  4877. break;
  4878. case(4):
  4879. player->tm_anim=MC_TROTB;
  4880. break;
  4881. case(3):
  4882. player->tm_anim=MC_TROTC;
  4883. break;
  4884. case(2):
  4885. player->tm_anim=MC_TROTD;
  4886. break;
  4887. case(1):
  4888. player->tm_anim=MC_TROTE;
  4889. break;
  4890. }
  4891. }
  4892. /******************************************************************************
  4893. *****************************************************************************/
  4894. void init_anim(match_player *player,int an)
  4895. {
  4896. /*
  4897. if (player->tm_act==STAND_ACT)
  4898. {
  4899. // Prevent temporary jump to stand animation!
  4900. player->tm_anim=player->ls_anim;
  4901. player->tm_frm=player->ls_frm;
  4902. }
  4903. */
  4904. if (an>=MC_AFOOTB && an<=MC_CJUMPBR)
  4905. {
  4906. init_save_anim(player,an);
  4907. }
  4908. else
  4909. {
  4910. switch(an)
  4911. {
  4912. case(MC_PASSL):
  4913. case(MC_CHIPL):
  4914. case(MC_SHOOTL):
  4915. case(MC_BACKHEELL):
  4916. init_kick_anim(player,an);
  4917. break;
  4918. case(MC_DIAGPASSL):
  4919. case(MC_DIAGBACKL):
  4920. case(MC_SIDEPASSL):
  4921. init_kick_l_anim(player,an);
  4922. break;
  4923. case(MC_CROSSL):
  4924. init_crl_anim(player);
  4925. break;
  4926. case(MC_CROSSR):
  4927. init_crr_anim(player);
  4928. break;
  4929. case(MC_DIAGPASSR):
  4930. case(MC_DIAGBACKR):
  4931. case(MC_SIDEPASSR):
  4932. init_kick_r_anim(player,an);
  4933. break;
  4934. case(MC_STOSL):
  4935. case(MC_STOSR):
  4936. init_tostand_anim(player,an);
  4937. break;
  4938. case(MC_STOSBL):
  4939. case(MC_STOSBR):
  4940. init_tostandb_anim(player,an);
  4941. break;
  4942. case(MC_CRTOSTB):
  4943. init_crtostb_anim(player);
  4944. break;
  4945. case(MC_STAND):
  4946. init_stand_anim(player);
  4947. break;
  4948. case(MC_PENALTY):
  4949. #ifdef EURO96
  4950. init_penalty_anim(player);
  4951. #else
  4952. init_stand_anim(player);
  4953. #endif
  4954. break;
  4955. case(MC_SHAME):
  4956. init_shame_anim(player);
  4957. break;
  4958. case(MC_TRAPL):
  4959. init_trap_anim(player);
  4960. break;
  4961. case(MC_CHEST):
  4962. init_chest_anim(player);
  4963. break;
  4964. case(MC_D_HEAD):
  4965. init_dnhead_anim(player);
  4966. break;
  4967. case(MC_BARGE):
  4968. init_barge_anim(player);
  4969. break;
  4970. case(MC_RUN):
  4971. init_run_anim(player);
  4972. break;
  4973. case(MC_JOG):
  4974. init_jog_anim(player);
  4975. break;
  4976. case(MC_TROTA):
  4977. init_trot_anim(player);
  4978. break;
  4979. case(MC_S_TACKLE):
  4980. init_tack_anim(player);
  4981. break;
  4982. case(MC_DV_HEAD):
  4983. init_dhdr_anim(player);
  4984. break;
  4985. case(MC_S_HEAD):
  4986. init_shdr_anim(player);
  4987. break;
  4988. case(MC_J_HEAD):
  4989. init_jhdr_anim(player);
  4990. break;
  4991. case(MC_OVERHEAD):
  4992. init_ohd_anim(player);
  4993. break;
  4994. case(MC_VOLLEYL):
  4995. init_voll_anim(player);
  4996. break;
  4997. case(MC_FALLR):
  4998. init_fallr_anim(player);
  4999. break;
  5000. case(MC_GETUPF):
  5001. init_getupf_anim(player);
  5002. break;
  5003. case(MC_GETUP):
  5004. init_getup_anim(player);
  5005. break;
  5006. case(MC_RIDEL):
  5007. init_ride_anim(player);
  5008. break;
  5009. case(MC_SOCKSL):
  5010. case(MC_SOCKSR):
  5011. init_socks_anim(player,an);
  5012. break;
  5013. case(MC_CELEB):
  5014. case(MC_KNEE):
  5015. case(MC_DUCK):
  5016. case(MC_MOON):
  5017. case(MC_MILLER):
  5018. case(MC_BABY):
  5019. case(MC_PUMP):
  5020. case(MC_REEVES):
  5021. case(MC_FINGER):
  5022. case(MC_PLANE):
  5023. init_celeb_anim(player,an);
  5024. break;
  5025. case(MC_PICKBALL):
  5026. init_pickup_anim(player);
  5027. break;
  5028. // Keeper specific anims...
  5029. case(MC_STANDB):
  5030. init_standb_anim(player);
  5031. break;
  5032. case(MC_BOUNCE):
  5033. init_bounce_anim(player);
  5034. break;
  5035. case(MC_KICKOUT):
  5036. init_kout_anim(player);
  5037. break;
  5038. case(MC_HALFVOLL):
  5039. init_hvoll_anim(player);
  5040. break;
  5041. case(MC_THROW):
  5042. init_throw_anim(player);
  5043. break;
  5044. case(MC_ROLL):
  5045. init_roll_anim(player);
  5046. break;
  5047. case(MC_RUNWITHB):
  5048. init_runb_anim(player);
  5049. break;
  5050. case(MC_WAVEUP):
  5051. init_waveup_anim(player);
  5052. break;
  5053. /*
  5054. case(MC_PENALTY):
  5055. init_penalty_anim(player);
  5056. break;
  5057. */
  5058. case(MC_THROWL):
  5059. init_throwl_anim(player);
  5060. break;
  5061. case(MC_THROWS):
  5062. init_throws_anim(player);
  5063. break;
  5064. }
  5065. }
  5066. }
  5067. /******************************************************************************
  5068. *****************************************************************************/
  5069. void process_anims(match_player *player)
  5070. {
  5071. if (!(ABS(player->tm_anim)==MC_THROWL && player->tm_frm<0.001))
  5072. // Initial throw-in animation is frozen...
  5073. player->tm_frm+=player->tm_fstep;
  5074. if (player->tm_anim==MC_BARGE && player->tm_act==RUN_ACT)
  5075. {
  5076. if (!(--player->tm_barge))
  5077. init_anim(player,MC_RUN);
  5078. }
  5079. else
  5080. player->tm_barge=0;
  5081. if (player->tm_limbo)
  5082. {
  5083. if (!--player->tm_limbo)
  5084. {
  5085. // Finished animation...
  5086. int a=ABS(player->tm_anim);
  5087. switch(a)
  5088. {
  5089. case(MC_KICKOUT):
  5090. case(MC_HALFVOLL):
  5091. case(MC_THROW):
  5092. case(MC_THROWL):
  5093. case(MC_THROWS):
  5094. case(MC_ROLL):
  5095. case(MC_GETUPF):
  5096. case(MC_GETUP):
  5097. init_stand_act(player);
  5098. }
  5099. }
  5100. }
  5101. }
  5102. /******************************************************************************
  5103. ******************************************************************************/
  5104. // User controls player...
  5105. void user_play(int player_num)
  5106. {
  5107. user_conts(&teams[player_num-1]);
  5108. override(&teams[player_num-1]);
  5109. player_ints(&teams[player_num-1]);
  5110. user_intelligence(&teams[player_num-1]);
  5111. if (!teams[player_num-1].tm_limbo && (ball_limbo_on<=0 || (ball_limbo_on>0 && ball_limbo_p!=player_num)))
  5112. {
  5113. player_comment(&teams[player_num-1]);
  5114. do_action();
  5115. }
  5116. }
  5117. /******************************************************************************
  5118. *****************************************************************************/
  5119. // Computer controls player...
  5120. void computer_play(int player_num)
  5121. {
  5122. #ifdef EURO96
  5123. if (setp_taker==player_num && ((player_num<12 && !auto_users_a)
  5124. || (player_num>11 && !auto_users_b)) && already_there
  5125. && (match_mode==PEN_KICK_A || match_mode==PEN_KICK_B))
  5126. {
  5127. if (!allow_replay)
  5128. init_replay();
  5129. if (ball_poss!=setp_taker)
  5130. collect_ball(&teams[setp_taker-1]);
  5131. // Must be a computer penalty kick...
  5132. if (reselection)
  5133. {
  5134. setp_kick_x=teams[setp_taker-1].tm_xdis;
  5135. setp_kick_y=teams[setp_taker-1].tm_ydis;
  5136. setp_power=0;
  5137. setp_hgt=0;
  5138. setp_byd=cntspot_y;
  5139. setp_bzd=0;
  5140. reselection=FALSE;
  5141. }
  5142. comp_set_piece(&teams[player_num-1]);
  5143. }
  5144. else
  5145. #endif
  5146. {
  5147. teams[player_num-1].tm_htype=HLITE_OFF; // Turn highlight off!
  5148. override(&teams[player_num-1]);
  5149. player_ints(&teams[player_num-1]);
  5150. intelligence(&teams[player_num-1]);
  5151. if (!teams[player_num-1].tm_limbo && (ball_limbo_on<=0 || (ball_limbo_on>0 && ball_limbo_p!=player_num)))
  5152. {
  5153. player_comment(&teams[player_num-1]);
  5154. do_action();
  5155. }
  5156. }
  5157. }
  5158. /******************************************************************************
  5159. *****************************************************************************/
  5160. void go_team(int p)
  5161. {
  5162. if ((p<12 && (team_a_on || p==KP_A)) || (p>=12 && (team_b_on || p==KP_B)))
  5163. {
  5164. for (player_num=p; player_num<p+players/2; player_num++)
  5165. {
  5166. if (teams[player_num-1].guy_on)
  5167. {
  5168. // For debugging purposes...
  5169. if (player_num==10)
  5170. {
  5171. player_num++;
  5172. player_num--;
  5173. }
  5174. process_anims(&teams[player_num-1]);
  5175. if (!teams[player_num-1].tm_limbo && (!ball_limbo_on || (ball_limbo_on && ball_limbo_p!=player_num)))
  5176. {
  5177. // He is NOT bound up in animation!!!
  5178. if (!just_thrown)
  5179. ball_interact(&teams[player_num-1]);
  5180. if (just_scored)
  5181. user_controlled=FALSE;
  5182. else
  5183. user_controlled=teams[player_num-1].control;
  5184. if (user_controlled)
  5185. {
  5186. // User controls player...
  5187. user_plr=player_num;
  5188. if (match_mode && match_mode!=THROW_IN_A && match_mode!=THROW_IN_B)
  5189. {
  5190. if ((user_taker==user_controlled) && (already_there))
  5191. {
  5192. user_set_piece(&teams[player_num-1]);
  5193. if (!ball_poss)
  5194. teams[player_num-1].tm_leave=-TRUE;
  5195. }
  5196. else
  5197. computer_play(player_num);
  5198. }
  5199. else
  5200. user_play(player_num);
  5201. }
  5202. else
  5203. computer_play(player_num);
  5204. if (teams[player_num-1].tm_act<=TURN_ACT || teams[player_num-1].tm_act==SAVE_ACT)
  5205. add_to_tussle_list(teams[player_num-1].tm_player);
  5206. if (!teams[player_num-1].tm_limbo && (!ball_limbo_on || (ball_limbo_on && ball_limbo_p!=player_num)))
  5207. {
  5208. process_dir(&teams[player_num-1]);
  5209. }
  5210. }
  5211. }
  5212. }
  5213. }
  5214. }
  5215. /******************************************************************************
  5216. *****************************************************************************/
  5217. void select_all_hlites()
  5218. {
  5219. char u;
  5220. short i;
  5221. char hcol=1;
  5222. for (short p=0; p<MAX_NET_USERS; p++)
  5223. {
  5224. if (users[p].control!=NET_CTRL && users[p].control && users[p].type)
  5225. {
  5226. // Controlled by a user on this machine...
  5227. if (users[p].type>0)
  5228. {
  5229. // Fixed player...
  5230. select_hlite(&teams[users[p].type-1],hcol);
  5231. hcol++;
  5232. }
  5233. else
  5234. {
  5235. // Auto-user...
  5236. if (users[p].type==-1)
  5237. {
  5238. // Team A...
  5239. for (i=0; i<11; i++)
  5240. {
  5241. if (teams[i].control==(p+1))
  5242. {
  5243. // This user...
  5244. select_hlite(&teams[i],hcol);
  5245. break;
  5246. }
  5247. }
  5248. hcol++;
  5249. }
  5250. else
  5251. {
  5252. // Team B...
  5253. for (i=11; i<22; i++)
  5254. {
  5255. if (teams[i].control==(p+1))
  5256. {
  5257. // This user...
  5258. select_hlite(&teams[i],hcol);
  5259. break;
  5260. }
  5261. }
  5262. hcol++;
  5263. }
  5264. }
  5265. }
  5266. }
  5267. }
  5268. /******************************************************************************
  5269. *****************************************************************************/
  5270. void process_teams()
  5271. {
  5272. int p;
  5273. init_tussles();
  5274. if (frame)
  5275. p=1;
  5276. else
  5277. p=12;
  5278. go_team(p);
  5279. if (p==1)
  5280. p=12;
  5281. else
  5282. p=1;
  5283. go_team(p);
  5284. if (!dead_ball_cnt && !just_scored)
  5285. player_tussles();
  5286. }