diff Actor.cpp @ 247:fb8a876f41e1

Merge
author Nomad
date Mon, 18 Feb 2013 03:59:31 +0200
parents f070b49d40dd
children 37dcbe8f3cca
line wrap: on
line diff
--- a/Actor.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/Actor.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -184,16 +184,13 @@
   if ( !pParty->uAlignment )
   {
     v14 = "-b";
-LABEL_7:
     strcat(pContainer, v14);
-    goto LABEL_8;
   }
-  if ( pParty->uAlignment == 2 )
+  else if ( pParty->uAlignment == 2 )
   {
     v14 = "-c";
-    goto LABEL_7;
+    strcat(pContainer, v14);
   }
-LABEL_8:
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
@@ -208,33 +205,38 @@
     if ( (signed int)pParty->GetPartyFame() <= v5->fame
       || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) )
     {
-LABEL_16:
       v9 = 1;
-      goto LABEL_17;
     }
-    if ( v10 > 1 )
-    {
-      if ( v10 == 2 )
-      {
-        v16 = 3;
-        goto LABEL_36;
-      }
-      if ( v10 != 3 )
-      {
-        if ( v10 == 4 )
-          goto LABEL_17;
-        goto LABEL_16;
-      }
-LABEL_35:
-      v16 = 2;
-LABEL_36:
-      v9 = v16;
-      goto LABEL_17;
-    }
-    if ( v5->rep )
-      goto LABEL_35;
+	else
+	{
+		if ( v10 > 1 )
+		{
+		  if ( v10 == 2 )
+		  {
+			v16 = 3;
+			v9 = v16;
+		  }
+		  else
+		  {
+			  if ( v10 != 3 )
+			  {
+				if ( v10 != 4 )
+				  v9 = 1;
+			  }
+			  else
+			  {
+				v16 = 2;
+				v9 = v16;
+			  }
+		  }
+		}
+		else if ( v5->rep )
+		{
+		  v16 = 2;
+		  v9 = v16;
+		}
+	}
   }
-LABEL_17:
   if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
   v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
@@ -2482,7 +2484,7 @@
 
   v1 = uActiveCharacter;
   v7 = uActorID;
-  pPlayer = &pParty->pPlayers[uActiveCharacter-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552];
+  pPlayer = &pParty->pPlayers[uActiveCharacter-1];
   result = pPlayer->CanAct();
   if ( result )
   {
@@ -2977,7 +2979,6 @@
   {
     v13 = &v14;
     v12 = 256;
-LABEL_16:
     Actor::_403EB6(uActorID, v16, v12, v13);
     return;
   }
@@ -2994,7 +2995,8 @@
   {
     v13 = &v14;
     v12 = 256;
-    goto LABEL_16;
+    Actor::_403EB6(uActorID, v16, v12, v13);
+    return;
   }
   v11 = v5->uMovementSpeed;
   v5->uYawAngle = v10;
@@ -3245,18 +3247,83 @@
   if ( v8 > MONSTER_HARPY_3 )
   {
     if ( v8 < MONSTER_OOZE_1 )
-      goto LABEL_21;
+	{
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
+	}
     if ( v8 <= MONSTER_OOZE_3 )
     {
       _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
-      goto LABEL_21;
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 )
     {
-LABEL_21:
       if ( !_this.uItemID )
-        goto LABEL_24;
-      goto LABEL_22;
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     _this.uItemID = ITEM_TROLL_BLOOD;
   }
@@ -3269,20 +3336,81 @@
     else
     {
       if ( v8 < MONSTER_DEVIL_1 )
-        goto LABEL_21;
+	  {
+		  if ( !_this.uItemID )
+		  {
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		  }
+		  if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		  return;
+	  }
       if ( v8 > MONSTER_DEVIL_3 )
       {
         if ( v8 <= MONSTER_DRAGON_3 )
         {
           _this.uItemID = ITEM_DRAGON_EYE;
-          goto LABEL_22;
+          if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+				pItemsTable->pItems[_this.uItemID].uSpriteID,
+				v1->vPosition.x,
+				v1->vPosition.y,
+				v1->vPosition.z + 16,
+				v9 % 200 + 200,
+				1,
+				1,
+				0,
+				&_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		    Actor::Explode(v11);
+		  return;
         }
-        goto LABEL_21;
+		if ( !_this.uItemID )
+		{
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		}
+		if ( rand() % 100 < 20 )
+		{
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		}
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
       }
       _this.uItemID = ITEM_DEVIL_ICHOR;
     }
   }
-LABEL_22:
   if ( rand() % 100 < 20 )
   {
     v9 = rand();
@@ -3297,7 +3425,6 @@
       0,
       &_this);
   }
-LABEL_24:
   if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
     Actor::Explode(v11);
 }
@@ -3719,60 +3846,79 @@
   v21 = 0;
   v24 = v6;
   v26 = 0;
-  if ( (signed int)uNumActors <= 0 )
-    goto LABEL_26;
-  v7 = pActors;
-  do
+  if ( (signed int)uNumActors > 0 )
   {
-	v8 = v7->uAIState;
-	if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
-      goto LABEL_23;
-    if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
-      goto LABEL_13;
-    if ( v7->IsAlive() == 1 )
-    {
-      v24 = v4;
-      v3->uLastCharacterIDToHit = v4;
-LABEL_13:
-      v10 = v3->GetActorsRelation(v7);
-      if ( v10 == v4 )
-        goto LABEL_23;
-      goto LABEL_14;
-    }
-	v18 = v7->uGroup;
-    if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
-      goto LABEL_23;
-    v10 = 4;
-LABEL_14:
-    if ( v3->pMonsterInfo.uHostilityType )
-      v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
-    v11 = dword_4DF380[v10];
-	v23 = abs(v3->vPosition.x - v7->vPosition.x);
-	v27 = abs(v3->vPosition.y - v7->vPosition.y);
-	v12 = abs(v3->vPosition.z - v7->vPosition.z);
-    v19 = v12;
-    if ( v23 <= v11
-      && v27 <= v11
-      && v12 <= v11
-      && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
-      && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
-    {
-      v25 = v23 * v23 + v27 * v27 + v19 * v19;
-      v21 = v26;
-    }
-    v4 = 0;
-LABEL_23:
-    ++v7;
-    v5 = v26++ + 1;
+	  v7 = pActors;
+	  do
+	  {
+		v8 = v7->uAIState;
+		if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
+		{
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		}
+		if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
+		{
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else if ( v7->IsAlive() == 1 )
+		{
+		  v24 = v4;
+		  v3->uLastCharacterIDToHit = v4;
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else
+		{
+			v18 = v7->uGroup;
+			if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
+			{
+				++v7;
+				v5 = v26++ + 1;
+				continue;
+			}
+			v10 = 4;
+		}
+		if ( v3->pMonsterInfo.uHostilityType )
+		  v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
+		v11 = dword_4DF380[v10];
+		v23 = abs(v3->vPosition.x - v7->vPosition.x);
+		v27 = abs(v3->vPosition.y - v7->vPosition.y);
+		v12 = abs(v3->vPosition.z - v7->vPosition.z);
+		v19 = v12;
+		if ( v23 <= v11
+		  && v27 <= v11
+		  && v12 <= v11
+		  && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
+		  && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
+		{
+		  v25 = v23 * v23 + v27 * v27 + v19 * v19;
+		  v21 = v26;
+		}
+		v4 = 0;
+		++v7;
+		v5 = v26++ + 1;
+	  }
+	  while ( v26 < (signed int)uNumActors );
+	  if ( v25 != -1 )
+	  {
+		v13 = 8 * v21;
+		LOBYTE(v13) = 8 * v21 | 3;
+		*v20 = v13;
+	  }
   }
-  while ( v26 < (signed int)uNumActors );
-  if ( v25 != -1 )
-  {
-    v13 = 8 * v21;
-    LOBYTE(v13) = 8 * v21 | 3;
-    *v20 = v13;
-  }
-LABEL_26:
   if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4
     && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) )
     a3 = v4;
@@ -3870,45 +4016,33 @@
   if ( a1 )
   {
     v9 = a1->uAlly;
-    if ( (signed int)v9 <= 0 )
-    {
-      if ( v9 != 9999 )
-        goto LABEL_30;
-    }
-    else
+    if ( (signed int)v9 > 0 )
     {
       if ( v9 != 9999 )
       {
         v7 = a1->uAlly;
-        goto LABEL_30;
       }
     }
-    v7 = 0;
-LABEL_30:
+	if(v9==9999)
+      v7 = 0;
     if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 )
       v7 = 0;
   }
-  if ( !v2 )
-    goto LABEL_40;
-  v10 = v2->uAlly;
-  if ( (signed int)v10 <= 0 )
-  {
-    if ( v10 != 9999 )
-      goto LABEL_38;
-  }
-  else
+  if ( v2 )
   {
-    if ( v10 != 9999 )
-    {
-      v8 = v2->uAlly;
-      goto LABEL_38;
-    }
+	  v10 = v2->uAlly;
+	  if ( (signed int)v10 > 0 )
+	  {
+		if ( v10 != 9999 )
+		{
+		  v8 = v2->uAlly;
+		}
+	  }
+	  if(v10==9999)
+	    v8 = 0;
+	  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
+		v8 = 0;
   }
-  v8 = 0;
-LABEL_38:
-  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
-    v8 = 0;
-LABEL_40:
   if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8
     || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 )
     return 0;
@@ -3917,7 +4051,15 @@
   if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 )
   {
     if ( v7 )
-      goto LABEL_55;
+	{
+		if ( (signed int)v7 < 89 )
+		{
+		  if ( v8 < 89 )
+			return pFactionTable->relations[v7][v8];
+		  return 0;
+		}
+		return 0;
+	}
     return 4;
   }
   if ( !v7 )
@@ -3925,16 +4067,18 @@
     if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000))
       && !pFactionTable->relations[v8][0]) 
     {
-LABEL_56:
       if ( v8 < 89 )
         return pFactionTable->relations[v7][v8];
       return 0;
     }
     return 4;
   }
-LABEL_55:
   if ( (signed int)v7 < 89 )
-    goto LABEL_56;
+  {
+    if ( v8 < 89 )
+      return pFactionTable->relations[v7][v8];
+    return 0;
+  }
   return 0;
 }