COL.cpp 10 KB

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