changeset 2363:7966fc2949a7

Merge
author Grumpy7
date Thu, 01 May 2014 12:59:50 +0200
parents eb136041adf1 (diff) d6bba1e6249d (current diff)
children 94e5a9740727
files
diffstat 9 files changed, 675 insertions(+), 664 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat Apr 19 23:56:01 2014 +0600
+++ b/Actor.cpp	Thu May 01 12:59:50 2014 +0200
@@ -1,5 +1,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 
+#include "PaletteManager.h"
 #include "ErrorHandling.h"
 #include "VectorTypes.h"
 #include "mm7_unsorted_subs.h"
@@ -4980,4 +4981,470 @@
   if ( current_sector != obj2_sector )
     return 0;
   return 1;
-}
\ No newline at end of file
+}
+
+
+//----- (00450B0A) --------------------------------------------------------
+bool __fastcall SpawnActor(unsigned int uMonsterID)
+{
+  unsigned int v1; // ebx@1
+  bool result; // eax@2
+  MonsterDesc *v3; // esi@5
+  MonsterInfo *v4; // edi@5
+  Vec3_int_ v5; // ST08_12@5
+  unsigned int v6; // ecx@5
+  Actor *v7; // eax@7
+  Actor actor; // [sp+4h] [bp-350h]@5
+  Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5
+
+  v1 = uMonsterID;
+  if ( uNumActors == 499 )
+  {
+    result = 0;
+  }
+  else
+  {
+    if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters )
+      v1 = 0;
+    v3 = &pMonsterList->pMonsters[v1];
+    v4 = &pMonsterStats->pInfos[v1 + 1];
+    memset(&actor, 0, 0x344u);
+    strcpy(actor.pActorName, v4->pName);
+    actor.sCurrentHP = LOWORD(v4->uHP);
+    memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u);
+    actor.word_000086_some_monster_id = v1 + 1;
+    actor.uActorRadius = v3->uMonsterRadius;
+    actor.uActorHeight = v3->uMonsterHeight;
+    actor.uMovementSpeed = v3->uMovementSpeed;
+    v5 = pParty->vPosition;
+    Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y);
+    actor.vInitialPosition.x = pOut.x;
+    actor.vPosition.x = pOut.x;
+    actor.uTetherDistance = 256;
+    actor.vInitialPosition.y = LOWORD(pOut.z);
+    actor.vPosition.y = LOWORD(pOut.z);
+    actor.vInitialPosition.z = LOWORD(pOut.y);
+    actor.vPosition.z = LOWORD(pOut.y);
+    pSprites_LOD->DeleteSomeSprites();
+    pPaletteManager->ResetNonTestLocked();
+    v6 = uNumActors - 1;
+    if ( dword_5C6DF8 == 1 )
+    {
+      dword_5C6DF8 = 0;
+      v6 = uNumActors++;
+    }
+    v7 = &pActors[v6];
+    memcpy(v7, &actor, 0x344u);
+    v7->PrepareSprites(1);
+    result = 1;
+  }
+  return result;
+}
+// 5C6DF8: using guessed type int dword_5C6DF8;
+
+
+//----- (0044FA4C) --------------------------------------------------------
+signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3)
+{
+  signed int v3; // ecx@6
+  Actor *v4; // edx@7
+  signed int result; // eax@13
+  Actor *v6; // esi@16
+  char *v7; // ebx@16
+  MonsterDesc *v8; // edi@16
+  unsigned __int16 v9; // ax@16
+  int v10; // ebx@16
+  //int v11; // edi@16
+  //int v12; // eax@16
+  //int v13; // ecx@16
+  //int v14; // ebx@16
+  const char *v15; // [sp-4h] [bp-24h]@2
+  //unsigned __int16 v16; // [sp+0h] [bp-20h]@1
+  //int v17; // [sp+4h] [bp-1Ch]@1
+  unsigned int uFaceID; // [sp+8h] [bp-18h]@16
+  int v19; // [sp+Ch] [bp-14h]@16
+  size_t v20; // [sp+10h] [bp-10h]@6
+  int v21; // [sp+14h] [bp-Ch]@14
+  //int v22; // [sp+18h] [bp-8h]@14
+  unsigned int v23; // [sp+1Ch] [bp-4h]@6
+
+  //v16 = a2;
+  //v17 = a1;
+  if ( a2 == 4 )
+  {
+    v15 = "Elemental Light C";
+  }
+  else if ( a2 == 3 )
+    v15 = "Elemental Light B";
+  else
+    v15 = "Elemental Light A";
+
+  v23 = pMonsterList->GetMonsterIDByName(v15);
+  v3 = 0;
+  v20 = uNumActors;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v4 = pActors.data();//[0].uAIState;
+    while ( v4->uAIState != Removed )
+    {
+      ++v3; 
+      ++v4;
+      if ( v3 >= (signed int)uNumActors )
+        break;
+    }
+    if( v3 < (signed int)uNumActors )
+      v20 = v3;
+  }
+  if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) )
+  {
+    v21 = 0;
+    //v22 = pParty->vPosition.z;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
+    v6 = &pActors[v20];
+    v7 = (char *)&pMonsterStats->pInfos[v23 + 1];
+    v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
+    v6->Reset();
+    v8 = &pMonsterList->pMonsters[v23];
+    strcpy(v6->pActorName, *(const char **)v7);
+    v6->sCurrentHP = *((short *)v7 + 32);
+    memcpy(&v6->pMonsterInfo, v7, 0x58u);
+    v6->word_000086_some_monster_id = v23 + 1;
+    v6->uActorRadius = v8->uMonsterRadius;
+    v6->uActorHeight = v8->uMonsterHeight;
+    v9 = v8->uMovementSpeed;
+    v6->pMonsterInfo.uTreasureDiceRolls = 0;
+    v6->pMonsterInfo.uTreasureType = 0;
+    v6->pMonsterInfo.uExp = 0;
+    v6->uMovementSpeed = v9;
+    v10 = rand() % 2048;
+    //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19);
+    uFaceID = stru_5C6E00->Sin(v10);
+    //v12 = pParty->vPosition.y;
+    //v13 = fixpoint_mul(uFaceID, v19);
+    //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19);
+    //LOWORD(v12) = v22;
+    v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19);
+    v6->vPosition.x = v6->vInitialPosition.x;
+    v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19);
+    v6->vPosition.y = v6->vInitialPosition.y;
+    v6->vInitialPosition.z = pParty->vPosition.z;
+    v6->vPosition.z = v6->vInitialPosition.z;
+    //LOWORD(v12) = v21;
+    v6->uTetherDistance = 256;
+    v6->uSectorID = v21;
+    v6->PrepareSprites(0);
+    v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+    v6->uAlly = 9999;
+    v6->uGroup = 0;
+    v6->uCurrentActionTime = 0;
+    v6->uAIState = Summoned;
+    v6->uCurrentActionLength = 256;
+    v6->UpdateAnimation();
+    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
+      || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z),
+      result == v21)
+      && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000)
+      && (result = abs(result - pParty->vPosition.z), result <= 1024) )
+    {
+      if ( v20 == uNumActors )
+        ++uNumActors;
+      v6->uSummonerID = PID(OBJECT_Player, a1);
+      result = v6->pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f,
+        a2,
+        a1,
+        0,
+        0);
+    }
+  }
+  return result;
+}
+
+
+//----- (0044F57C) --------------------------------------------------------
+void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5)
+{
+  //MapInfo *v5; // esi@1
+  //SpawnPointMM7 *v6; // ebx@1
+  int v7; // eax@2
+  char v8; // zf@5
+  //  int v9; // edi@9
+  //  int v10; // eax@9
+  //  int v11; // ecx@9
+  int v12; // edx@9
+  //  int v13; // eax@9
+  //  int v14; // eax@14
+  //  int v15; // ecx@14
+  //  int v16; // eax@19
+  //  int v17; // ecx@19
+  int v18; // esi@31
+  //int pPosX; // ecx@32
+  //int v20; // edx@32
+  //int v21; // eax@32
+  Actor *pMonster; // esi@35
+  int v23; // edx@36
+  signed int v24; // edi@36
+  int v25; // ecx@36
+  //  unsigned __int16 v26; // ax@47
+  MonsterDesc *v27; // edi@48
+  signed int v28; // eax@48
+  //  __int16 v29; // cx@50
+  //  __int16 v30; // ax@50
+  //  __int16 v31; // ax@50
+  int v32; // eax@50
+  //  int v33; // edi@50
+  //  int v34; // eax@50
+  //  int v35; // eax@50
+  //  int v36; // eax@50
+  int v37; // eax@51
+  int v38; // eax@52
+  int v39; // edi@52
+  std::string v40; // [sp-18h] [bp-100h]@60
+  //  void *v41; // [sp-14h] [bp-FCh]@50
+  //void *v42; // [sp-10h] [bp-F8h]@50
+  //size_t v43; // [sp-Ch] [bp-F4h]@50
+  const char *v44; // [sp-8h] [bp-F0h]@13
+  char *pTexture; // [sp-4h] [bp-ECh]@9
+  char Str[32]; // [sp+Ch] [bp-DCh]@60
+  char Str2[120]; // [sp+2Ch] [bp-BCh]@29
+  unsigned int uFaceID; // [sp+A4h] [bp-44h]@52
+  MonsterInfo *Src; // [sp+A8h] [bp-40h]@50
+  int v50; // [sp+ACh] [bp-3Ch]@47
+  char Source[32]; // [sp+B0h] [bp-38h]@20
+  int v52; // [sp+D0h] [bp-18h]@34
+  int v53; // [sp+D4h] [bp-14h]@34
+  int pSector; // [sp+D8h] [bp-10h]@32
+  int pPosX; // [sp+DCh] [bp-Ch]@32
+  int v56; // [sp+E0h] [bp-8h]@8
+  int v57; // [sp+E4h] [bp-4h]@1
+
+  //auto a2 = spawn;
+  v57 = 0;
+  //v5 = pMapInfo;
+  //v6 = spawn;
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    v7 = pOutdoor->ddm.field_C_alert;
+  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    v7 = pIndoor->dlv.field_C_alert;
+  else
+    v7 = 0;
+  if (v7)
+    v8 = (spawn->uAttributes & 1) == 0;
+  else
+    v8 = (spawn->uAttributes & 1) == 1;
+  if (v8)
+    return;
+  //result = (void *)(spawn->uIndex - 1);
+  v56 = 1;
+  switch (spawn->uIndex - 1)
+  {
+  case 0:
+    //v9 = pMapInfo->uEncounterMonster1AtLeast;
+    //v10 = rand();
+    //v11 = pMapInfo->uEncounterMonster1AtMost;
+    //pTexture = pMapInfo->pEncounterMonster1Texture;
+    v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1);
+    //v13 = pMapInfo->Dif_M1;
+    v57 = pMapInfo->Dif_M1;
+    v56 = pMapInfo->uEncounterMonster1AtLeast + v12;
+    strcpy(Source, pMapInfo->pEncounterMonster1Texture);
+    break;
+  case 3:
+    //pTexture = pMapInfo->pEncounterMonster1Texture;
+    //v44 = "%s A";
+    sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture);
+    break;
+  case 4:
+    //pTexture = pMapInfo->pEncounterMonster2Texture;
+    //v44 = "%s A";
+    sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture);
+    break;
+  case 5:
+    //pTexture = pMapInfo->pEncounterMonster3Texture;
+    //v44 = "%s A";
+    sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture);
+    break;
+  case 1:
+    //v9 = pMapInfo->uEncounterMonster2AtLeast;
+    //v14 = rand();
+    //v15 = pMapInfo->uEncounterMonster2AtMost;
+    //pTexture = pMapInfo->pEncounterMonster2Texture;
+    v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1);
+    //v13 = pMapInfo->Dif_M2;
+    v57 = pMapInfo->Dif_M2;
+    v56 = pMapInfo->uEncounterMonster2AtLeast + v12;
+    strcpy(Source, pMapInfo->pEncounterMonster2Texture);
+    break;
+  case 6:
+    //pTexture = pMapInfo->pEncounterMonster1Texture;
+    //v44 = "%s B";
+    sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture);
+    break;
+  case 7:
+    //pTexture = pMapInfo->pEncounterMonster2Texture;
+    //v44 = "%s B";
+    sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture);
+    break;
+  case 8:
+    //pTexture = pMapInfo->pEncounterMonster3Texture;
+    //v44 = "%s B";
+    sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture);
+    break;
+  case 2:
+    //v9 = pMapInfo->uEncounterMonster3AtLeast;
+    //v16 = rand();
+    //v17 = pMapInfo->uEncounterMonster3AtMost;
+    //pTexture = pMapInfo->pEncounterMonster3Texture;
+    v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1);
+    //v13 = pMapInfo->Dif_M3;
+    v57 = pMapInfo->Dif_M3;
+    v56 = pMapInfo->uEncounterMonster3AtLeast + v12;
+    strcpy(Source, pMapInfo->pEncounterMonster3Texture);
+    break;
+  case 9:
+    //pTexture = pMapInfo->pEncounterMonster1Texture;
+    //v44 = "%s C";
+    sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture);
+    break;
+  case 10:
+    //pTexture = pMapInfo->pEncounterMonster2Texture;
+    //v44 = "%s C";
+    sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture);
+    break;
+  case 11:
+    //pTexture = pMapInfo->pEncounterMonster3Texture;
+    //v44 = "%s C";
+    sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture);
+    break;
+  default:
+    return;
+  }
+  if (Source[0] == '0')
+    return;
+  v57 += a3;
+  if ( v57 > 4 )
+    v57 = 4;
+  strcpy(Str2, Source);
+  if ( a4 )
+    v56 = a4;
+  v18 = v56;
+  if ( (signed int)(v56 + uNumActors) >= 500 )
+    return;
+  pSector = 0;
+  pPosX = spawn->vPosition.x;
+  a4 = spawn->vPosition.y;
+  a3 = spawn->vPosition.z;
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
+  v53 = 0;
+  v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
+  if ( v18 <= 0 )
+    return;
+  for (uint i = v53; i < v56; ++i)
+  {
+    pMonster = &pActors[uNumActors];
+    pActors[uNumActors].Reset();
+    if ( v57 )
+    {
+      v23 = rand() % 100;
+      v24 = 3;
+      v25 = (unsigned __int16)word_4E8152[3 * v57];
+      if ( v23 >= v25 )
+      {
+        if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] )
+          v24 = 2;
+      }
+      else
+      {
+        v24 = 1;
+      }
+      if ( v24 == 1 )
+      {
+        pTexture = Source;
+        v44 = "%s A";
+      }
+      else
+      {
+        if ( v24 == 2 )
+        {
+          pTexture = Source;
+          v44 = "%s B";
+        }
+        else
+        {
+          if ( v24 != 3 )
+            continue;
+          pTexture = Source;
+          v44 = "%s C";
+        }
+      }
+      sprintf(Str2, v44, pTexture);
+    }
+    v50 = pMonsterList->GetMonsterIDByName(Str2);
+    pTexture = Str2;
+    if ( (signed __int16)v50 == -1 )
+    {
+      sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture);
+      MessageBoxA(nullptr, Str, nullptr, 0);
+      ExitProcess(0);
+    }
+    v27 = &pMonsterList->pMonsters[(signed __int16)v50];
+    v28 = pMonsterStats->FindMonsterByTextureName(pTexture);
+    if ( !v28 )
+      v28 = 1;
+    Src = &pMonsterStats->pInfos[v28];
+    strcpy(pMonster->pActorName, Src->pName);
+    pMonster->sCurrentHP = Src->uHP;
+    assert(sizeof(MonsterInfo) == 88);
+    memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));
+    pMonster->word_000086_some_monster_id = v50 + 1;
+    pMonster->uActorRadius = v27->uMonsterRadius;
+    pMonster->uActorHeight = v27->uMonsterHeight;
+    pMonster->uMovementSpeed = v27->uMovementSpeed;
+    pMonster->vInitialPosition.x = spawn->vPosition.x;
+    pMonster->vPosition.x = spawn->vPosition.x;
+    pMonster->uTetherDistance = 256;
+    pMonster->vInitialPosition.y = a4;
+    pMonster->vPosition.y = a4;
+    pMonster->vInitialPosition.z = a3;
+    pMonster->vPosition.z = a3;
+    pMonster->uSectorID = pSector;
+    pMonster->uGroup = spawn->uGroup;
+    pMonster->PrepareSprites(0);
+    pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+    v32 = rand();
+    a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52);
+    pPosX = a3 + spawn->vPosition.x;
+    a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52);
+    a4 = a3 + spawn->vPosition.y;
+    a3 = spawn->vPosition.z;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+    {
+      if ( a5 )
+        pMonster->uAttributes |= 0x080000;
+      ++uNumActors;
+      continue;
+    }
+    v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z);
+    if ( v37 == pSector )
+    {
+      v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID);
+      v39 = v38;
+      if ( v38 != -30000 )
+      {
+        if ( abs(v38 - a3) <= 1024 )
+        {
+          a3 = v39;
+          if ( a5 )
+            pMonster->uAttributes |= 0x080000;
+          ++uNumActors;
+          continue;
+        }
+      }
+    }
+    ;
+    //v53 = (char *)v53 + 1;
+    //result = v53;
+  }
+  //while ( (signed int)v53 < v56 );
+}
--- a/Actor.h	Sat Apr 19 23:56:01 2014 +0600
+++ b/Actor.h	Thu May 01 12:59:50 2014 +0200
@@ -304,3 +304,6 @@
 void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3);
 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle);
 bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID);
+bool __fastcall SpawnActor(unsigned int uMonsterID);
+int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
+void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
--- a/DecorationList.cpp	Sat Apr 19 23:56:01 2014 +0600
+++ b/DecorationList.cpp	Thu May 01 12:59:50 2014 +0200
@@ -6,6 +6,8 @@
 #include "mm7_data.h"
 #include "Indoor.h"
 #include "ErrorHandling.h"
+#include "stru123.h"
+#include "Level\Decoration.h"
 
 //----- (0045864C) --------------------------------------------------------
 void DecorationList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
@@ -260,4 +262,29 @@
     }
   }
   return 0;
+}
+
+
+//----- (00450AAA) --------------------------------------------------------
+void RespawnGlobalDecorations()
+{
+  memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125);
+
+  uint decorEventIdx = 0;
+  for (uint i = 0; i < uNumLevelDecorations; ++i)
+  {
+    LevelDecoration* decor = &pLevelDecorations[i];
+
+    if (!decor->uEventID)
+    {
+      if (decor->IsInteractive())
+      {
+        if (decorEventIdx < 124)
+        {
+          decor->_idx_in_stru123 = decorEventIdx + 75;
+          stru_5E4C90_MapPersistVars._decor_events[decorEventIdx++] = decor->GetGlobalEvent();
+        }
+      }
+    }
+  }
 }
\ No newline at end of file
--- a/DecorationList.h	Sat Apr 19 23:56:01 2014 +0600
+++ b/DecorationList.h	Thu May 01 12:59:50 2014 +0200
@@ -75,4 +75,6 @@
 #pragma pack(pop)
 
 
-extern struct DecorationList *pDecorationList;
\ No newline at end of file
+extern struct DecorationList *pDecorationList;
+
+void RespawnGlobalDecorations();
\ No newline at end of file
--- a/GUIWindow.cpp	Sat Apr 19 23:56:01 2014 +0600
+++ b/GUIWindow.cpp	Thu May 01 12:59:50 2014 +0200
@@ -27,6 +27,7 @@
 #include "Outdoor.h"
 #include "Game.h"
 #include "IconFrameTable.h"
+#include "Actor.h"
 
 
 #include "mm7_data.h"
--- a/Indoor.cpp	Sat Apr 19 23:56:01 2014 +0600
+++ b/Indoor.cpp	Thu May 01 12:59:50 2014 +0200
@@ -6301,4 +6301,174 @@
   if ( result )
     result = abs(((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / result);
   return result;
+}
+
+//----- (00450DA3) --------------------------------------------------------
+int  GetAlertStatus()
+{
+  int result; // eax@2
+
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    result = pOutdoor->ddm.field_C_alert;
+  else
+    result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0;
+  return result;
+}
+
+
+//----- (0045063B) --------------------------------------------------------
+int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2)
+{
+  int result; // eax@8
+  int v6; // edi@11
+  int v7; // ebx@11
+  int v8; // edi@11
+  int v9; // ebx@12
+  int v10; // eax@12
+  char v11; // zf@16
+  int v12; // edi@20
+  int v13; // eax@20
+  int v14; // ebx@20
+  int v15; // eax@20
+  int v16; // eax@20
+  int v17; // eax@20
+  int v18; // eax@21
+  SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1
+  int v22; // [sp+2Ch] [bp-18h]@3
+  unsigned int uFaceID; // [sp+38h] [bp-Ch]@10
+  int v26; // [sp+3Ch] [bp-8h]@11
+  int v27; // [sp+40h] [bp-4h]@11
+
+  if (!uNumActors)
+    return 0;
+
+  for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id )
+  {
+    if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C
+      (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C
+      (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C
+      pActors[mon_id].CanAct())
+    {
+      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+      {
+        v22 = 0;
+        uint face_id = 0;
+        for ( face_id; face_id < 100; ++face_id )
+        {
+          v6 = rand() % 1024 + 512;
+          v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
+          v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6);
+          v8 = 0;
+          v19.uIndex = a2;
+          v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y;
+          v19.vPosition.z = pParty->vPosition.z;
+          v26 = 0;
+          v27 = 0;
+          v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0);
+          for( int i = 0; i < pOutdoor->uNumBModels; i++ )
+          {
+            v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y);
+            v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x);
+            if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 )
+            {
+              v22 = 1;
+              break;
+            }
+          }
+          if ( v22 )
+          {
+            v11 = face_id == 100;
+            break;
+          }
+        }
+        v11 = face_id == 100;
+      }
+      else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      {
+        v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
+        for ( uint i = 0; i < 100; ++i )
+        {
+          v12 = rand() % 512 + 256;
+          v13 = rand();
+          v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi;
+          v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi);
+          v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12);
+          v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi);
+          v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y;
+          v19.vPosition.z = pParty->vPosition.z;
+          v19.uIndex = a2;
+          v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z);
+          if ( v17 == v22 )
+          {
+            v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID);
+            v19.vPosition.z = v18;
+            if ( v18 != -30000 )
+            {
+              if ( abs(v18 - pParty->vPosition.z) <= 1024 )
+                break;
+            }
+          }
+        }
+        v11 = v26 == 100;
+      }
+      if ( v11 )
+        result = 0;
+      else
+      {
+        SpawnEncounter(a1, &v19, 0, 0, 1);
+        result = a2;
+      }
+    }
+
+    //break;
+    //v22 = v3->pMonsterInfo.uID - 1;
+    //v4 = (signed __int64)((double)v22 * 0.3333333333333333);
+    //if ( (int)v4 != 40 )
+    //{
+    //  if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() )
+    //    break;
+    //}
+    //++v2;
+    //++v3;
+    //if ( v2 >= (signed int)uNumActors )
+    //  goto LABEL_8;
+  }
+  return result;
+}
+
+//----- (00450521) --------------------------------------------------------
+int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6)
+{
+  int v6; // edi@1
+  int v7; // esi@1
+  signed int v8; // edi@1
+  unsigned __int16 v9; // cx@1
+  //  char *v10; // edx@2
+  unsigned __int16 v11; // ax@5
+  SpriteObject a1; // [sp+8h] [bp-70h]@1
+
+  v6 = ecx0;
+  v7 = a2;
+  pItemsTable->GenerateItem(v6, v7, &a1.stru_24);
+  v8 = 0;
+  v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
+  a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
+  v11 = 0;
+  for( int i = 0; i < pObjectList->uNumObjects; i++ )
+  {
+    if( v9 == pObjectList->pObjects[i].uObjectID )
+    {
+      v11 = i;
+      break;
+    }
+  }
+  a1.uObjectDescID = v11;
+  a1.vPosition.y = a4;
+  a1.vPosition.x = a3;
+  a1.vPosition.z = a5;
+  a1.uFacing = a6;
+  a1.uAttributes = 0;
+  a1.uSectorID = pIndoor->GetSector(a3, a4, a5);
+  a1.uSpriteFrameID = 0;
+  return a1.Create(0, 0, 0, 0);
 }
\ No newline at end of file
--- a/Indoor.h	Sat Apr 19 23:56:01 2014 +0600
+++ b/Indoor.h	Thu May 01 12:59:50 2014 +0200
@@ -556,3 +556,6 @@
 int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6);
 void __fastcall PrepareDrawLists_BLV();
 void PrepareToLoadBLV(unsigned int bLoading);
+int GetAlertStatus();
+int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2);
+int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
--- a/mm7_2.cpp	Sat Apr 19 23:56:01 2014 +0600
+++ b/mm7_2.cpp	Thu May 01 12:59:50 2014 +0200
@@ -959,661 +959,6 @@
   return result;
 }
 
-//----- (0044F57C) --------------------------------------------------------
-void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5)
-{
-  //MapInfo *v5; // esi@1
-  //SpawnPointMM7 *v6; // ebx@1
-  int v7; // eax@2
-  char v8; // zf@5
-//  int v9; // edi@9
-//  int v10; // eax@9
-//  int v11; // ecx@9
-  int v12; // edx@9
-//  int v13; // eax@9
-//  int v14; // eax@14
-//  int v15; // ecx@14
-//  int v16; // eax@19
-//  int v17; // ecx@19
-  int v18; // esi@31
-  //int pPosX; // ecx@32
-  //int v20; // edx@32
-  //int v21; // eax@32
-  Actor *pMonster; // esi@35
-  int v23; // edx@36
-  signed int v24; // edi@36
-  int v25; // ecx@36
-//  unsigned __int16 v26; // ax@47
-  MonsterDesc *v27; // edi@48
-  signed int v28; // eax@48
-//  __int16 v29; // cx@50
-//  __int16 v30; // ax@50
-//  __int16 v31; // ax@50
-  int v32; // eax@50
-//  int v33; // edi@50
-//  int v34; // eax@50
-//  int v35; // eax@50
-//  int v36; // eax@50
-  int v37; // eax@51
-  int v38; // eax@52
-  int v39; // edi@52
-  std::string v40; // [sp-18h] [bp-100h]@60
-//  void *v41; // [sp-14h] [bp-FCh]@50
-  //void *v42; // [sp-10h] [bp-F8h]@50
-  //size_t v43; // [sp-Ch] [bp-F4h]@50
-  const char *v44; // [sp-8h] [bp-F0h]@13
-  char *pTexture; // [sp-4h] [bp-ECh]@9
-  char Str[32]; // [sp+Ch] [bp-DCh]@60
-  char Str2[120]; // [sp+2Ch] [bp-BCh]@29
-  unsigned int uFaceID; // [sp+A4h] [bp-44h]@52
-  MonsterInfo *Src; // [sp+A8h] [bp-40h]@50
-  int v50; // [sp+ACh] [bp-3Ch]@47
-  char Source[32]; // [sp+B0h] [bp-38h]@20
-  int v52; // [sp+D0h] [bp-18h]@34
-  int v53; // [sp+D4h] [bp-14h]@34
-  int pSector; // [sp+D8h] [bp-10h]@32
-  int pPosX; // [sp+DCh] [bp-Ch]@32
-  int v56; // [sp+E0h] [bp-8h]@8
-  int v57; // [sp+E4h] [bp-4h]@1
-
-  //auto a2 = spawn;
-  v57 = 0;
-  //v5 = pMapInfo;
-  //v6 = spawn;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    v7 = pOutdoor->ddm.field_C_alert;
-  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-    v7 = pIndoor->dlv.field_C_alert;
-  else
-    v7 = 0;
-  if (v7)
-    v8 = (spawn->uAttributes & 1) == 0;
-  else
-    v8 = (spawn->uAttributes & 1) == 1;
-  if (v8)
-    return;
-    //result = (void *)(spawn->uIndex - 1);
-  v56 = 1;
-  switch (spawn->uIndex - 1)
-  {
-    case 0:
-        //v9 = pMapInfo->uEncounterMonster1AtLeast;
-        //v10 = rand();
-        //v11 = pMapInfo->uEncounterMonster1AtMost;
-        //pTexture = pMapInfo->pEncounterMonster1Texture;
-        v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1);
-        //v13 = pMapInfo->Dif_M1;
-        v57 = pMapInfo->Dif_M1;
-        v56 = pMapInfo->uEncounterMonster1AtLeast + v12;
-        strcpy(Source, pMapInfo->pEncounterMonster1Texture);
-        break;
-    case 3:
-        //pTexture = pMapInfo->pEncounterMonster1Texture;
-        //v44 = "%s A";
-        sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture);
-        break;
-    case 4:
-        //pTexture = pMapInfo->pEncounterMonster2Texture;
-        //v44 = "%s A";
-        sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture);
-        break;
-    case 5:
-        //pTexture = pMapInfo->pEncounterMonster3Texture;
-        //v44 = "%s A";
-        sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture);
-        break;
-    case 1:
-        //v9 = pMapInfo->uEncounterMonster2AtLeast;
-        //v14 = rand();
-        //v15 = pMapInfo->uEncounterMonster2AtMost;
-        //pTexture = pMapInfo->pEncounterMonster2Texture;
-        v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1);
-        //v13 = pMapInfo->Dif_M2;
-        v57 = pMapInfo->Dif_M2;
-        v56 = pMapInfo->uEncounterMonster2AtLeast + v12;
-        strcpy(Source, pMapInfo->pEncounterMonster2Texture);
-        break;
-    case 6:
-        //pTexture = pMapInfo->pEncounterMonster1Texture;
-        //v44 = "%s B";
-        sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture);
-        break;
-    case 7:
-        //pTexture = pMapInfo->pEncounterMonster2Texture;
-        //v44 = "%s B";
-        sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture);
-        break;
-    case 8:
-        //pTexture = pMapInfo->pEncounterMonster3Texture;
-        //v44 = "%s B";
-        sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture);
-        break;
-    case 2:
-        //v9 = pMapInfo->uEncounterMonster3AtLeast;
-        //v16 = rand();
-        //v17 = pMapInfo->uEncounterMonster3AtMost;
-        //pTexture = pMapInfo->pEncounterMonster3Texture;
-        v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1);
-        //v13 = pMapInfo->Dif_M3;
-        v57 = pMapInfo->Dif_M3;
-        v56 = pMapInfo->uEncounterMonster3AtLeast + v12;
-        strcpy(Source, pMapInfo->pEncounterMonster3Texture);
-        break;
-    case 9:
-        //pTexture = pMapInfo->pEncounterMonster1Texture;
-        //v44 = "%s C";
-        sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture);
-        break;
-    case 10:
-        //pTexture = pMapInfo->pEncounterMonster2Texture;
-        //v44 = "%s C";
-        sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture);
-        break;
-    case 11:
-        //pTexture = pMapInfo->pEncounterMonster3Texture;
-        //v44 = "%s C";
-        sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture);
-        break;
-    default:
-        return;
-  }
-  if (Source[0] == '0')
-    return;
-  v57 += a3;
-  if ( v57 > 4 )
-    v57 = 4;
-  strcpy(Str2, Source);
-  if ( a4 )
-    v56 = a4;
-  v18 = v56;
-  if ( (signed int)(v56 + uNumActors) >= 500 )
-    return;
-  pSector = 0;
-  pPosX = spawn->vPosition.x;
-  a4 = spawn->vPosition.y;
-  a3 = spawn->vPosition.z;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
-  v53 = 0;
-  v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
-  if ( v18 <= 0 )
-    return;
-  for (uint i = v53; i < v56; ++i)
-  {
-      pMonster = &pActors[uNumActors];
-      pActors[uNumActors].Reset();
-      if ( v57 )
-      {
-        v23 = rand() % 100;
-        v24 = 3;
-        v25 = (unsigned __int16)word_4E8152[3 * v57];
-        if ( v23 >= v25 )
-        {
-          if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] )
-            v24 = 2;
-        }
-        else
-        {
-          v24 = 1;
-        }
-        if ( v24 == 1 )
-        {
-          pTexture = Source;
-          v44 = "%s A";
-        }
-        else
-        {
-          if ( v24 == 2 )
-          {
-            pTexture = Source;
-            v44 = "%s B";
-          }
-          else
-          {
-            if ( v24 != 3 )
-              continue;
-            pTexture = Source;
-            v44 = "%s C";
-          }
-        }
-        sprintf(Str2, v44, pTexture);
-      }
-      v50 = pMonsterList->GetMonsterIDByName(Str2);
-      pTexture = Str2;
-      if ( (signed __int16)v50 == -1 )
-      {
-        sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture);
-        MessageBoxA(nullptr, Str, nullptr, 0);
-        ExitProcess(0);
-      }
-      v27 = &pMonsterList->pMonsters[(signed __int16)v50];
-      v28 = pMonsterStats->FindMonsterByTextureName(pTexture);
-      if ( !v28 )
-        v28 = 1;
-      Src = &pMonsterStats->pInfos[v28];
-      strcpy(pMonster->pActorName, Src->pName);
-      pMonster->sCurrentHP = Src->uHP;
-      assert(sizeof(MonsterInfo) == 88);
-      memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));
-      pMonster->word_000086_some_monster_id = v50 + 1;
-      pMonster->uActorRadius = v27->uMonsterRadius;
-      pMonster->uActorHeight = v27->uMonsterHeight;
-      pMonster->uMovementSpeed = v27->uMovementSpeed;
-      pMonster->vInitialPosition.x = spawn->vPosition.x;
-      pMonster->vPosition.x = spawn->vPosition.x;
-      pMonster->uTetherDistance = 256;
-      pMonster->vInitialPosition.y = a4;
-      pMonster->vPosition.y = a4;
-      pMonster->vInitialPosition.z = a3;
-      pMonster->vPosition.z = a3;
-      pMonster->uSectorID = pSector;
-      pMonster->uGroup = spawn->uGroup;
-      pMonster->PrepareSprites(0);
-      pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-      v32 = rand();
-      a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52);
-      pPosX = a3 + spawn->vPosition.x;
-      a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52);
-      a4 = a3 + spawn->vPosition.y;
-      a3 = spawn->vPosition.z;
-      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
-	  {
-        if ( a5 )
-            pMonster->uAttributes |= 0x080000;
-        ++uNumActors;
-        continue;
-	  }
-      v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z);
-      if ( v37 == pSector )
-      {
-        v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID);
-        v39 = v38;
-        if ( v38 != -30000 )
-        {
-          if ( abs(v38 - a3) <= 1024 )
-          {
-            a3 = v39;
-            if ( a5 )
-              pMonster->uAttributes |= 0x080000;
-            ++uNumActors;
-            continue;
-          }
-        }
-      }
-      ;
-      //v53 = (char *)v53 + 1;
-      //result = v53;
-    }
-    //while ( (signed int)v53 < v56 );
-}
-
-//----- (0044FA4C) --------------------------------------------------------
-signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3)
-{
-  signed int v3; // ecx@6
-  Actor *v4; // edx@7
-  signed int result; // eax@13
-  Actor *v6; // esi@16
-  char *v7; // ebx@16
-  MonsterDesc *v8; // edi@16
-  unsigned __int16 v9; // ax@16
-  int v10; // ebx@16
-  //int v11; // edi@16
-  //int v12; // eax@16
-  //int v13; // ecx@16
-  //int v14; // ebx@16
-  const char *v15; // [sp-4h] [bp-24h]@2
-  //unsigned __int16 v16; // [sp+0h] [bp-20h]@1
-  //int v17; // [sp+4h] [bp-1Ch]@1
-  unsigned int uFaceID; // [sp+8h] [bp-18h]@16
-  int v19; // [sp+Ch] [bp-14h]@16
-  size_t v20; // [sp+10h] [bp-10h]@6
-  int v21; // [sp+14h] [bp-Ch]@14
-  //int v22; // [sp+18h] [bp-8h]@14
-  unsigned int v23; // [sp+1Ch] [bp-4h]@6
-
-  //v16 = a2;
-  //v17 = a1;
-  if ( a2 == 4 )
-  {
-    v15 = "Elemental Light C";
-  }
-  else if ( a2 == 3 )
-      v15 = "Elemental Light B";
-    else
-      v15 = "Elemental Light A";
-
-  v23 = pMonsterList->GetMonsterIDByName(v15);
-  v3 = 0;
-  v20 = uNumActors;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v4 = pActors.data();//[0].uAIState;
-    while ( v4->uAIState != Removed )
-    {
-      ++v3; 
-      ++v4;
-      if ( v3 >= (signed int)uNumActors )
-        break;
-    }
-	if( v3 < (signed int)uNumActors )
-		v20 = v3;
-  }
-  if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) )
-  {
-    v21 = 0;
-    //v22 = pParty->vPosition.z;
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-    v6 = &pActors[v20];
-    v7 = (char *)&pMonsterStats->pInfos[v23 + 1];
-    v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
-    v6->Reset();
-    v8 = &pMonsterList->pMonsters[v23];
-    strcpy(v6->pActorName, *(const char **)v7);
-    v6->sCurrentHP = *((short *)v7 + 32);
-    memcpy(&v6->pMonsterInfo, v7, 0x58u);
-    v6->word_000086_some_monster_id = v23 + 1;
-    v6->uActorRadius = v8->uMonsterRadius;
-    v6->uActorHeight = v8->uMonsterHeight;
-    v9 = v8->uMovementSpeed;
-    v6->pMonsterInfo.uTreasureDiceRolls = 0;
-    v6->pMonsterInfo.uTreasureType = 0;
-    v6->pMonsterInfo.uExp = 0;
-    v6->uMovementSpeed = v9;
-    v10 = rand() % 2048;
-    //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19);
-    uFaceID = stru_5C6E00->Sin(v10);
-    //v12 = pParty->vPosition.y;
-    //v13 = fixpoint_mul(uFaceID, v19);
-    //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19);
-    //LOWORD(v12) = v22;
-    v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19);
-    v6->vPosition.x = v6->vInitialPosition.x;
-    v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19);
-    v6->vPosition.y = v6->vInitialPosition.y;
-    v6->vInitialPosition.z = pParty->vPosition.z;
-    v6->vPosition.z = v6->vInitialPosition.z;
-    //LOWORD(v12) = v21;
-    v6->uTetherDistance = 256;
-    v6->uSectorID = v21;
-    v6->PrepareSprites(0);
-    v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-    v6->uAlly = 9999;
-    v6->uGroup = 0;
-    v6->uCurrentActionTime = 0;
-    v6->uAIState = Summoned;
-    v6->uCurrentActionLength = 256;
-    v6->UpdateAnimation();
-    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
-      || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z),
-          result == v21)
-      && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000)
-      && (result = abs(result - pParty->vPosition.z), result <= 1024) )
-    {
-      if ( v20 == uNumActors )
-        ++uNumActors;
-      v6->uSummonerID = PID(OBJECT_Player, a1);
-      result = v6->pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f,
-                 a2,
-                 a1,
-                 0,
-                 0);
-    }
-  }
-  return result;
-}
-
-//----- (00450521) --------------------------------------------------------
-int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6)
-{
-  int v6; // edi@1
-  int v7; // esi@1
-  signed int v8; // edi@1
-  unsigned __int16 v9; // cx@1
-//  char *v10; // edx@2
-  unsigned __int16 v11; // ax@5
-  SpriteObject a1; // [sp+8h] [bp-70h]@1
-
-  v6 = ecx0;
-  v7 = a2;
-  pItemsTable->GenerateItem(v6, v7, &a1.stru_24);
-  v8 = 0;
-  v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
-  a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
-  v11 = 0;
-	for( int i = 0; i < pObjectList->uNumObjects; i++ )
-	{
-		if( v9 == pObjectList->pObjects[i].uObjectID )
-		{
-			v11 = i;
-			break;
-		}
-	}
-  a1.uObjectDescID = v11;
-  a1.vPosition.y = a4;
-  a1.vPosition.x = a3;
-  a1.vPosition.z = a5;
-  a1.uFacing = a6;
-  a1.uAttributes = 0;
-  a1.uSectorID = pIndoor->GetSector(a3, a4, a5);
-  a1.uSpriteFrameID = 0;
-  return a1.Create(0, 0, 0, 0);
-}
-
-//----- (0045063B) --------------------------------------------------------
-int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2)
-{
-  int result; // eax@8
-  int v6; // edi@11
-  int v7; // ebx@11
-  int v8; // edi@11
-  int v9; // ebx@12
-  int v10; // eax@12
-  char v11; // zf@16
-  int v12; // edi@20
-  int v13; // eax@20
-  int v14; // ebx@20
-  int v15; // eax@20
-  int v16; // eax@20
-  int v17; // eax@20
-  int v18; // eax@21
-  SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1
-  int v22; // [sp+2Ch] [bp-18h]@3
-  unsigned int uFaceID; // [sp+38h] [bp-Ch]@10
-  int v26; // [sp+3Ch] [bp-8h]@11
-  int v27; // [sp+40h] [bp-4h]@11
-  
-  if (!uNumActors)
-    return 0;
-
-  for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id )
-  {
-    if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C
-        (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C
-        (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C
-         pActors[mon_id].CanAct())
-    {
-      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
-      {
-        v22 = 0;
-        uint face_id = 0;
-        for ( face_id; face_id < 100; ++face_id )
-        {
-          v6 = rand() % 1024 + 512;
-          v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
-          v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6);
-          v8 = 0;
-          v19.uIndex = a2;
-          v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y;
-          v19.vPosition.z = pParty->vPosition.z;
-          v26 = 0;
-          v27 = 0;
-          v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0);
-          for( int i = 0; i < pOutdoor->uNumBModels; i++ )
-          {
-            v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y);
-            v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x);
-            if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 )
-            {
-              v22 = 1;
-              break;
-            }
-          }
-          if ( v22 )
-          {
-            v11 = face_id == 100;
-            break;
-          }
-        }
-        v11 = face_id == 100;
-      }
-      else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      {
-        v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-        for ( uint i = 0; i < 100; ++i )
-        {
-          v12 = rand() % 512 + 256;
-          v13 = rand();
-          v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi;
-          v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi);
-          v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12);
-          v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi);
-          v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y;
-          v19.vPosition.z = pParty->vPosition.z;
-          v19.uIndex = a2;
-          v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z);
-          if ( v17 == v22 )
-          {
-            v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID);
-            v19.vPosition.z = v18;
-            if ( v18 != -30000 )
-            {
-              if ( abs(v18 - pParty->vPosition.z) <= 1024 )
-                break;
-            }
-          }
-        }
-        v11 = v26 == 100;
-      }
-      if ( v11 )
-        result = 0;
-      else
-      {
-        SpawnEncounter(a1, &v19, 0, 0, 1);
-        result = a2;
-      }
-    }
-
-    //break;
-    //v22 = v3->pMonsterInfo.uID - 1;
-    //v4 = (signed __int64)((double)v22 * 0.3333333333333333);
-    //if ( (int)v4 != 40 )
-    //{
-    //  if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() )
-    //    break;
-    //}
-    //++v2;
-    //++v3;
-    //if ( v2 >= (signed int)uNumActors )
-    //  goto LABEL_8;
-  }
-  return result;
-}
-
-//----- (00450AAA) --------------------------------------------------------
-void RespawnGlobalDecorations()
-{
-  memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125);
-
-  uint decorEventIdx = 0;
-  for (uint i = 0; i < uNumLevelDecorations; ++i)
-  {
-    LevelDecoration* decor = &pLevelDecorations[i];
-
-    if (!decor->uEventID)
-    {
-      if (decor->IsInteractive())
-      {
-        if (decorEventIdx < 124)
-        {
-          decor->_idx_in_stru123 = decorEventIdx + 75;
-          stru_5E4C90_MapPersistVars._decor_events[decorEventIdx++] = decor->GetGlobalEvent();
-        }
-      }
-    }
-  }
-}
-
-//----- (00450B0A) --------------------------------------------------------
-bool __fastcall SpawnActor(unsigned int uMonsterID)
-{
-  unsigned int v1; // ebx@1
-  bool result; // eax@2
-  MonsterDesc *v3; // esi@5
-  MonsterInfo *v4; // edi@5
-  Vec3_int_ v5; // ST08_12@5
-  unsigned int v6; // ecx@5
-  Actor *v7; // eax@7
-  Actor actor; // [sp+4h] [bp-350h]@5
-  Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5
-
-  v1 = uMonsterID;
-  if ( uNumActors == 499 )
-  {
-    result = 0;
-  }
-  else
-  {
-    if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters )
-      v1 = 0;
-    v3 = &pMonsterList->pMonsters[v1];
-    v4 = &pMonsterStats->pInfos[v1 + 1];
-    memset(&actor, 0, 0x344u);
-    strcpy(actor.pActorName, v4->pName);
-    actor.sCurrentHP = LOWORD(v4->uHP);
-    memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u);
-    actor.word_000086_some_monster_id = v1 + 1;
-    actor.uActorRadius = v3->uMonsterRadius;
-    actor.uActorHeight = v3->uMonsterHeight;
-    actor.uMovementSpeed = v3->uMovementSpeed;
-    v5 = pParty->vPosition;
-    Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y);
-    actor.vInitialPosition.x = pOut.x;
-    actor.vPosition.x = pOut.x;
-    actor.uTetherDistance = 256;
-    actor.vInitialPosition.y = LOWORD(pOut.z);
-    actor.vPosition.y = LOWORD(pOut.z);
-    actor.vInitialPosition.z = LOWORD(pOut.y);
-    actor.vPosition.z = LOWORD(pOut.y);
-    pSprites_LOD->DeleteSomeSprites();
-    pPaletteManager->ResetNonTestLocked();
-    v6 = uNumActors - 1;
-    if ( dword_5C6DF8 == 1 )
-    {
-      dword_5C6DF8 = 0;
-      v6 = uNumActors++;
-    }
-    v7 = &pActors[v6];
-    memcpy(v7, &actor, 0x344u);
-    v7->PrepareSprites(1);
-    result = 1;
-  }
-  return result;
-}
-// 5C6DF8: using guessed type int dword_5C6DF8;
-
-//----- (00450DA3) --------------------------------------------------------
-int  GetAlertStatus()
-{
-  int result; // eax@2
-
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    result = pOutdoor->ddm.field_C_alert;
-  else
-    result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0;
-  return result;
-}
 
 //----- (00450DDE) --------------------------------------------------------
 stru350 *stru350::_450DDE()
--- a/mm7_unsorted_subs.h	Sat Apr 19 23:56:01 2014 +0600
+++ b/mm7_unsorted_subs.h	Thu May 01 12:59:50 2014 +0200
@@ -116,13 +116,6 @@
 void ShowNothingHereStatus();
 int const_2();
 bool TeleportToNWCDungeon();
-void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
-int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
-int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
-int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2);
-void RespawnGlobalDecorations();
-bool __fastcall SpawnActor(unsigned int uMonsterID);
-int GetAlertStatus();
 inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count)
 {
   unsigned __int32* p = (unsigned __int32 *)ptr;