diff mm7_5.cpp @ 1297:5450af4f57ef

moving files mm7_x ending
author Ritor1
date Wed, 19 Jun 2013 17:06:58 +0600
parents c423f946dc99
children 8c2f689b5f0b
line wrap: on
line diff
--- a/mm7_5.cpp	Tue Jun 18 17:28:11 2013 +0600
+++ b/mm7_5.cpp	Wed Jun 19 17:06:58 2013 +0600
@@ -4065,89 +4065,6 @@
   memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/
 }
 
-//----- (00438BDF) --------------------------------------------------------
-bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype)
-{
-  unsigned __int8 v2; // zf@15
-  char v3; // sf@15
-  unsigned __int8 v4; // of@15
-  bool result; // eax@33
-
-  switch ( eSupertype )
-  {
-    case MONSTER_SUPERTYPE_UNDEAD:
-      if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3
-        || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3
-        || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3
-        || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3
-        || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3
-        || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 )
-        goto ret_true;
-      if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3);
-      v2 = uMonsterInfoID == MONSTER_GHOUL_3;
-      v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_KREEGAN:
-      if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3);
-      v2 = uMonsterInfoID == MONSTER_DEVIL_3;
-      v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_ELF:
-      if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1
-        && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3
-        || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 )
-        goto ret_true;
-      if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3);
-      v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3;
-      v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_DRAGON:
-      if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3);
-      v2 = uMonsterInfoID == MONSTER_DRAGON_3;
-      v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_WATER_ELEMENTAL:
-      if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3);
-      v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3;
-      v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_TREANT:
-      if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3);
-      v2 = uMonsterInfoID == MONSTER_TREANT_3;
-      v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0;
-      goto false_if_outside;
-    case MONSTER_SUPERTYPE_TITAN:
-      if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 )
-        goto ret_false;
-      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3);
-      v2 = uMonsterInfoID == MONSTER_TITAN_3;
-      v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0;
-false_if_outside:
-      if ( !((unsigned __int8)(v3 ^ v4) | v2) )
-        goto ret_false;
-ret_true:
-      result = 1;
-      break;
-    default:
-ret_false:
-      result = 0;
-      break;
-  }
-  return result;
-}
-
 //----- (00438F8F) --------------------------------------------------------
 void __cdecl area_of_effect__damage_evaluate()
 {
@@ -4376,983 +4293,8 @@
 }
 // 50FE08: using guessed type stru298 stru_50FE08;
 
-//----- (00439474) --------------------------------------------------------
-void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
-{
-  //signed int v3; // eax@1
-  SpriteObject *v4; // ebx@1
-  //int v5; // edx@3
-  //bool uPlayerID; // eax@3
-  //Player *pPlayer; // edi@4
-  Actor *pMonster; // esi@7
-  //SpriteObject *v9; // ebx@12
-  int v10; // eax@12
-  int v11; // ebx@12
-  unsigned int v12; // ecx@12
-  int v13; // edx@15
-  int v14; // edx@17
-  int v15; // eax@24
-  unsigned __int16 v16; // cx@25
-  int v17; // eax@29
-  int v18; // eax@38
-  unsigned __int8 v19; // zf@38
-  unsigned __int8 v20; // sf@38
-  int v21; // edx@44
-  int v22; // eax@44
-  unsigned __int8 v23; // zf@44
-  unsigned __int8 v24; // sf@44
-  int v25; // edx@51
-  int v26; // ecx@51
-  //signed int v27; // eax@51
-  //int v28; // eax@53
-  signed int v29; // eax@76
-  signed int v30; // eax@84
-  signed int v31; // eax@92
-  int v32; // eax@94
-  int v33; // eax@100
-  int v34; // eax@104
-  signed int v35; // eax@104
-  double v36; // st7@104
-  float v37; // ST08_4@104
-  float v38; // ST04_4@104
-  float v39; // ST00_4@104
-  int v40; // ebx@107
-  unsigned int v41; // ebx@109
-  signed __int64 v42; // qax@125
-  unsigned __int16 v43; // ax@132
-  char v44; // bl@132
-  unsigned __int16 v45; // ax@132
-  unsigned __int64 v46; // [sp+Ch] [bp-60h]@6
-  const char *v47; // [sp+14h] [bp-58h]@104
-  char *pPlayerName; // [sp+18h] [bp-54h]@12
-  char *pMonsterName; // [sp+1Ch] [bp-50h]@6
-  int v50; // [sp+20h] [bp-4Ch]@6
-  //unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6
-  int v52; // [sp+34h] [bp-38h]@12
-  //int v53; // [sp+38h] [bp-34h]@10
-  //int v54; // [sp+3Ch] [bp-30h]@1
-  //int v55; // [sp+40h] [bp-2Ch]@12
-  signed int a4; // [sp+44h] [bp-28h]@1
-  PlayerEquipment *v57; // [sp+48h] [bp-24h]@10
-  //int v58; // [sp+4Ch] [bp-20h]@10
-  int v59; // [sp+50h] [bp-1Ch]@1
-  unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
-  int v61; // [sp+58h] [bp-14h]@1
-  bool v62; // [sp+5Ch] [bp-10h]@1
-  int uDamageAmount; // [sp+60h] [bp-Ch]@1
-  int a2; // [sp+64h] [bp-8h]@27
-  int a3; // [sp+6Bh] [bp-1h]@6
-
-  //v3 = a1;
-  v4 = 0;
-  uActorID_Monster_ = uActorID_Monster;
-  //v54 = a1;
-  uDamageAmount = 0;
-  a4 = 0;
-  v61 = 0;
-  v59 = 0;
-  v62 = 0;
-  if ( PID_TYPE(a1) == OBJECT_Item)
-  {
-    v4 = &pSpriteObjects[PID_ID(a1)];
-    //uDamageAmount = (int)v4;
-    v61 = v4->field_60_distance_related_prolly_lod;
-    a1 = v4->spell_caster_pid;
-    //v54 = v4->field_58_pid;
-  }
-  //v5 = a1 & 7;
-  //uPlayerID = a1 >> 3;
-  if (PID_TYPE(a1) != OBJECT_Player)
-    return;
-
-  assert(PID_ID(abs(a1)) < 4);
-  auto player = &pParty->pPlayers[PID_ID(a1)];
-  pMonster = &pActors[uActorID_Monster_];
-  //uPlayerID = pMonster->IsAlive();
-  if (pMonster->IsNotAlive())
-    return;
-
-  BYTE1(pMonster->uAttributes) |= 0xC0u;
-  if ( pMonster->uAIState == Fleeing )
-    pMonster->uAttributes |= 0x20000u;
-  //v57 = 0;
-  //v53 = 0;
-  //v58 = 0;
-  bool hit_will_stun = false,
-       hit_will_paralyze = false;
-  if ( !v4 )
-  {
-    //v51 = (unsigned __int64 *)player->pEquipment.uMainHand;
-    int main_hand_idx = player->pEquipment.uMainHand;
-    v59 = 1;
-    if ( player->HasItemEquipped(EQUIP_MAIN_HAND) )
-    {
-      auto main_hand_skill = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType;
-      //v55 = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType;
-      //v28 = SkillToMastery(player->pActiveSkills[v55]);
-      auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]);
-      //uDamageAmount = v28;
-      switch (main_hand_skill)
-      {
-        case PLAYER_SKILL_STAFF:
-          if (main_hand_mastery >= 3)
-          {
-            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F))  // stun chance when mastery >= 3
-              hit_will_stun = true;
-          }
-        break;
-
-        case PLAYER_SKILL_MACE:
-          if (main_hand_mastery >= 3)
-          {
-            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F))
-              hit_will_stun = true;
-          }
-          if (main_hand_mastery >= 4)
-          {
-            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F))
-              hit_will_paralyze = true;
-          }
-        break;
-      }
-    }
-    v50 = pMonster->pMonsterInfo.uID;
-    a2 = 4;
-    //v27 = player->CalculateMeleeDamageTo(0, 0, v50);
-    uDamageAmount = player->CalculateMeleeDamageTo(0, 0, v50);
-    //if ( !v57 )
-      goto LABEL_67;
-    //goto LABEL_69;
-  }
-
-
-  v19 = v4->spell_id == SPELL_DARK_SOULDRINKER;
-  v61 = v4->field_60_distance_related_prolly_lod;
-  if ( !v19 )
-  {
-    //v9 = (SpriteObject *)uDamageAmount;
-	v50 = pParty->vPosition.x - v4->vPosition.x;
-    //v55 = abs(v50);
-    pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y);
-    //v51 = (unsigned __int64 *)abs((int)pMonsterName);
-    pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z);
-    v52 = abs((int)pPlayerName);
-    v61 = abs(v50);
-    v10 = abs(v50);
-    v11 = (int)abs((int)pMonsterName);
-    v12 = v52;
-    if ( v10 < v11)
-    {
-      v10 = (int)v11;
-      v11 = v10;
-    }
-    if ( v10 < v52 )
-    {
-      v13 = v10;
-      v10 = v52;
-      v12 = v13;
-    }
-    if ( v11 < (signed int)v12 )
-    {
-      v14 = v12;
-      v12 = v11;
-      v11 = v14;
-    }
-    //uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
-    v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
-    if ( v61 >= 2560 )
-    {
-      if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
-        return;
-      v61 = 2;
-    }
-    else
-    {
-      v61 = 1;
-    }
-    //v4 = (SpriteObject *)uDamageAmount;
-  }
-
-  v15 = v4->spell_id;
-  if ( v15 == SPELL_LASER_PROJECTILE )
-  {
-    v16 = player->pActiveSkills[7];
-    v61 = 1;
-    if ( (signed int)SkillToMastery(v16) >= 3 )
-      a4 = player->pActiveSkills[7] & 0x3F;
-    a2 = 4;
-    uDamageAmount = player->CalculateMeleeDamageTo(1, 1, 0);
-    goto LABEL_67;
-  }
-  if ( v15 != SPELL_BOW_ARROW )
-  {
-    if ( v15 == SPELL_101 )
-    {
-      a2 = 0;
-      v18 = player->CalculateRangedDamageTo(0);
-      v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
-      v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
-      uDamageAmount = v18;
-      if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-        uDamageAmount >>= 1;
-      v59 = 1;
-      goto LABEL_67;
-    }
-    if ( v15 == SPELL_EARTH_BLADES )
-    {
-      a4 = 5 * v4->spell_level;
-      a2 = player->GetSpellSchool(0x27u);
-      v21 = v4->spell_level;
-      v50 = pMonster->sCurrentHP;
-      pMonsterName = (char *)v4->spell_skill;
-      v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50);
-      v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
-      v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
-      uDamageAmount = v22;
-      if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-        uDamageAmount >>= 1;
-      v59 = 0;
-LABEL_67:
-      if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
-      {
-//LABEL_68:
-        player->PlaySound(SPEECH_52, 0);
-        return;
-      }
-      goto LABEL_69;
-    }
-    if ( v15 == SPELL_EARTH_STUN )
-    {
-      uDamageAmount = 0;
-      a2 = 4;
-      hit_will_stun = 1;
-      goto LABEL_67;
-    }
-    a2 = player->GetSpellSchool(v4->spell_id);
-    v25 = v4->spell_level;
-    v26 = v4->spell_id;
-    v50 = pMonster->sCurrentHP;
-    pMonsterName = (char *)v4->spell_skill;
-    //v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50);
-    v59 = 0;
-    //v57 = (PlayerEquipment *)1;
-//LABEL_65:
-    uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50);
-    //if ( !v57 )
-    //  goto LABEL_67;
-    goto LABEL_69;
-  }
-  v50 = pMonster->word_000086_some_monster_id;
-  a2 = 4;
-  v17 = player->CalculateRangedDamageTo(v50);
-  v19 = v4->stru_24.uItemID == 0;
-  uDamageAmount = v17;
-  v57 = 0;
-  if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 )
-  {
-    a2 = 0;
-    v57 = (PlayerEquipment *)1;
-  }
-  if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0
-    && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-    uDamageAmount >>= 1;
-  v59 = 1;
-//LABEL_66:
-  if ( !v57 )
-    goto LABEL_67;
-LABEL_69:
-  if (player->Weak())
-    uDamageAmount /= 1;
-  if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
-    uDamageAmount = 0;
-  v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount);
-  if ( !v4 && player->IsUnarmed() && (signed __int64)player->pPlayerBuffs[6].uExpireTime > 0 )
-  {
-    v50 = player->pPlayerBuffs[6].uPower;
-    v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50);
-    v61 += v29;
-  }
-  uDamageAmount = v61;
-  if ( v59 )
-  {
-    if ( v4 )
-    {
-      a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62);
-      if ( v62 && pMonster->sCurrentHP > 0 )
-      {
-        player->sHealth += v61 / 5;
-        if ( player->sHealth > player->GetMaxHealth() )
-          player->sHealth = player->GetMaxHealth();
-        v62 = 0;
-      }
-      v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
-      uDamageAmount = v61 + v30;
-    }
-    else
-    {
-      v59 = 0;
-      v57 = &player->pEquipment;
-      do
-      {
-        if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
-        {
-          auto _s = (ItemGen *)&player->pInventoryItems[v57->uShield - 1];
-          a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
-          if ( v62 && pMonster->sCurrentHP > 0 )
-          {
-            player->sHealth += v61 / 5;
-            if ( player->sHealth > player->GetMaxHealth() )
-              player->sHealth = player->GetMaxHealth();
-            v62 = 0;
-          }
-          v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
-          uDamageAmount += v31;
-        }
-        ++v59;
-        v57 = (PlayerEquipment *)((char *)v57 + 4);
-      }
-      while ( v59 <= 1 );
-    }
-  }
-  v32 = uDamageAmount;
-  pMonster->sCurrentHP -= uDamageAmount;
-  if ( !v32 && !hit_will_stun )
-  {
-    player->PlaySound(SPEECH_52, 0);
-    return;
-  }
-  if ( pMonster->sCurrentHP > 0 )
-  {
-    Actor::AI_Stun(uActorID_Monster_, a1, 0);
-    Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
-    if ( bShowDamage )
-    {
-      v50 = uDamageAmount;
-      pMonsterName = (char *)pMonster;
-      pPlayerName = player->pName;
-      if ( v4 )
-        v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points"
-      else
-        v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage"
-      sprintfex(pTmpBuf.data(), v47, pPlayerName, pMonsterName, v50);
-      ShowStatusBarString(pTmpBuf.data(), 2u);
-    }
-    v41 = 0;
-  }
-  else
-  {
-    if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 )
-    {
-      v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius;
-      //v55 = v33;
-      if ( pRenderer->pRenderD3D )
-      {
-        if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
-        {
-          v50 = 0;
-          pMonsterName = 0;
-          v34 = pMonster->vPosition.z;
-          *(float *)&pPlayerName = (double)v33;
-          //v51 = (unsigned __int64 *)v34;
-          *(float *)&v47 = 0.0;
-          v35 = pMonster->vPosition.y;
-          *((float *)&v46 + 1) = 0.0;
-          *(float *)&v46 = 1.0;
-          v36 = (double)(signed int)pMonster->vPosition.z;
-          //v51 = (unsigned __int64 *)v35;
-          v37 = v36;
-          //v51 = (unsigned __int64 *)pMonster->vPosition.x;
-          v38 = (double)v35;
-          v39 = (double)(signed int)pMonster->vPosition.x;
-          pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0);
-        }
-      }
-    }
-    Actor::Die(uActorID_Monster_);
-    Actor::ApplyFineForKillingPeasant(uActorID_Monster_);
-    Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
-    if ( pMonster->pMonsterInfo.uExp )
-      GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
-    v40 = SPEECH_51;
-    if ( rand() % 100 < 20 )
-      v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
-    player->PlaySound((PlayerSpeech)v40, 0);
-    v41 = 0;
-    if ( bShowDamage )
-    {
-      v50 = (int)pMonster;
-      pMonsterName = (char *)uDamageAmount;
-      pPlayerName = player->pName;             // "%s inflicts %lu points killing %s"
-      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster);
-      ShowStatusBarString(pTmpBuf.data(), 2u);
-    }
-  }
-  if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41
-    && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41
-     || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41)
-    && uDamageAmount != v41 )
-    player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2);
-  v50 = 24;
-  v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP;
-  if ( (player->_48EA46_calc_special_bonus_by_items(24) || hit_will_stun != v41)
-    && stru_50C198.GetMagicalResistance(pMonster, 3u) )
-  {
-    LODWORD(v42) = 20;
-    v59 = 10;
-    if ( pParty->bTurnBasedModeOn == v41 )
-      v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666);
-    pMonster->pMonsterInfo.uRecoveryTime += v42;
-    if ( bShowDamage != v41 )
-    {
-      v50 = (int)pMonster;
-      pMonsterName = player->pName;            // "%s stuns %s"
-      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster);
-      ShowStatusBarString(pTmpBuf.data(), 2u);
-    }
-  }
-  if ( hit_will_paralyze != v41 )
-  {
-    if ( pMonster->CanAct() )
-    {
-      if ( stru_50C198.GetMagicalResistance(pMonster, 3) )
-      {
-        LOBYTE(v43) = player->GetActualSkillLevel(PLAYER_SKILL_MACE);
-        v44 = v43;
-        v45 = SkillToMastery(v43);
-        //v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F));
-        v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v44 & 0x3F)) * 0.033333335);
-        pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0);
-        if ( bShowDamage )
-        {
-          v50 = (int)pMonster;
-          pMonsterName = player->pName;        // "%s paralyzes %s"
-          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster);
-          ShowStatusBarString(pTmpBuf.data(), 2u);
-        }
-      }
-    }
-  }
-  if ( v59 > 10 )
-    v59 = 10;
-  if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
-  {
-    pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16;
-    pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16;
-    pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16;
-    pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x);
-    pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
-    pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
-  }
-  Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
-}
 // 4D864C: using guessed type char byte_4D864C;
 
-//----- (00439FCB) --------------------------------------------------------
-void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4)
-{
-  signed int v4; // esi@1
-  unsigned int v5; // ecx@1
-  Player *v6; // ebx@3
-  Actor *v7; // esi@3
-  unsigned int v8; // eax@4
-  char *v9; // eax@5
-  signed int v10; // eax@6
-  int v11; // edx@8
-  int v12; // edx@9
-  int v13; // edx@10
-  int v14; // edx@16
-  int v15; // edx@17
-  int v16; // edx@18
-  enum SoundID v17; // eax@24
-  int v18; // eax@26
-  unsigned __int8 v19; // zf@26
-  unsigned __int8 v20; // sf@26
-  unsigned __int16 v21; // ax@29
-  signed int v22; // edi@36
-  int v23; // eax@38
-  signed int v24; // eax@44
-  unsigned __int16 v25; // cx@47
-  signed int v26; // eax@49
-  int v27; // eax@54
-  float v28; // ST18_4@58
-  double v29; // st7@58
-  float v30; // ST08_4@58
-  double v31; // st7@58
-  float v32; // ST04_4@58
-  float v33; // ST00_4@58
-  int v34; // edi@61
-  int v35; // eax@70
-  double v36; // st7@70
-  SpriteObject *v37; // ebx@77
-  int v38; // edi@77
-  int v39; // esi@77
-  int v40; // eax@77
-  int v41; // eax@77
-  int v42; // eax@78
-  Player *v43; // eax@81
-  Actor *v44; // esi@82
-  Player *v45; // edi@84
-  unsigned __int16 v46; // ax@84
-  int v47; // ebx@105
-  int v48; // eax@107
-  unsigned __int16 v49; // ax@116
-  int v50; // ebx@123
-  unsigned __int16 v51; // ax@124
-  char v52; // bl@124
-  int v53; // eax@128
-  signed int v54; // eax@134
-  unsigned __int16 v55; // cx@137
-  signed int v56; // eax@139
-  int v57; // eax@144
-  float v58; // ST18_4@148
-  double v59; // st7@148
-  float v60; // ST08_4@148
-  double v61; // st7@148
-  float v62; // ST04_4@148
-  float v63; // ST00_4@148
-  int v64; // ebx@151
-  int v65; // eax@161
-  double v66; // st7@161
-  signed int v67; // ecx@164
-  signed int v68; // eax@170
-  int v69; // ecx@170
-  int v70; // eax@171
-  enum SoundID v71; // [sp+20h] [bp-34h]@12
-  int v72; // [sp+30h] [bp-24h]@164
-  double v73; // [sp+40h] [bp-14h]@72
-  signed int v74; // [sp+44h] [bp-10h]@1
-  unsigned int v75; // [sp+48h] [bp-Ch]@3
-  unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
-  int v77; // [sp+50h] [bp-4h]@26
-  signed int a4a; // [sp+60h] [bp+Ch]@162
-  Player *a4b; // [sp+60h] [bp+Ch]@168
-
-  v4 = PID_ID(uObjID);
-  v5 = PID_TYPE(uObjID) - 2;
-  v74 = a2;
-  uActorID = v4;
-  if ( v5 )
-  {
-    if ( v5 != 1
-      || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4],
-                                     v75 = v6->sHealth,
-                                     !stru_50C198.ActorHitOrMiss(v7, v6)) )
-      return;
-    v8 = v6->pEquipment.uArmor;
-    if ( !v8
-      || (v9 = (char *)v6 + 36 * v8, v9[516] & 2)
-      || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10)
-      || v10 > 11 )
-    {
-      v14 = rand() % 4;
-      if ( !v14 )
-      {
-        v71 = (SoundID)108;
-        goto LABEL_24;
-      }
-      v15 = v14 - 1;
-      if ( !v15 )
-      {
-        v71 = (SoundID)109;
-        goto LABEL_24;
-      }
-      v16 = v15 - 1;
-      if ( !v16 )
-      {
-        v71 = (SoundID)110;
-        goto LABEL_24;
-      }
-      if ( v16 == 1 )
-      {
-        v71 = (SoundID)44;
-        goto LABEL_24;
-      }
-    }
-    else
-    {
-      v11 = rand() % 4;
-      if ( !v11 )
-      {
-        v71 = (SoundID)105;
-        goto LABEL_24;
-      }
-      v12 = v11 - 1;
-      if ( !v12 )
-      {
-        v71 = (SoundID)106;
-        goto LABEL_24;
-      }
-      v13 = v12 - 1;
-      if ( !v13 )
-      {
-        v71 = (SoundID)107;
-        goto LABEL_24;
-      }
-      if ( v13 == 1 )
-      {
-        v71 = (SoundID)45;
-LABEL_24:
-        v17 = v71;
-        goto LABEL_26;
-      }
-    }
-    v17 = (SoundID)a4;
-LABEL_26:
-    pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0);
-    v18 = Actor::_43B3E0_CalcDamage(v7, v74);
-    v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0;
-    v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0;
-    v77 = v18;
-    if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) )
-    {
-      v21 = v7->pActorBuffs[3].uPower;
-      if ( v21 )
-        v77 /= (signed int)v21;
-    }
-    if ( v74 )
-    {
-      if ( v74 == 1 )
-      {
-        v22 = v7->pMonsterInfo.uAttack2Type;
-      }
-      else
-      {
-        if ( v74 == 2 )
-        {
-          v23 = v7->pMonsterInfo.uSpell1ID;
-        }
-        else
-        {
-          if ( v74 != 3 )
-          {
-            if ( v74 == 4 )
-              v22 = v7->pMonsterInfo.field_3C_some_special_attack;
-            else
-              v22 = 4;
-            goto LABEL_43;
-          }
-          v23 = v7->pMonsterInfo.uSpell2ID;
-        }
-        v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool);
-      }
-    }
-    else
-    {
-      v22 = v7->pMonsterInfo.uAttack1Type;
-    }
-LABEL_43:
-    if ( !(dword_6BE368_debug_settings_2 & 0x10) )
-    {
-      v24 = v6->ReceiveDamage(v77, (DAMAGE_TYPE)v22);
-      if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0
-        && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) )
-      {
-        v25 = v7->uAIState;
-        if ( v25 != 5 )
-        {
-          if ( v25 != 4 )
-          {
-            v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24);
-            v7->sCurrentHP -= v26;
-            if ( v26 )
-            {
-              if ( v7->sCurrentHP >= 1 )
-              {
-                Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
-                Actor::AggroSurroundingPeasants(uActorID, 1);
-              }
-              else
-              {
-                if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 )
-                {
-                  v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius;
-                  v74 = v27;
-                  if ( pRenderer->pRenderD3D )
-                  {
-                    if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
-                    {
-                      v28 = (double)v74;
-                      v74 = v7->vPosition.z;
-                      v29 = (double)v74;
-                      v74 = v7->vPosition.y;
-                      v30 = v29;
-                      v31 = (double)v74;
-                      v74 = v7->vPosition.x;
-                      v32 = v31;
-                      v33 = (double)v74;
-                      pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0);
-                    }
-                  }
-                }
-                Actor::Die(uActorID);
-                Actor::ApplyFineForKillingPeasant(uActorID);
-                Actor::AggroSurroundingPeasants(uActorID, 1);
-                if ( v7->pMonsterInfo.uExp )
-                  GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
-                v34 = SPEECH_51;
-                if ( rand() % 100 < 20 )
-                  v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
-                v6->PlaySound((PlayerSpeech)v34, 0);
-              }
-            }
-          }
-        }
-      }
-      if ( !(dword_6BE368_debug_settings_2 & 0x10)
-        && v7->pMonsterInfo.uSpecialAttack
-        && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType )
-        v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7);
-    }
-    if ( !pParty->bTurnBasedModeOn )
-    {
-      v35 = v6->GetActualEndurance();
-      v36 = (double)(20 - v6->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
-      v6->SetRecoveryTime((signed __int64)v36);
-    }
-    if ( v77 )
-    {
-      v73 = (double)(signed int)v75;
-      if ( (double)v6->GetMaxHealth() * 0.25 < v73 )
-      {
-        if ( v6->sHealth > 0 )
-        {
-          if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
-            v6->PlaySound(SPEECH_48, 0);
-        }
-      }
-    }
-    viewparams->bRedrawGameUI = 1;
-    return;
-  }
-  v37 = &pSpriteObjects[uActorID];
-  v38 = PID_TYPE(v37->spell_caster_pid);
-  v39 = PID_ID(v37->spell_caster_pid);
-  v40 = PID_TYPE(v37->spell_caster_pid);
-  uActorID = PID_ID(v37->spell_caster_pid);
-  v41 = v40 - 2;
-  if ( !v41 )
-    goto LABEL_80;
-  v42 = v41 - 1;
-  if ( !v42 )
-  {
-    v44 = &pActors[v39];
-    if ( a4 == -1 )
-      a4 = stru_50C198.which_player_would_attack(v44);
-    v45 = &pParty->pPlayers[a4];
-    v77 = Actor::_43B3E0_CalcDamage(v44, v74);
-    v46 = v37->uType;
-    if ( v37->uType == 545 )
-    {
-      LOBYTE(v51) = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-      v52 = v51;
-      if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) )
-      {
-		  sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], v45->pName);
-        ShowStatusBarString(pTmpBuf.data(), 2u);
-        v45->PlaySound(SPEECH_6, 0);
-        return;
-      }
-    }
-    else
-    {
-      if ( v46 != 555
-        && v46 != 510
-        && v46 != 500
-        && v46 != 515
-        && v46 != 505
-        && v46 != 530
-        && v46 != 525
-        && v46 != 520
-        && v46 != 535
-        && v46 != 540 )
-        goto LABEL_115;
-    }
-    if ( !stru_50C198.ActorHitOrMiss(v44, v45) )
-      return;
-    if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 )
-      v77 >>= 1;
-    if ( v45->HasEnchantedItemEquipped(36) )
-      v77 >>= 1;
-    if ( v45->HasEnchantedItemEquipped(69) )
-      v77 >>= 1;
-    if ( v45->HasItemEquipped(EQUIP_ARMOUR)
-		&& *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 )
-      v77 >>= 1;
-    v75 = 0;
-	v47 = (int)&v45->pEquipment;
-    do
-    {
-      if ( v45->HasItemEquipped((ITEM_EQUIP_TYPE)v75) )
-      {
-        v48 = *(int *)&v45[36 * *(int *)v47 + 496];
-        if ( v48 == 520 )
-          v77 >>= 1;
-        if ( v48 == 531 )
-          v77 >>= 1;
-        if ( v45->GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v75) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4 )
-          v77 >>= 1;
-      }
-      ++v75;
-      v47 += 4;
-    }
-    while ( (signed int)v75 <= 1 );
-LABEL_115:
-    if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 )
-    {
-      v49 = v44->pActorBuffs[3].uPower;
-      if ( v49 )
-        v77 /= (signed int)v49;
-    }
-    if ( !v74 )
-    {
-      v50 = v44->pMonsterInfo.uAttack1Type;
-      goto LABEL_133;
-    }
-    if ( v74 == 1 )
-    {
-      v50 = v44->pMonsterInfo.uAttack2Type;
-      goto LABEL_133;
-    }
-    if ( v74 == 2 )
-    {
-      v53 = v44->pMonsterInfo.uSpell1ID;
-    }
-    else
-    {
-      if ( v74 != 3 )
-      {
-        if ( v74 == 4 )
-          v50 = v44->pMonsterInfo.field_3C_some_special_attack;
-        else
-          v50 = 4;
-LABEL_133:
-        if ( !(dword_6BE368_debug_settings_2 & 0x10) )
-        {
-          v54 = v45->ReceiveDamage(v77, (DAMAGE_TYPE)v50);
-          if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) >= 0 )
-          {
-            if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v45->pPlayerBuffs[10].uExpireTime) )
-            {
-              v55 = v44->uAIState;
-              if ( v55 != 5 )
-              {
-                if ( v55 != 4 )
-                {
-                  v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54);
-                  v44->sCurrentHP -= v56;
-                  if ( v56 )
-                  {
-                    if ( v44->sCurrentHP >= 1 )
-                    {
-                      Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
-                      Actor::AggroSurroundingPeasants(uActorID, 1);
-                    }
-                    else
-                    {
-                      if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 )
-                      {
-                        v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius;
-                        v75 = v57;
-                        if ( pRenderer->pRenderD3D )
-                        {
-                          if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
-                          {
-                            v58 = (double)(signed int)v75;
-                            v75 = v44->vPosition.z;
-                            v59 = (double)(signed int)v75;
-                            v75 = v44->vPosition.y;
-                            v60 = v59;
-                            v61 = (double)(signed int)v75;
-                            v75 = v44->vPosition.x;
-                            v62 = v61;
-                            v63 = (double)(signed int)v75;
-                            pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0);
-                          }
-                        }
-                      }
-                      Actor::Die(uActorID);
-                      Actor::ApplyFineForKillingPeasant(uActorID);
-                      Actor::AggroSurroundingPeasants(uActorID, 1);
-                      if ( v44->pMonsterInfo.uExp )
-                        GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
-                      v64 = SPEECH_51;
-                      if ( rand() % 100 < 20 )
-                        v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
-                      v45->PlaySound((PlayerSpeech)v64, 0);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        if ( !v74
-          && !(dword_6BE368_debug_settings_2 & 0x10)
-          && v44->pMonsterInfo.uSpecialAttack
-          && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType )
-          v45->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44);
-        if ( !pParty->bTurnBasedModeOn )
-        {
-          v65 = v45->GetActualEndurance();
-          v66 = (double)(20 - v45->GetParameterBonus(v65))
-              * flt_6BE3A4_debug_recmod1
-              * 2.133333333333333;
-          v45->SetRecoveryTime((signed __int64)v66);
-        }
-        return;
-      }
-      v53 = v44->pMonsterInfo.uSpell2ID;
-    }
-    v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool);
-    goto LABEL_133;
-  }
-  if ( v42 != 1 )
-    return;
-LABEL_80:
-  if ( a4 != -1 )
-  {
-    v43 = &pParty->pPlayers[a4];
-LABEL_168:
-    a4b = v43;
-    if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW)
-    {
-      v70 = v43->GetMaxHealth();
-      v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70);
-      v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool);
-    }
-    else
-    {
-      v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
-      v69 = 0;
-    }
-    a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
-    if ( v38 == OBJECT_Player && !qword_A750D8 )
-    {
-      qword_A750D8 = 256i64;
-      word_A750E0 = 44;
-      word_A750E2 = uActorID + 1;
-    }
-    return;
-  }
-  v74 = 0;
-  a4a = 1;
-  do
-  {
-    if ( pPlayers[a4a]->CanAct() )
-    {
-      v67 = v74++;
-      *(&v72 + v67) = a4a;
-    }
-    ++a4a;
-  }
-  while ( a4a <= 4 );
-  if ( v74 )
-  {
-    v43 = &pParty->pPlayers[*(&v72+rand()%v74)-1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
-    goto LABEL_168;
-  }
-}
-
 //----- (0043A97E) --------------------------------------------------------
 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
 {
@@ -5440,47 +4382,6 @@
   return result;
 }
 
-//----- (0043AFE3) --------------------------------------------------------
-int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4)
-{
-  int result; // eax@1
-  unsigned int v5; // [sp-4h] [bp-8h]@9
-
-  result = 0;
-  if ( a1 == 7 )
-  {
-    if ( a3 <= 0 )
-      return result;
-    if ( a3 <= 2 )
-    {
-      v5 = 6;
-    }
-    else
-    {
-      if ( a3 == 3 )
-      {
-        v5 = 8;
-      }
-      else
-      {
-        if ( a3 != 4 )
-          return result;
-        v5 = 10;
-      }
-    }
-    result = GetDiceResult(a2, v5);
-  }
-  else
-  {
-    if ( a1 == 44 )
-      result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100;
-    else
-      result = *((char *)&pSpellDatas[0].field_10 + 20 * a1)
-             + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1));
-  }
-  return result;
-}
-
 //----- (0043B057) --------------------------------------------------------
 void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity)
 {
@@ -5654,369 +4555,14 @@
   }
 }
 
-//----- (0043C91D) --------------------------------------------------------
-int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder)
-{
-  int result; // eax@2
-  char v5; // zf@3
-  const char *v6; // [sp-Ch] [bp-18h]@88
-  signed int v7; // [sp-8h] [bp-14h]@61
-  int v8; // [sp-4h] [bp-10h]@61
-  signed int v9; // [sp-4h] [bp-10h]@69
-
-  result = 0; //BUG   fn is void
-  if ( item_id <= 500 )
-  {
-    //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
-    v5 = party_has_equipment[(item_id - 100) + 32 + 2] == 0;
-    switch ( item_id )
-    {
-      case 516:
-        v5 = byte_5111F6[2] == 0;
-        break;
-      case 505:
-        v5 = byte_5111F6[1] == 0;
-        break;
-      case 504:
-        v5 = byte_5111F6[0] == 0;
-        break;
-      case 533:
-        v5 = byte_5111F6[16] == 0;
-        break;
-      case 512:
-        v5 = byte_5111F6[3] == 0;
-        break;
-      case 521:
-        v5 = byte_5111F6[4] == 0;
-        break;
-      case 522:
-        v5 = byte_5111F6[5] == 0;
-        break;
-      case 523:
-        v5 = byte_5111F6[6] == 0;
-        break;
-      case 532:
-        v5 = byte_5111F6[7] == 0;
-        break;
-      case 544:
-        v5 = byte_5111F6[8] == 0;
-        break;
-      case 524:
-        v5 = byte_5111F6[9] == 0;
-        break;
-      case 535:
-        v5 = byte_5111F6[10] == 0;
-        break;
-      case 525:
-        v5 = byte_5111F6[11] == 0;
-        break;
-      case 530:
-        v5 = byte_5111F6[12] == 0;
-        break;
-      case 547:
-        v5 = byte_5111F6[13] == 0;
-        break;
-      case 548:
-        v5 = byte_5111F6[14] == 0;
-        break;
-      case 550:
-        v5 = byte_5111F6[15] == 0;
-        break;
-      default:
-        break;
-    }
-    if ( v5 )
-      return result;
-    result = 516;
-    if ( item_id < 66 || item_id > 78 )
-    {
-      if ( item_id == 516 )
-      {
-        if ( !shoulder )
-          return sprintf(pOut, "item%3.3dv%d", 234, index);
-        if ( shoulder == 1 )
-          return sprintf(pOut, "item%3.3dv%da1", 234, index);
-        if ( shoulder == 2 )
-          return sprintf(pOut, "item%3.3dv%da2", 234, index);
-      }
-      if ( item_id != 504 && item_id != 505 && item_id != 533 )
-      {
-        if ( (item_id < 100 || item_id > 104) && item_id != 524 && item_id != 535 )
-        {
-          if ( item_id >= 115 && item_id <= 119 || item_id == 512 )
-          {
-            if ( item_id == 512 )
-              item_id = 312;
-            return sprintf(pOut, "item%3.3dv%d", item_id, index);
-          }
-          if ( (item_id < 89 || item_id > 99) && item_id != 521 && item_id != 522 && item_id != 523 && item_id != 532 && item_id != 544 )
-          {
-            result = 525;
-            if ( (item_id < 105 || item_id > 109) && item_id != 525 && item_id != 530 && item_id != 547 && item_id != 548 && item_id != 550 )
-              return result;
-            switch ( item_id )
-            {
-              case 525:
-                item_id = 325;
-                break;
-              case 530:
-                item_id = 330;
-                break;
-              case 547:
-                item_id = 347;
-                break;
-              case 548:
-                item_id = 348;
-                break;
-              case 550:
-                item_id = 350;
-                break;
-            }
-            if ( !shoulder )
-              return sprintf(pOut, "item%3.3dv%d", item_id, index);
-            return sprintf(pOut, "item%3.3dv%da1", item_id, index);
-          }
-          if ( item_id == 521 )
-            return sprintf(pOut, "item%3.3dv%d", 239, index);
-          if ( item_id == 522 )
-            return sprintf(pOut, "item%3.3dv%d", 240, index);
-          if ( item_id == 523 )
-            return sprintf(pOut, "item%3.3dv%d", 241, index);
-          if ( item_id != 532 )
-          {
-            if ( item_id == 544 )
-              item_id = 344;
-            return sprintf(pOut, "item%3.3dv%d", item_id, index);
-          }
-          return sprintf(pOut, "item%3.3dv%d", 93, index);
-        }
-        if ( item_id == 524 )
-          return sprintf(pOut, "item%3.3dv%d", 324, index);
-        if ( item_id == 535 )
-          item_id = 104;
-        return sprintf(pOut, "item%3.3dv%d", item_id, index);
-      }
-    }
-    if ( item_id != 516 )
-    {
-      switch ( item_id )
-      {
-        case 504:
-          item_id = 235;
-          break;
-        case 505:
-          item_id = 236;
-          break;
-        case 533:
-          item_id = 73;
-          break;
-      }
-      if ( !shoulder )
-        return sprintf(pOut, "item%3.3dv%d", item_id, index);
-      if ( shoulder == 1 )
-        return sprintf(pOut, "item%3.3dv%da1", item_id, index);
-      if ( shoulder == 2 )
-        return sprintf(pOut, "item%3.3dv%da2", item_id, index);
-    }
-    if ( !shoulder )
-      return sprintf(pOut, "item%3.3dv%d", 234, index);
-    if ( shoulder == 1 )
-      return sprintf(pOut, "item%3.3dv%da1", 234, index);
-    if ( shoulder == 2 )
-      return sprintf(pOut, "item%3.3dv%da2", 234, index);
-  }
-  result = item_id - 504;
-  return result;
-}
-
-//----- (0043ED6F) --------------------------------------------------------
-bool _43ED6F_check_party_races(bool a1)
-{
-  bool v6; // zf@5
-
-  for (uint i = 0; i < 4; ++i)
-  {
-    auto player = pParty->pPlayers + i;
-    auto race = player->GetRace();
-
-    if (race != CHARACTER_RACE_HUMAN &&
-        race != CHARACTER_RACE_ELF &&
-        race != CHARACTER_RACE_GOBLIN)
-      v6 = a1 == 1;
-    else
-      v6 = !a1;
-
-    if (v6)
-      return true;
-  }
-  return false;
-}
+// A750D8: using guessed type __int64 qword_A750D8;
+
+
 // A750D8: using guessed type __int64 qword_A750D8;
 
-//----- (0043EDB9) --------------------------------------------------------
-bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1)
-{
-  unsigned int pNum; // ebp@1
-  Player **pPlayer; // ebx@1
-  Player *pPlayer2; // esi@2
-  enum CHARACTER_RACE pRace; // edi@2
-  bool pSex; // eax@2
-  char v6; // zf@7
-
-//pPlayer = &pPlayers[1];
-  /*pNum = a1;
-  
-  while ( 1 )
-  {
-    pPlayer2 = *pPlayer;
-    pRace = pPlayer2->GetRace();
-    pSex = pPlayer2->GetSexByVoice();
-    if ( !pRace )
-      break;
-    if ( pRace == 1 || pRace == 2 )
-      break;
-    if ( !pSex && pNum == 2 )//
-      //goto LABEL_15;
-    {
-      pSex = 1;
-      return pSex;
-    }
-    v6 = pNum == 3;//
-LABEL_11:
-    if ( v6 )
-      //goto LABEL_15;
-    {
-      pSex = 1;
-      return pSex;
-    }
-    ++pPlayer;
-    if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )//
-    {
-      pSex = 0;
-      return pSex;
-    }
-  }
-  if ( pSex || pNum )
-  {
-    v6 = pNum == 1;
-    goto LABEL_11;
-  }
-//LABEL_15:
-  pSex = 1;
-  return pSex;*/
-  for (uint i = 1; i <= 4; ++i)
-    {
-      pRace = pPlayers[i]->GetRace();
-      pSex = pPlayers[i]->GetSexByVoice();
-      if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 )
-        return 1;
-    }
- return 0;
-}
+
 // A750D8: using guessed type __int64 qword_A750D8;
 
-//----- (0043EE15) --------------------------------------------------------
-bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
-{
-  if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
-  {
-    for ( uint i = 0; i < 126; ++i )
-    {
-      if ( pPlayer->pInventoryIndices[i] > 0 )
-      {
-        if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID )
-          return true;
-      }
-    }
-    for ( uint i = 0; i < 16; ++i )
-    {
-      if ( pPlayer->pEquipment.pIndices[i] )
-      {
-        if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID )
-          return true;
-      }
-    }
-  }
-  return false;
-}
-
-//----- (0043EE77) --------------------------------------------------------
-bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
-{
-  bool result; // eax@0
-  Player *v2; // edx@3
-  int v3; // ecx@3
-  Player **pPlayers; // esi@8
-  unsigned int v5; // ecx@8
-  Player *v6; // edx@9
-
-  if ( a1 < 1 || a1 > 4 )
-  {
-    if ( !a1 )
-    {
-      pPlayers = &::pPlayers[1];
-      v5 = 604;
-      while ( 1 )
-      {
-        result = Player_has_item(v5, *pPlayers, 0);
-        if ( !result )
-          break;
-        result = v6->pEquipment.uArmor;
-        if ( !result )
-          break;
-        result *= 9;
-        if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
-          break;
-        ++pPlayers;
-        if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
-          goto LABEL_13;
-      }
-    }
-    goto LABEL_6;
-  }
-  result = Player_has_item(604u, ::pPlayers[a1], 0);
-  if ( !result
-    || (result = v2->pEquipment.uArmor) == 0
-    || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
-  {
-LABEL_6:
-    LOBYTE(result) = 0;
-    return result;
-  }
-LABEL_13:
-  LOBYTE(result) = 1;
-  return result;
-}
-// A750D8: using guessed type __int64 qword_A750D8;
-
-
-//----- (0043F333) --------------------------------------------------------
-void BspRenderer::MakeVisibleSectorList()
-{
-  int v6; // ebx@3
-
-  uNumVisibleNotEmptySectors = 0;
-  for (uint i = 0; i < num_nodes; ++i)
-  {
-      if (!uNumVisibleNotEmptySectors)
-      {
-        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID;
-        continue;
-      }
-      
-      v6 = 0;
-        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID )
-        {
-          ++v6;
-          if ( v6 >= uNumVisibleNotEmptySectors)
-          {
-            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID;
-          }
-        }
-
-  }
-}
-
 //----- (0043F515) --------------------------------------------------------
 void FindBillboardsLightLevels_BLV()
 {
@@ -8061,835 +6607,6 @@
   return result;
 }
 
-//----- (00407A1C) --------------------------------------------------------
-bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
-{
-  unsigned int v4; // esi@1
-  Vec3_int_ v5; // ST08_12@2
-  int v6; // edi@2
-  int v7; // ebx@2
-  int v8; // esi@2
-  signed int v9; // ecx@2
-  int v10; // eax@2
-  int v11; // ecx@4
-  int v12; // eax@4
-  int v13; // ebx@4
-  int v14; // edx@6
-  char *v15; // edi@16
-  ODMFace *v16; // esi@19
-  int v17; // ST34_4@25
-  int v18; // ST38_4@25
-  int v19; // eax@25
-  char v20; // zf@25
-  int v21; // ebx@25
-  int v22; // eax@26
-  signed int v23; // edi@26
-  int v24; // ST34_4@30
-  signed __int64 v25; // qtt@31
-  int v26; // eax@31
-  Vec3_int_ v27; // ST08_12@37
-  Vec3_int_ v28; // ST08_12@37
-  int v29; // edi@37
-  int v30; // ebx@37
-  int v31; // esi@37
-  signed int v32; // ecx@37
-  int v33; // eax@37
-  int v34; // ecx@39
-  int v35; // eax@39
-  int v36; // ebx@39
-  int v37; // edx@41
-  char *v38; // edi@51
-  ODMFace *v39; // esi@54
-  int v40; // ebx@60
-  int v41; // eax@61
-  signed int v42; // edi@61
-  signed __int64 v43; // qtt@66
-  int v44; // eax@66
-  Vec3_int_ v45; // ST08_12@73
-  int v46; // edi@73
-  int v47; // ebx@73
-  int v48; // esi@73
-  signed int v49; // ecx@73
-  int v50; // eax@73
-  int v51; // edx@75
-  int v52; // ecx@75
-  int v53; // eax@75
-  int v54; // ebx@75
-  int v55; // edi@77
-  int v56; // ecx@77
-  int v57; // eax@81
-  int v58; // esi@81
-  int v59; // eax@90
-  BLVSector *v60; // edx@90
-  int v61; // ecx@90
-  BLVFace *v62; // esi@91
-  int v63; // ST34_4@98
-  int v64; // ST30_4@98
-  int v65; // eax@98
-  int v66; // ebx@98
-  int v67; // eax@99
-  signed int v68; // edi@99
-  int v69; // ST2C_4@103
-  signed __int64 v70; // qtt@104
-  int v71; // eax@104
-  Vec3_int_ v72; // ST08_12@111
-  Vec3_int_ v73; // ST08_12@111
-  int v74; // edi@111
-  int v75; // ebx@111
-  int v76; // esi@111
-  signed int v77; // ecx@111
-  int v78; // eax@111
-  int v79; // edx@113
-  int v80; // ecx@113
-  int v81; // eax@113
-  int v82; // ebx@113
-  int v83; // edi@115
-  int v84; // ecx@115
-  int v85; // eax@119
-  int v86; // esi@119
-  int v87; // ecx@128
-  BLVSector *v88; // eax@128
-  int v89; // ecx@128
-  BLVFace *v90; // esi@129
-  int v91; // ebx@136
-  int v92; // eax@137
-  signed int v93; // edi@137
-  signed __int64 v94; // qtt@142
-  int v95; // eax@142
-  Vec3_int_ v97; // [sp-18h] [bp-94h]@1
-  int v98; // [sp-Ch] [bp-88h]@88
-  int v99; // [sp-Ch] [bp-88h]@126
-  int v100; // [sp-8h] [bp-84h]@88
-  int v101; // [sp-8h] [bp-84h]@126
-  int v102; // [sp-4h] [bp-80h]@88
-  int v103; // [sp-4h] [bp-80h]@126
-  int v104; // [sp+Ch] [bp-70h]@13
-  int v105; // [sp+Ch] [bp-70h]@48
-  int v106; // [sp+10h] [bp-6Ch]@18
-  int v107; // [sp+10h] [bp-6Ch]@98
-  int v108; // [sp+10h] [bp-6Ch]@104
-  int v109; // [sp+18h] [bp-64h]@25
-  int v110; // [sp+18h] [bp-64h]@31
-  int i; // [sp+18h] [bp-64h]@90
-  int v112; // [sp+18h] [bp-64h]@128
-  signed int v113; // [sp+20h] [bp-5Ch]@1
-  signed int v114; // [sp+24h] [bp-58h]@1
-  unsigned __int64 a4; // [sp+28h] [bp-54h]@1
-  unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
-  int v117; // [sp+34h] [bp-48h]@4
-  int v118; // [sp+34h] [bp-48h]@39
-  int v119; // [sp+34h] [bp-48h]@75
-  int v120; // [sp+34h] [bp-48h]@113
-  int v121; // [sp+38h] [bp-44h]@4
-  int v122; // [sp+38h] [bp-44h]@39
-  int v123; // [sp+38h] [bp-44h]@76
-  int v124; // [sp+38h] [bp-44h]@114
-  int v125; // [sp+3Ch] [bp-40h]@4
-  int v126; // [sp+3Ch] [bp-40h]@39
-  int v127; // [sp+3Ch] [bp-40h]@77
-  int v128; // [sp+3Ch] [bp-40h]@115
-  int v129; // [sp+40h] [bp-3Ch]@11
-  int v130; // [sp+40h] [bp-3Ch]@46
-  int v131; // [sp+40h] [bp-3Ch]@78
-  int v132; // [sp+40h] [bp-3Ch]@116
-  int v133; // [sp+44h] [bp-38h]@10
-  int v134; // [sp+44h] [bp-38h]@45
-  int v135; // [sp+44h] [bp-38h]@81
-  int v136; // [sp+44h] [bp-38h]@119
-  int v137; // [sp+48h] [bp-34h]@7
-  int v138; // [sp+48h] [bp-34h]@42
-  int v139; // [sp+48h] [bp-34h]@82
-  int v140; // [sp+48h] [bp-34h]@120
-  int v141; // [sp+4Ch] [bp-30h]@6
-  int v142; // [sp+4Ch] [bp-30h]@41
-  int v143; // [sp+4Ch] [bp-30h]@75
-  int v144; // [sp+4Ch] [bp-30h]@113
-  int v145; // [sp+50h] [bp-2Ch]@5
-  int v146; // [sp+50h] [bp-2Ch]@40
-  int v147; // [sp+50h] [bp-2Ch]@75
-  int v148; // [sp+50h] [bp-2Ch]@113
-  int v149; // [sp+54h] [bp-28h]@4
-  int v150; // [sp+54h] [bp-28h]@39
-  int v151; // [sp+54h] [bp-28h]@75
-  int v152; // [sp+54h] [bp-28h]@113
-  int sDepth; // [sp+58h] [bp-24h]@17
-  int sDeptha; // [sp+58h] [bp-24h]@52
-  int sDepthb; // [sp+58h] [bp-24h]@90
-  char *a5; // [sp+5Ch] [bp-20h]@16
-  char *a5a; // [sp+5Ch] [bp-20h]@51
-  signed int a5b; // [sp+5Ch] [bp-20h]@83
-  signed int a5c; // [sp+5Ch] [bp-20h]@121
-  signed int v160; // [sp+60h] [bp-1Ch]@12
-  signed int v161; // [sp+60h] [bp-1Ch]@47
-  int v162; // [sp+60h] [bp-1Ch]@128
-  int v163; // [sp+64h] [bp-18h]@2
-  int outx; // [sp+68h] [bp-14h]@2
-  int outy; // [sp+6Ch] [bp-10h]@2
-  int outz; // [sp+70h] [bp-Ch]@2
-  Vec3_int_ pOut; // [sp+74h] [bp-8h]@2
-  int ya; // [sp+84h] [bp+8h]@60
-  int yb; // [sp+84h] [bp+8h]@136
-  int ve; // [sp+88h] [bp+Ch]@60
-  int va; // [sp+88h] [bp+Ch]@60
-  int vb; // [sp+88h] [bp+Ch]@66
-  int vf; // [sp+88h] [bp+Ch]@136
-  int vc; // [sp+88h] [bp+Ch]@136
-  int vd; // [sp+88h] [bp+Ch]@142
-  int v_4; // [sp+8Ch] [bp+10h]@60
-  int v_4a; // [sp+8Ch] [bp+10h]@65
-  int v_4b; // [sp+8Ch] [bp+10h]@136
-  int v_4c; // [sp+8Ch] [bp+10h]@141
-  int v_8; // [sp+90h] [bp+14h]@53
-
-  a4 = __PAIR__(z, x);
-  v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
-  v114 = 0;
-  v97.z = y;
-  v113 = 0;
-  a4_8 = v4;
-  *(_QWORD *)&v97.x = a4;
-  if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
-  {
-    Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
-    v45.z = v.z;
-    *(_QWORD *)&v45.x = *(_QWORD *)&v;
-    Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163);
-    v46 = outy - pOut.y;
-    v47 = v163 - outz;
-    v48 = outx - pOut.x;
-    v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47);
-    v50 = 65536;
-    if ( v49 )
-      v50 = 65536 / v49;
-    v51 = outx;
-    v143 = v48 * v50;
-    v52 = v46 * v50;
-    v53 = v47 * v50;
-    v54 = pOut.x;
-    v147 = v52;
-    v151 = v53;
-    v119 = pOut.x;
-    if ( pOut.x < outx )
-    {
-      v123 = outx;
-    }
-    else
-    {
-      v119 = outx;
-      v123 = pOut.x;
-    }
-    v55 = pOut.y;
-    v56 = outy;
-    v127 = pOut.y;
-    if ( pOut.y < outy )
-    {
-      v131 = outy;
-    }
-    else
-    {
-      v127 = outy;
-      v131 = pOut.y;
-    }
-    v57 = v163;
-    v58 = outz;
-    v135 = outz;
-    if ( outz < v163 )
-    {
-      v139 = v163;
-    }
-    else
-    {
-      v135 = v163;
-      v139 = outz;
-    }
-    a5b = 0;
-    while ( !v114 )
-    {
-      if ( a5b )
-      {
-        v102 = v58;
-        v100 = v55;
-        v98 = v54;
-      }
-      else
-      {
-        v102 = v57;
-        v100 = v56;
-        v98 = v51;
-      }
-      v59 = pIndoor->GetSector(v98, v100, v102);
-      v60 = pIndoor->pSectors;
-      v61 = 116 * v59;
-      sDepthb = 0;
-      for ( i = 116 * v59;
-            sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61)
-                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
-            ++sDepthb )
-      {
-        v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
-        if ( v62->Portal()
-          || v119 > v62->pBounding.x2
-          || v123 < v62->pBounding.x1
-          || v127 > v62->pBounding.y2
-          || v131 < v62->pBounding.y1
-          || v135 > v62->pBounding.z2
-          || v139 < v62->pBounding.z1
-          || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16,
-              v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16,
-              v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16,
-              v20 = v63 + v64 + v65 == 0,
-              v66 = v63 + v64 + v65,
-              v107 = v63 + v64 + v65,
-              v20) )
-          goto LABEL_107;
-        v67 = outz * v62->pFacePlane_old.vNormal.z;
-        v68 = -(v62->pFacePlane_old.dist
-              + v67
-              + pOut.y * v62->pFacePlane_old.vNormal.y
-              + pOut.x * v62->pFacePlane_old.vNormal.x);
-        if ( v66 <= 0 )
-        {
-          if ( v62->pFacePlane_old.dist
-             + v67
-             + pOut.y * v62->pFacePlane_old.vNormal.y
-             + pOut.x * v62->pFacePlane_old.vNormal.x < 0 )
-            goto LABEL_107;
-        }
-        else
-        {
-          if ( v62->pFacePlane_old.dist
-             + v67
-             + pOut.y * v62->pFacePlane_old.vNormal.y
-             + pOut.x * v62->pFacePlane_old.vNormal.x > 0 )
-            goto LABEL_107;
-        }
-        v69 = abs(-(v62->pFacePlane_old.dist
-                  + v67
-                  + pOut.y * v62->pFacePlane_old.vNormal.y
-                  + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14;
-        if ( v69 <= abs(v66) )
-        {
-          LODWORD(v70) = v68 << 16;
-          HIDWORD(v70) = v68 >> 16;
-          v71 = v70 / v107;
-          v108 = v70 / v107;
-          if ( v71 >= 0 )
-          {
-            if ( sub_4075DB(
-                   pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16),
-                   pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16),
-                   outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16),
-                   v62) )
-            {
-              v114 = 1;
-              break;
-            }
-          }
-        }
-        v61 = i;
-LABEL_107:
-        v60 = pIndoor->pSectors;
-      }
-      ++a5b;
-      if ( a5b >= 2 )
-        break;
-      v57 = v163;
-      v56 = outy;
-      v51 = outx;
-      v58 = outz;
-      v55 = pOut.y;
-      v54 = pOut.x;
-    }
-    v72.z = y;
-    *(_QWORD *)&v72.x = a4;
-    Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
-    v73.z = v.z;
-    *(_QWORD *)&v73.x = *(_QWORD *)&v;
-    Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
-    v74 = outy - pOut.y;
-    v75 = v163 - outz;
-    v76 = outx - pOut.x;
-    v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75);
-    v78 = 65536;
-    if ( v77 )
-      v78 = 65536 / v77;
-    v79 = outx;
-    v144 = v76 * v78;
-    v80 = v74 * v78;
-    v81 = v75 * v78;
-    v82 = pOut.x;
-    v148 = v80;
-    v152 = v81;
-    v120 = pOut.x;
-    if ( pOut.x < outx )
-    {
-      v124 = outx;
-    }
-    else
-    {
-      v120 = outx;
-      v124 = pOut.x;
-    }
-    v83 = pOut.y;
-    v84 = outy;
-    v128 = pOut.y;
-    if ( pOut.y < outy )
-    {
-      v132 = outy;
-    }
-    else
-    {
-      v128 = outy;
-      v132 = pOut.y;
-    }
-    v85 = v163;
-    v86 = outz;
-    v136 = outz;
-    if ( outz < v163 )
-    {
-      v140 = v163;
-    }
-    else
-    {
-      v136 = v163;
-      v140 = outz;
-    }
-    a5c = 0;
-    while ( 1 )
-    {
-      if ( v113 )
-        return !v114 || !v113;
-      if ( a5c )
-      {
-        v103 = v86;
-        v101 = v83;
-        v99 = v82;
-      }
-      else
-      {
-        v103 = v85;
-        v101 = v84;
-        v99 = v79;
-      }
-      v87 = pIndoor->GetSector(v99, v101, v103);
-      v88 = pIndoor->pSectors;
-      v89 = 116 * v87;
-      v162 = 0;
-      v112 = v89;
-      if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
-         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
-        break;
-LABEL_148:
-      ++a5c;
-      if ( a5c >= 2 )
-        return !v114 || !v113;
-      v85 = v163;
-      v84 = outy;
-      v79 = outx;
-      v86 = outz;
-      v83 = pOut.y;
-      v82 = pOut.x;
-    }
-    while ( 1 )
-    {
-      v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
-      if ( v90->Portal()
-        || v120 > v90->pBounding.x2
-        || v124 < v90->pBounding.x1
-        || v128 > v90->pBounding.y2
-        || v132 < v90->pBounding.y1
-        || v136 > v90->pBounding.z2
-        || v140 < v90->pBounding.z1
-        || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16,
-            v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16,
-            vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16,
-            v20 = yb + vf + v_4b == 0,
-            v91 = yb + vf + v_4b,
-            vc = yb + vf + v_4b,
-            v20) )
-        goto LABEL_145;
-      v92 = outz * v90->pFacePlane_old.vNormal.z;
-      v93 = -(v90->pFacePlane_old.dist
-            + v92
-            + pOut.y * v90->pFacePlane_old.vNormal.y
-            + pOut.x * v90->pFacePlane_old.vNormal.x);
-      if ( v91 <= 0 )
-      {
-        if ( v90->pFacePlane_old.dist
-           + v92
-           + pOut.y * v90->pFacePlane_old.vNormal.y
-           + pOut.x * v90->pFacePlane_old.vNormal.x < 0 )
-          goto LABEL_145;
-      }
-      else
-      {
-        if ( v90->pFacePlane_old.dist
-           + v92
-           + pOut.y * v90->pFacePlane_old.vNormal.y
-           + pOut.x * v90->pFacePlane_old.vNormal.x > 0 )
-          goto LABEL_145;
-      }
-      v_4c = abs(-(v90->pFacePlane_old.dist
-                 + v92
-                 + pOut.y * v90->pFacePlane_old.vNormal.y
-                 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14;
-      if ( v_4c <= abs(v91) )
-      {
-        LODWORD(v94) = v93 << 16;
-        HIDWORD(v94) = v93 >> 16;
-        v95 = v94 / vc;
-        vd = v94 / vc;
-        if ( v95 >= 0 )
-        {
-          if ( sub_4075DB(
-                 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16),
-                 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16),
-                 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16),
-                 v90) )
-          {
-            v113 = 1;
-            goto LABEL_148;
-          }
-        }
-      }
-      v89 = v112;
-LABEL_145:
-      v88 = pIndoor->pSectors;
-      ++v162;
-      if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
-                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
-        goto LABEL_148;
-    }
-  }
-  Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
-  v5.z = v.z;
-  *(_QWORD *)&v5.x = *(_QWORD *)&v;
-  Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163);
-  v6 = outy - pOut.y;
-  v7 = v163 - outz;
-  v8 = outx - pOut.x;
-  v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7);
-  v10 = 65536;
-  if ( v9 )
-    v10 = 65536 / v9;
-  v125 = v8 * v10;
-  v11 = v10;
-  v12 = v7 * v10;
-  v13 = pOut.x;
-  v117 = v12;
-  v121 = v6 * v11;
-  v149 = pOut.x;
-  if ( pOut.x < outx )
-  {
-    v145 = outx;
-  }
-  else
-  {
-    v149 = outx;
-    v145 = pOut.x;
-  }
-  v14 = outy;
-  v141 = pOut.y;
-  if ( pOut.y < outy )
-  {
-    v137 = outy;
-  }
-  else
-  {
-    v141 = outy;
-    v137 = pOut.y;
-  }
-  v133 = outz;
-  if ( outz < v163 )
-  {
-    v129 = v163;
-  }
-  else
-  {
-    v133 = v163;
-    v129 = outz;
-  }
-  v160 = 0;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
-  {
-    v104 = 0;
-    while ( 1 )
-    {
-      v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
-      a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
-      if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
-      {
-        sDepth = 0;
-        if ( *((int *)v15 + 2) > 0 )
-          break;
-      }
-LABEL_36:
-      ++v160;
-      ++v104;
-      if ( v160 >= (signed int)pOutdoor->uNumBModels )
-        goto LABEL_37;
-      v14 = outy;
-      v13 = pOut.x;
-    }
-    v106 = 0;
-    while ( 1 )
-    {
-      v16 = (ODMFace *)(v106 + *((int *)a5 + 4));
-      if ( v149 > v16->pBoundingBox.x2
-        || v145 < v16->pBoundingBox.x1
-        || v141 > v16->pBoundingBox.y2
-        || v137 < v16->pBoundingBox.y1
-        || v133 > v16->pBoundingBox.z2
-        || v129 < v16->pBoundingBox.z1
-        || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16,
-            v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16,
-            v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16,
-            v20 = v17 + v18 + v19 == 0,
-            v21 = v17 + v18 + v19,
-            v109 = v17 + v18 + v19,
-            v20) )
-        goto LABEL_33;
-      v22 = pOut.y * v16->pFacePlane.vNormal.y;
-      v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x);
-      if ( v21 <= 0 )
-      {
-        if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 )
-          goto LABEL_33;
-      }
-      else
-      {
-        if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 )
-          goto LABEL_33;
-      }
-      v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14;
-      if ( v24 <= abs(v21) )
-      {
-        LODWORD(v25) = v23 << 16;
-        HIDWORD(v25) = v23 >> 16;
-        v26 = v25 / v109;
-        v110 = v25 / v109;
-        if ( v26 >= 0 )
-        {
-          if ( sub_4077F1(
-                 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16),
-                 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16),
-                 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16),
-                 v16,
-                 (BSPVertexBuffer *)a5) )
-          {
-            v114 = 1;
-            goto LABEL_36;
-          }
-        }
-      }
-LABEL_33:
-      ++sDepth;
-      v106 += 308;
-      if ( sDepth >= *((int *)a5 + 2) )
-        goto LABEL_36;
-    }
-  }
-LABEL_37:
-  v27.z = y;
-  *(_QWORD *)&v27.x = a4;
-  Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
-  v28.z = v.z;
-  *(_QWORD *)&v28.x = *(_QWORD *)&v;
-  Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
-  v29 = outy - pOut.y;
-  v30 = v163 - outz;
-  v31 = outx - pOut.x;
-  v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30);
-  v33 = 65536;
-  if ( v32 )
-    v33 = 65536 / v32;
-  v126 = v31 * v33;
-  v34 = v33;
-  v35 = v30 * v33;
-  v36 = pOut.x;
-  v118 = v35;
-  v122 = v29 * v34;
-  v150 = pOut.x;
-  if ( pOut.x < outx )
-  {
-    v146 = outx;
-  }
-  else
-  {
-    v150 = outx;
-    v146 = pOut.x;
-  }
-  v37 = outy;
-  v142 = pOut.y;
-  if ( pOut.y < outy )
-  {
-    v138 = outy;
-  }
-  else
-  {
-    v142 = outy;
-    v138 = pOut.y;
-  }
-  v134 = outz;
-  if ( outz < v163 )
-  {
-    v130 = v163;
-  }
-  else
-  {
-    v134 = v163;
-    v130 = outz;
-  }
-  v161 = 0;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
-  {
-    v105 = 0;
-    while ( 1 )
-    {
-      v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
-      a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
-      if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
-      {
-        sDeptha = 0;
-        if ( *((int *)v38 + 2) > 0 )
-          break;
-      }
-LABEL_71:
-      ++v161;
-      ++v105;
-      if ( v161 >= (signed int)pOutdoor->uNumBModels )
-        return !v114 || !v113;
-      v37 = outy;
-      v36 = pOut.x;
-    }
-    v_8 = 0;
-    while ( 1 )
-    {
-      v39 = (ODMFace *)(v_8 + *((int *)a5a + 4));
-      if ( v150 > v39->pBoundingBox.x2
-        || v146 < v39->pBoundingBox.x1
-        || v142 > v39->pBoundingBox.y2
-        || v138 < v39->pBoundingBox.y1
-        || v134 > v39->pBoundingBox.z2
-        || v130 < v39->pBoundingBox.z1
-        || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16,
-            ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16,
-            v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16,
-            v20 = ya + ve + v_4 == 0,
-            v40 = ya + ve + v_4,
-            va = ya + ve + v_4,
-            v20) )
-        goto LABEL_68;
-      v41 = pOut.y * v39->pFacePlane.vNormal.y;
-      v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x);
-      if ( v40 <= 0 )
-      {
-        if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 )
-          goto LABEL_68;
-      }
-      else
-      {
-        if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 )
-          goto LABEL_68;
-      }
-      v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14;
-      if ( v_4a <= abs(v40) )
-      {
-        LODWORD(v43) = v42 << 16;
-        HIDWORD(v43) = v42 >> 16;
-        v44 = v43 / va;
-        vb = v43 / va;
-        if ( v44 >= 0 )
-        {
-          if ( sub_4077F1(
-                 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16),
-                 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16),
-                 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16),
-                 v39,
-                 (BSPVertexBuffer *)a5a) )
-          {
-            v113 = 1;
-            goto LABEL_71;
-          }
-        }
-      }
-LABEL_68:
-      ++sDeptha;
-      v_8 += 308;
-      if ( sDeptha >= *((int *)a5a + 2) )
-        goto LABEL_71;
-    }
-  }
-  return !v114 || !v113;
-}
-
-//----- (00408768) --------------------------------------------------------
-void InitializeActors()
-{
-  signed int v5; // [sp+Ch] [bp-10h]@1
-  signed int v6; // [sp+10h] [bp-Ch]@1
-  signed int v7; // [sp+14h] [bp-8h]@1
-  signed int v8; // [sp+18h] [bp-4h]@1
-
-  v8 = 0;
-  v6 = 0;
-  v7 = 0;
-  v5 = 0;
-  if ( !_stricmp(pCurrentMapName.data(), "d25.blv") )
-    v8 = 1;
-  if ( !_stricmp(pCurrentMapName.data(), "d26.blv") )
-    v6 = 1;
-  if (_449B57_test_bit(pParty->_quest_bits, 99))
-    v7 = 1;
-  if (_449B57_test_bit(pParty->_quest_bits, 100))
-    v5 = 1;
-
-  Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0;  original code behaviour is identical
-  for (uint i = 0; i < uNumActors; ++i)
-  {
-    auto actor = &pActors[i];
-
-    if (actor->CanAct() || actor->uAIState == Disabled)
-    {
-      actor->vPosition.x = actor->vInitialPosition.x;
-      actor->vPosition.y = actor->vInitialPosition.y;
-      actor->vPosition.z = actor->vInitialPosition.z;
-      actor->sCurrentHP = actor->pMonsterInfo.uHP;
-      if (actor->uAIState != Disabled)
-      {
-        Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0);
-      }
-    }
-
-    actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-
-    if (!v8 || v7)
-      if (!v6 || v5)
-        if (actor->IsPeasant())
-          BYTE2(actor->uAttributes) &= 0xF7u;
-
-    BYTE2(actor->uAttributes) &= 0x7Fu;
-    if (BYTE2(actor->uAttributes) & 0x40)
-        Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1);
-  }
-}
-
-//----- (00408896) --------------------------------------------------------
-void InitializeSpriteObjects()
-{
-  for (uint i = 0; i < uNumSpriteObjects; ++i)
-  {
-    auto item = &pSpriteObjects[i];
-
-    if (item->uType &&
-        (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10))
-      SpriteObject::OnInteraction(i);
-  }
-
-  for (uint i = 0; i < 100; ++i)
-    array_5118E8.pElements[i].field_C_time_left = 0;
-}
-
 //----- (004088E9) --------------------------------------------------------
 signed int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6)
 {
@@ -8911,151 +6628,6 @@
   return result;
 }
 
-//----- (00408A27) --------------------------------------------------------
-unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors)
-{
-  unsigned int *v1; // esi@1
-  int v2; // eax@1
-  unsigned int v3; // ebp@1
-  signed int v4; // ebx@1
-  Actor *v5; // edi@2
-  unsigned int v6; // eax@3
-  int v8; // [sp+Ch] [bp-4h]@1
-
-  v1 = pTotalActors;
-  v2 = GetAlertStatus();
-  v3 = 0;
-  v4 = 0;
-  *v1 = 0;
-  v8 = v2;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v5 = pActors.data();
-    do
-    {
-      v6 = v5->uAttributes;
-      if ( (v6 & 0x100000) == v8 )
-      {
-        ++*v1;
-        if ( v5->IsNotAlive() == 1 )
-          ++v3;
-      }
-      ++v4;
-      ++v5;
-    }
-    while ( v4 < (signed int)uNumActors );
-  }
-  return v3;
-}
-
-//----- (00408A7E) --------------------------------------------------------
-unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
-{
-  unsigned int *v2; // esi@1
-  signed int v3; // ebx@1
-  Actor *v4; // edi@2
-  int v5; // eax@3
-  int v7; // [sp+8h] [bp-Ch]@1
-  int v8; // [sp+Ch] [bp-8h]@1
-  unsigned int v9; // [sp+10h] [bp-4h]@1
-
-  v7 = uMonsterID;
-  v2 = pTotalActors;
-  v3 = 0;
-  v8 = GetAlertStatus();
-  *v2 = 0;
-  v9 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v4 = pActors.data();//[0].pMonsterInfo.uID;
-    do
-    {
-	  v5 = v4->uAttributes;                // actor::attributes
-      if ( (v5 & 0x100000) == v8 )
-      {
-		if ( v4->pMonsterInfo.field_33 == v7 )
-        {
-          ++*v2;
-          if ( v4->IsNotAlive() == 1 )
-            ++v9;
-        }
-      }
-      ++v3;
-      ++v4;
-    }
-    while ( v3 < (signed int)uNumActors );
-  }
-  return v9;
-}
-
-//----- (00408AE7) --------------------------------------------------------
-unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup)
-{
-  unsigned int *v2; // esi@1
-  signed int v3; // ebx@1
-  Actor *v4; // edi@2
-  int v5; // eax@3
-  unsigned int v7; // [sp+8h] [bp-Ch]@1
-  int v8; // [sp+Ch] [bp-8h]@1
-  unsigned int v9; // [sp+10h] [bp-4h]@1
-
-  v7 = uGroup;
-  v2 = pTotalActors;
-  v3 = 0;
-  v8 = GetAlertStatus();
-  *v2 = 0;
-  v9 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v4 = pActors.data();//[0].uGroup;
-    do
-    {
-	  v5 = v4->uAttributes;
-      if ( (v5 & 0x100000) == v8 )
-      {
-		if ( v4->uGroup == v7 )
-        {
-          ++*v2;
-          if ( v4->IsNotAlive() == 1 )
-            ++v9;
-        }
-      }
-      ++v3;
-      ++v4;
-    }
-    while ( v3 < (signed int)uNumActors );
-  }
-  return v9;
-}
-
-//----- (00408B54) --------------------------------------------------------
-unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
-{
-  unsigned int v2; // edi@1
-  unsigned int *v3; // esi@1
-  int v4; // eax@1
-  unsigned int v5; // ebx@1
-  unsigned int v6; // edx@1
-
-  v2 = a2;
-  v3 = pTotalActors;
-  v4 = GetAlertStatus();
-  v5 = 0;
-  *v3 = 0;
-  v6 = pActors[v2].uAttributes;
-  if ( (v6 & 0x100000) == v4 )
-  {
-    *v3 = 1;
-    if ( pActors[v2].IsNotAlive() == 1 )
-      v5 = 1;
-  }
-  return v5;
-}
-
-
-
-
-
 //----- (0040DEDB) --------------------------------------------------------
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
 {
@@ -9070,12 +6642,6 @@
                            LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
 }
 
-//----- (0040DF3D) --------------------------------------------------------
-void __cdecl CallRenderPresent()
-{
-  pRenderer->Present();
-}
-
 //----- (0040DFA7) --------------------------------------------------------
 int __stdcall retzero_sub_40DFA7(int a1)
 {
@@ -9185,30 +6751,6 @@
   }
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-//----- (00410AF5) --------------------------------------------------------
-void __cdecl SetMoonPhaseNames()
-{
-  aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
-  aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
-  aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
-  aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
-  aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
-}
-
-
 //----- (00410D99) --------------------------------------------------------
 signed int __fastcall sub_410D99_get_map_index(int a1)
 {
@@ -9236,720 +6778,14 @@
   return v2;
 }
 
-//----- (00410DEC) --------------------------------------------------------
-unsigned int __cdecl DrawLloydBeaconsScreen()
-{
-  Player *pPlayer; // esi@1
-  char *v1; // eax@1
-  unsigned __int16 v2; // ax@6
-  unsigned int result; // eax@11
-  unsigned int v4; // esi@13
-  unsigned int v5; // ecx@13
-  char v6; // zf@13
-  LloydBeacon *v7; // esi@14
-  int v8; // eax@14
-  unsigned __int64 v9; // kr08_8@14
-  unsigned int v10; // esi@14
-  unsigned int v11; // eax@14
-  char *v12; // eax@19
-  char *v13; // ecx@22
-  int v14; // eax@27
-  Texture *v19; // [sp-4h] [bp-8Ch]@4
-  GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
-  unsigned int v23; // [sp+64h] [bp-24h]@14
-  __int64 v24; // [sp+68h] [bp-20h]@14
-  unsigned int v25; // [sp+70h] [bp-18h]@13
-  char *Str; // [sp+74h] [bp-14h]@14
-  int v27; // [sp+78h] [bp-10h]@11
-  LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
-  RGBTexture *v29; // [sp+80h] [bp-8h]@12
-  int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
-
-  pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
-  pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
-  v1 = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
-  pWindow.uFrameX = game_viewport_x;
-  pWindow.uFrameY = game_viewport_y;
-  pWindow.uFrameWidth = 428;
-  pWindow.uFrameHeight = game_viewport_height;
-  pWindow.uFrameZ = 435;
-  pWindow.uFrameW = game_viewport_w;
-  if ( !bRecallingBeacon )
-    v1 = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
-  sprintf(pTmpBuf.data(), "%s", v1);
-  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u);
-  if ( bRecallingBeacon )
-  {
-    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
-    v19 = pTex_tab_an_6a__zoom_off;
-  }
-  else
-  {
-    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
-    v19 = pTex_tab_an_6b__zoom_on;
-  }
-  pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
-  v2 = pPlayer->pActiveSkills[14];
-  uNumMaxBeacons = 1;
-  if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
-  {
-    uNumMaxBeacons = 5;
-  }
-  else
-  {
-    if ( v2 & 0x40 )
-      uNumMaxBeacons = 3;
-  }
-  result = 0;
-  v27 = 0;
-  if ( uNumMaxBeacons > 0 )
-  {
-    v29 = pSavegameThumbnails.data();
-    v28 = pPlayer->pInstalledBeacons;
-    while ( 1 )
-    {
-      pWindow.uFrameWidth = 92;
-      v4 = result;
-      pWindow.uFrameHeight = 68;
-      v5 = pLloydsBeaconsPreviewXs[result];
-      pWindow.uFrameY = pLloydsBeaconsPreviewYs[result];
-      v25 = pWindow.uFrameY;
-      pWindow.uFrameX = v5;
-      pWindow.uFrameW = pWindow.uFrameY + 67;
-      v6 = v29->pPixels == 0;
-      pWindow.uFrameZ = v5 + 91;
-      if ( !v6 )
-        break;
-      if ( !bRecallingBeacon )
-      {
-        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-        v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
-        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);
-      }
-LABEL_29:
-      ++v29;
-      ++v28;
-      result = v27++ + 1;
-      if ( v27 >= uNumMaxBeacons )
-        goto LABEL_30;
-    }
-    pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-    pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
-    v7 = v28;
-    Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
-    v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
-    pWindow.uFrameY += -6 - v8;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
-    v9 = v7->uBeaconTime - pParty->uTimePlayed;
-    LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
-    HIDWORD(v24) = HIDWORD(v9);
-    v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
-    v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
-    v11 = v10 / 0x18;
-    if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
-    {
-      v13 = pGlobalTXT_LocalizationStrings[57]; // Days
-      if ( v11 > 1 )
-      {
-        sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
-      }
-    }
-    else
-    {
-      if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
-      {
-        if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
-          v12 = pGlobalTXT_LocalizationStrings[109];// Hour
-        else
-          v12 = pGlobalTXT_LocalizationStrings[110];// Hours
-        sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
-      }
-    }
-    v13 = pGlobalTXT_LocalizationStrings[56];   // Day
-    sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-    pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-    goto LABEL_29;
-  }
-LABEL_30:
-  if ( byte_506360 )
-  {
-    /*result = pMessageQueue_50CBD0->uNumMessages;
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-      result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-      *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
-  }
-  return result;
-}
-
-
-//----- (00413FF1) --------------------------------------------------------
-void SetMonthNames()
-{
-  aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
-  aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
-  aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
-  aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
-  aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
-  aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
-  aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
-  aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
-  aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
-  aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
-  aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
-  aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
-}
-
-//----- (0041406F) --------------------------------------------------------
-void SetDayNames()
-{
-  aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
-  aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
-  aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
-  aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
-  aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
-  aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
-  aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
-}
-
-//----- (004140BB) --------------------------------------------------------
-void SetSpellSchoolNames()
-{
-  aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
-  aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
-  aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
-  aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
-  aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
-  aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
-  aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
-  aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
-  aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
-}
-
-//----- (0041411B) --------------------------------------------------------
-void SetAttributeNames()
-{
-  aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
-  aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
-  aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
-  aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
-  aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
-  aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
-  aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
-}
-
-//----- (00414162) --------------------------------------------------------
-void uGameUIFontMain_initialize()
-{
-  uGameUIFontMain = TargetColor(0xAu, 0, 0);
-}
-
-//----- (00414174) --------------------------------------------------------
-void uGameUIFontShadow_initialize()
-{
-  uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u);
-}
-
-
-
-
-//----- (0041420D) --------------------------------------------------------
-void __cdecl sub_41420D_press_esc()
-{
-  GUIWindow v0; // [sp+4h] [bp-54h]@1
-
-  sprintf(pTmpBuf2.data(), "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape
-  v0.Hint = pTmpBuf2.data();
-  v0.uFrameWidth = 400;
-  v0.uFrameHeight = 100;
-  v0.uFrameX = 120;
-  v0.uFrameY = 140;
-  v0.uFrameZ = 519;
-  v0.uFrameW = 239;
-  v0.DrawMessageBox(0);
-}
-
-//----- (0041426F) --------------------------------------------------------
-void __cdecl sub_41426F()
-{
-  GUIWindow *v0; // ecx@1
-
-  v0 = ptr_507BDC;
-  pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0);
-
-  v0->Release();
-  ptr_507BDC = 0;
-  pCurrentScreen = dword_506F0C[0];
-  pEventTimer->Resume();
-}
 // 4E28F8: using guessed type int pCurrentScreen;
 
-
-
 void LoadFonts_and_DrawCopyrightWindow()
 {
   MainMenuUI_LoadFontsAndSomeStuff();
   DrawCopyrightWindow();
 }
 
-//----- (00415485) --------------------------------------------------------
-void DrawCopyrightWindow()
-{
-  GUIWindow Dst; // [sp+8h] [bp-54h]@1
-
-  memset(&Dst, 0, 0x54u);
-  Dst.uFrameWidth = 624;
-  Dst.uFrameHeight = 256;
-  Dst.uFrameX = 8;
-  Dst.uFrameY = 30;                             // c 1999 The 3DO Company.
-  Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
-                   + 2 * LOBYTE(pFontSmallnum->uFontHeight)
-                   + 24;
-  Dst.uFrameY = 470 - Dst.uFrameHeight;
-  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
-  Dst.uFrameW = 469;
-  //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
-  Dst.DrawMessageBox(0);
-
-  Dst.uFrameWidth -= 24;
-  Dst.uFrameX += 12;
-  Dst.uFrameY += 12;
-  Dst.uFrameHeight -= 12;
-  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
-  Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
-  Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3);
-}
-
-
-
-//----- (004156F0) --------------------------------------------------------
-void GUI_UpdateWindows() 
-{
-  GUIWindow *pWindow; // esi@4
-  //unsigned int pWindowType; // eax@4
-  const char *pHint; // edx@66
-  GUIButton *pButtonPtr_1C; // ebp@79
-  char *pHint1; // edx@80
-  int v26; // eax@98
-  unsigned int v27; // ebp@106
-  GUIWindow *pGUIWindow2; // ecx@109
-  GUIFont *pGUIFont; // ST1C_4@115
-  int v31; // eax@115
-  GUIButton *pButton; // ebp@118
-  int v39; // eax@129
-  unsigned int pNumMessages; // eax@142
-  GUIButton *pGUIButton; // ebp@146
-  //unsigned int pX; // [sp-1Ch] [bp-124h]@17
-  //unsigned int pY; // [sp-18h] [bp-120h]@17
-  //Texture *pTexture; // [sp-14h] [bp-11Ch]@17
-  //Texture *pTexture2; // [sp-14h] [bp-11Ch]@86
-  int i; // [sp+0h] [bp-108h]@3
-  ItemGen pItemGen; // [sp+4h] [bp-104h]@98
-  GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133
-  ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129
-
-  if (GetCurrentMenuID() != MENU_CREATEPARTY)
-    UI_OnKeyDown(VK_NEXT);
-
-  for ( i = 1; i <= uNumVisibleWindows; ++i )
-  {
-    pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
-    switch (pWindow->eWindowType)
-    {
-      case WINDOW_OptionsButtons:
-      {
-        pRenderer->DrawTextureIndexed(pViewport->uViewportTL_Y,
-                                      pViewport->uViewportTL_X, pIcons_LOD->GetTexture(uTextureID_Options));
-        viewparams->bRedrawGameUI = 1;
-        continue;
-      }
-      case WINDOW_CharacterRecord:
-      {
-        CharacterUI_CharacterScreen_Draw(pPlayers[uActiveCharacter]);
-        continue;
-      }
-      case WINDOW_Options:
-      {
-        GameMenuUI_Options_Draw();
-        continue;
-      }
-      case WINDOW_Book:
-      {
-        BookUI_Draw((WindowType)(int)pWindow->ptr_1C);
-        continue;
-      }
-      case WINDOW_Dialogue:
-      {
-        GameUI_DrawDialogue();
-        continue;
-      }
-      case WINDOW_QuickReference:
-      {
-        GameUI_QuickRef_Draw();
-        continue;
-      }
-      case WINDOW_Rest:
-      {
-        RestUI_Draw();
-        continue;
-      }
-      case WINDOW_ChangeLocation:
-      {
-        TravelUI_Draw();
-        continue;
-      }
-      case WINDOW_SpellBook:
-      {
-        DrawSpellBookContent(pPlayers[uActiveCharacter]);
-        continue;
-      }
-      case WINDOW_GreetingNPC:
-      {
-        GameUI_DrawBranchlessDialogue();
-        continue;
-      }
-      case WINDOW_Chest:
-      {
-        if ( pCurrentScreen == SCREEN_CHEST )
-        {
-          Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
-        }
-        else if ( pCurrentScreen == SCREEN_CHEST_INVENTORY )
-        {
-          pRenderer->ClearZBuffer(0, 479);
-          draw_leather();
-          CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
-          pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
-        }
-        continue;
-      }
-      case WINDOW_SaveLoadButtons:
-      {
-        SaveUI_Draw();
-        continue;
-      }
-      case WINDOW_MainMenu_Load:
-      {
-        LoadUI_Draw();
-        continue;
-      }
-      case WINDOW_HouseInterior:
-      {
-        pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager();
-        if ( !window_SpeakInHouse )
-          continue;
-        if ( (signed int)window_SpeakInHouse->ptr_1C >= 53 )
-          continue;
-        if ( pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] <=pParty->uTimePlayed )
-        {
-          if ( (signed int)window_SpeakInHouse->ptr_1C < 53 )
-          {
-            pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] = 0;
-          }
-          continue;
-        }
-        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      case WINDOW_Transition:
-      {
-        TransitionUI_Draw();
-        continue;
-      }
-      case WINDOW_Scroll:
-      {
-        CreateScrollWindow();
-        continue;
-      }
-      case WINDOW_CastSpell_InInventory:
-      {
-        pRenderer->ClearZBuffer(0, 479);
-        draw_leather();
-        CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
-        CharacterUI_DrawPaperdoll(pPlayers[uActiveCharacter]);
-        pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u));
-        continue;
-      }
-      case WINDOW_FinalWindow:
-      {
-        sub_41420D_press_esc();
-        continue;
-      }
-      case WINDOW_50:
-      {
-        v27 = TargetColor(255, 255, 255);
-        if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
-        {
-          ptr_507BD0->DrawMessageBox(0);
-          ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-          v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-          ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pFontCreate);
-          continue;
-        }
-        if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
-        {
-          pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-          pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0);
-          pEventTimer->Resume();
-          ptr_507BD0->Release();
-          pCurrentScreen = SCREEN_GAME;
-          viewparams->bRedrawGameUI = true;
-          continue;
-        }
-        if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
-        {
-          pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-          pEventTimer->Resume();
-          ptr_507BD0->Release();
-          continue;
-        }
-      }
-      case WINDOW_59:
-      {
-        pWindow->DrawMessageBox(0);
-        pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-        pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-        if ( !pKeyActionMap->field_204 )
-        {
-          ItemGen2.Reset();
-          pWindow->Release();
-          pEventTimer->Resume();
-          pCurrentScreen = 0;
-          viewparams->bRedrawGameUI = true;
-          v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          if ( v26 > 0 )
-          {
-            if ( v26 < 800 )
-            {
-              ItemGen2.uAttributes |= 1u;
-              ItemGen2.uItemID = v26;
-              if ( pItemsTable->pItems[v26].uEquipType == 12 )
-              {
-                ItemGen2.uNumCharges = rand() % 6 + pItemsTable->pItems[ItemGen2.uItemID].uDamageMod + 1;
-                ItemGen2.uMaxCharges = LOBYTE(ItemGen2.uNumCharges);
-              }
-              else
-              {
-                if ( v26 >= 221 && v26 < 271 )
-                  ItemGen2.uEnchantmentType = rand() % 10 + 1;
-              }
-              pItemsTable->SetSpecialBonus(&ItemGen2);
-              pParty->SetHoldingItem(&ItemGen2);
-            }
-          }
-        }
-        continue;
-      }
-      case WINDOW_PressedButton2:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        if ( pButton->uX >= 0 && pButton->uX <= 640 )
-        {
-          if ( pButton->uY >= 0 && pButton->uY <= 480 )
-          {
-            pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
-            viewparams->bRedrawGameUI = 1;
-            if ( pWindow->Hint )
-            {
-              if ( pWindow->Hint != (char *)1 )
-                pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
-            }
-            pWindow->Release();
-            continue;
-          }
-        }
-        viewparams->bRedrawGameUI = 1;
-        if ( pWindow->Hint )
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
-        }
-        pWindow->Release();
-        continue;
-      }
-      case WINDOW_CharactersPressedButton:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
-        viewparams->bRedrawGameUI = 1;
-        if ( pWindow->Hint )
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
-        }
-        pWindow->Release();
-        continue;
-      }
-      case WINDOW_PressedButton:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
-        viewparams->bRedrawGameUI = 1;
-        if ( pWindow->Hint )
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
-        }
-        pWindow->Release();
-        continue;
-      }
-      case WINDOW_5D:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
-        viewparams->bRedrawGameUI = 1;
-        pWindow->Release();
-        continue;
-      }
-      case WINDOW_SaveLoadBtn:
-      {
-        if (pWindow->Hint != (char *)1)
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          pButton->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-        if (pCurrentScreen == SCREEN_SAVEGAME)
-          pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
-        else
-          pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
-        continue;
-      }
-      case WINDOW_LoadGame_CancelBtn:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
-        viewparams->bRedrawGameUI = 1;
-        if ( pWindow->Hint && pWindow->Hint != (char *)1 )
-          pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
-        pWindow->Release();
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      case WINDOW_CloseRestWindowBtn:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        pGUIButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]);
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      case WINDOW_ExitCharacterWindow:
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          pButton->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      case WINDOW_RestWindow:
-      {
-        memset(&GUIButton2, 0, 0xBCu);
-        GUIButton2.uZ = 197;
-        GUIButton2.uW = 197;
-        GUIButton2.uX = 27;
-        GUIButton2.uY = 161;
-        GUIButton2.uWidth = 171;
-        GUIButton2.uHeight = 37;
-        GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
-        pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
-        viewparams->bRedrawGameUI = 1;
-        GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Отдых и лечение 8 часов
-        GUIButton2.pParent = 0;
-        pGUIWindow2 = pWindow;
-        pGUIWindow2->Release();
-        continue;
-      }
-      case WINDOW_BooksWindow:
-      {
-        pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameY,
-                                      pWindow->uFrameX, pButton->pTextures[0]);
-        viewparams->bRedrawGameUI = true;
-        continue;
-      }
-      case WINDOW_CharacterWindow_Inventory:
-      {
-        pWindow->DrawMessageBox(0);
-        pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-        pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-        if ( !pKeyActionMap->field_204 )
-        {
-          ItemGen2.Reset();
-          pWindow->Release();
-          pEventTimer->Resume();
-          pCurrentScreen = SCREEN_GAME;
-          viewparams->bRedrawGameUI = 1;
-          v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          if ( v39 > 0 )
-          {
-            if ( v39 < 800 )
-              SpawnActor(v39);
-          }
-        }
-        continue;
-      }
-      case WINDOW_KeyMappingOptions:
-      {
-        GameMenuUI_DrawKeyBindings();
-        continue;
-      }
-      case WINDOW_VideoOptions:
-      {
-        GameMenuUI_DrawVideoOptions();
-        continue;
-      }
-      default:
-      {
-        continue;
-      }
-    }
-  }
-  if ( GetCurrentMenuID() == -1 )
-    GameUI_DrawFoodAndGold();
-  if ( sub_4637E0_is_there_popup_onscreen() )
-    sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
-}
 
 //----- (00416196) --------------------------------------------------------
 void identify_item()
@@ -10377,85 +7213,6 @@
   }
 }
 
-//----- (004178FE) --------------------------------------------------------
-unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2)
-{
-  unsigned __int16 v2; // dx@2
-  unsigned __int16 v3; // cx@2
-  int v5; // eax@5
-  unsigned __int16 v6; // [sp-4h] [bp-8h]@2
-
-  if ( a1 <= a2 )
-  {
-    if ( a1 == a2 )
-      return 0;
-    v5 = 100 * a1 / a2;
-    v3 = 255;
-    if ( v5 >= 25 )
-    {
-      v6 = 100;
-      v2 = 255;
-    }
-    else
-    {
-      v6 = 0;
-      v2 = 0;
-    }
-  }
-  else
-  {
-    v6 = 0;
-    v2 = 255;
-    v3 = 0;
-  }
-  return TargetColor(v3, v2, v6);
-}
-
-//----- (00417939) --------------------------------------------------------
-signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx)
-{
-  unsigned int v1; // ebx@1
-  signed int v2; // edi@1
-  unsigned int v3; // esi@1
-  unsigned int v4; // eax@1
-  unsigned int v6; // [sp+Ch] [bp-4h]@1
-
-  v1 = uConditionIdx;
-  v2 = 65535;
-  v3 = TargetColor(0xE1u, 0xCDu, 0x23u);
-  v6 = TargetColor(0xFFu, 0x23u, 0);
-  v4 = TargetColor(0, 0xFFu, 0);
-  switch ( v1 )
-  {
-    case 0u:
-    case 1u:
-    case 3u:
-    case 4u:
-    case 5u:
-    case 6u:
-    case 7u:
-      v2 = v4;
-      break;
-    case 2u:
-    case 8u:
-    case 9u:
-    case 0xCu:
-    case 0xDu:
-      v2 = v3;
-      break;
-    case 0xAu:
-    case 0xBu:
-    case 0xEu:
-    case 0xFu:
-    case 0x10u:
-      v2 = v6;
-      break;
-    default:
-      return v2;
-  }
-  return v2;
-}
-
 //----- (004179BC) --------------------------------------------------------
 void __fastcall sub_4179BC_draw_tooltip( const char *a1, const char *a2 )
     {