COL.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. #include "COL.h"
  2. #include "CBall.h"
  3. #include "CPlayer.h"
  4. #include "GM.h"
  5. #include "XMATH.h"
  6. #include "GU.h"
  7. #include "GL.h"
  8. #include "SNDGAME.h"
  9. #include "Util.h"
  10. struct TLimbInfo {
  11. int field_0;
  12. int field_4;
  13. };
  14. struct tBoneNodeInfo {
  15. int i_0;
  16. int i_4;
  17. };
  18. // 0033E918
  19. TLimbInfo COL_tLimbInfo[14] =
  20. {
  21. {20, 2},
  22. {21, 20},
  23. {5, 15},
  24. {15, 9},
  25. {9, 11},
  26. {24, 34},
  27. {34, 28},
  28. {28, 30},
  29. {12, 4},
  30. {4, 8},
  31. {8, 13},
  32. {31, 23},
  33. {23, 27},
  34. {27, 32}};
  35. tBoneNodeInfo COL_tBoneNodeInfo[42] = {
  36. {0, 0},
  37. {0, 0},
  38. {1, 4096},
  39. {0, 0},
  40. {1, 3276},
  41. {1, 3072},
  42. {0, 0},
  43. {0, 0},
  44. {1, 2730},
  45. {1, 3072},
  46. {0, 0},
  47. {1, 3072},
  48. {1, 4096},
  49. {1, 3276},
  50. {0, 0},
  51. {1, 3072},
  52. {0, 0},
  53. {0, 0},
  54. {0, 3072},
  55. {0, 3072},
  56. {1, 4096},
  57. {1, 8192},
  58. {0, 0},
  59. {1, 3276},
  60. {1, 3072},
  61. {0, 0},
  62. {0, 0},
  63. {1, 2730},
  64. {1, 3072},
  65. {0, 0},
  66. {1, 3072},
  67. {1, 4096},
  68. {1, 3276},
  69. {0, 0},
  70. {1, 3072},
  71. {0, 0},
  72. {0, 0},
  73. {0, 3072},
  74. {0, 3072},
  75. {0, 0},
  76. {0, 0},
  77. {0, 0}};
  78. void COL_PlayerBallCollideEvent(CPlayer *pPlayer_0, int i_1, bool &b_2) {
  79. TAnimData *tAnimData_r7; // r7
  80. CPlayer *pPlarer_r0; // r0
  81. CPlayer *pPlayer_r8 = 0; // r8
  82. int iStance_r0; // r0
  83. int i_r1; // r1
  84. TPoint v18; // r2
  85. TPoint v20; // r2
  86. TPoint tPoint_r0; // r0
  87. int i_v23_54; // [sp+Ch] [bp-54h]
  88. TPoint tPoint_4C; // [sp+14h] [bp-4Ch] BYREF
  89. int i_mag_44; // [sp+1Ch] [bp-44h] BYREF
  90. TPoint3D t_Point3D_40; // [sp+20h] [bp-40h] BYREF
  91. TPoint3D tPoint_30; // [sp+30h] [bp-30h] BYREF
  92. // 00171E98
  93. tAnimData_r7 = pPlayer_0->GetAnimData(); // call 001704DC
  94. pPlarer_r0 = tGame.allplay_14[tGame.mTLogic_6678.team_40]
  95. .teamlist_0[tGame.mTLogic_6678.player_3C];
  96. if (pPlarer_r0->uc_88)
  97. pPlayer_r8 = tGame.allplay_14[tGame.mTLogic_6678.team_40]
  98. .teamlist_0[tGame.mTLogic_6678.player_3C];
  99. // 00171ED8
  100. if (i_1 != -1) {
  101. // 00171EDC
  102. i_v23_54 = pPlayer_0->tStr32_44.uc_0;
  103. if (XMATH_Distance3D(&cBall.ballPosPrev_4, &tGame.mTMath_6734.field_370) <
  104. tGame.mTMath_6734.field_388[0] +
  105. tGame.mTMath_6734.field_388[1]) // call 001F3490
  106. {
  107. // 00171F0E
  108. tPoint_30.point_0.dx_0 = cBall.ballPosPrev_4.point_0.dx_0 -
  109. tGame.mTMath_6734.field_370.point_0.dx_0;
  110. tPoint_30.point_0.dy_4 = cBall.ballPosPrev_4.point_0.dy_4 -
  111. tGame.mTMath_6734.field_370.point_0.dy_4;
  112. tPoint_30.dz_8 =
  113. cBall.ballPosPrev_4.dz_8 - tGame.mTMath_6734.field_370.dz_8;
  114. XMATH_Normalize(&tPoint_30,
  115. tGame.mTMath_6734.field_388[0] +
  116. tGame.mTMath_6734.field_388[1]); // call 001F2586
  117. cBall.ballPosPrev_4.point_0.dx_0 =
  118. tGame.mTMath_6734.field_370.point_0.dx_0 + tPoint_30.point_0.dx_0;
  119. cBall.ballPosPrev_4.point_0.dy_4 =
  120. tGame.mTMath_6734.field_370.point_0.dy_4 + tPoint_30.point_0.dy_4;
  121. cBall.ballPosPrev_4.dz_8 =
  122. tPoint_30.dz_8 + tGame.mTMath_6734.field_370.dz_8;
  123. }
  124. /// 171F58
  125. if (tGame.field_6C34 <= 2 && tGame.mTLogic_6678.field_48 == 11 &&
  126. tGame.mTLogic_6678.field_44 == pPlayer_0->tStr32_44.uc_0 &&
  127. tGame.mTLogic_6678.field_50 == pPlayer_0->tStr32_44.uc_1 /// 00171F88
  128. && (tGame.mTMath_6734.field_370.point_0.dy_4 -
  129. tGame.mTMath_6734.field_37C.point_0.dy_4) /
  130. 1024 * cBall.ballMovePrev_10.point_0.dy_4 / 256 +
  131. cBall.ballMovePrev_10.point_0.dx_0 *
  132. ((tGame.mTMath_6734.field_370.point_0.dx_0 -
  133. tGame.mTMath_6734.field_37C.point_0.dx_0) /
  134. 1024) /
  135. 256 +
  136. cBall.ballMovePrev_10.dz_8 *
  137. ((tGame.mTMath_6734.field_370.dz_8 -
  138. tGame.mTMath_6734.field_37C.dz_8) /
  139. 1024) /
  140. 256 <=
  141. -1) {
  142. tGame.field_6C34 = 0;
  143. } else {
  144. // 0017200A
  145. pPlayer_0->field_14C = i_1;
  146. i_mag_44 = XMATH_Mag3D(&cBall.ballMovePrev_10); // call 001F3274
  147. if ((pPlayer_0->tStr32_44.field_8 & 0xFFFFFFFE) == 8) // 00172024
  148. {
  149. // 00172024
  150. iStance_r0 = (pPlayer_0->tStr32_44.field_14 -
  151. tAnimData_r7->filed_20[0].filed_0) /
  152. pPlayer_0->tStr32_44.field_1C; // call 002A3CC0
  153. if (iStance_r0 < 0) {
  154. iStance_r0 = -iStance_r0; // 00172036
  155. }
  156. // 00172038
  157. if (iStance_r0 > 3) {
  158. // 001720A4
  159. tPoint_4C =
  160. XMATH_Project(pPlayer_0->u_0.s_2_0.s_2, 0x8000); // 001F32DC
  161. if (i_mag_44 <= 2136) i_mag_44 = 2136;
  162. // 001720C8
  163. t_Point3D_40.point_0 = tPoint_4C;
  164. t_Point3D_40.dz_8 = (tGame.mTMath_6734.field_37C.dz_8 -
  165. tGame.mTMath_6734.field_370.dz_8) /
  166. 8;
  167. XMATH_Normalize(
  168. &t_Point3D_40,
  169. (4 * (uint)i_mag_44) / 5u); // call 002A3C14 //call 001F2586
  170. } else {
  171. // 0017203C
  172. t_Point3D_40.dz_8 = pPlayer_0->aPoint3D_178[1].dz_8;
  173. t_Point3D_40.point_0 = pPlayer_0->aPoint3D_178[1].point_0;
  174. }
  175. // 001720EE
  176. cBall.SetVel(t_Point3D_40.point_0.dx_0, t_Point3D_40.point_0.dy_4,
  177. t_Point3D_40.dz_8); // 00157668
  178. b_2 = 1;
  179. } else {
  180. // 0017204C
  181. t_Point3D_40.point_0.dx_0 = tGame.mTMath_6734.field_37C.point_0.dx_0 -
  182. tGame.mTMath_6734.field_370.point_0.dx_0;
  183. t_Point3D_40.point_0.dy_4 = tGame.mTMath_6734.field_37C.point_0.dy_4 -
  184. tGame.mTMath_6734.field_370.point_0.dy_4;
  185. t_Point3D_40.dz_8 = (tGame.mTMath_6734.field_37C.dz_8 -
  186. tGame.mTMath_6734.field_370.dz_8) /
  187. 8;
  188. XMATH_Normalize(&t_Point3D_40, i_mag_44); // call 001F2586
  189. // 0017208C
  190. if ((pPlayer_r8 == 0 || pPlayer_r8 == pPlayer_0)) // call 001F328A
  191. {
  192. // 00172098
  193. cBall.SetVel(t_Point3D_40.point_0.dx_0, t_Point3D_40.point_0.dy_4,
  194. t_Point3D_40.dz_8); // call 00157668
  195. } else {
  196. // loc_1721CE
  197. if(XMATH_Mag(&pPlayer_r8->Point3D_14.point_0)>(i_mag_44/2)){
  198. GM_DeflectBallFromDribbler(pPlayer_0, &i_mag_44); // 00171E50
  199. b_2 = 1;
  200. }else{
  201. // 00172098
  202. cBall.SetVel(t_Point3D_40.point_0.dx_0, t_Point3D_40.point_0.dy_4,
  203. t_Point3D_40.dz_8); // call 00157668
  204. }
  205. }
  206. }
  207. // 001720FE
  208. i_r1 = 0xFA5;
  209. if (i_mag_44 / 2 > 0xFA5) i_r1 = i_mag_44 / 2;
  210. // 0017210C
  211. XMATH_Normalize(&cBall.ballMovePrev_10, i_r1);
  212. if (pPlayer_r8 == 0 || pPlayer_r8 == pPlayer_0) {
  213. cBall.SetVelRel(pPlayer_0->point_20.dx_0 / 4,
  214. pPlayer_0->point_20.dy_4 / 4, 0); // call 00157678
  215. }
  216. // 0017213A
  217. if (pPlayer_0->tStr32_44.uc_0 == 2) {
  218. // 00172142
  219. tGame.field_6C34 = 0;
  220. tGame.mTLogic_6678.field_48 = 11;
  221. } else {
  222. // 00172154
  223. GL_SetTouch(i_v23_54, pPlayer_0->tStr32_44.uc_1,
  224. (pPlayer_0->tStr32_44.field_8 | 1) == 9, EKickType_11,
  225. "Deflection");
  226. }
  227. // 00172174
  228. if (pPlayer_0->tStr32_44.field_8 != 8 &&
  229. pPlayer_0->tStr32_44.field_8 != 15) {
  230. // 00172190
  231. if ((int)cBall.speedXY_28 < 16021) {
  232. // 001721F6
  233. if ((int)cBall.speedXY_28 < 10681) {
  234. // 00172230
  235. tPoint_r0.dx_0 = cBall.point3D_44.point_0.dx_0 / 8 +
  236. pPlayer_0->Point3D_14.point_0.dx_0 / 2;
  237. tPoint_r0.dy_4 = cBall.point3D_44.point_0.dy_4 / 8 +
  238. pPlayer_0->Point3D_14.point_0.dy_4 / 2;
  239. pPlayer_0->Point3D_14.point_0 = tPoint_r0;
  240. } else {
  241. // 001721FE
  242. v20 = pPlayer_0->point_20;
  243. tPoint_4C.dx_0 = v20.dx_0 + cBall.point3D_44.point_0.dx_0 / 8;
  244. tPoint_4C.dy_4 = v20.dy_4 + cBall.point3D_44.point_0.dy_4 / 8;
  245. pPlayer_0->Trip(0, GU_GetRot(&tPoint_4C));
  246. }
  247. } else {
  248. // 0017219C
  249. v18 = pPlayer_0->point_20;
  250. tPoint_4C.dx_0 = v18.dx_0 + cBall.point3D_44.point_0.dx_0 / 8;
  251. tPoint_4C.dy_4 = v18.dy_4 + cBall.point3D_44.point_0.dy_4 / 8;
  252. pPlayer_0->Fell(GU_GetRot(&tPoint_4C), 0);
  253. }
  254. }
  255. // 0017217E
  256. cBall.Deflect();
  257. SNDGAME_PlaySFX(0x14u);
  258. }
  259. }
  260. }
  261. //00171878
  262. uint COL_PlayerBallCollision(CPlayer *player_0) {
  263. unsigned int iIndex_r4; // r4
  264. int i_x_r1; // r1
  265. TLimbInfo *pTLimbInfo_r10; // r10
  266. int i_y_r3; // r3
  267. TPoint v8; // d16
  268. int i_r9; // r12
  269. int i_r7; // r7
  270. int i_Distance_3D; // [sp+3Ch] [bp-29Ch]
  271. TPoint3D tTPoint3Ds_48[42]; // [sp+48h] [bp-290h] BYREF
  272. TPoint3D tPoint_240; // [sp+240h] [bp-98h] BYREF
  273. TPoint3D tPoint_250; // [sp+250h] [bp-88h] BYREF
  274. TPoint3D tPoint_260; // [sp+260h] [bp-78h] BYREF
  275. TPoint3D tPoint_270; // [sp+270h] [bp-68h] BYREF
  276. uint8 b_flags_280[0x2A] = {0}; // [sp+280h] [bp-58h]
  277. // 001718B6
  278. tPoint_270 = cBall.point3D_2C;
  279. tPoint_260 = cBall.ballPosPrev_4;
  280. i_Distance_3D = XMATH_Distance3D(&tPoint_270, &tPoint_260); // call 001F3490
  281. iIndex_r4 = 0;
  282. // 001718DA
  283. while (iIndex_r4 <= 0xD) {
  284. // 001718DE
  285. i_x_r1 = COL_tLimbInfo[iIndex_r4].field_0;
  286. if (!b_flags_280[i_x_r1]) // 001718E6
  287. {
  288. // 001718EC
  289. player_0->GetBonePosition(i_x_r1, &tTPoint3Ds_48[i_x_r1]); // call 001715EC
  290. //i_x_r1 = COL_tLimbInfo[iIndex_r4].field_0;
  291. b_flags_280[i_x_r1] = 1;
  292. }
  293. // 00171904
  294. pTLimbInfo_r10 = &COL_tLimbInfo[iIndex_r4];
  295. i_y_r3 = pTLimbInfo_r10->field_4;
  296. if (!b_flags_280[i_y_r3]) // 0017190E
  297. {
  298. // 00171910
  299. player_0->GetBonePosition(pTLimbInfo_r10->field_4, &tTPoint3Ds_48[i_y_r3]); // call 001715EC
  300. // i_x_r1 = COL_tLimbInfo[iIndex_r4].field_0;
  301. // i_y_r3 = pTLimbInfo_r10->field_4;
  302. b_flags_280[i_y_r3] = 1;
  303. }
  304. // 0017192C
  305. tPoint_240 = tTPoint3Ds_48[i_y_r3];
  306. tPoint_250 = tTPoint3Ds_48[i_x_r1];
  307. // 00171958
  308. uint u_r12 = XMATH_Distance3D(&tPoint_250, &tPoint_240); // call 001F3490
  309. i_r7 = COL_tBoneNodeInfo[COL_tLimbInfo[iIndex_r4].field_0].i_4;
  310. // 0017198A
  311. if (i_r7 < COL_tBoneNodeInfo[pTLimbInfo_r10->field_4].i_4)
  312. i_r7 = COL_tBoneNodeInfo[pTLimbInfo_r10->field_4].i_4;
  313. // 001719C4
  314. ++iIndex_r4;
  315. if (UTILCOL_CapsuleCapsuleCheck(tPoint_250, tPoint_240, tPoint_270, tPoint_260, i_r7, 0x1000, u_r12, i_Distance_3D)) // call 001787A0
  316. return iIndex_r4 - 1;
  317. }
  318. return -1;
  319. }