changeset 1415:ff495bf260d9

LevelDecoration::GetGlobalEvent
author Nomad
date Sat, 27 Jul 2013 22:21:09 +0200
parents 110eac219e5a
children b69805ffeb4b a8b1bbac95d4
files mm7_2.cpp mm7_5.cpp mm7_data.h
diffstat 3 files changed, 124 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Jul 27 16:32:20 2013 +0200
+++ b/mm7_2.cpp	Sat Jul 27 22:21:09 2013 +0200
@@ -1640,11 +1640,11 @@
 }
 
 //----- (0045063B) --------------------------------------------------------
-int __fastcall sub_45063B(MapInfo *a1, int a2)
+int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2)
 {
   signed int v2; // edi@1
   Actor *v3; // esi@2
-  signed __int64 v4; // qax@3
+  //signed __int64 v4; // qax@3
   int result; // eax@8
   int v6; // edi@11
   int v7; // ebx@11
@@ -1661,33 +1661,49 @@
   int v18; // eax@21
   SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1
   int v20; // [sp+24h] [bp-20h]@11
-  MapInfo *v21; // [sp+28h] [bp-1Ch]@1
+  //MapInfo *v21; // [sp+28h] [bp-1Ch]@1
   int v22; // [sp+2Ch] [bp-18h]@3
   int v23; // [sp+30h] [bp-14h]@11
-  int v24; // [sp+34h] [bp-10h]@1
+  //int v24; // [sp+34h] [bp-10h]@1
   unsigned int uFaceID; // [sp+38h] [bp-Ch]@10
   int v26; // [sp+3Ch] [bp-8h]@11
   int v27; // [sp+40h] [bp-4h]@11
-
-  v21 = a1;
-  v24 = a2;
+  
+  if (!uNumActors)
+    return 0;
+
+  //v21 = a1;
+  //v24 = a2;
   v2 = 0;
-  if ( (signed int)uNumActors <= 0 )
-    goto LABEL_8;
   v3 = pActors.data();
   while ( 1 )
   {
-    v22 = v3->pMonsterInfo.uID - 1;
-    v4 = (signed __int64)((double)v22 * 0.3333333333333333);
-    if ( (int)v4 != 40 )
+    if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C
+        v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C
+        v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C
+        !v3->CanAct())
     {
-      if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() )
-        break;
+      ++v2;
+      ++v3;
+
+      if (v2 >= uNumActors)
+        return 0;
+
+      continue;
     }
-    ++v2;
-    ++v3;
-    if ( v2 >= (signed int)uNumActors )
-      goto LABEL_8;
+
+    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;
   }
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
   {
@@ -1704,7 +1720,7 @@
       v20 = stru_5C6E00->Sin(v7);
       v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16;
       v8 = 0;
-      v19.uIndex = v24;
+      v19.uIndex = a2;
       v19.vPosition.y = v23 + pParty->vPosition.y;
       v19.vPosition.z = pParty->vPosition.z;
       v26 = 0;
@@ -1763,7 +1779,7 @@
       v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16;
       v19.vPosition.y = v23 + pParty->vPosition.y;
       v19.vPosition.z = pParty->vPosition.z;
-      v19.uIndex = v24;
+      v19.uIndex = a2;
       v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z);
       if ( v17 == v22 )
       {
@@ -1786,8 +1802,8 @@
   }
   else
   {
-    SpawnEncounter(v21, &v19, 0, 0, 1);
-    result = v24;
+    SpawnEncounter(a1, &v19, 0, 0, 1);
+    result = a2;
   }
   return result;
 }
@@ -1809,108 +1825,90 @@
   int v12; // eax@21
   int v13; // eax@22
 
-  v1 = this;
-  rand();
-  v2 = v1->uDecorationDescID;
-  if ( v2 > 208 )
-  {
-    switch ( v2 )
-    {
-      case 209:
-        result = rand() % 7 + 183;
-        break;
-      case 210:
-        result = 150;
-        break;
-      case 211:
-        result = 151;
-        break;
-      case 212:
-        result = 152;
-        break;
-      case 213:
-        result = 153;
-        break;
-      case 214:
-        result = 154;
-        break;
-      case 215:
-        result = 155;
-        break;
-      case 216:
-        result = 156;
-        break;
-      case 217:
-        result = 157;
-        break;
-      case 218:
-        result = 158;
-        break;
-      case 219:
-        result = 159;
-        break;
-      case 220:
-        result = 160;
-        break;
-      case 221:
-        result = 161;
-        break;
-      default:
-        goto LABEL_45;
-    }
-  }
-  else
-  {
-    if ( v2 == 208 )
-    {
-      result = rand() % 7 + 176;
-    }
-    else
-    {
-      if ( v2 > 24 )
-      {
-        v9 = v2 - 34;
-        if ( !v9 )
-          return rand() % 6 + 4;
-        v10 = v9 - 150;
-        if ( !v10 )
-          return 33;
-        v11 = v10 - 3;
-        if ( !v11 || (v12 = v11 - 3) == 0 )
-          return 37;
-        v13 = v12 - 16;
-        if ( !v13 )
-          return rand() % 7 + 162;
-        if ( v13 == 1 )
-          return rand() % 7 + 169;
-      }
-      else
-      {
-        if ( v2 == 24 )
-          return 36;
-        v3 = v2 - 4;
-        if ( !v3 )
-          return 16;
-        v4 = v3 - 1;
-        if ( !v4 )
-          return 32;
-        v5 = v4 - 1;
-        if ( !v5 )
-          return rand() % 4 + 12;
-        v6 = v5 - 5;
-        if ( !v6 )
-          return 34;
-        v7 = v6 - 2;
-        if ( !v7 )
-          return 17;
-        if ( v7 == 1 )
-          return 18;
-      }
-LABEL_45:
-      result = 0;
-    }
-  }
-  return result;
+  switch (uDecorationDescID)
+  {
+    case   0: case 1:
+    case   2: case 3:
+      return 0;
+
+    case   4: return 16;               // dec01 "Trash Pile"
+    case   5: return 32;               // dec02 "Campfire"
+    case   6: return 12 + rand() % 4;  // dec03 "Cauldron"
+    case   7: case 8:
+    case   9: case 10:
+      return 0;
+
+    case  11: return 34;               // dec08 "Fruit plate"
+    case  12:
+      return 0;
+
+    case  13: return 17;               // dec10 "Trash Pile"
+    case  14: return 18;               // dec11 "Filth"
+    case  15: case 16: case 17:
+    case  18: case 19: case 20:
+    case  21: case 22: case 23:
+      return 0;
+
+    case  24: return 36;               // dec21 "Keg"
+    case  25: case 26: case 27: case 28: case 29:
+    case  30: case 31: case 32: case 33:
+      return 0;
+
+    case  34: return 4 + rand() % 6;   // dec32 "Barrel"
+    case  35: case  36: case  37: case  38: case  39:
+    case  40: case  41: case  42: case  43: case  44: case  45: case  46: case  47: case  48: case  49:
+    case  50: case  51: case  52: case  53: case  54: case  55: case  56: case  57: case  58: case  59:
+    case  60: case  61: case  62: case  63: case  64: case  65: case  66: case  67: case  68: case  69:
+    case  70: case  71: case  72: case  73: case  74: case  75: case  76: case  77: case  78: case  79:
+    case  80: case  81: case  82: case  83: case  84: case  85: case  86: case  87: case  88: case  89:
+    case  90: case  91: case  92: case  93: case  94: case  95: case  96: case  97: case  98: case  99:
+    case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109:
+    case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119:
+    case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129:
+    case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139:
+    case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149:
+    case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159:
+    case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169:
+    case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179:
+    case 180: case 181: case 182: case 183:
+
+    case 184: return 33;               // dec24 "Campfire"
+    case 185: case 186:
+      return 0;
+
+    case 187:                          // dec88 "Mushroom"
+    case 190:                          // dec91 "Mushroom"
+      return 37;
+
+    case 188: case 189:
+    case 191: case 192: case 193: case 194: case 195: case 196:
+    case 197: case 198: case 199: case 200: case 201: case 202:
+    case 203: case 204: case 205:
+      return 0;
+
+    case 206: return 162 + rand() % 7; // dec60
+    case 207: return 169 + rand() % 7; // dec61
+    case 208: return 176 + rand() % 7; // dec62
+    case 209: return 183 + rand() % 7; // dec63
+    case 210: return 150;              // dec64 "Magic Pedistal"
+    case 211: return 151;              // dec65 "Magic Pedistal"
+    case 212: return 152;              // dec66 "Magic Pedistal"
+    case 213: return 153;              // dec67 "Magic Pedistal"
+    case 214: return 154;              // dec68 "Magic Pedistal"
+    case 215: return 155;              // dec69 "Magic Pedistal"
+    case 216: return 156;              // dec70 "Magic Pedistal"
+    case 217: return 157;              // dec71 "Magic Pedistal"
+    case 218: return 158;              // dec72 "Magic Pedistal"
+    case 219: return 159;              // dec73 "Magic Pedistal"
+    case 220: return 160;              // dec74 "Magic Pedistal"
+    case 221: return 161;              // dec75 "Magic Pedistal"
+
+    case 222: case 223: case 224:
+    case 225: case 226: case 227:
+      return 0;
+
+    default: assert(false && "Invalid Decoration");
+  }
 }
 
 //----- (00450AAA) --------------------------------------------------------
--- a/mm7_5.cpp	Sat Jul 27 16:32:20 2013 +0200
+++ b/mm7_5.cpp	Sat Jul 27 22:21:09 2013 +0200
@@ -2569,7 +2569,7 @@
                 pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2);
               else
                 pNPCData4 = (NPCData *)1;
-              if ( !sub_45063B(pMapInfo, (int)pNPCData4) )
+              if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) )
                 pNPCData4 = 0;
               if ( pNPCData4 )
               {
--- a/mm7_data.h	Sat Jul 27 16:32:20 2013 +0200
+++ b/mm7_data.h	Sat Jul 27 22:21:09 2013 +0200
@@ -1256,7 +1256,7 @@
 int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
 
 signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
-int __fastcall sub_45063B(struct MapInfo *a1, int a2);
+int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2);
 void RespawnGlobalDecorations();
 bool __fastcall SpawnActor(unsigned int uMonsterID);
 int __cdecl GetAlertStatus();