diff Outdoor.cpp @ 2091:75edfa36c4de

Слияние
author Ritor1
date Thu, 12 Dec 2013 09:28:05 +0600
parents 6c0dbff26f5d 3920278a2905
children a869b0376b48
line wrap: on
line diff
--- a/Outdoor.cpp	Thu Dec 12 09:27:55 2013 +0600
+++ b/Outdoor.cpp	Thu Dec 12 09:28:05 2013 +0600
@@ -3645,7 +3645,7 @@
 {
   int v1; // edi@1
   int v2; // ebx@1
-  int v3; // eax@14
+  int floor_level; // eax@14
   int v6; // esi@45
   ODMFace *face; // ecx@45
   signed int v33; // eax@143
@@ -3663,28 +3663,16 @@
   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
   BSPModel *v54; // eax@215
   int v55; // eax@217
-  signed int v56; // ebx@228
-  int v57; // eax@228
   BSPModel *v58; // eax@228
   unsigned __int64 v59; // qax@228
   BSPModel *v60; // eax@228
   unsigned __int64 v61; // qax@228
   int v62; // eax@241
-  unsigned int v65; // ebx@263
   unsigned int v66; // esi@263
-  int v67; // eax@263
   signed int v68; // ecx@263
   int v69; // eax@263
-  int v70; // ebx@271
-  int v71; // esi@271
-  int v72; // edi@271
-  int v73; // eax@271
   unsigned int v76; // edi@293
   bool v77; // edx@297
   bool v78; // ecx@303
@@ -3710,7 +3698,7 @@
   bool bFeatherFall; // [sp+28h] [bp-6Ch]@4
   int v105; // [sp+2Ch] [bp-68h]@24
   bool bWaterWalk; // [sp+30h] [bp-64h]@1
-  int v109; // [sp+3Ch] [bp-58h]@28
+  int ceiling_height; // [sp+3Ch] [bp-58h]@28
   int v110; // [sp+40h] [bp-54h]@180
   int v111; // [sp+44h] [bp-50h]@14
   bool hovering; // [sp+48h] [bp-4Ch]@1
@@ -3725,7 +3713,6 @@
   int pZ; // [sp+74h] [bp-20h]@1
   bool party_walking_flag; // [sp+78h] [bp-1Ch]@1
   int _angle_y; // [sp+7Ch] [bp-18h]@48
-  int v126; // [sp+80h] [bp-14h]@48
   int v128; // [sp+88h] [bp-Ch]@1
   int v129; // [sp+8Ch] [bp-8h]@92
 
@@ -3773,15 +3760,16 @@
 
   int bmodel_standing_on_pid;
   int is_on_water = false;
-  v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
+  floor_level = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
   int is_not_on_bmodel = bmodel_standing_on_pid == 0;
 
-  v111 = v3;
+  v111 = floor_level;
   if ( bFeatherFall )
-    pParty->uFallStartY = v3;
+    pParty->uFallStartY = floor_level;
   else
-    v3 = pParty->uFallStartY;
-  if ( v3 - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )
+    floor_level = pParty->uFallStartY;
+
+  if ( floor_level - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )//  3D Model
   {
     if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
     {
@@ -3796,18 +3784,17 @@
         v105 = 20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance());
         pParty->pPlayers[i].SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
       }
-      //}
-      //while ( (signed int)v4 <= (signed int)&pPlayers[4] );
     }
   }
-  v109 = -1;
+
+  ceiling_height = -1;
   if ( pParty->bFlying )
-    v109 = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);
+    ceiling_height = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);// 
   //v107 = bmodel_standing_on_pid == 0;
   v105 = v111 + 1;
   if ( pZ <= v111 + 1 )
   {
-    v109 = -1;
+    ceiling_height = -1;
     pParty->bFlying = false;
   }
   else
@@ -3842,7 +3829,7 @@
 		  if ( BYTE3(face[v6].uAttributes) & 4 )
           {
             pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);
-            v103 = face[v6].sCogTriggeredID;
+            v103 = face[v6].sCogTriggeredID; //
           }
         }
       }
@@ -3852,7 +3839,7 @@
   _walk_speed = pParty->uWalkSpeed;
   _angle_y = pParty->sRotationY;
   _angle_x = pParty->sRotationX;
-  v126 = pEventTimer->dt_in_some_format;
+  //v126 = pEventTimer->dt_in_some_format;
   /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format
                                       * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed
                                                                     * stru_5C6E00->uIntegerPi)
@@ -3887,16 +3874,16 @@
               v2 = 0;
               pParty->uFallSpeed = 0;
               *(float *)&v128 = 0.0;
-              if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 )//  ()
+              if ( v102 && pZ < ceiling_height && (signed int)(pParty->uPartyHeight + pZ) >= ceiling_height )//  ()
               {
                 pParty->field_6E0 = 0;
                 pParty->field_6E4 = 0;
                 pPartyActionQueue->uNumActions = 0;
                 pParty->uFlags |= PARTY_FLAGS_1_LANDING;
-                pParty->vPosition.z = v109 - pParty->uPartyHeight - 31;
+                pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 31;
                 pParty->field_6F0 = pZ;
                 pParty->bFlying = false;
-                pZ = v109 - pParty->uPartyHeight - 31;
+                pZ = ceiling_height - pParty->uPartyHeight - 31;
                 v113 = pParty->field_6F0;
               }
               pParty->uFallSpeed = 0;
@@ -4129,7 +4116,7 @@
       case PARTY_Jump:
         if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
         {
-          v126 = pParty->field_24 << 6;
+          //v126 = pParty->field_24 << 6;
           hovering = true;
           pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
         }
@@ -4152,15 +4139,14 @@
     }
   }
 
-//LABEL_123:
   pParty->sRotationY = _angle_y;
   pParty->sRotationX = _angle_x;
   if ( pZ < v111 || pParty->bFlying)
   {
     if ( pParty->bFlying )
     {
-      v126 = stru_5C6E00->Cos(GetTickCount());
-      v129 = (unsigned __int64)(4i64 * v126) >> 16;
+      //v126 = stru_5C6E00->Cos(GetTickCount());
+      v129 = (unsigned __int64)(4i64 * stru_5C6E00->Cos(GetTickCount())) >> 16;
       pZ = v113 + v129;
       if ( pModel )
         pZ = v113;
@@ -4237,45 +4223,45 @@
 	  }
   }
   else
-  {
-//LABEL_150:
-  pParty->uFallStartY = pZ;
-  }
+    pParty->uFallStartY = pZ;
 
   if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope )
   {
     *(float *)&v128 = 0.0;
     v2 = 0;
   }
+//---------------------------------------------------------------------
   stru_721530.field_84 = -1;
   stru_721530.field_70 = 0;
   stru_721530.prolly_normal_d = pParty->field_14_radius;
   stru_721530.field_8_radius = pParty->field_14_radius >> 1;
-  v126 = 0;
   stru_721530.field_0 = 1;
   stru_721530.height = pParty->uPartyHeight - 32;
-  do
+  for ( uint i = 0; i < 100; i++ )
   {
     stru_721530.position.x = pX;
+    stru_721530.position.y = pY;
+    stru_721530.position.z = stru_721530.height + pZ + 1;
+
     stru_721530.normal.x = pX;
-    stru_721530.velocity.x = v2;
-    stru_721530.position.y = pY;
     stru_721530.normal.y = pY;
     stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1;
-    stru_721530.position.z = stru_721530.height + pZ + 1;
+
+    stru_721530.velocity.x = v2;
     stru_721530.velocity.y = v128;
     stru_721530.velocity.z = pParty->uFallSpeed;
-    v36 = 0;
+
     stru_721530.uSectorID = 0;
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
+    v36 = 0;
+    if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == 3 )
       v36 = 13312;
     if ( stru_721530._47050A(v36) )
       break;
-    _46E889_collide_against_bmodels(1u);
+    _46E889_collide_against_bmodels(1);
     v37 = WorldPosToGridCellZ(pParty->vPosition.y);
     v38 = WorldPosToGridCellX(pParty->vPosition.x);
     _46E26D_collide_against_sprites(v38, v37);
-    _46ED8A_collide_against_sprite_objects(4u);
+    _46ED8A_collide_against_sprite_objects(4);
     for ( i = 0; i < (signed int)uNumActors; ++i )
       Actor::_46DF1A_collide_against_actor(i, 0);
     if ( stru_721530.field_7C >= stru_721530.field_6C )
@@ -4298,43 +4284,43 @@
     pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
     v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
     is_not_on_bmodel = false;
-    v118 = v42;
+    //v118 = v42;
     if ( !v97 && !v110 && !bmodel_standing_on_pid )
       is_not_on_bmodel = true;
     v43 = 1;
     v44 = 1;
     if ( bUnderwater || !is_not_on_bmodel )
-	{
-		  pX = _angle_x;
-		  if ( v43 )
-			  pY = _angle_y;
-	}
-	else
-	{
-		if ( pModel && v129 > pZ )
-		  v44 = 0;
-		if ( v118 && v119 > pZ )
-		  v43 = 0;
-		if ( v44 )
-		{
-			  pX = _angle_x;
-			  if ( v43 )
-				  pY = _angle_y;
-		}
-		else if ( v43 )
-		  pY = _angle_y;
-		else
-		{
-			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;
-			  if ( v43 )
-				  pY = _angle_y;
-			}
-		}
-	}
+    {
+      pX = _angle_x;
+      if ( v43 )
+        pY = _angle_y;
+    }
+    else
+    {
+      if ( pModel && v129 > pZ )
+        v44 = 0;
+      if ( v42 && v119 > pZ )
+        v43 = 0;
+      if ( v44 )
+      {
+        pX = _angle_x;
+        if ( v43 )
+          pY = _angle_y;
+      }
+      else if ( v43 )
+        pY = _angle_y;
+      else
+      {
+        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;
+          if ( v43 )
+            pY = _angle_y;
+        }
+      }
+    }
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       if ( !is_not_on_bmodel )
@@ -4356,29 +4342,22 @@
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
 
       viewparams->bRedrawGameUI = true;
-		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;
-	}
+      v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+      pModel = (BSPModel *)58500;
+      v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+      v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+      pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+      continue;
+    }
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
-      v56 = integer_sqrt(v2 * v2 + v128 * v128);
-      v118 = v56;
-      v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
+      //v118 = integer_sqrt(v2 * v2 + v128 * v128);
+      v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
                                _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
-      v129 = v57;
-      v58 = (BSPModel *)stru_5C6E00->Cos(v57);
-      pModel = v58;
-      v59 = (signed int)v58 * (signed __int64)v56;
+      v59 = (signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128);
       v122 = v59 >> 16;
       v2 = v59 >> 16;
-      v60 = (BSPModel *)stru_5C6E00->Sin(v129);
-      pModel = v60;
-      v61 = (signed int)v60 * (signed __int64)v118;
+      v61 = (signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128);
       v122 = v61 >> 16;
       v128 = v61 >> 16;
     }
@@ -4388,15 +4367,10 @@
       {
         pParty->bFlying = false;
         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 = pODMFace->pFacePlane.vNormal.z;
-        v129 = (unsigned __int8)(v50 ^ v51 | v49);
-        v119 = v52 < 46378;
+        v129 = v48 <= 32;
+        v119 = pODMFace->pFacePlane.vNormal.z < 46378;
         if ( bUnderwater == 1 )
           v119 = 0;
         if ( pODMFace->uPolygonType == POLYGON_Floor )
@@ -4412,33 +4386,27 @@
           if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE))
           {
             pParty->floor_face_pid = v45;
-            v103 = pODMFace->sCogTriggeredID;
+            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 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )//   
         {
-          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
+          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y
+               + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z
+               + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
           if ((stru_721530.speed >> 3) > v118 )
             v118 = stru_721530.speed >> 3;
-          v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16;
-          _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
+          v2 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16;
+          v128 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
           if ( !v119 )
-          {
-            pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z;
-            pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16);
-            v54 = pModel;
-          }
-          pParty->uFallSpeed += (int)v54;
-          v128 += _walk_speed;
-          v2 += v129;
+            pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16;
           v55 = stru_721530.prolly_normal_d
               - ((signed int)(pODMFace->pFacePlane.dist
                             + v122 * pODMFace->pFacePlane.vNormal.z
@@ -4451,72 +4419,62 @@
             if ( !v119 )
               pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
-//LABEL_220:
-			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
-			{
-				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 ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 )
+          {
+            pParty->floor_face_pid = stru_721530.uFaceID;
+            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;
+          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          continue;
         }
-        v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
+        v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y
+             + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
         if ((stru_721530.speed >> 3) > v118 )
           v118 = stru_721530.speed >> 3;
-        v122 = pODMFace->pFacePlane.vNormal.x;
-        v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
-        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;
-        pParty->uFallSpeed += v129;
-        v2 += v122;
-        v128 += (int)pModel;
+        v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16;
+        v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16;
+        pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
         if ( v2 * v2 + v128 * v128 >= 400 )
-		{
-			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
-			{
-				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 ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 )
+          {
+            pParty->floor_face_pid = stru_721530.uFaceID;
+            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;
+        }
         v2 = 0;
         pParty->uFallSpeed = 0;
         *(float *)&v128 = 0.0;
       }
     }
-//LABEL_234:
     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;
   }
-  while ( v126 < 100 );
-
+
+  //  /------------------------
+  v122 = abs(pParty->vPosition.x - pX);
+  uint pY_ = abs(pParty->vPosition.y - pY);
+  v62 = abs(pParty->vPosition.z - pZ);
   if ( bWalkSound && pParty->walk_sound_timer <= 0 )
   {
-    v122 = abs(pParty->vPosition.x - pX);
-    v126 = abs(pParty->vPosition.y - pY);
-    v62 = abs(pParty->vPosition.z - pZ);
-    if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) >= 8 )
+    pAudioPlayer->_4AA258(804);//stop sound
+    if ( party_running_flag && (!hovering || high_fall_flag) )
     {
-      if ( party_running_flag && (!hovering || !high_fall_flag) )
+      if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 16 )
       {
         if ( !is_not_on_bmodel
            && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
@@ -4526,8 +4484,12 @@
           v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1);
           pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//  
         }
+        pParty->walk_sound_timer = 96;//  
       }
-      else if ( party_walking_flag && (!hovering || !high_fall_flag) )
+    }
+    else if( party_walking_flag && (!hovering || high_fall_flag) )
+    {
+      if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 8 )
       {
         if ( is_not_on_bmodel
           || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
@@ -4537,60 +4499,52 @@
         }
         else
           pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0);//   3D Model
+        pParty->walk_sound_timer = 144;//  
       }
     }
-    else
-    {
-      pAudioPlayer->_4AA258(804);
-      pParty->walk_sound_timer = 64;
-    }
   }
-
+  if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) < 8 )//     
+    pAudioPlayer->_4AA258(804);
+//------------------------------------------------------------------------
   if ( !hovering || !high_fall_flag )
     pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
   else
     pParty->uFlags |= PARTY_FLAGS_1_FALLING;
-  v126 = WorldPosToGridCellX(pParty->vPosition.x);
-  v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+  int pMap_X = WorldPosToGridCellX(pParty->vPosition.x);
+  int pMap_Y = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   unsigned int v114_a = WorldPosToGridCellX(pX);
   v66 = WorldPosToGridCellZ(pY) - 1;
-  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
-  v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, v65) >> 1) & 1;
-  v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
+  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, pMap_Y) >> 1) & 1);
+  v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, pMap_Y) >> 1) & 1;
   v68 = 0;
-  v69 = (~(unsigned int)v67 >> 1) & 1;
-  if ( v114_a == v126 && v66 == v65 && v122 && v69 )
+  v69 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, v66) >> 1) & 1;
+  if ( v114_a == pMap_X && v66 == pMap_Y && v122 && v69 )
     v68 = 1;
   if ( !is_not_on_bmodel )
     v68 = 1;
   if ( v68 )
   {
-    v70 = pZ;
-    v71 = pX;
-    v72 = pY;
-    //pParty->uFallSpeed = v121;
-    v73 = pZ;
     pParty->vPosition.x = pX;
     pParty->vPosition.y = pY;
     pParty->vPosition.z = pZ;
     pParty->field_6F0 = v113;
     if ( pZ > 8160 )
     {
-      v73 = 8160;
+      pZ = 8160;
       pParty->uFallStartY = 8160;
       pParty->vPosition.z = 8160;
     }
-    if ( !v103
-      || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
-      && pParty->vPosition.y == v72
-      && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
+    if ( !v103 //  
+      || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
+      && pParty->vPosition.y == pY
+      && pParty->vPosition.z == pZ )
     {
-      if ( v73 < v111 )
+      if ( pParty->vPosition.z < v111 )
       {
         pParty->uFallSpeed = 0;
-        v73 = v105;
+        //v73 = v105;
         pParty->vPosition.z = v105;
-        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(    )
+        if ( pParty->uFallStartY - pZ > 512 && !bFeatherFall && pZ <= v105 && !bUnderwater )//Fall to the ground(    )
         {
           if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
           {
@@ -4601,22 +4555,22 @@
             for ( uint i = 1; i <= 4; ++i )
             {
               v110 = pPlayers[i]->GetMaxHealth();
-              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
                 DMGT_PHISYCAL);
               v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
               pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
             }
-            v73 = pParty->vPosition.z;
+            //v73 = pParty->vPosition.z;
           }
         }
-        pParty->uFallStartY = v70;
+        pParty->uFallStartY = pZ;
       }
-      if ( v102 && v73 < v109 )
+      if ( v102 && pParty->vPosition.z < ceiling_height )
       {
-        if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
+        if ( (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height )
         {
-          pParty->vPosition.z = v109 - pParty->uPartyHeight - 1;
-          pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
+          pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 1;
+          pParty->field_6F0 = ceiling_height - pParty->uPartyHeight - 1;
         }
       }
       pParty->uFlags &= ~0x204;
@@ -4632,26 +4586,21 @@
   if ( !pParty->bFlying && high_fall_flag && !bWaterWalk )
   {
     if ( pModel )
+      v78 = v69 != 0;
+    else
     {
-      v78 = v69 != 0;
+      party_drowning_flag = true;
+      v78 = true;
     }
-	else
-	{
-		party_drowning_flag = true;
-		v78 = 1;
-	}
   }
   else
-	v78 = 1;
-//LABEL_306:
+    v78 = true;
+
   if ( v77 )
-  {
     pParty->vPosition.x = pX;
-  }
   if ( v78 )
-  {
     pParty->vPosition.y = pY;
-  }
+
   if ( v78 || v77)
   {
     if ( bWaterWalk )
@@ -4677,7 +4626,7 @@
     pAudioPlayer->_4AA258(804);
     pParty->walk_sound_timer = 64;
   }
-//LABEL_318:
+
   v81 = pZ;
   v82 = pZ;
   pParty->vPosition.z = pZ;
@@ -4696,12 +4645,13 @@
     if ( pParty->vPosition.z <= pTerrainHeight + 1 )//   +1
       pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE;
   }
-  if ( !v103
+
+  if ( !v103//  
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
     && pParty->vPosition.y == pY
     && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) )
   {
-    if ( v82 < v111 )
+    if ( pParty->vPosition.z < v111 )
     {
       v82 = v105;
       pParty->uFallSpeed = 0;
@@ -4727,10 +4677,10 @@
       }
       pParty->uFallStartY = v81;
     }
-    if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
+    if ( v102 && v82 < ceiling_height && (signed int)(pParty->uPartyHeight + v82) >= ceiling_height )
     {
-      pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1;
-      pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
+      pParty->vPosition.z = v82 + pParty->uPartyHeight - ceiling_height + 1;
+      pParty->field_6F0 = v82 + pParty->uPartyHeight - ceiling_height + 1;
     }
   }
 }