BALL.CPP 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  1. /******************************************************************************
  2. *******************************************************************************
  3. Ball movement routines...
  4. ******************************************************************************
  5. *****************************************************************************/
  6. #include "global.h"
  7. #include "defines.h"
  8. #include "externs.h"
  9. #include "audio.h"
  10. #include "front.h"
  11. #include "data.h"
  12. #include "eurofrnt\euro_int.h"
  13. extern match_data match_info;
  14. extern setup_info setup;
  15. extern stad_info stadlist[];
  16. /******************************************************************************
  17. *****************************************************************************/
  18. /******************************************************************************
  19. *****************************************************************************/
  20. float get_angle(float x,float y,float d)
  21. {
  22. float a=(acos(x/d))*180/PI;
  23. if (y<0)
  24. a=360-a;
  25. return(a);
  26. }
  27. /******************************************************************************
  28. *****************************************************************************/
  29. void get_xydis_from_ang(float a,float d)
  30. {
  31. ballxdis=((float)(d)*cos(a*PI/180));
  32. ballydis=-((float)(d)*sin(a*PI/180));
  33. }
  34. /******************************************************************************
  35. *****************************************************************************/
  36. float get_s_angle(float z,float d)
  37. {
  38. float a=(asin(z/d))*180/PI;
  39. return(a);
  40. }
  41. /******************************************************************************
  42. *****************************************************************************/
  43. void get_zdis_from_ang(float a,float d)
  44. {
  45. ballzdis=((float)(d)*sin(a*PI/180));
  46. }
  47. /******************************************************************************
  48. *****************************************************************************/
  49. void stop_ball_spin()
  50. {
  51. swerve=0;full_zspin=0;full_xyspin=0;
  52. ball_zspin=0;ball_xyspin=0;
  53. max_sw_factor=0;
  54. swerve_factor=0;
  55. rebound_ball=FALSE;
  56. headed_ball=FALSE;
  57. }
  58. /******************************************************************************
  59. *****************************************************************************/
  60. void swerve_xyz()
  61. {
  62. float x,y,z,d,dz,dn;
  63. d=calc_dist(ballxdis,ballydis);
  64. x=ballxdis/d;
  65. y=ballydis/d;
  66. dz=calc_dist(ballzdis,d);
  67. z=ballzdis/dz;
  68. dn=d/dz;
  69. ballxdis=d*((x*cos(ball_xyspin))-(y*sin(ball_xyspin)));
  70. ballydis=d*((y*cos(ball_xyspin))+(x*sin(ball_xyspin)));
  71. ballzdis=d*((z*cos(ball_zspin))+(dn*sin(ball_zspin)));
  72. }
  73. /******************************************************************************
  74. *****************************************************************************/
  75. void inc_swerve()
  76. {
  77. spin_cnt++;
  78. ball_zspin=-(full_zspin*(SW_HOLD_FACTOR/(SW_HOLD_FACTOR+spin_cnt)));
  79. if (swerve<0)
  80. ball_xyspin=-(full_xyspin*(SW_HOLD_FACTOR/(SW_HOLD_FACTOR+spin_cnt)));
  81. else
  82. ball_xyspin=(full_xyspin*(SW_HOLD_FACTOR/(SW_HOLD_FACTOR+spin_cnt)));
  83. }
  84. /******************************************************************************
  85. *****************************************************************************/
  86. void get_aftert_spin()
  87. {
  88. spin_cnt++;
  89. float xys,zs;
  90. float x,y,z,d,dz,dn;
  91. d=calc_dist(ballxdis,ballydis);
  92. x=ballxdis/d;
  93. y=ballydis/d;
  94. dz=calc_dist(ballzdis,d);
  95. z=ballzdis/dz;
  96. dn=d/dz;
  97. char u=after_touch_on-1;
  98. #ifdef SUPPORT_LP
  99. if (users[u].control==LOGPAD_CTRL)
  100. {
  101. if (!prediction)
  102. xys=1;
  103. xys=0;
  104. if (users_dir[u].f&4 && !(users_dir[u].f&8))
  105. xys=1;
  106. if (users_dir[u].f&8 && !(users_dir[u].f&4))
  107. xys=-1;
  108. }
  109. else
  110. {
  111. xys=((users_dir[u].x*shoot_y)-(users_dir[u].y*shoot_x));
  112. }
  113. #else
  114. xys=((users_dir[u].x*shoot_y)-(users_dir[u].y*shoot_x));
  115. #endif
  116. zs=((users_dir[u].x*shoot_x)+(users_dir[u].y*shoot_y));
  117. ball_xyspin=-(xys*full_xyspin*(SW_HOLD_FACTOR/(SW_HOLD_FACTOR+spin_cnt)));
  118. ball_zspin=-(zs*full_zspin*(SW_HOLD_FACTOR/(SW_HOLD_FACTOR+spin_cnt)));
  119. // ball_zspin=0.05;
  120. ballxdis=d*((x*cos(ball_xyspin))-(y*sin(ball_xyspin)));
  121. ballydis=d*((y*cos(ball_xyspin))+(x*sin(ball_xyspin)));
  122. ballzdis=dz*((z*cos(ball_zspin))+(dn*sin(ball_zspin)));
  123. zs=0;
  124. }
  125. /******************************************************************************
  126. *****************************************************************************/
  127. void add_spin_fx()
  128. {
  129. // if (!prediction)
  130. {
  131. if (swerve!=0)
  132. {
  133. float d=calc_dist(ballxdis,ballydis);
  134. if (d<1)
  135. // Ball is hardly travelling (swerve OFF)
  136. stop_ball_spin();
  137. else
  138. {
  139. inc_swerve();
  140. swerve_xyz();
  141. }
  142. }
  143. else
  144. {
  145. if (after_touch_on)
  146. get_aftert_spin();
  147. }
  148. if (shot_pending)
  149. {
  150. swerve_factor=ABS(ball_xyspin);
  151. if (swerve_factor>max_sw_factor)
  152. max_sw_factor=swerve_factor;
  153. }
  154. }
  155. }
  156. /******************************************************************************
  157. *****************************************************************************/
  158. void move_ball()
  159. {
  160. ballx+=ballxdis;
  161. bally+=ballydis;
  162. if (prediction)
  163. {
  164. ns_ballx=ballx;
  165. ns_bally=bally;
  166. ns_ballz=ballz;
  167. }
  168. if (ball_inair)
  169. {
  170. ballz+=ballzdis;
  171. if (ballz<ball_diam/2)
  172. {
  173. ballz=ball_diam/2;
  174. ballzdis=-ballzdis;
  175. ballzdis-=bounce_dis;
  176. // Landing friction...
  177. ballxdis=ballxdis-(0.1*ballxdis);
  178. ballydis=ballydis-(0.1*ballydis);
  179. if (ballzdis<0)
  180. {
  181. ballzdis=0;
  182. ball_inair=0;
  183. }
  184. else
  185. if (!prediction)
  186. {
  187. if (ABS(ballzdis)>7)
  188. play_fx(PS_HARDBOUNCE,ballx,bally);
  189. else
  190. play_fx(PS_SOFTBOUNCE,ballx,bally);
  191. }
  192. }
  193. if (ball_inair)
  194. {
  195. add_spin_fx();
  196. if (!prediction)
  197. {
  198. ball_horz_ang+=ball_xyspin*40;
  199. float x,y,d;
  200. d=((cos(ball_horz_ang)*launch_x)+(sin(ball_horz_ang)*launch_y));
  201. if (d>1.0)
  202. d=1;
  203. if (d<-1.0)
  204. d=-1;
  205. ball_vert_ang+=d*(-ball_zspin*40);
  206. ball_vert_ang+=IN_AIR_SPIN*launch_type;
  207. }
  208. }
  209. }
  210. }
  211. /******************************************************************************
  212. *****************************************************************************/
  213. void grav_ball()
  214. {
  215. if (ball_inair)
  216. {
  217. ballzdis-=gravity;
  218. }
  219. }
  220. /******************************************************************************
  221. *****************************************************************************/
  222. void ball_friction()
  223. {
  224. float friction_factor;
  225. if (ball_inair)
  226. friction_factor=AIR_FRICTION;
  227. else
  228. friction_factor=GRND_FRICTION;
  229. if (wind_on)
  230. // Wind Fx...
  231. {
  232. float wf=wind_speed/(800-(ballz*2));
  233. if (wf>MAX_WIND)
  234. wf=MAX_WIND;
  235. ballxdis+=wind_x*wf;
  236. ballydis+=wind_y*wf;
  237. }
  238. ballxdis=(friction_factor*ballxdis);
  239. ballydis=(friction_factor*ballydis);
  240. if (!ball_inair)
  241. {
  242. if ((ballxdis>-0.25) && (ballxdis<0.25))
  243. ballxdis=0;
  244. if ((ballydis>-0.25) && (ballydis<0.25))
  245. ballydis=0;
  246. }
  247. }
  248. /******************************************************************************
  249. *****************************************************************************/
  250. void roll_ball()
  251. {
  252. if ((!prediction) && (!ball_inair))
  253. {
  254. // Roll ball...
  255. float x=ballxdis;
  256. float y=ballydis;
  257. float d=calc_dist(x,y);
  258. x=x/d;
  259. y=y/d;
  260. ball_horz_ang=acos(x);
  261. if (y<0)
  262. ball_horz_ang=(PI*2)-ball_horz_ang;
  263. ball_vert_ang+=d/ball_diam;
  264. }
  265. }
  266. /******************************************************************************
  267. *****************************************************************************/
  268. void ball_trajectory()
  269. {
  270. if (!ball_poss)
  271. {
  272. if (game_action==-1)
  273. game_action=0;
  274. move_ball();
  275. grav_ball();
  276. ball_friction();
  277. }
  278. if (ballxdis || ballydis)
  279. {
  280. ball_still=0;
  281. if ((!ball_in_hands) || (!ball_poss))
  282. roll_ball();
  283. }
  284. else
  285. ball_still=1;
  286. }
  287. /******************************************************************************
  288. *****************************************************************************/
  289. void get_ball_zone()
  290. {
  291. if ((!ball_out_of_play) && ((!match_mode) || (match_mode>GOAL_KICK_BR)))
  292. {
  293. if (ball_in_hands)
  294. {
  295. if (ball_poss==KP_A)
  296. {
  297. // Pretend Goal kick for A...
  298. ball_zone1=11;
  299. ball_zone2=20;
  300. }
  301. else
  302. {
  303. if (ball_poss==KP_B)
  304. {
  305. // Pretend Goal kick for B...
  306. ball_zone1=19;
  307. ball_zone2=12;
  308. }
  309. }
  310. }
  311. else
  312. {
  313. int bx1=ballx;
  314. int bx2=ballx;
  315. int by1=bally;
  316. int by2=bally;
  317. bx1=((bx1+(zone_wid/2))/(zone_wid));
  318. zone1_x=bx1*zone_wid;
  319. bx2=7-bx1;
  320. zone2_x=bx2*zone_wid;
  321. by1=((by1+(zone_hgt/2))/(zone_hgt));
  322. zone1_y=by1*zone_hgt;
  323. by2=3-by1;
  324. zone2_y=by2*zone_hgt;
  325. if (by2>=0)
  326. {
  327. ball_zone1=(by1*8)+bx1;
  328. ball_zone2=(by2*8)+bx2;
  329. }
  330. }
  331. }
  332. }
  333. /******************************************************************************
  334. *****************************************************************************/
  335. void launch_ball(int p)
  336. {
  337. float d=calc_dist(ballxdis,ballydis);
  338. if (d>0.2)
  339. {
  340. launch_x=ballxdis/d;
  341. launch_y=ballydis/d;
  342. ball_horz_ang=acos(launch_x);
  343. if (launch_y<0)
  344. ball_horz_ang=(PI*2)-ball_horz_ang;
  345. launch_type=p;
  346. }
  347. }
  348. /******************************************************************************
  349. *****************************************************************************/
  350. void reset_shot()
  351. {
  352. real_shot=FALSE;
  353. shot_acknowledged=FALSE;
  354. shot_pending=FALSE;
  355. after_touch_on=FALSE;
  356. swerve=FALSE;
  357. }
  358. /******************************************************************************
  359. *****************************************************************************/
  360. void new_shot(int p)
  361. {
  362. if (men_in_wall>1)
  363. wall_is_up=TRUE;
  364. else
  365. wall_is_up=FALSE;
  366. float r;
  367. shot_acknowledged=FALSE;
  368. must_shoot=FALSE;
  369. shooter=p;
  370. if (ballx>cntspot_x || (ballx<=cntspot_x && ballxdis>ABS(ballydis)))
  371. // Keeper B to see it...
  372. {
  373. r=teams[KP_B-1].tm_dist;
  374. shot_pending=-1-((128-teams[KP_B-1].tm_vis)/10);
  375. if (r<LONG_RANGE && shot_pending<-1)
  376. shot_pending=(((r*1.4)/LONG_RANGE)*(shot_pending+1))-1;
  377. if (penalty_shot && teams[KP_B-1].control)
  378. shot_pending=-1;
  379. }
  380. else
  381. // Keeper A to see it...
  382. if (ballx<=cntspot_x || (ballx>cntspot_x && ballxdis<ABS(ballydis)))
  383. {
  384. r=teams[KP_A-1].tm_dist;
  385. shot_pending=-1-((128-teams[KP_A-1].tm_vis)/10);
  386. if (r<LONG_RANGE && shot_pending<-1)
  387. shot_pending=(((r*1.4)/LONG_RANGE)*(shot_pending+1))-1;
  388. if (penalty_shot && teams[KP_A-1].control)
  389. shot_pending=-1;
  390. }
  391. }
  392. /******************************************************************************
  393. *****************************************************************************/
  394. void reset_ball()
  395. {
  396. holder_lose_ball();
  397. ballz=ball_diam/2;ballxdis=0;ballydis=0;ballzdis=0;
  398. ball_zspin=0;ball_xyspin=0;
  399. ball_inair=0;ball_still=1;super_shot=0;
  400. ball_in_goal=FALSE;
  401. last_touch=0;
  402. shot_attempt=0;
  403. stop_ball_spin();
  404. reset_all_ideas();
  405. reset_shot();
  406. use_ball_limit=FALSE;
  407. }
  408. /******************************************************************************
  409. *****************************************************************************/
  410. void respot_ball()
  411. {
  412. if (shot_pending && match_mode>=GOAL_KICK_TL && match_mode<=GOAL_KICK_BR)
  413. fired_a_shot=TRUE;
  414. else
  415. fired_a_shot=FALSE;
  416. reset_ball();
  417. if (!penalty_game)
  418. {
  419. if (last_goal==1)
  420. {
  421. match_mode=CENTRE_B;
  422. last_goal=0;
  423. }
  424. if (last_goal==2)
  425. {
  426. match_mode=CENTRE_A;
  427. last_goal=0;
  428. }
  429. if (match_mode)
  430. init_match_mode();
  431. }
  432. }
  433. /******************************************************************************
  434. *****************************************************************************/
  435. void shot_passed()
  436. {
  437. float d;
  438. if (ballx<0)
  439. {
  440. // Left goal...
  441. d=calc_dist(ballx,bally-cntspot_y);
  442. if (d>prat*8)
  443. shot_missed=-25; // Laughable attempt!
  444. else
  445. if (ballz>prat*5)
  446. shot_missed=-25; // Laughable attempt!
  447. else
  448. shot_missed=25; // good attempt!
  449. }
  450. else
  451. {
  452. if (ballx>pitch_len)
  453. {
  454. // Right goal...
  455. d=calc_dist(ballx-pitch_len,bally-cntspot_y);
  456. if (d>prat*8)
  457. shot_missed=-15; // Laughable attempt!
  458. else
  459. if (ballz>prat*5)
  460. shot_missed=-15; // Laughable attempt!
  461. else
  462. shot_missed=15; // good attempt!
  463. }
  464. }
  465. }
  466. /******************************************************************************
  467. *****************************************************************************/
  468. void stadium_bounds()
  469. {
  470. if (ballx>(pitch_len+stadlist[setup.stadium].st_l))
  471. {
  472. ballx=(pitch_len+stadlist[setup.stadium].st_l);
  473. ballxdis=-ballxdis;
  474. }
  475. else
  476. if (ballx<-stadlist[setup.stadium].st_l)
  477. {
  478. ballx=-stadlist[setup.stadium].st_l;
  479. ballxdis=-ballxdis;
  480. }
  481. else
  482. if (bally>(pitch_wid+stadlist[setup.stadium].st_w))
  483. {
  484. bally=(pitch_wid+stadlist[setup.stadium].st_w);
  485. ballydis=-ballydis;
  486. }
  487. else
  488. if (bally<-stadlist[setup.stadium].st_w)
  489. {
  490. bally=-stadlist[setup.stadium].st_w;
  491. ballydis=-ballydis;
  492. }
  493. }
  494. /******************************************************************************
  495. *****************************************************************************/
  496. void pitch_bounds()
  497. {
  498. if ((ballx<0) || (ballx>=pitch_len) || (bally<0) || (bally>=pitch_wid))
  499. {
  500. if ((!((ball_poss) && (teams[ball_poss-1].tm_act==THROW_ACT)))
  501. && (just_thrown==FALSE))
  502. {
  503. // Not taking throw in...
  504. if (play_advantage)
  505. {
  506. retake_foul();
  507. }
  508. else
  509. {
  510. use_ball_limit=TRUE;
  511. ballx_out=ballx;
  512. bally_out=bally;
  513. ballz_out=ballz;
  514. if (shot_pending)
  515. shot_passed(); // For crowd noise...
  516. ball_out_of_play=25;
  517. match_mode=bounds_rules();
  518. }
  519. }
  520. }
  521. }
  522. /******************************************************************************
  523. *****************************************************************************/
  524. void rebound_post()
  525. {
  526. // Ball strikes post and rebounds off maintaining zdis...
  527. shot_passed(); // For crowd noise...
  528. float x,y,d,ang;
  529. d=calc_dist(ballxdis,ballydis);
  530. x=ballxdis/d;
  531. y=ballydis/d;
  532. // Get angle to come off ( favours 180 degrees )...
  533. ang=(float)(seed);
  534. af_randomize();
  535. ang+=(float)seed;
  536. af_randomize(); // Favour 128...
  537. ang=ang*PI/128;
  538. ballxdis=((x*cos(ang))-(y*sin(ang)))*d*REBOUND_FACTOR;
  539. ballydis=((y*cos(ang))+(x*sin(ang)))*d*REBOUND_FACTOR;
  540. rebound_ball=TRUE;
  541. if (shot_pending)
  542. PlayCommentaryMessage(PM_POST);
  543. }
  544. /******************************************************************************
  545. *****************************************************************************/
  546. void rebound_bar()
  547. {
  548. // Ball strikes cross-bar and rebounds off maintaining x,ydis...
  549. shot_passed(); // For crowd noise...
  550. float z,d,ndxy,dxy,ang;
  551. dxy=calc_dist(ballxdis,ballydis);
  552. d=calc_dist(dxy,ballzdis);
  553. z=ballzdis/d;
  554. // Get angle to come off ( favours 180 degrees )...
  555. ang=(float)(seed);
  556. af_randomize();
  557. ang+=(float)seed;
  558. af_randomize(); // Favour 128...
  559. ang=ang*PI/128;
  560. ballzdis=((z*cos(ang))-(dxy/d*sin(ang)))*d*REBOUND_FACTOR;
  561. ndxy=ABS(((dxy/d*cos(ang))+(z*sin(ang)))*d*REBOUND_FACTOR);
  562. ballxdis=-ballxdis*(ndxy/dxy);
  563. ballydis=ballydis*(ndxy/dxy);
  564. rebound_ball=TRUE;
  565. if (shot_pending)
  566. PlayCommentaryMessage(PM_CROSSBAR);
  567. }
  568. /******************************************************************************
  569. *****************************************************************************/
  570. void own_goal()
  571. {
  572. goal_scorer=last_touch;
  573. inc_ogs(goal_scorer);
  574. if (penalty_game)
  575. just_scored=PEN_SCORE_WAIT;
  576. else
  577. just_scored=SCORE_WAIT;
  578. reset_shot();
  579. holder_lose_ball();
  580. ball_out_of_play=25;
  581. do_goal_anim(0);
  582. shamed_player=goal_scorer;
  583. }
  584. /******************************************************************************
  585. *****************************************************************************/
  586. void good_goal()
  587. {
  588. inc_goal(goal_scorer);
  589. if (penalty_game)
  590. just_scored=PEN_SCORE_WAIT;
  591. else
  592. just_scored=SCORE_WAIT;
  593. reset_shot();
  594. holder_lose_ball();
  595. ball_out_of_play=25;
  596. do_goal_anim(0);
  597. shamed_player=0;
  598. }
  599. /******************************************************************************
  600. *****************************************************************************/
  601. void hit_goal_post()
  602. {
  603. rebound_post();
  604. if (ballx>cntspot_x)
  605. ballx=pitch_len-1;
  606. else
  607. ballx=1;
  608. reset_shot();
  609. }
  610. /******************************************************************************
  611. *****************************************************************************/
  612. void hit_cross_bar()
  613. {
  614. rebound_bar();
  615. if (ballx>cntspot_x)
  616. ballx=pitch_len-1;
  617. else
  618. ballx=1;
  619. reset_shot();
  620. }
  621. /******************************************************************************
  622. *****************************************************************************/
  623. void hit_high_side_net()
  624. {
  625. if (swerve!=0)
  626. stop_ball_spin();
  627. ballzdis=ballzdis/2;
  628. ballxdis=ballxdis/2;
  629. ballydis=-ballydis/2;
  630. bally=top_post_y;
  631. }
  632. /******************************************************************************
  633. *****************************************************************************/
  634. void hit_low_side_net()
  635. {
  636. if (swerve!=0)
  637. stop_ball_spin();
  638. ballzdis=ballzdis/2;
  639. ballxdis=ballxdis/2;
  640. ballydis=-ballydis/2;
  641. bally=bot_post_y;
  642. }
  643. /******************************************************************************
  644. *****************************************************************************/
  645. void hit_top_net()
  646. {
  647. if (swerve!=0)
  648. stop_ball_spin();
  649. ballz=goal_height+1;
  650. ballzdis=0;
  651. if (ballxdis<0)
  652. ballxdis-=2;
  653. else
  654. ballxdis+=2;
  655. ballxdis=ballxdis/2;
  656. ballydis=ballydis/2;
  657. }
  658. /******************************************************************************
  659. *****************************************************************************/
  660. void hit_inside_back_net()
  661. {
  662. if (swerve!=0)
  663. stop_ball_spin();
  664. ballzdis=ballzdis/2;
  665. ballxdis=-ballxdis/2;
  666. ballydis=ballydis/2;
  667. ballx=1-goal_depth;
  668. }
  669. /******************************************************************************
  670. *****************************************************************************/
  671. void hit_inside_back_net_r()
  672. {
  673. if (swerve!=0)
  674. stop_ball_spin();
  675. ballzdis=ballzdis/2;
  676. ballxdis=-ballxdis/2;
  677. ballydis=ballydis/2;
  678. ballx=pitch_len+goal_depth-1;
  679. }
  680. /******************************************************************************
  681. *****************************************************************************/
  682. void hit_inside_top_net()
  683. {
  684. if (swerve!=0)
  685. stop_ball_spin();
  686. ballz=goal_height-1;
  687. ballzdis=0;
  688. ballxdis=ballxdis/2;
  689. ballydis=ballydis/2;
  690. }
  691. /******************************************************************************
  692. *****************************************************************************/
  693. void hit_inside_high_side()
  694. {
  695. if (swerve!=0)
  696. stop_ball_spin();
  697. ballzdis=ballzdis/2;
  698. ballxdis=ballxdis/2;
  699. ballydis=-ballydis/2;
  700. bally=top_post_y+1;
  701. }
  702. /******************************************************************************
  703. *****************************************************************************/
  704. void hit_inside_low_side()
  705. {
  706. if (swerve!=0)
  707. stop_ball_spin();
  708. ballzdis=ballzdis/2;
  709. ballxdis=ballxdis/2;
  710. ballydis=-ballydis/2;
  711. bally=bot_post_y-1;
  712. }
  713. /******************************************************************************
  714. *****************************************************************************/
  715. short real_player(short p)
  716. {
  717. if (match_half&1)
  718. {
  719. // swapped...
  720. p=((p>11) ? p-11:p+11);
  721. }
  722. return(p);
  723. }
  724. /******************************************************************************
  725. *****************************************************************************/
  726. short standard_player(short p)
  727. {
  728. if (p>11)
  729. p-=11;
  730. return(p);
  731. }
  732. /******************************************************************************
  733. *****************************************************************************/
  734. short country(char t)
  735. {
  736. short p;
  737. if (t)
  738. p=setup.team_b;
  739. else
  740. p=setup.team_a;
  741. return(p);
  742. }
  743. /******************************************************************************
  744. *****************************************************************************/
  745. void go_right_goal()
  746. {
  747. if (golden_goal && (match_half>1 && match_half<4))
  748. {
  749. // Sudden death... Golden goal has been scored! (End of match)
  750. golden_goal=2;
  751. }
  752. if (!ball_out_of_play)
  753. {
  754. ball_in_goal=TRUE;
  755. last_goal=1;
  756. if (match_mode==NORMAL_PLAY)
  757. {
  758. if (match_half&1)
  759. team_b_goals++;
  760. else
  761. team_a_goals++;
  762. if (penalty_game)
  763. EUROmatch_info.Team_B_penalties++;
  764. if (last_touch>11)
  765. // Deflection, own goal or keeper's poss...
  766. {
  767. if (last_touch==KP_B)
  768. {
  769. // Keeper bad save...
  770. PlayCommentaryMessage(GL_KEEPER);
  771. goal_scorer=pre_kp_touch;
  772. if (goal_scorer<12)
  773. {
  774. // Opposition scored...
  775. do_goal_menu(team_a,standard_player(goal_scorer)-1,match_time.min);
  776. if (!penalty_game)
  777. GOAL_SCORED(0,(int)real_player(goal_scorer)-1,(int)match_time.min+(penalty_shot ? 256:0));
  778. good_goal();
  779. }
  780. else
  781. {
  782. // Own goal...
  783. do_owngoal_menu(team_b,standard_player(goal_scorer)-1,match_time.min);
  784. if (!penalty_game)
  785. GOAL_SCORED(0,(int)real_player(goal_scorer)-1,(int)match_time.min+512+(penalty_shot ? 256:0));
  786. own_goal();
  787. }
  788. }
  789. else
  790. {
  791. PlayCommentaryMessage(GL_DEFLECT);
  792. do_owngoal_menu(team_b,standard_player(last_touch)-1,match_time.min);
  793. if (!penalty_game)
  794. GOAL_SCORED(0,real_player(last_touch)-1,match_time.min+512+(penalty_shot ? 256:0));
  795. own_goal();
  796. }
  797. }
  798. else
  799. {
  800. if (headed_ball)
  801. PlayCommentaryMessage(GL_HEADER);
  802. else
  803. if (rebound_ball)
  804. PlayCommentaryMessage(GL_POST);
  805. else
  806. if (max_sw_factor>GOOD_SWERVE)
  807. if (wall_is_up)
  808. PlayCommentaryMessage(GL_CURVEWALL);
  809. else
  810. PlayCommentaryMessage(GL_CURVE);
  811. else
  812. if (shot_speed>18)
  813. PlayCommentaryMessage(GL_HARDKICK);
  814. else
  815. PlayCommentaryMessage(GL_GENERIC);
  816. do_goal_menu(team_a,standard_player(last_touch)-1,match_time.min);
  817. if (!penalty_game)
  818. GOAL_SCORED(0,real_player(last_touch)-1,match_time.min+(penalty_shot ? 256:0));
  819. goal_scorer=last_touch;
  820. good_goal();
  821. }
  822. }
  823. PauseCommentary();
  824. }
  825. }
  826. /******************************************************************************
  827. *****************************************************************************/
  828. void go_left_goal()
  829. {
  830. if (golden_goal && (match_half>1 && match_half<4))
  831. {
  832. // Sudden death... Golden goal has been scored! (End of match)
  833. golden_goal=2;
  834. }
  835. if (!ball_out_of_play)
  836. {
  837. ball_in_goal=TRUE;
  838. last_goal=2;
  839. if (match_mode==NORMAL_PLAY)
  840. {
  841. if (match_half&1)
  842. team_a_goals++;
  843. else
  844. team_b_goals++;
  845. if (penalty_game)
  846. EUROmatch_info.Team_A_penalties++;
  847. if (last_touch<12)
  848. // Deflection, own goal or keeper's poss...
  849. {
  850. if (last_touch==KP_A)
  851. {
  852. // Keeper bad save...
  853. PlayCommentaryMessage(GL_KEEPER);
  854. goal_scorer=pre_kp_touch;
  855. if (goal_scorer>11)
  856. {
  857. // Opposition scored...
  858. do_goal_menu(team_b,standard_player(goal_scorer)-1,match_time.min);
  859. if (!penalty_game)
  860. GOAL_SCORED(0,(int)real_player(goal_scorer)-1,(int)match_time.min+(penalty_shot ? 256:0));
  861. good_goal();
  862. }
  863. else
  864. {
  865. // Own goal...
  866. do_owngoal_menu(team_a,standard_player(goal_scorer)-1,match_time.min);
  867. if (!penalty_game)
  868. GOAL_SCORED(0,(int)real_player(goal_scorer)-1,(int)match_time.min+512+(penalty_shot ? 256:0));
  869. own_goal();
  870. }
  871. }
  872. else
  873. {
  874. PlayCommentaryMessage(GL_DEFLECT);
  875. do_owngoal_menu(team_a,standard_player(last_touch)-1,match_time.min);
  876. if (!penalty_game)
  877. GOAL_SCORED(0,real_player(last_touch)-1,match_time.min+512+(penalty_shot ? 256:0));
  878. own_goal();
  879. }
  880. }
  881. else
  882. {
  883. if (headed_ball)
  884. PlayCommentaryMessage(GL_HEADER);
  885. else
  886. if (rebound_ball)
  887. PlayCommentaryMessage(GL_POST);
  888. else
  889. if (max_sw_factor>GOOD_SWERVE)
  890. PlayCommentaryMessage(GL_CURVE);
  891. else
  892. if (shot_speed>16)
  893. PlayCommentaryMessage(GL_HARDKICK);
  894. else
  895. PlayCommentaryMessage(GL_GENERIC);
  896. do_goal_menu(team_b,standard_player(last_touch)-1,match_time.min);
  897. if (!penalty_game)
  898. GOAL_SCORED(0,real_player(last_touch)-1,match_time.min+(penalty_shot ? 256:0));
  899. goal_scorer=last_touch;
  900. good_goal();
  901. }
  902. }
  903. PauseCommentary();
  904. }
  905. }
  906. /******************************************************************************
  907. *****************************************************************************/
  908. void outside_of_net(float f,float y,float z)
  909. {
  910. float dx=ballx-prev_ballx;
  911. float dy=bally-prev_bally;
  912. float dz=ballz-prev_ballz;
  913. float x;
  914. if ((ballx<0 && prev_ballx>=0) || (ballx>pitch_len && prev_ballx<=pitch_len))
  915. {
  916. if ((z>=goal_height) && (z<goal_height+post_width)
  917. && (y>top_post_y-post_width) && (y<bot_post_y+post_width))
  918. // Hit cross Bar...
  919. {
  920. hit_cross_bar();
  921. }
  922. else
  923. {
  924. if ((z<goal_height) && (y>top_post_y-post_width)
  925. && (y<=top_post_y))
  926. // Hit Top post...
  927. {
  928. hit_goal_post();
  929. }
  930. else
  931. {
  932. if ((z<goal_height) && (y<bot_post_y+post_width)
  933. && (y>=bot_post_y))
  934. // Hit Bot post...
  935. {
  936. hit_goal_post();
  937. }
  938. else
  939. {
  940. // Try top-side netting...
  941. f=(top_post_y-prev_bally)/dy;
  942. z=prev_ballz+(f*dz);
  943. x=prev_ballx+(f*dx);
  944. if (((x>-goal_depth && x<0)
  945. || (x<pitch_len+goal_depth && x>pitch_len))
  946. && (z<goal_height))
  947. // Hit high side netting...
  948. {
  949. hit_high_side_net();
  950. }
  951. else
  952. // Try low-side netting...
  953. {
  954. f=(bot_post_y-prev_bally)/dy;
  955. z=prev_ballz+(f*dz);
  956. x=prev_ballx+(f*dx);
  957. if (((x>-goal_depth && x<0)
  958. || (x<pitch_len+goal_depth && x>pitch_len))
  959. && (z<goal_height))
  960. // Hit low side netting...
  961. {
  962. hit_low_side_net();
  963. }
  964. }
  965. }
  966. }
  967. }
  968. }
  969. else
  970. {
  971. if ((ballz<goal_height) && (prev_ballz>=goal_height))
  972. // Falling... check top net...
  973. {
  974. f=(goal_height-prev_ballz)/dz;
  975. y=prev_bally+(f*dy);
  976. x=prev_ballx+(f*dx);
  977. if (((x>-goal_depth && x<0)
  978. || (x<pitch_len+goal_depth && x>pitch_len))
  979. && (y>top_post_y) && (y<bot_post_y))
  980. // On top of net...
  981. {
  982. hit_top_net();
  983. }
  984. else
  985. // Try top-side netting...
  986. {
  987. f=(top_post_y-prev_bally)/dy;
  988. z=prev_ballz+(f*dz);
  989. x=prev_ballx+(f*dx);
  990. if (((x>-goal_depth && x<0)
  991. || (x<pitch_len+goal_depth && x>pitch_len))
  992. && (z<goal_height))
  993. // Hit high side netting...
  994. {
  995. hit_high_side_net();
  996. }
  997. else
  998. // Try low-side netting...
  999. {
  1000. f=(bot_post_y-prev_bally)/dy;
  1001. z=prev_ballz+(f*dz);
  1002. x=prev_ballx+(f*dx);
  1003. if (((x>-goal_depth && x<0)
  1004. || (x<pitch_len+goal_depth && x>pitch_len))
  1005. && (z<goal_height))
  1006. // Hit low side netting...
  1007. {
  1008. hit_low_side_net();
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. }
  1015. /******************************************************************************
  1016. *****************************************************************************/
  1017. void is_it_a_goal()
  1018. {
  1019. float dx=ballx-prev_ballx;
  1020. float dy=bally-prev_bally;
  1021. float dz=ballz-prev_ballz;
  1022. float f,x,y,z;
  1023. if (!ball_in_goal)
  1024. // Not inside goal-net...
  1025. {
  1026. if (ballx<0)
  1027. // Crossed Left goal-line...
  1028. {
  1029. f=prev_ballx/dx;
  1030. y=prev_bally-(f*dy);
  1031. z=prev_ballz-(f*dz);
  1032. if (prev_ballx>=0)
  1033. {
  1034. // Just crossed goal-line...
  1035. if ((z<goal_height) && (y>top_post_y) && (y<bot_post_y))
  1036. // Its a goal!!!!
  1037. {
  1038. go_left_goal();
  1039. }
  1040. else
  1041. {
  1042. outside_of_net(f,y,z);
  1043. }
  1044. }
  1045. else
  1046. {
  1047. outside_of_net(f,y,z);
  1048. }
  1049. }
  1050. else
  1051. // Behind Left goal-line...
  1052. {
  1053. if (ballx>pitch_len)
  1054. {
  1055. f=(pitch_len-prev_ballx)/dx;
  1056. y=prev_bally+(f*dy);
  1057. z=prev_ballz+(f*dz);
  1058. if (prev_ballx<pitch_len)
  1059. {
  1060. if ((z<goal_height) && (y>top_post_y) && (y<bot_post_y))
  1061. // Its a goal!!!!
  1062. {
  1063. go_right_goal();
  1064. }
  1065. else
  1066. {
  1067. outside_of_net(f,y,z);
  1068. }
  1069. }
  1070. else
  1071. {
  1072. outside_of_net(f,y,z);
  1073. }
  1074. }
  1075. }
  1076. }
  1077. else
  1078. // Inside goal-net...
  1079. {
  1080. if (ballx<0)
  1081. // Inside left goal...
  1082. {
  1083. if (ballx<-goal_depth)
  1084. hit_inside_back_net();
  1085. if (bally<top_post_y)
  1086. hit_inside_high_side();
  1087. if (bally>bot_post_y)
  1088. hit_inside_low_side();
  1089. if (ballz>goal_height)
  1090. hit_inside_top_net();
  1091. }
  1092. else
  1093. // Inside right goal...
  1094. {
  1095. if (ballx>pitch_len+goal_depth)
  1096. hit_inside_back_net_r();
  1097. if (bally<top_post_y)
  1098. hit_inside_high_side();
  1099. if (bally>bot_post_y)
  1100. hit_inside_low_side();
  1101. if (ballz>goal_height)
  1102. hit_inside_top_net();
  1103. }
  1104. }
  1105. }
  1106. /******************************************************************************
  1107. *****************************************************************************/
  1108. void ball_collision()
  1109. {
  1110. is_it_a_goal();
  1111. prev_ballx=ballx;
  1112. prev_bally=bally;
  1113. prev_ballz=ballz;
  1114. }
  1115. /******************************************************************************
  1116. *****************************************************************************/
  1117. void oball_collision()
  1118. {
  1119. if (ballx<cntspot_x)
  1120. {
  1121. // Left side
  1122. if (!ball_in_goal)
  1123. {
  1124. // Not in goal
  1125. if (ballx<0)
  1126. {
  1127. // Behind posts
  1128. if (prev_ballx>=-goal_depth)
  1129. {
  1130. if ((prev_ballz<goal_height) || (ballz<goal_height))
  1131. {
  1132. if (bally<cntspot_y)
  1133. {
  1134. // High side
  1135. if ((bally>top_post_y) || (prev_bally>top_post_y))
  1136. {
  1137. if ((ballz-ballzdis)>=goal_height)
  1138. hit_top_net();
  1139. if ((bally-ballydis)<=top_post_y)
  1140. {
  1141. if ((ballx-ballxdis>post_width)
  1142. && (ABS(ballxdis)>ABS(ballydis)))
  1143. hit_goal_post();
  1144. else
  1145. hit_high_side_net();
  1146. }
  1147. else
  1148. go_left_goal();
  1149. }
  1150. }
  1151. else
  1152. {
  1153. // Low side
  1154. if (bally<bot_post_y)
  1155. {
  1156. if ((ballz-ballzdis)>=goal_height)
  1157. hit_top_net();
  1158. if ((bally-ballydis)>=cntspot_y+(4*prat))
  1159. {
  1160. if ((ballx-ballxdis>post_width)
  1161. && (ABS(ballxdis)>ABS(ballydis)))
  1162. hit_goal_post();
  1163. else
  1164. hit_low_side_net();
  1165. }
  1166. else
  1167. go_left_goal();
  1168. }
  1169. }
  1170. }
  1171. }
  1172. }
  1173. else
  1174. {
  1175. if (ballx<=post_width)
  1176. // On goal line
  1177. {
  1178. if ((bally>top_post_y-post_width)
  1179. && (bally<=top_post_y)
  1180. && (ballz<=goal_height))
  1181. hit_goal_post();
  1182. if ((bally<bot_post_y+post_width)
  1183. && (bally>=bot_post_y)
  1184. && (ballz<=goal_height))
  1185. hit_goal_post();
  1186. if ((bally>top_post_y-post_width)
  1187. && (bally<bot_post_y+post_width)
  1188. && (ballz>=goal_height)
  1189. && (ballz<goal_height+post_width))
  1190. hit_cross_bar();
  1191. }
  1192. }
  1193. }
  1194. else
  1195. {
  1196. // Inside Left goal
  1197. if (ballx<-goal_depth)
  1198. hit_inside_back_net();
  1199. if (bally<top_post_y)
  1200. hit_inside_high_side();
  1201. if (bally>bot_post_y)
  1202. hit_inside_low_side();
  1203. if (ballz>goal_height)
  1204. hit_inside_top_net();
  1205. }
  1206. }
  1207. else
  1208. {
  1209. // Right side
  1210. if (!ball_in_goal)
  1211. {
  1212. // Not in goal
  1213. if (ballx>pitch_len)
  1214. {
  1215. // Behind posts
  1216. if (ballx<=pitch_len+goal_depth)
  1217. {
  1218. if (ballz<goal_height)
  1219. {
  1220. if (bally<cntspot_y)
  1221. {
  1222. // High side
  1223. if (bally>top_post_y)
  1224. {
  1225. if ((ballz-ballzdis)>=goal_height)
  1226. hit_top_net();
  1227. if ((bally-ballydis)<=top_post_y)
  1228. {
  1229. if ((ballx-ballxdis<pitch_len-post_width)
  1230. && (ABS(ballxdis)>ABS(ballydis)))
  1231. hit_goal_post();
  1232. else
  1233. hit_high_side_net();
  1234. }
  1235. else
  1236. go_right_goal();
  1237. }
  1238. }
  1239. else
  1240. {
  1241. // Low side
  1242. if (bally<bot_post_y)
  1243. {
  1244. if ((ballz-ballzdis)>=goal_height)
  1245. hit_top_net();
  1246. if ((bally-ballydis)>=cntspot_y+(4*prat))
  1247. {
  1248. if ((ballx-ballxdis<pitch_len-post_width)
  1249. && (ABS(ballxdis)>ABS(ballydis)))
  1250. hit_goal_post();
  1251. else
  1252. hit_low_side_net();
  1253. }
  1254. else
  1255. go_right_goal();
  1256. }
  1257. }
  1258. }
  1259. }
  1260. }
  1261. else
  1262. {
  1263. if (ballx>=pitch_len-post_width)
  1264. // On goal line
  1265. {
  1266. if ((bally>top_post_y-post_width)
  1267. && (bally<=top_post_y)
  1268. && (ballz<=goal_height))
  1269. hit_goal_post();
  1270. if ((bally<bot_post_y+post_width)
  1271. && (bally>=bot_post_y)
  1272. && (ballz<=goal_height))
  1273. hit_goal_post();
  1274. if ((bally>top_post_y-post_width)
  1275. && (bally<bot_post_y+post_width)
  1276. && (ballz>=goal_height)
  1277. && (ballz<goal_height+post_width))
  1278. hit_cross_bar();
  1279. }
  1280. }
  1281. }
  1282. else
  1283. {
  1284. // Inside Right goal
  1285. if (ballx>pitch_len+goal_depth)
  1286. hit_inside_back_net_r();
  1287. if (bally<top_post_y)
  1288. hit_inside_high_side();
  1289. if (bally>bot_post_y)
  1290. hit_inside_low_side();
  1291. if (ballz>goal_height)
  1292. hit_inside_top_net();
  1293. }
  1294. }
  1295. }
  1296. /******************************************************************************
  1297. *****************************************************************************/
  1298. void get_ball_speed()
  1299. {
  1300. float tot=ABS(ballxdis)+ABS(ballydis)+ABS(ballzdis);
  1301. ball_speed=sqrt(tot);
  1302. }
  1303. /******************************************************************************
  1304. *****************************************************************************/
  1305. void ball_limbo(int p,float c)
  1306. {
  1307. ball_limbo_c=ABS(c);
  1308. ball_limbo_p=p;
  1309. ball_limbo_on=TRUE;
  1310. }
  1311. /******************************************************************************
  1312. *****************************************************************************/
  1313. void ball_possession()
  1314. {
  1315. // Calculate possession for audio...
  1316. if (!just_scored && !match_mode && last_touch!=KP_A && last_touch!=KP_B)
  1317. {
  1318. good_poss+=(last_touch<12 ? ballx/20:-(pitch_len-ballx)/20);
  1319. }
  1320. if (ABS(good_poss)>MAX_GOOD_POSS)
  1321. {
  1322. if (audio_version)
  1323. PlayPossessionSample((good_poss<0 ? team_b:team_a));
  1324. good_poss=0;
  1325. }
  1326. }
  1327. /******************************************************************************
  1328. *****************************************************************************/
  1329. void process_ball()
  1330. {
  1331. ball_possession();
  1332. if (ball_limbo_on>0)
  1333. {
  1334. // Ball is bound to a player's animation and should not be processed
  1335. // until the contact point of animation is exceeded...
  1336. if (teams[ball_limbo_p-1].tm_frm+teams[ball_limbo_p-1].tm_fstep>ball_limbo_c)
  1337. // Contact exceeded...
  1338. {
  1339. ball_limbo_on=FALSE;
  1340. if (teams[ball_limbo_p-1].tm_anim==MC_KICKOUT)
  1341. play_fx(PS_HARDKICK,ballx,bally);
  1342. }
  1343. }
  1344. if ((!ball_limbo_on) && (!ball_poss || (ball_poss && teams[ball_poss-1].contact<0)))
  1345. {
  1346. prediction=FALSE;
  1347. if (shot_acknowledged)
  1348. shot_acknowledged--; // Counter for re-acknowledgement.
  1349. // if ((shot_pending) && (shooter==last_touch))
  1350. if (shot_pending)
  1351. {
  1352. if (!(++shot_pending))
  1353. shot_pending=1;
  1354. }
  1355. else
  1356. {
  1357. shot_pending=0;
  1358. real_shot=0;
  1359. }
  1360. get_ball_speed();
  1361. if (ball_out_of_play)
  1362. {
  1363. ball_trajectory();
  1364. ball_collision();
  1365. if (just_scored)
  1366. {
  1367. if (!(--just_scored))
  1368. {
  1369. ResumeCommentary();
  1370. PlayScoreSample(team_a_goals,team_b_goals);
  1371. }
  1372. }
  1373. else
  1374. {
  1375. if (!--ball_out_of_play && match_mode!=SWAP_ENDS)
  1376. {
  1377. respot_ball();
  1378. get_ball_zone();
  1379. predict_ball();
  1380. }
  1381. }
  1382. stadium_bounds();
  1383. }
  1384. else
  1385. {
  1386. ball_trajectory();
  1387. ball_collision();
  1388. if (!just_scored && match_mode!=SWAP_ENDS && match_half<=10)
  1389. {
  1390. pitch_bounds();
  1391. get_ball_zone();
  1392. predict_ball();
  1393. }
  1394. }
  1395. }
  1396. }