changeset 2094:dbd8515924da

m
author Ritor1
date Thu, 12 Dec 2013 21:42:18 +0600
parents 48b790721bdc
children 577c081b8019
files Indoor.cpp Outdoor.cpp
diffstat 2 files changed, 219 insertions(+), 265 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Sat Dec 07 14:25:50 2013 +0600
+++ b/Indoor.cpp	Thu Dec 12 21:42:18 2013 +0600
@@ -6866,40 +6866,30 @@
   int v26; // eax@67
   double v27; // st7@67
   int v28; // ST40_4@67
-  unsigned int v35; // eax@74
-  int v36; // ecx@88
   int new_party_z; // esi@96
   int v38; // eax@96
   int v39; // ecx@106
   int v40; // eax@106
-  Player **v41; // esi@113
   int v42; // eax@120
-  signed int v43; // ecx@123
-  BLVFace *v44; // esi@126
-  PolygonType v45; // al@126
+  BLVFace *pFace; // esi@126
   int v46; // ecx@133
-  char v47; // zf@133
-  int v48; // eax@133
-  int v49; // ST40_4@136
-  int v50; // ST40_4@140
-  int v51; // eax@140
+  //int v48; // eax@133
+  //int v49; // ST40_4@136
+  //int v50; // ST40_4@140
   int v52; // eax@140
-  signed int v53; // edi@146
+  //signed int v53; // edi@146
   int v54; // ebx@146
-  int v55; // ST30_4@146
+  //int v55; // ST30_4@146
   int v63; // [sp-8h] [bp-68h]@75
   int v65; // [sp-4h] [bp-64h]@75
-  int v69; // [sp+10h] [bp-50h]@140
   unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
   bool party_running_flag; // [sp+1Ch] [bp-44h]@1
-  signed int v73; // [sp+20h] [bp-40h]@100
-  int v74; // [sp+20h] [bp-40h]@140
   bool bFeatherFall; // [sp+24h] [bp-3Ch]@15
   unsigned int uSectorID; // [sp+28h] [bp-38h]@1
   bool party_walking_flag; // [sp+2Ch] [bp-34h]@1
   unsigned int uFaceID; // [sp+30h] [bp-30h]@1
   int v80; // [sp+34h] [bp-2Ch]@1
-  int v81; // [sp+38h] [bp-28h]@47
+  //int v81; // [sp+38h] [bp-28h]@47
   int v82; // [sp+3Ch] [bp-24h]@47
   int _view_angle; // [sp+40h] [bp-20h]@47
   int bJumping; // [sp+44h] [bp-1Ch]@1
@@ -6918,7 +6908,7 @@
   uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   party_running_flag = false;
   party_walking_flag = false;
-  bJumping = 0;
+  bJumping = false;
 
   uFaceID = -1;
   int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
@@ -6988,12 +6978,11 @@
       pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
     else for (uint i = 0; i < 4; ++i)
     {                                      // receive falling damage
-      Player* player = &pParty->pPlayers[i];
-      if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS))
+      if (!pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS))
       {
-        player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL);
-        v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
-        player->SetRecoveryTime((signed __int64)v10);
+        pParty->pPlayers[i].ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * pParty->pPlayers[i].GetMaxHealth()) / 256, DMGT_PHISYCAL);
+        v10 = (double)(20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
+        pParty->pPlayers[i].SetRecoveryTime((signed __int64)v10);
       }
     }
   }
@@ -7024,9 +7013,8 @@
 
     if (!bJumping && pParty->floor_face_pid != uFaceID)
     {
-      BLVFace* pFace = &pIndoor->pFaces[uFaceID];
-      if (pFace->uAttributes & FACE_PRESSURE_PLATE)
-        uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
+      if (pIndoor->pFaces[uFaceID].uAttributes & FACE_PRESSURE_PLATE)
+        uFaceEvent = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].uFaceExtraID].uEventID;
     }
   }
   if (!bJumping)
@@ -7036,12 +7024,11 @@
   if ( pIndoor->pFaces[uFaceID].Fluid())
     on_water = true;
 
-  v81 = pParty->uWalkSpeed;
+  //v81 = pParty->uWalkSpeed;
   angle = pParty->sRotationY;
   _view_angle = pParty->sRotationX;
   v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi)
                                           / 180)) >> 16;
-//LABEL_87:
   while ( pPartyActionQueue->uNumActions )
   {
     switch ( pPartyActionQueue->Next() )
@@ -7074,54 +7061,52 @@
         break;
 
       case PARTY_StrafeLeft:
-        v2 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
-        v1 += fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
+        v2 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2);
+        v1 += fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2);
         party_walking_flag = true;
         break;
       case PARTY_StrafeRight:
-        v2 += fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
-        v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
+        v2 += fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2);
+        v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2);
         party_walking_flag = true;
         break;
       case PARTY_WalkForward:
-        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier);
-        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier);
+        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
+        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
         party_walking_flag = true;
         break;
       case PARTY_WalkBackward:
-        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
-        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
+        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier);
+        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier);
         party_walking_flag = true;
         break;
       case PARTY_RunForward:
-        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier);
-        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier);
+        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
+        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
         party_running_flag = true;
         break;
       case PARTY_RunBackward:
         //v32 = stru_5C6E00->SinCos(angle);
         //v33 = (double)v81;
         //v88 = (double)v81;
-        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
+        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier);
         //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
+        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier);
         party_running_flag = true;
         break;
       case PARTY_LookUp:
         _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
         if ( _view_angle > 128 )
           _view_angle = 128;
-        v35 = uActiveCharacter;
         if ( uActiveCharacter )
-          pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0);
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_63, 0);
         break;
       case PARTY_LookDown:
         _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
         if ( _view_angle < -128 )
           _view_angle = -128;
-        v35 = uActiveCharacter;
         if ( uActiveCharacter )
-          pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_64, 0);
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_64, 0);
         break;
       case PARTY_CenterView:
         _view_angle = 0;
@@ -7137,28 +7122,25 @@
         break;
     }
   }
-  v36 = 0;
   pParty->sRotationY = angle;
   pParty->sRotationX = _view_angle;
   if ( bJumping )
   {
-	pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
-	if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
-	{
-		if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
-		{
-			v41 = &pPlayers[1];
-			do
-			{
-				if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
-					(*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
-				++v41;
-			}
-			while ( (signed int)v41 <= (signed int)&pPlayers[4] );
-		}
-	}
-	else
-		pParty->uFallStartY = party_z;
+    pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
+    if ( bJumping && pParty->uFallSpeed <= 0 )
+    {
+      if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
+      {
+        for ( uint pl = 1; pl <= 4; pl++ )
+        {
+          if ( !pPlayers[pl]->HasEnchantedItemEquipped(72)
+            && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
+             pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
+        }
+      }
+    }
+    else
+      pParty->uFallStartY = party_z;
   }
   else
   {
@@ -7167,12 +7149,12 @@
       pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
       pParty->uFallStartY = party_z;
     }
-	else
-	{
-		if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
-		  pParty->uFallSpeed = 0;
-		pParty->uFallStartY = party_z;
-	}
+    else
+    {
+      if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
+        pParty->uFallSpeed = 0;
+      pParty->uFallStartY = party_z;
+    }
   }
   if ( v2 * v2 + v1 * v1 < 400 )
   {
@@ -7190,32 +7172,32 @@
   {
     new_party_z = party_z;
     stru_721530.position.x = new_party_x;
+    stru_721530.position.y = new_party_y;
+    stru_721530.position.z = stru_721530.height + party_z + 1;
+
     stru_721530.normal.x = new_party_x;
-    stru_721530.velocity.x = v2;
-    stru_721530.position.y = new_party_y;
     stru_721530.normal.y = new_party_y;
+    stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
+
+    stru_721530.velocity.x = v2;
     stru_721530.velocity.y = v1;
-    stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
-    stru_721530.position.z = stru_721530.height + party_z + 1;
     stru_721530.velocity.z = pParty->uFallSpeed;
+
     stru_721530.uSectorID = uSectorID;
     v38 = 0;
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
+    if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == 3 )
       v38 = 13312;
     if ( stru_721530._47050A(v38) )
       break;
-    v73 = 0;
-    do
+    for ( uint j = 0; j < 100; ++j )
     {
-      _46E44E_collide_against_faces_and_portals(1u);
+      _46E44E_collide_against_faces_and_portals(1);
       _46E0B2_collide_against_decorations();
       for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
         Actor::_46DF1A_collide_against_actor(v80, 0);
       if ( _46F04E_collide_against_portals() )
         break;
-      ++v73;
     }
-    while ( v73 < 100 );
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       v39 = stru_721530.normal2.x;
@@ -7240,7 +7222,6 @@
     }
     new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
     new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
-    v43 = stru_721530.uFaceID;
     uSectorID = stru_721530.uSectorID;
     stru_721530.field_70 += stru_721530.field_7C;
     unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z;
@@ -7249,29 +7230,25 @@
       if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0
         && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
-      viewparams->bRedrawGameUI = 1;
+      viewparams->bRedrawGameUI = true;
     }
-	else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+    else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
-      v53 = integer_sqrt(v2 * v2 + v1 * v1);
-      v80 = v53;
       v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
               new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
-      v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)v53) >> 16;
-      v55 = stru_5C6E00->Sin(v54);
-      v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16;
+      v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16;
+      v1 = (unsigned __int64)(stru_5C6E00->Sin(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16;
     }
     else
     {
       if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
-        v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
-        v45 = v44->uPolygonType;
-        if ( v45 == 3 )
+        pFace = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
+        if ( pFace->uPolygonType == POLYGON_Floor )
         {
           if ( pParty->uFallSpeed < 0 )
             pParty->uFallSpeed = 0;
-          v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1;
+          v87 = pIndoor->pVertices[*pFace->pVertexIDs].z + 1;
           if ( pParty->uFallStartY - v87 < 512 )
             pParty->uFallStartY = v87;
           if ( v2 * v2 + v1 * v1 < 400 )
@@ -7279,69 +7256,55 @@
             v1 = 0;
             v2 = 0;
           }
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+          if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+            uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
         }
-		else
-		{
-			v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
-			v47 = v45 == 4;
-			v48 = v44->pFacePlane_old.vNormal.x;
-			if ( !v47 )
-			{
-			  v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-			  if ((stru_721530.speed >> 3) > v80 )
-				v80 = stru_721530.speed >> 3;
-			  v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-			  v81 = v44->pFacePlane_old.vNormal.y;
-			  v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-			  v82 = v44->pFacePlane_old.vNormal.z;
-			  v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-			  v2 += v50;
-			  pParty->uFallSpeed += v82;
-			  v74 = v44->pFacePlane_old.vNormal.z;
-			  v51 = v44->pFacePlane_old.vNormal.y;
-			  v69 = v44->pFacePlane_old.vNormal.x;
-			  v80 = v51;
-			  v1 += v81;
-			  v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
-			  if ( v52 > 0 )
-			  {
-				new_party_x += v52 * v69 >> 16;
-				new_party_y += v52 * v80 >> 16;
-				v87 += v52 * v74 >> 16;
-			  }
-			  v43 = stru_721530.uFaceID;
-			  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-				uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-			}
-			else
-			{
-				v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-				if ((stru_721530.speed >> 3) > v80 )
-				  v80 = stru_721530.speed >> 3;
-				v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-				v81 = v44->pFacePlane_old.vNormal.y;
-				v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-				v82 = v44->pFacePlane_old.vNormal.z;
-				v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-				v2 += v49;
-				v1 += v81;
-				pParty->uFallSpeed += v82;
-				if ( v2 * v2 + v1 * v1 >= 400 )
-				{
-				  v43 = stru_721530.uFaceID;
-				  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-					uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-				}
-				else
-				{
-					v2 = 0;
-					v1 = 0;
-					pParty->uFallSpeed = 0;
-				}
-			}
-		}
+        else
+        {
+          v46 = pParty->uFallSpeed * pFace->pFacePlane_old.vNormal.z;
+          if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall )
+          {
+            v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16;
+            if ((stru_721530.speed >> 3) > v80 )
+              v80 = stru_721530.speed >> 3;
+            v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16;
+            v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16;
+            pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16;
+            //v80 = pFace->pFacePlane_old.vNormal.y;
+            v52 = stru_721530.prolly_normal_d - ((pFace->pFacePlane_old.dist
+                  + v87 * pFace->pFacePlane_old.vNormal.z
+                  + new_party_y * pFace->pFacePlane_old.vNormal.y
+                  + new_party_x * pFace->pFacePlane_old.vNormal.x) >> 16);
+            if ( v52 > 0 )
+            {
+              new_party_x += v52 * pFace->pFacePlane_old.vNormal.x >> 16;
+              new_party_y += v52 * pFace->pFacePlane_old.vNormal.y >> 16;
+              v87 += v52 * pFace->pFacePlane_old.vNormal.z >> 16;
+            }
+            if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+              uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
+          }
+          if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall )
+          {
+            v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16;
+            if ((stru_721530.speed >> 3) > v80 )
+              v80 = stru_721530.speed >> 3;
+            v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16;
+            v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16;
+            pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16;
+            if ( v2 * v2 + v1 * v1 >= 400 )
+            {
+              if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+                uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
+            }
+            else
+            {
+              v2 = 0;
+              v1 = 0;
+              pParty->uFallSpeed = 0;
+            }
+          }
+        }
       }
     }
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
--- a/Outdoor.cpp	Sat Dec 07 14:25:50 2013 +0600
+++ b/Outdoor.cpp	Thu Dec 12 21:42:18 2013 +0600
@@ -3663,14 +3663,8 @@
   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
@@ -3840,7 +3834,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; //
           }
         }
       }
@@ -4299,37 +4293,37 @@
     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 ( 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;
+        }
+      }
+    }
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       if ( !is_not_on_bmodel )
@@ -4351,29 +4345,23 @@
         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;
+      ++v126;
+      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)v118;
       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)v118;
       v122 = v61 >> 16;
       v128 = v61 >> 16;
     }
@@ -4386,12 +4374,12 @@
         //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;
+        //v51 = __OFSUB__(v48, 32);
+        //v49 = v48 == 32;
+        //v50 = v48 - 32 < 0;
+        //v52 = pODMFace->pFacePlane.vNormal.z;
+        v129 = v48 <= 32;
+        v119 = pODMFace->pFacePlane.vNormal.z < 46378;
         if ( bUnderwater == 1 )
           v119 = 0;
         if ( pODMFace->uPolygonType == POLYGON_Floor )
@@ -4407,33 +4395,35 @@
           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;
+          //++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;
+            //pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z;
+            pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16;
+            //v54 = pModel;
           }
-          pParty->uFallSpeed += (int)v54;
-          v128 += _walk_speed;
-          v2 += v129;
+          //pParty->uFallSpeed += (int)v54;
+          //v128 += _walk_speed;
+          //v2 += v129;
           v55 = stru_721530.prolly_normal_d
               - ((signed int)(pODMFace->pFacePlane.dist
                             + v122 * pODMFace->pFacePlane.vNormal.z
@@ -4446,48 +4436,49 @@
             if ( !v119 )
               pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
-			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;
+          //v45 = stru_721530.uFaceID;
+          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;
         }
-        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;
+        //v122 = pODMFace->pFacePlane.vNormal.x;
+        v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16;
+        //pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y;
+        v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16;
+        //v129 = pODMFace->pFacePlane.vNormal.z;
+        pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
+        //pParty->uFallSpeed += v129;
+        //v2 += v122;
+        //v128 += (int)pModel;
         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;
-		}
+        {
+          //v45 = stru_721530.uFaceID;
+          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;
@@ -4575,7 +4566,7 @@
       pParty->uFallStartY = 8160;
       pParty->vPosition.z = 8160;
     }
-    if ( !v103
+    if ( !v103 //
       || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
       && pParty->vPosition.y == v72
       && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
@@ -4693,7 +4684,7 @@
       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) )