diff SpriteObject.cpp @ 2085:52abdea20b9e

Door_switch_animation
author Ritor1
date Wed, 11 Dec 2013 23:12:54 +0600
parents a290d9fbdc95
children 7f403ebf619f
line wrap: on
line diff
--- a/SpriteObject.cpp	Tue Dec 03 16:35:57 2013 +0600
+++ b/SpriteObject.cpp	Wed Dec 11 23:12:54 2013 +0600
@@ -206,26 +206,14 @@
 //----- (00471C03) --------------------------------------------------------
 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
 {
-  //SpriteObject *v1; // esi@1
   ObjectDesc *object; // ebx@1
-  signed int v3; // edx@1
-  int v4; // ecx@1
-  int v5; // ST04_4@1
   int v6; // eax@1
   int v7; // ecx@1
   int v8; // edi@1
   int v9; // eax@4
-  __int16 v10; // ax@7
-  int v11; // edx@11
-  int v12; // ecx@11
-  signed int v13; // edx@14
-  signed int v14; // edx@16
-  int v15; // eax@24
-  int v16; // eax@25
   int v17; // ST10_4@25
-  signed int v18; // eax@25
-  signed int v19; // eax@28
-  Actor *v20; // edi@31
+  //signed int v19; // eax@28
+  //Actor *v20; // edi@31
   int v21; // eax@41
   int v22; // ecx@43
   __int16 v23; // bx@45
@@ -235,16 +223,16 @@
   int v27; // eax@52
   __int16 v28; // cx@55
   int v29; // eax@55
-  signed int v30; // edi@59
-  BSPModel *v31; // ecx@61
-  ODMFace *v32; // edi@61
+  //signed int v30; // edi@59
+  BSPModel *bmodel; // ecx@61
+  ODMFace *face; // edi@61
   int v33; // eax@62
   int v34; // ecx@62
   int v35; // eax@63
   int v36; // ecx@67
   __int16 v37; // ax@67
   int v38; // eax@72
-  int v39; // eax@72
+  //int v39; // eax@72
   unsigned __int64 v40; // qax@72
   int v41; // eax@72
   unsigned __int8 v42; // sf@74
@@ -258,7 +246,6 @@
   int v50; // [sp+10h] [bp-98h]@52
   Vec3_int_ v51; // [sp+14h] [bp-94h]@11
   Particle_sw Dst; // [sp+20h] [bp-88h]@45
-  unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1
   int v54; // [sp+8Ch] [bp-1Ch]@1
   int v55; // [sp+90h] [bp-18h]@1
   int v56; // [sp+94h] [bp-14h]@11
@@ -267,16 +254,11 @@
   int on_water; // [sp+A0h] [bp-8h]@1
   int v60; // [sp+A4h] [bp-4h]@11
 
-  uLayingItemID_ = uLayingItemID;
-  //v1 = &pSpriteObjects[uLayingItemID];
   v58 = 0;
   object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
   v57 = IsTerrainSlopeTooHigh(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y);
-  v3 = pSpriteObjects[uLayingItemID].vPosition.y;
-  v4 = pSpriteObjects[uLayingItemID].vPosition.x;
-  v5 = object->uHeight;
   v55 = 0;
-  v6 = ODM_GetFloorLevel(v4, v3, pSpriteObjects[uLayingItemID].vPosition.z, v5, &on_water, &v55, 0);
+  v6 = ODM_GetFloorLevel(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uHeight, &on_water, &v55, 0);
   v7 = v6;
   v54 = v6;
   v8 = v6 + 1;
@@ -286,16 +268,15 @@
     {
       v9 = v6 + 60;
       if ( v55 )
-        v9 = v7 + 30;
+        v9 = v6 + 30;
       sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v9);
-      SpriteObject::OnInteraction(uLayingItemID_);
+      SpriteObject::OnInteraction(uLayingItemID);
     }
   }
   else
   {
     v58 = 1;
   }
-  v10 = object->uFlags;
   if ( !(object->uFlags & OBJECT_DESC_NO_GRAVITY) )
   {
     if ( v58 )
@@ -305,10 +286,8 @@
     }
     if ( v57 )
     {
-      v11 = pSpriteObjects[uLayingItemID].vPosition.y;
-      v12 = pSpriteObjects[uLayingItemID].vPosition.x;
       pSpriteObjects[uLayingItemID].vPosition.z = v8;
-      ODM_GetTerrainNormalAt(v12, v11, &v51);
+      ODM_GetTerrainNormalAt(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, &v51);
       pSpriteObjects[uLayingItemID].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       v56 = abs(v51.y * pSpriteObjects[uLayingItemID].vVelocity.y + v51.z * pSpriteObjects[uLayingItemID].vVelocity.z + v51.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16;
       //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
@@ -320,11 +299,11 @@
       v7 = v54;
       goto LABEL_13;
     }
-    if ( v10 & 0x40 )
+    if ( object->uFlags & OBJECT_DESC_INTERACTABLE )
     {
       if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
         pSpriteObjects[uLayingItemID].vPosition.z = v8;
-      if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) )
+      if ( !_46BFFA_check_object_intercept(uLayingItemID, 0) )
         return;
     }
     pSpriteObjects[uLayingItemID].vPosition.z = v8;
@@ -334,31 +313,29 @@
     pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
     pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
     pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
-
-    if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 )
-        {
-
-    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
-    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
-    memset(&Dst, 0, 0x68u);
-    Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
-    Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
-    Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
-    Dst.r = 0.0;
-    Dst.g = 0.0;
-    Dst.b = 0.0;
-    if (object->uFlags & OBJECT_DESC_TRIAL_FIRE )
+    if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y
+        + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 )
     {
-      Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
-      Dst.uDiffuse = 0xFF3C1E;
-      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
-      Dst.flt_28 = 1.0;
-      pGame->pParticleEngine->AddParticle(&Dst);
-    }
-    else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE)
-    {
-
+      pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+      pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+      memset(&Dst, 0, 0x68u);
+      Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
+      Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
+      Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
+      Dst.r = 0.0;
+      Dst.g = 0.0;
+      Dst.b = 0.0;
+      if (object->uFlags & OBJECT_DESC_TRIAL_FIRE )
+      {
+        Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+        Dst.uDiffuse = 0xFF3C1E;
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+      }
+      else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE)
+      {
         Dst.type = ParticleType_Line;
         Dst.uDiffuse = rand();
         Dst.timeToLive = 64;
@@ -366,46 +343,41 @@
         Dst.flt_28 = 1.0;
         pGame->pParticleEngine->AddParticle(&Dst);
       }
-    else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
-        {
-      Dst.type = ParticleType_Bitmap | ParticleType_8;
-      Dst.uDiffuse = rand();
-      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
-      Dst.flt_28 = 1.0;
-      pGame->pParticleEngine->AddParticle(&Dst);
+      else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
+      {
+        Dst.type = ParticleType_Bitmap | ParticleType_8;
+        Dst.uDiffuse = rand();
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+      }
+      return;
     }
-    return;
-        }
   }
 LABEL_13:
-  if ( pSpriteObjects[uLayingItemID].vPosition.z > v7
-    && (v13 = pSpriteObjects[uLayingItemID].vPosition.x, v13 >= -0x8000)
-    && v13 <= 0x8000
-    && (v14 = pSpriteObjects[uLayingItemID].vPosition.y, v14 >= -0x8000)
-    && v14 <= 0x8000
-    && pSpriteObjects[uLayingItemID].vPosition.z <= 13000
+  if ( pSpriteObjects[uLayingItemID].vPosition.x >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.x <= 0x8000
+    && pSpriteObjects[uLayingItemID].vPosition.y >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.y <= 0x8000
+    && pSpriteObjects[uLayingItemID].vPosition.z > v7 && pSpriteObjects[uLayingItemID].vPosition.z <= 13000
     || !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
     goto LABEL_92;
   if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
     pSpriteObjects[uLayingItemID].vPosition.z = v8;
-  if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) )
+  if ( _46BFFA_check_object_intercept(uLayingItemID, 0) )
   {
 LABEL_92:
     stru_721530.field_0 = 0;
-    v55 = 0;
     stru_721530.prolly_normal_d = object->uRadius;
     stru_721530.height = object->uHeight;
     stru_721530.field_8_radius = 0;
     stru_721530.field_70 = 0;
-    while ( 1 )
+    for ( v55 = 0; v55 < 100; ++v55 )
     {
       stru_721530.position.x = pSpriteObjects[uLayingItemID].vPosition.x;
       stru_721530.normal.x = stru_721530.position.x;
-      v15 = pSpriteObjects[uLayingItemID].vPosition.y;
       stru_721530.uSectorID = 0;
-      stru_721530.position.y = v15;
-      stru_721530.normal.y = v15;
+      stru_721530.position.y = pSpriteObjects[uLayingItemID].vPosition.y;
+      stru_721530.normal.y = pSpriteObjects[uLayingItemID].vPosition.y;
       stru_721530.position.z = pSpriteObjects[uLayingItemID].vPosition.z + stru_721530.prolly_normal_d + 1;
       stru_721530.normal.z = stru_721530.position.z;
       stru_721530.velocity.x = pSpriteObjects[uLayingItemID].vVelocity.x;
@@ -414,24 +386,19 @@
       if ( stru_721530._47050A(0) )
         return;
       _46E889_collide_against_bmodels(0);
-      v16 = WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y);
-      v18 = WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x);
-      _46E26D_collide_against_sprites(v18, v16);
+      _46E26D_collide_against_sprites(WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x), WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y));
       if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
         _46EF01_collision_chech_player(0);
       if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor)
       {
-        v19 = PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid);
-        if (( v19 >= 0 )&&( v19 < (signed int)(uNumActors - 1) ))
+        if (( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) >= 0 )
+          &&( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < (signed int)(uNumActors - 1) ))
         {
-         
-            v20 = &pActors[v19];
-           for (v56 =0; v56 < uNumActors; ++v56)            
-              {
-                if ( v20->GetActorsRelation(&pActors[v56]) )
-                  Actor::_46DF1A_collide_against_actor(v56, 0);
-
-              }
+          for (v56 =0; v56 < uNumActors; ++v56)
+          {
+            if ( pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[v56]) )
+              Actor::_46DF1A_collide_against_actor(v56, 0);
+          }
         }
       }
       else
@@ -449,7 +416,7 @@
         else
           v44 = v54 + 60;
         sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v44);
-        SpriteObject::OnInteraction(uLayingItemID_);
+        SpriteObject::OnInteraction(uLayingItemID);
         return;
       }
       if ( stru_721530.field_7C >= stru_721530.field_6C )
@@ -510,30 +477,28 @@
       {
         if ( v29 < v54 )
           pSpriteObjects[uLayingItemID].vPosition.z = v54 + 1;
-        if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
+        if ( !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
           return;
       }
-      v30 = (signed int)PID_ID(stru_721530.uFaceID);
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
         break;
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
-        v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
-        v32 = &v31->pFaces[v30 & 0x3F];
-        if ( v32->uPolygonType != 3 )
+        bmodel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
+        face = &bmodel->pFaces[PID_ID(stru_721530.uFaceID) & 0x3F];
+        if ( face->uPolygonType != POLYGON_Floor )
         {
-          v56 = abs(v32->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z + v32->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y
-                                                                + v32->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16;
+          v56 = abs(face->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x
+                  + face->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y
+                  + face->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z) >> 16;
           if ( (stru_721530.speed >> 3) > v56 )
             v56 = stru_721530.speed >> 3;
-          v57 = v32->pFacePlane.vNormal.x;
-          v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
-          v58 = v32->pFacePlane.vNormal.y;
-          v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
-          v60 = ((unsigned __int64)(v56 * (signed __int64)v32->pFacePlane.vNormal.z) >> 16);
+          v57 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.x) >> 16;
+          v58 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.y) >> 16;
+          v60 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.z) >> 16;
           pSpriteObjects[uLayingItemID].vVelocity.x += 2 * v57;
           pSpriteObjects[uLayingItemID].vVelocity.y += 2 * v58;
-          if ( v32->pFacePlane.vNormal.z <= 32000 )
+          if ( face->pFacePlane.vNormal.z <= 32000 )
           {
             v37 = 2 * (short)v60;
           }
@@ -545,17 +510,16 @@
             v37 = (unsigned int)(32000 * v36) >> 16;
           }
           pSpriteObjects[uLayingItemID].vVelocity.z += v37;
-          if ( BYTE3(v32->uAttributes) & 0x10 )
-            EventProcessor(v32->sCogTriggeredID, 0, 1);
+          if ( BYTE3(face->uAttributes) & 0x10 )
+            EventProcessor(face->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
-        v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z;
-        v34 = pSpriteObjects[uLayingItemID].vVelocity.x;
-        pSpriteObjects[uLayingItemID].vPosition.z = v33 + 1;
-        if ( pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + v34 * v34 >= 400 )
+        pSpriteObjects[uLayingItemID].vPosition.z = bmodel->pVertices.pVertices[face->pVertexIDs[0]].z + 1;
+        if ( pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
+           + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y >= 400 )
         {
-          if ( BYTE3(v32->uAttributes) & 0x10 )
-            EventProcessor(v32->sCogTriggeredID, 0, 1);
+          if ( BYTE3(face->uAttributes) & 0x10 )
+            EventProcessor(face->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
         LOWORD(v35) = 0;
@@ -564,29 +528,16 @@
         pSpriteObjects[uLayingItemID].vVelocity.y = v35;
       }
 LABEL_74:
-      pSpriteObjects[uLayingItemID].vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.x) >> 16);
-      pSpriteObjects[uLayingItemID].vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.y) >> 16);
-      pSpriteObjects[uLayingItemID].vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.z) >> 16);
-
-      ++v55;
-      //v43 = __OFSUB__(v55, 100);
-   //   v42 = v55 - 100 < 0;
-      if (v55>=100 )//!(v42 ^ v43) 
-        return;
+      pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
+      pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
+      pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
     }
-    v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x);
-    v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[v30].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[v30].vPosition.y);
-    v56 = v38;
-    v39 = stru_5C6E00->Cos(v38);
-   // v60 = v39;
-    v40 = v39 * (signed __int64)v57;
-    v58 = v40 >> 16;
-    pSpriteObjects[uLayingItemID].vVelocity.x = WORD1(v40);
-    v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi);
-   // v60 = v41;
-    v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16;
-    v58 = v35;
-    pSpriteObjects[uLayingItemID].vVelocity.y = v35;
+    v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
+                     + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y);
+    v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.x,
+                             pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.y);
+    pSpriteObjects[uLayingItemID].vVelocity.x = (unsigned __int64)(stru_5C6E00->Cos(v38) * (signed __int64)v57) >> 16;
+    pSpriteObjects[uLayingItemID].vVelocity.y = (unsigned __int64)(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v57) >> 16;
     goto LABEL_74;
   }
 }
@@ -596,53 +547,28 @@
 {
   SpriteObject *pSpriteObject; // esi@1
   ObjectDesc *pObject; // edi@1
-  //int v3; // ST08_4@1
-  //__int16 v4; // ax@5
-  __int16 v5; // ax@7
-  BLVFace *v6; // ecx@11
-  BLVFace *v7; // eax@11
-  signed int v8; // ebx@12
   int v9; // ecx@16
   __int16 v10; // di@18
-  char v11; // al@19
-  //int v12; // eax@25
-  int v13; // eax@31
   int v14; // ebx@34
   signed int v15; // ebx@46
-  BLVFace *v16; // edi@48
   int v17; // eax@50
   int v18; // eax@52
   int v19; // ecx@52
   Vec3_short_ *v20; // ecx@53
-  //int v21; // ecx@57
   __int16 v22; // ax@57
   int v23; // edi@62
-  //int v24; // edi@62
-  //int v25; // eax@62
-  //unsigned __int64 v26; // qax@62
   unsigned __int8 v27; // sf@64
   unsigned __int8 v28; // of@64
   __int16 v29; // di@67
   char v30; // al@68
-  const char *v31; // [sp-8h] [bp-98h]@19
-  const char *v32; // [sp-8h] [bp-98h]@68
-  enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19
-  enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68
   Particle_sw Dst; // [sp+Ch] [bp-84h]@18
-  //unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
-  //ObjectDesc *v37; // [sp+78h] [bp-18h]@1
   unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
   int v39; // [sp+80h] [bp-10h]@33
-  Actor *v39b;
   int v40; // [sp+84h] [bp-Ch]@28
-  //int v41; // [sp+88h] [bp-8h]@34
-  int v42; // [sp+8Ch] [bp-4h]@4
+   int v42; // [sp+8Ch] [bp-4h]@4
 
-  //uLayingItemID_ = uLayingItemID;
   pSpriteObject = &pSpriteObjects[uLayingItemID];
   pObject = &pObjectList->pObjects[pSpriteObject->uObjectDescID];
-  //v3 = pSpriteObject->vPosition.x;
-  //v37 = &pObjectList->pObjects[pSpriteObject->uObjectDescID];
   pSpriteObject->uSectorID = pIndoor->GetSector(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z);
   v42 = BLV_GetFloorLevel(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z, pSpriteObject->uSectorID, &uFaceID);
   if ( abs(pSpriteObject->vPosition.x) > 32767
@@ -655,82 +581,56 @@
     SpriteObject::OnInteraction(uLayingItemID);
     return;
   }
-  v5 = pObject->uFlags;
-  if ( v5 & 0x20 )
+  if ( pObject->uFlags & OBJECT_DESC_NO_GRAVITY )//не падающие объекты
   {
-LABEL_24:
-    v8 = 0;
 LABEL_25:
-    stru_721530.field_0 = v8;
-    uFaceID = v8;
+    stru_721530.field_0 = 0;
     stru_721530.prolly_normal_d = pObject->uRadius;
-
     stru_721530.field_84 = -1;
     stru_721530.height = pObject->uHeight;
-    stru_721530.field_8_radius = v8;
-    stru_721530.field_70 = v8;
-    while ( 1 )
+    stru_721530.field_8_radius = 0;
+    stru_721530.field_70 = 0;
+    for ( uFaceID = 0; uFaceID < 100; uFaceID++ )
     {
       stru_721530.position.x = pSpriteObject->vPosition.x;
+      stru_721530.position.y = pSpriteObject->vPosition.y;
+      stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
+
       stru_721530.normal.x = stru_721530.position.x;
-      stru_721530.position.y = pSpriteObject->vPosition.y;
       stru_721530.normal.y = stru_721530.position.y;
-      stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
       stru_721530.normal.z = stru_721530.position.z;
+
       stru_721530.velocity.x = pSpriteObject->vVelocity.x;
       stru_721530.velocity.y = pSpriteObject->vVelocity.y;
       stru_721530.velocity.z = pSpriteObject->vVelocity.z;
+
       stru_721530.uSectorID = pSpriteObject->uSectorID;
-      if ( stru_721530._47050A(v8) )
+      if ( stru_721530._47050A(0) )
         return;
-      v40 = v8;
-      do
+
+      for ( v40 = 0; v40 < 100; ++v40 )
       {
         _46E44E_collide_against_faces_and_portals(0);
         _46E0B2_collide_against_decorations();
         if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player)
           _46EF01_collision_chech_player(1);
-        v13 = pSpriteObject->spell_caster_pid;
-        v42 = v8;
-        if (PID_TYPE(v13) == OBJECT_Actor)
+        if (PID_TYPE(pSpriteObject->spell_caster_pid) == OBJECT_Actor)
         {
-          if ( (signed int)uNumActors > v8 )
+          for ( v42 = 0; v42 < (signed int)uNumActors; ++v42 )
           {
-            v39b = pActors.data();//[0].word_000086_some_monster_id;
-            do
-            {
-              //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
-              //v14 = (signed __int64)((double)v41 * 0.3333333333333333);
-              //v41 = *(short *)(v39 - 38) - 1;
-              //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
-				if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID )
-					//not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
-					Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
-              ++v42;
-              ++v39b;// += 836;
-            }
-            while ( v42 < (signed int)uNumActors );
-            v8 = 0;
+            if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != pActors[v42].pMonsterInfo.uID )
+             //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
+              Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
           }
         }
         else
         {
-          if ( (signed int)uNumActors > v8 )
-          {
-            v39b = pActors.data();//[0].word_000086_some_monster_id;
-            do
-            {
-				Actor::_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
-              ++v39b;
-            }
-            while ( v42 < (signed int)uNumActors );
-          }
+          for ( v42 = 0; v42 < (signed int)uNumActors; v42++ )
+            Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
         }
         if ( _46F04E_collide_against_portals() )
           break;
-        ++v40;
       }
-      while ( v40 < 100 );
       if ( stru_721530.field_7C >= stru_721530.field_6C )
       {
         pSpriteObject->vPosition.x = stru_721530.normal2.x;
@@ -739,44 +639,42 @@
         pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID);
         if ( !(HIBYTE(pObject->uFlags) & 1) )
           return;
-        memset(&Dst, v8, 0x68u);
-        v29 = pObject->uFlags;
+        memset(&Dst, 0, 0x68u);
         Dst.x = (double)pSpriteObject->vPosition.x;
         Dst.y = (double)pSpriteObject->vPosition.y;
         Dst.z = (double)pSpriteObject->vPosition.z;
         Dst.r = 0.0;
         Dst.g = 0.0;
         Dst.b = 0.0;
-        if ( v29 & 0x200 )
+        if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
         {
           Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
           Dst.uDiffuse = 0xFF3C1E;
-          v30 = rand();
-          v34 = (TEXTURE_TYPE)v8;
-          v32 = "effpar01";
+          Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+          Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
         }
-        else
+        else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
         {
-          if ( v29 & 0x400 )
-          {
-            Dst.type = ParticleType_Line;
-            Dst.uDiffuse = rand();
-            Dst.timeToLive = 64;
-            Dst.uTextureID = v8;
-            Dst.flt_28 = 1.0;
-            pGame->pParticleEngine->AddParticle(&Dst);
-            return;
-          }
+          Dst.type = ParticleType_Line;
+          Dst.uDiffuse = rand();
+          Dst.timeToLive = 64;
+          Dst.uTextureID = 0;
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
+        }
+        else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+        {
           Dst.type = ParticleType_Bitmap | ParticleType_8;
           Dst.uDiffuse = rand();
-          v30 = rand();
-          v34 = (TEXTURE_TYPE)v8;
-          v32 = "effpar03";
+          Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+          Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
         }
-        Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128;
-        Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
-        Dst.flt_28 = 1.0;
-        pGame->pParticleEngine->AddParticle(&Dst);
         return;
       }
       //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
@@ -787,7 +685,7 @@
       pSpriteObject->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       pSpriteObject->uSectorID = stru_721530.uSectorID;
       stru_721530.field_70 += stru_721530.field_7C;
-      if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
+      if ( pObject->uFlags & OBJECT_DESC_INTERACTABLE && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
         return;
       v15 = (signed int)stru_721530.uFaceID >> 3;
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
@@ -798,145 +696,129 @@
         pSpriteObject->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v23), v40);
         pSpriteObject->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v23), v40);
       }
-      else
+      if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
-        if (PID_TYPE(stru_721530.uFaceID) != OBJECT_BModel)
-          goto LABEL_64;
         stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID);
-        v16 = &pIndoor->pFaces[v15];
-        if ( v16->uPolygonType != 3 )
+        if ( pIndoor->pFaces[v15].uPolygonType != POLYGON_Floor )
         {
-          v42 = abs(v16->pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x + v16->pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z
-                                                                    + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16;
+          v42 = abs(pIndoor->pFaces[v15].pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x
+                  + pIndoor->pFaces[v15].pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y
+                  + pIndoor->pFaces[v15].pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z) >> 16;
           if ( (stru_721530.speed >> 3) > v42 )
             v42 = stru_721530.speed >> 3;
-          pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.x);
-          pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.y);
-          v39 = fixpoint_mul(v42, v16->pFacePlane_old.vNormal.z);
-          if ( v16->pFacePlane_old.vNormal.z <= 32000 )
-          {
+          pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.x);
+          pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.y);
+          v39 = fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.z);
+          if ( pIndoor->pFaces[v15].pFacePlane_old.vNormal.z <= 32000 )
             v22 = 2 * v39;
-          }
           else
           {
             pSpriteObject->vVelocity.z += v39;
             v22 = fixpoint_mul(32000, v39);
           }
           pSpriteObject->vVelocity.z += v22;
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        if ( pObject->uFlags & 0x80 )
+        if ( pObject->uFlags & OBJECT_DESC_BOUNCE )
         {
-          v17 = -pSpriteObject->vVelocity.z >> 1;
+          v17 = -pSpriteObject->vVelocity.z / 2;
           pSpriteObject->vVelocity.z = v17;
           if ( (signed __int16)v17 < 10 )
             pSpriteObject->vVelocity.z = 0;
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        v18 = pSpriteObject->vVelocity.y;
-        v19 = pSpriteObject->vVelocity.x;
         pSpriteObject->vVelocity.z = 0;
-        if ( v19 * v19 + v18 * v18 >= 400 )
+        if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y >= 400 )
         {
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        v20 = pIndoor->pVertices;
         pSpriteObject->vVelocity.z = 0;
         pSpriteObject->vVelocity.y = 0;
         pSpriteObject->vVelocity.x = 0;
-        pSpriteObject->vPosition.z = v20[*v16->pVertexIDs].z + 1;
+        pSpriteObject->vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v15].pVertexIDs].z + 1;
       }
-LABEL_63:
-      //v2 = v37;
-LABEL_64:
       pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
       pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
       pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
-      ++uFaceID;
-      v28 = __OFSUB__(uFaceID, 100);
-      v27 = uFaceID - 100 < 0;
-      if ( !(v27 ^ v28) )
-        return;
-      v8 = 0;
     }
   }
+  //для падающих объектов(для примера выброс вещи из инвентаря)
   if ( v42 <= pSpriteObject->vPosition.z - 3 )
   {
     pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
-    goto LABEL_24;
+    goto LABEL_25;
   }
-  if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID, 0) )
+  if ( !(pObject->uFlags & OBJECT_DESC_INTERACTABLE) || _46BFFA_check_object_intercept(uLayingItemID, 0) )
   {
-    v6 = pIndoor->pFaces;
     pSpriteObject->vPosition.z = v42 + 1;
-    v7 = &v6[uFaceID];
-    if ( v7->uPolygonType == 3 )
-    {
-      v8 = 0;
+    if ( pIndoor->pFaces[uFaceID].uPolygonType == POLYGON_Floor )
       pSpriteObject->vVelocity.z = 0;
-    }
     else
     {
-      if ( v7->pFacePlane_old.vNormal.z < 45000 )
+      if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 45000 )
         pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
-      v8 = 0;
     }
     pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
     pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
     pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
-    v9 = pSpriteObject->vVelocity.x;
-    if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
+    if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
     {
-      pSpriteObject->vVelocity.z = v8;
-      pSpriteObject->vVelocity.y = v8;
-      pSpriteObject->vVelocity.x = v8;
-      if ( !(pObject->uFlags & 1) )
+      pSpriteObject->vVelocity.x = 0;
+      pSpriteObject->vVelocity.y = 0;
+      pSpriteObject->vVelocity.z = 0;
+      if ( !(pObject->uFlags & OBJECT_DESC_NO_SPRITE) )
         return;
-      memset(&Dst, v8, 0x68u);
-      v10 = pObject->uFlags;
+      memset(&Dst, 0, 0x68u);
       Dst.x = (double)pSpriteObject->vPosition.x;
       Dst.y = (double)pSpriteObject->vPosition.y;
       Dst.z = (double)pSpriteObject->vPosition.z;
       Dst.r = 0.0;
       Dst.g = 0.0;
       Dst.b = 0.0;
-      if ( v10 & 0x200 )
+      if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
       {
         Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
         Dst.uDiffuse = 0xFF3C1E;
         Dst.flt_28 = 1.0;
-        v11 = rand();
-        v33 = (TEXTURE_TYPE)v8;
-        v31 = "effpar01";
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+        pGame->pParticleEngine->AddParticle(&Dst);
+        return;
       }
-      else
+      else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
       {
-        if ( v10 & 0x400 )
-        {
-          Dst.type = ParticleType_Line;
-          Dst.uDiffuse = rand();
-          Dst.timeToLive = 64;
-          Dst.uTextureID = v8;
-          Dst.flt_28 = 1.0;
-          pGame->pParticleEngine->AddParticle(&Dst);
-          return;
-        }
+        Dst.type = ParticleType_Line;
+        Dst.uDiffuse = rand();
+        Dst.timeToLive = 64;
+        Dst.uTextureID = 0;
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+        return;
+      }
+      else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+      {
         Dst.type = ParticleType_Bitmap | ParticleType_8;
         Dst.uDiffuse = rand();
         Dst.flt_28 = 1.0;
-        v11 = rand();
-        v33 = (TEXTURE_TYPE)v8;
-        v31 = "effpar03";
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+        pGame->pParticleEngine->AddParticle(&Dst);
       }
-      Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
-      pGame->pParticleEngine->AddParticle(&Dst);
       return;
     }
     goto LABEL_25;
@@ -1032,16 +914,16 @@
 
 //----- (0042FA22) --------------------------------------------------------
 void CompactLayingItemsList()
-    {
-    int new_obj_pos=0;
+{
+  int new_obj_pos = 0;
 
-    for (int i=0; i<MAX_SPRITE_OBJECTS; ++i)
-        {
-        if (pSpriteObjects[i].uObjectDescID)
-            memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject));
-        }
-    uNumSpriteObjects = new_obj_pos;
-    }
+  for (int i=0; i < MAX_SPRITE_OBJECTS; ++i)
+  {
+    if (pSpriteObjects[i].uObjectDescID)
+      memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject));
+  }
+  uNumSpriteObjects = new_obj_pos;
+}
 //----- (00408896) --------------------------------------------------------
 void InitializeSpriteObjects()
 {
@@ -1049,31 +931,27 @@
   {
     SpriteObject* item = &pSpriteObjects[i];
 
-    if (item->uType &&
-        (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10))
+    if (item->uType && (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & OBJECT_DESC_UNPICKABLE))
       SpriteObject::OnInteraction(i);
   }
 }
 //----- (0046BEF1) --------------------------------------------------------
 void SpriteObject::_46BEF1_apply_spells_aoe()
 {
-  SpriteObject *v1; // edi@1
-  Actor *v2; // esi@2
-  __int16 v3; // fps@4
-  unsigned __int8 v4; // c0@4
-  unsigned __int8 v5; // c3@4
-  signed int v6; // [sp+8h] [bp-4h]@1
+  //SpriteObject *v1; // edi@1
+  //Actor *v2; // esi@2
+  //__int16 v3; // fps@4
+  //unsigned __int8 v4; // c0@4
+  //unsigned __int8 v5; // c3@4
+  //signed int v6; // [sp+8h] [bp-4h]@1
 
-  int v7,v8,v9,v10,v11;
-
-  v6 = 0;
-  v1 = this;
+  int v7,v9,v10,v11;
+  __debugbreak();//Ritor1
   if ( (signed int)uNumActors > 0 )
   {
-    v2 = pActors.data();//[0].vPosition.y;
-    do
+    for ( uint i = 0; i < uNumActors; ++i )
     {
-      if ( v2->CanAct() )
+      if ( pActors[i].CanAct() )
       {
         //UNDEF(v3);
 		//.text:0046BF26                 movsx   eax, word ptr [esi-2]
@@ -1081,17 +959,17 @@
 		//.text:0046BF31                 mov     [ebp+var_8], eax
 		//.text:0046BF37                 fild    [ebp+var_8]
 		// v7 pushed to stack
-		v7 = v2->vPosition.x - this->vPosition.x;
+		v7 = pActors[i].vPosition.x - this->vPosition.x;
 
 		//.text:0046BF2D                 movsx   ecx, word ptr [esi+2]
-		v8 = v2->vPosition.z;
+		//v8 = pActors[i].vPosition.z;
 
 		//.text:0046BF34                 movsx   eax, word ptr [esi]
 		//.text:0046BF3A                 sub     eax, [edi+8]
 		//.text:0046BF3D                 mov     [ebp+var_8], eax
 		//.text:0046BF44                 fild    [ebp+var_8]
 		// v9 pushed to stack
-		v9 = v2->vPosition.y - this->vPosition.y;
+		v9 = pActors[i].vPosition.y - this->vPosition.y;
 
 		//.text:0046BF40                 movsx   eax, word ptr [esi-6]
 		//.text:0046BF47                 sar     eax, 1
@@ -1101,12 +979,12 @@
 		//.text:0046BF51                 fild    [ebp+var_8]
 		//.text:0046BF58                 fld     st
 		// v10 pushed to stack, two times
-		v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y;
+		v10 = pActors[i].uActorHeight / 2 + pActors[i].vPosition.z - this->vVelocity.y;
 
 		//.text:0046BF54                 movsx   eax, word ptr [esi-8]
 		//.text:0046BF5A                 add     eax, 100h
 		//.text:0046BF63                 mov     ecx, eax
-		v11 = this->vVelocity.x;
+		//v11 = this->vVelocity.x;
 
 		//.text:0046BF5F                 fmul    st, st(1)
 		// stack: v10*v10, v10, v9, v7
@@ -1118,7 +996,7 @@
 		// stack: v7*v9, v10*v10, v10, v9, v7
 		
 		//.text:0046BF67                 imul    ecx, eax
-		v11 = v11 * v11;
+		v11 = this->vVelocity.x * this->vVelocity.x;
 
 		//.text:0046BF6A                 faddp   st(1), st
 		// stack: v10*v10+v7*v9, v10, v9, v7
@@ -1148,23 +1026,16 @@
 		//.text:0046BF83                 fstp    st
 		//.text:0046BF85                 jnz     short loc_46BFDD
 
-		if ( v11 >= v10*v10+v7*v9+v7*v7 )
+		if ( v11 >= v7 * v7 + v9 * v9 + v10 * v10 )
         {
-          if ( stru_50C198.GetMagicalResistance(v2, 0xAu) )
+          if ( stru_50C198.GetMagicalResistance(&pActors[i], 0xAu) )
           {
-			  v2->pActorBuffs[v1->spell_id].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->spell_level << 7) * 0.033333335),
-              v1->spell_skill,
-              4u,
-              0,
-              0);
-            HIWORD(v2->uAttributes) |= 8u;
+            pActors[i].pActorBuffs[this->spell_id].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(this->spell_level << 7) * 0.033333335),
+                   this->spell_skill, 4, 0, 0);
+            HIWORD(pActors[i].uAttributes) |= 8;
           }
         }
       }
-      ++v6;
-      ++v2;
     }
-    while ( v6 < (signed int)uNumActors );
   }
 }
\ No newline at end of file