diff mm7_3.cpp @ 1424:5930342f092b

fall to the water
author Ritor1
date Tue, 30 Jul 2013 15:14:46 +0600
parents 483b1b453986
children 1987f2cca08f
line wrap: on
line diff
--- a/mm7_3.cpp	Tue Jul 30 09:34:14 2013 +0600
+++ b/mm7_3.cpp	Tue Jul 30 15:14:46 2013 +0600
@@ -2110,39 +2110,11 @@
 //----- (00473893) --------------------------------------------------------
 void ODM_ProcessPartyActions()
 {
-  //int _zero; // esi@1
   int v1; // edi@1
   int v2; // ebx@1
   int v3; // eax@14
-  //Player **v4; // esi@21
-  //int v5; // eax@24
   int v6; // esi@45
   ODMFace *v7; // ecx@45
-  //unsigned int v8; // eax@71
-  //double v9; // st7@72
-  //signed __int64 v10; // qax@74
-  //double v11; // st7@75
-  //int v12; // ecx@77
-  //int v13; // eax@84
-  //double v14; // st7@84
-  //int v15; // eax@87
-  //double v16; // st7@87
-  //int v17; // eax@88
-  //double v18; // st7@88
-  //int v19; // eax@89
-  //double v20; // st7@89
-  //int v21; // eax@92
-  //double v22; // st7@92
-  //int v23; // eax@96
-  //double v24; // st7@96
-  //int v25; // eax@97
-  //double v26; // st7@97
-  //int v27; // eax@98
-  //double v28; // st7@98
-  //signed __int64 v29; // qax@98
-  //unsigned int v30; // eax@103
-  int v31; // eax@130
-  //int v32; // ecx@141
   signed int v33; // eax@143
   int v34; // esi@143
   int v35; // esi@147
@@ -2151,19 +2123,17 @@
   signed int v38; // eax@159
   signed int i; // esi@159
   int v40; // esi@162
-  //Player **v41; // esi@172
   bool v42; // eax@180
   signed int v43; // ecx@184
   signed int v44; // edx@184
   int v45; // ecx@200
-  BSPModel *v46; // eax@203
-  ODMFace *v47; // esi@203
+  BSPModel *pModel; // eax@203
+  ODMFace *pODMFace; // esi@203
   int v48; // eax@203
   char v49; // zf@203
   char v50; // sf@203
   unsigned __int8 v51; // of@203
   int v52; // eax@203
-  unsigned __int8 v53; // dl@205
   BSPModel *v54; // eax@215
   int v55; // eax@217
   signed int v56; // ebx@228
@@ -2173,8 +2143,6 @@
   BSPModel *v60; // eax@228
   unsigned __int64 v61; // qax@228
   int v62; // eax@241
-  signed int v63; // ST04_4@255
-  signed int v64; // eax@255
   unsigned int v65; // ebx@263
   unsigned int v66; // esi@263
   int v67; // eax@263
@@ -2184,8 +2152,6 @@
   int v71; // esi@271
   int v72; // edi@271
   int v73; // eax@271
-  Player **v74; // esi@283
-  int v75; // eax@284
   unsigned int v76; // edi@293
   bool v77; // edx@297
   bool v78; // ecx@303
@@ -2193,9 +2159,7 @@
   __int16 v80; // dx@317
   int v81; // ebx@318
   int v82; // ecx@318
-  int v83; // eax@321
-  Player **v84; // esi@333
-  int v85; // eax@334
+  int pTerrainHeight; // eax@321
   int v86; // [sp-20h] [bp-B4h]@246
   int v87; // [sp-20h] [bp-B4h]@248
   signed int v88; // [sp-1Ch] [bp-B0h]@246
@@ -2203,23 +2167,16 @@
   signed int v90; // [sp-14h] [bp-A8h]@246
   signed int v91; // [sp-10h] [bp-A4h]@246
   int v92; // [sp-Ch] [bp-A0h]@246
-  //int v93; // [sp-8h] [bp-9Ch]@104
   unsigned int v94; // [sp-8h] [bp-9Ch]@246
-  //int v95; // [sp-4h] [bp-98h]@104
   int v96; // [sp-4h] [bp-98h]@246
   int v97; // [sp+Ch] [bp-88h]@180
   Vec3_int_ v98;
-  //int v98; // [sp+10h] [bp-84h]@147
-  //int v99; // [sp+14h] [bp-80h]@147
-  //int v100; // [sp+18h] [bp-7Ch]@147
   bool v101; // [sp+1Ch] [bp-78h]@33
   int v102; // [sp+20h] [bp-74h]@1
   int v103; // [sp+24h] [bp-70h]@1
   int bFeatherFall; // [sp+28h] [bp-6Ch]@4
   int v105; // [sp+2Ch] [bp-68h]@24
   int bWaterWalk; // [sp+30h] [bp-64h]@1
-  //bool v107; // [sp+34h] [bp-60h]@30
-  //int v108; // [sp+38h] [bp-5Ch]@1
   int v109; // [sp+3Ch] [bp-58h]@28
   int v110; // [sp+40h] [bp-54h]@180
   int v111; // [sp+44h] [bp-50h]@14
@@ -2230,20 +2187,15 @@
   int pX; // [sp+58h] [bp-3Ch]@1
   int pY; // [sp+5Ch] [bp-38h]@1
   int v118; // [sp+60h] [bp-34h]@1
-  //Player **v119; // [sp+64h] [bp-30h]@4
   int _angle_x; // [sp+68h] [bp-2Ch]@48
-  int v121; // [sp+6Ch] [bp-28h]@1
   unsigned int v122; // [sp+70h] [bp-24h]@180
   int pZ; // [sp+74h] [bp-20h]@1
   int v124; // [sp+78h] [bp-1Ch]@1
   int _angle_y; // [sp+7Ch] [bp-18h]@48
   int v126; // [sp+80h] [bp-14h]@48
-  BSPModel *v127; // [sp+84h] [bp-10h]@1
   int v128; // [sp+88h] [bp-Ch]@1
   int v129; // [sp+8Ch] [bp-8h]@92
-  //int v130; // [sp+90h] [bp-4h]@14
-
-  v121 = pParty->uFallSpeed;
+
   pZ = pParty->vPosition.z;
   v1 = 0;
   v103 = 0;
@@ -2259,7 +2211,7 @@
   v114 = 0;
   v124 = 0;
   v102 = 0;
-  v127 = 0;
+  pModel = 0;
   bWaterWalk = 0;
   if (!pParty->FeatherFallActive())
   {
@@ -2401,7 +2353,7 @@
               }
               v1 = 0;
               v2 = 0;
-              v121 = 0;
+              pParty->uFallSpeed = 0;
               *(float *)&v128 = 0.0;
               if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 )
               {
@@ -2416,7 +2368,7 @@
                 v113 = pParty->field_6F0;
               }
               pParty->uFallSpeed = 0;
-              v127 = (BSPModel *)1;
+              pModel = (BSPModel *)1;
             }
           }
       }
@@ -2433,9 +2385,9 @@
             pZ -= 30;
             v113 -= 30;
             pParty->uFallSpeed = 0;
-            v121 = 0;
+            //pParty->uFallSpeed = 0;
             pParty->bFlying = 1;
-            v127 = (BSPModel *)1;
+            pModel = (BSPModel *)1;
             if ( pZ <= v111 )
             {
               pParty->bFlying = 0;
@@ -2540,7 +2492,7 @@
         float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
               cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
 
-        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;        
+        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
         int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
 
         if (pParty->bFlying)
@@ -2614,7 +2566,6 @@
       }
       break;
 
-      
       case PARTY_CenterView:
         _angle_x = 0;
       break;
@@ -2640,7 +2591,7 @@
         {
           v126 = pParty->field_24 << 6;
           bJumping = 1;
-          v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121);
+          pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
         }
       break;
 
@@ -2666,30 +2617,26 @@
   {
     if ( pParty->bFlying )
     {
-//LABEL_130:
-      v31 = GetTickCount();
-      v126 = stru_5C6E00->Cos(v31);
+      v126 = stru_5C6E00->Cos(GetTickCount());
       v129 = (unsigned __int64)(4i64 * v126) >> 16;
       pZ = v113 + v129;
-      if ( v127 )
+      if ( pModel )
         pZ = v113;
       if (pParty->FlyActive())
         stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFEu;
       pParty->uFallStartY = pZ;
-      //goto LABEL_141;
     }
-	else
-	{
-		if ( is_on_water && v121 )
-		  sub_42F960_create_object(pX, pY, v111);
-		v121 = 0;
-		pZ = v111;
-		pParty->uFallStartY = v111;
-	    v113 = pZ;
-	    if (pParty->FlyActive())
-		  stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;
-
-	}
+    else
+    {
+      if ( is_on_water && pParty->uFallSpeed )
+        sub_42F960_create_object(pX, pY, v111);
+      pParty->uFallSpeed = 0;
+      pZ = v111;
+      pParty->uFallStartY = v111;
+      v113 = pZ;
+      if (pParty->FlyActive())
+        stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;
+    }
   }
   else
   {
@@ -2701,12 +2648,12 @@
   if (bJumping && !pParty->bFlying)
   {
     v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
-    v34 = v121 + 2 * v33;
-    v121 += 2 * v33;
+    v34 = pParty->uFallSpeed + 2 * v33;
+    pParty->uFallSpeed += 2 * v33;
   }
   else if (!partyAtHighSlope)
   {
-    v34 = v121;
+    v34 = pParty->uFallSpeed;
   }
   else if (!bJumping)
   {
@@ -2717,17 +2664,17 @@
 		// and falling to the gravity, gradually sliding downwards. nice trick
 		pZ = v111;
 		ODM_GetTerrainNormalAt(pX, pY, &v98);
-		v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
+		v35 = pParty->uFallSpeed + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
 		v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
 		v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
 		v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
 		v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
 		v128 = v1;
-		v121 = v34;
+		pParty->uFallSpeed = v34;
 	}
   }
   else
-	  v34 = v121;
+	  v34 = pParty->uFallSpeed;
 
 //LABEL_164:
   if(bJumping)
@@ -2776,7 +2723,7 @@
     stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1;
     stru_721530.field_34.z = stru_721530.field_C + pZ + 1;
     stru_721530.field_20 = v128;
-    stru_721530.field_24 = v121;
+    stru_721530.field_24 = pParty->uFallSpeed;
     v36 = 0;
     stru_721530.uSectorID = 0;
     if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
@@ -2800,14 +2747,14 @@
     {
       _angle_x = pX + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
       _angle_y = pY + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      v127 = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+      pModel = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
       v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ;
     }
     v122 = v40;
     ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
     v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0);
     auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0);
-    v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
+    pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
     v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
     is_not_on_bmodel = false;
     v118 = v42;
@@ -2823,7 +2770,7 @@
 	}
 	else
 	{
-		if ( v127 && v129 > pZ )
+		if ( pModel && v129 > pZ )
 		  v44 = 0;
 		if ( v118 && v119 > pZ )
 		  v43 = 0;
@@ -2837,8 +2784,8 @@
 		  pY = _angle_y;
 		else
 		{
-			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
-			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
+			pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
+			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ )
 			{
 			  v43 = 1;
 			  pX = _angle_x;
@@ -2869,11 +2816,11 @@
 
       viewparams->bRedrawGameUI = 1;
 		v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-		v127 = (BSPModel *)58500;
+		pModel = (BSPModel *)58500;
 		v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-		v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+		v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 		++v126;
-		v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+		pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 		continue;
 	}
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
@@ -2884,12 +2831,12 @@
                                _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
       v129 = v57;
       v58 = (BSPModel *)stru_5C6E00->Cos(v57);
-      v127 = v58;
+      pModel = v58;
       v59 = (signed int)v58 * (signed __int64)v56;
       v122 = v59 >> 16;
       v2 = v59 >> 16;
       v60 = (BSPModel *)stru_5C6E00->Sin(v129);
-      v127 = v60;
+      pModel = v60;
       v61 = (signed int)v60 * (signed __int64)v118;
       v122 = v61 >> 16;
       v128 = v61 >> 16;
@@ -2899,128 +2846,125 @@
       if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
         pParty->bFlying = 0;
-        v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
-        v127 = v46;
-		v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
-        v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1;
+        pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
+        //v127 = v46;
+        pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
+        v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1;
         v51 = __OFSUB__(v48, 32);
         v49 = v48 == 32;
         v50 = v48 - 32 < 0;
-        v52 = v47->pFacePlane.vNormal.z;
+        v52 = pODMFace->pFacePlane.vNormal.z;
         v129 = (unsigned __int8)(v50 ^ v51 | v49);
         v119 = v52 < 46378;
         if ( bUnderwater == 1 )
           v119 = 0;
-        v53 = v47->uPolygonType;
-        if ( v53 == 3 )
+        if ( pODMFace->uPolygonType == POLYGON_Floor )
         {
-			if ( v121 < 0 )
-				v121 = 0;
-			pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
-			if ( v2 * v2 + v128 * v128 < 400 )
-			{
-				v2 = 0;
-				*(float *)&v128 = 0.0;
-			}
-			if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE))
-			{
-				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
-			}
-			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
-			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
-			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
-			continue;
+          if ( pParty->uFallSpeed < 0 )
+            pParty->uFallSpeed = 0;
+          pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1;
+          if ( v2 * v2 + v128 * v128 < 400 )
+          {
+            v2 = 0;
+            *(float *)&v128 = 0.0;
+          }
+          if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE))
+          {
+            pParty->floor_face_pid = v45;
+            v103 = pODMFace->sCogTriggeredID;
+          }
+          v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+          pModel = (BSPModel *)58500;
+          v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+          v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          ++v126;
+          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          continue;
         }
-        if ( !v129 && (v53 != 4 || v119) )
+        if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб
         {
-          v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
+          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
           if ( stru_721530.field_64 >> 3 > v118 )
             v118 = stru_721530.field_64 >> 3;
-          v129 = v47->pFacePlane.vNormal.x;
-          v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
-          _walk_speed = v47->pFacePlane.vNormal.y;
-          _walk_speed = (unsigned __int64)(v118 * (signed __int64)_walk_speed) >> 16;
+          v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16;
+          _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
           if ( !v119 )
           {
-            v127 = (BSPModel *)v47->pFacePlane.vNormal.z;
-            v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
-            v54 = v127;
+            pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z;
+            pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16);
+            v54 = pModel;
           }
-          v121 += (int)v54;
+          pParty->uFallSpeed += (int)v54;
           v128 += _walk_speed;
           v2 += v129;
           v55 = stru_721530.prolly_normal_d
-              - ((signed int)(v47->pFacePlane.dist
-                            + v122 * v47->pFacePlane.vNormal.z
-                            + _angle_y * v47->pFacePlane.vNormal.y
-                            + _angle_x * v47->pFacePlane.vNormal.x) >> 16);
+              - ((signed int)(pODMFace->pFacePlane.dist
+                            + v122 * pODMFace->pFacePlane.vNormal.z
+                            + _angle_y * pODMFace->pFacePlane.vNormal.y
+                            + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16);
           if ( v55 > 0 )
           {
-            pX = _angle_x + (v47->pFacePlane.vNormal.x * v55 >> 16);
-            pY = _angle_y + (v47->pFacePlane.vNormal.y * v55 >> 16);
+            pX = _angle_x + (pODMFace->pFacePlane.vNormal.x * v55 >> 16);
+            pY = _angle_y + (pODMFace->pFacePlane.vNormal.y * v55 >> 16);
             if ( !v119 )
-              pZ = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
+              pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
 //LABEL_220:
 			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
 			{
 				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
+				v103 = pODMFace->sCogTriggeredID;
 			}
 			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
+			pModel = (BSPModel *)58500;
 			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			continue;
         }
-        v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
+        v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
         if ( stru_721530.field_64 >> 3 > v118 )
           v118 = stru_721530.field_64 >> 3;
-        v122 = v47->pFacePlane.vNormal.x;
+        v122 = pODMFace->pFacePlane.vNormal.x;
         v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
-        v127 = (BSPModel *)v47->pFacePlane.vNormal.y;
-        v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
-        v129 = v47->pFacePlane.vNormal.z;
+        pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y;
+        pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16);
+        v129 = pODMFace->pFacePlane.vNormal.z;
         v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
-        v121 += v129;
+        pParty->uFallSpeed += v129;
         v2 += v122;
-        v128 += (int)v127;
+        v128 += (int)pModel;
         if ( v2 * v2 + v128 * v128 >= 400 )
 		{
 			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
 			{
 				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
+				v103 = pODMFace->sCogTriggeredID;
 			}
 			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
+			pModel = (BSPModel *)58500;
 			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			continue;
 		}
         v2 = 0;
-        v121 = 0;
+        pParty->uFallSpeed = 0;
         *(float *)&v128 = 0.0;
       }
     }
 //LABEL_234:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-    v127 = (BSPModel *)58500;
+    pModel = (BSPModel *)58500;
     v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-    v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+    v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
     ++v126;
-    v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+    pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
   }
   while ( v126 < 100 );
   if ( bWalkSound && pParty->walk_sound_timer <= 0 )
@@ -3040,13 +2984,13 @@
 		  if ( !is_not_on_bmodel
 			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
 		  {
-            pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound(SOUND_64, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		  else
 		  {
-			v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-			v64 = WorldPosToGridCellX(pParty->vPosition.x);
-			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 1);
+			//v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+			//v64 = WorldPosToGridCellX(pParty->vPosition.x);
+			v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1);
 			pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		}
@@ -3057,13 +3001,13 @@
 			  if ( is_not_on_bmodel
 				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
 			  {
-				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-				v64 = WorldPosToGridCellX(pParty->vPosition.x);
-				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 0);
+				//v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+				//v64 = WorldPosToGridCellX(pParty->vPosition.x);
+				v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0);
 				pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 			  }
 			  else
-                pAudioPlayer->PlaySound((SoundID)103, 804, 1, -1, 0, 0, 0, 0);
+                pAudioPlayer->PlaySound(SOUND_103, 804, 1, -1, 0, 0, 0, 0);
 			}
 			else
 			{
@@ -3081,7 +3025,7 @@
   v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   v114 = WorldPosToGridCellX(pX);
   v66 = WorldPosToGridCellZ(pY) - 1;
-  v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
+  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
   v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
   v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
   v68 = 0;
@@ -3095,7 +3039,7 @@
     v70 = pZ;
     v71 = pX;
     v72 = pY;
-    pParty->uFallSpeed = v121;
+    //pParty->uFallSpeed = v121;
     v73 = pZ;
     pParty->vPosition.x = pX;
     pParty->vPosition.y = pY;
@@ -3117,7 +3061,7 @@
         pParty->uFallSpeed = 0;
         v73 = v105;
         pParty->vPosition.z = v105;
-        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
+        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(падение на землю с высоты)
         {
           if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
           {
@@ -3125,19 +3069,14 @@
           }
           else
           {
-            v74 = &pPlayers[1];
-            do
+            for ( uint i = 1; i <= 4; ++i )
             {
-              v110 = (*v74)->GetMaxHealth();
-              (*v74)->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              v110 = pPlayers[i]->GetMaxHealth();
+              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
                 DMGT_PHISYCAL);
-              v75 = (*v74)->GetActualEndurance();
-              v110 = 20 - (*v74)->GetParameterBonus(v75);
-              (*v74)->SetRecoveryTime(
-                (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
-              ++v74;
+              v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
+              pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
             }
-            while ( (signed int)v74 <= (signed int)&pPlayers[4] );
             v73 = pParty->vPosition.z;
           }
         }
@@ -3156,14 +3095,14 @@
     return;
   }
   v76 = pParty->bFlying;
-  if ( pParty->bFlying || v101 == 0 || bWaterWalk || !v127 )
+  if ( pParty->bFlying || v101 == 0 || bWaterWalk || !pModel )
     v77 = 1;
   else
     v77 = v122 != 0;
   v114 = 0;
   if ( !pParty->bFlying && v101 != 0 && !bWaterWalk )
   {
-    if ( v127 )
+    if ( pModel )
     {
       v78 = v69 != 0;
     }
@@ -3220,14 +3159,13 @@
     pParty->vPosition.z = 8160;
   }
   LOWORD(pParty->uFlags) &= 0xFDFBu;
-  pParty->uFallSpeed = v121;
+  //pParty->uFallSpeed = v121;
   pParty->field_6F0 = v113;
-  if ( v114 )
-  {
-    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
-    v82 = pParty->vPosition.z;
-    if ( pParty->vPosition.z <= v83 )
-      pParty->uFlags |= 4u;
+  if ( v114 )//party stand to the water(группа стоит на воде)
+  {
+    pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
+    if ( pParty->vPosition.z <= pTerrainHeight + 1 )//положение группы всегда +1
+      pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE;
   }
   if ( !v103
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
@@ -3239,7 +3177,7 @@
       v82 = v105;
       pParty->uFallSpeed = 0;
       pParty->vPosition.z = v105;
-      if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
+      if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )//Fall to the water(падение на воду с высоты)
       {
         if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
         {
@@ -3247,19 +3185,14 @@
         }
         else
         {
-          v84 = &pPlayers[1];
-          do
+          for ( uint i = 1; i <= 4; ++i )
           {
-            v110 = (*v84)->GetMaxHealth();
-            (*v84)->ReceiveDamage(
-              (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+            v110 = pPlayers[i]->GetMaxHealth();
+            pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
               DMGT_PHISYCAL);
-            v85 = (*v84)->GetActualEndurance();
-            v110 = 20 - (*v84)->GetParameterBonus(v85);
-            (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
-            ++v84;
+            v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
+            pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
           }
-          while ( (signed int)v84 <= (signed int)&pPlayers[4] );
           v82 = pParty->vPosition.z;
         }
       }