diff mm7_6.cpp @ 303:3dcc9d945eeb

DamageMonsterFromParty
author Nomad
date Tue, 19 Feb 2013 15:39:50 +0200
parents 640a176c030f
children cc8e4dc397ec
line wrap: on
line diff
--- a/mm7_6.cpp	Tue Feb 19 13:31:50 2013 +0200
+++ b/mm7_6.cpp	Tue Feb 19 15:39:50 2013 +0200
@@ -3512,8 +3512,8 @@
         a1.uSpriteFrameID = 0;
         a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v19 = 8 * v3->uPlayerID;
-        LOBYTE(v19) = v19 | 4;
-        a1.field_58 = v19;
+        LOBYTE(v19) = v19 | OBJECT_Player;
+        a1.field_58_pid = v19;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -3550,8 +3550,8 @@
         a1.uSpriteFrameID = 0;
         a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
         v22 = 8 * v3->uPlayerID;
-        LOBYTE(v22) = v22 | 4;
-        a1.field_58 = v22;
+        LOBYTE(v22) = v22 | OBJECT_Player;
+        a1.field_58_pid = v22;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -3656,8 +3656,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v34 = 8 * v3->uPlayerID;
-        LOBYTE(v34) = v34 | 4;
-        a1.field_58 = v34;
+        LOBYTE(v34) = v34 | OBJECT_Player;
+        a1.field_58_pid = v34;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -3689,9 +3689,9 @@
         v37 = v3->uPlayerID;
         a1.field_60_distance_related_prolly_lod = 0;
         v37 *= 8;
-        LOBYTE(v37) = v37 | 4;
+        LOBYTE(v37) = v37 | OBJECT_Player;
         a1.uFacing = v1;
-        a1.field_58 = v37;
+        a1.field_58_pid = v37;
         v38 = a2 >> 3;
         a1.uSoundID = LOWORD(v3->field_10);
         v39 = a2 >> 3;
@@ -3733,9 +3733,9 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v44 *= 8;
-        LOBYTE(v44) = v44 | 4;
+        LOBYTE(v44) = v44 | OBJECT_Player;
         v38 = (signed int)v726;
-        a1.field_58 = v44;
+        a1.field_58_pid = v44;
         a1.uSoundID = LOWORD(v3->field_10);
         a1.vPosition.x = *(__int16 *)((char *)&pActors[0].vPosition.x + HIDWORD(v733));
         v45 = *(__int16 *)((char *)&pActors[0].vPosition.y + HIDWORD(v733));
@@ -3771,8 +3771,8 @@
         a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, v48);
         a1.uSpriteFrameID = v1;
         v49 = 8 * v3->uPlayerID;
-        LOBYTE(v49) = v49 | 4;
-        a1.field_58 = v49;
+        LOBYTE(v49) = v49 | OBJECT_Player;
+        a1.field_58_pid = v49;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -3818,8 +3818,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v50 = 8 * v3->uPlayerID;
-        LOBYTE(v50) = v50 | 4;
-        a1.field_58 = v50;
+        LOBYTE(v50) = v50 | OBJECT_Player;
+        a1.field_58_pid = v50;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -3967,8 +3967,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v62 = 8 * v3->uPlayerID;
-        LOBYTE(v62) = v62 | 4;
-        a1.field_58 = v62;
+        LOBYTE(v62) = v62 | OBJECT_Player;
+        a1.field_58_pid = v62;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -4369,9 +4369,9 @@
             a1.uSectorID = 0;
             a1.uSpriteFrameID = 0;
             v120 = 8 * *(short *)(v119 + 2);
-            LOBYTE(v120) = v120 | 4;
+            LOBYTE(v120) = v120 | OBJECT_Player;
             a1.field_60_distance_related_prolly_lod = 0;
-            a1.field_58 = v120;
+            a1.field_58_pid = v120;
             a1.uFacing = 0;
             a1.uSoundID = *(short *)(v119 + 16);
             a1.vPosition.x = v112->vPosition.x;
@@ -4572,7 +4572,7 @@
             a1.uSectorID = v1;
             a1.vPosition.z = a2 + v713;
             a1.uSpriteFrameID = v1;
-            a1.field_58 = 8 * v3->uPlayerID | 4;
+            a1.field_58_pid = 8 * v3->uPlayerID | OBJECT_Player;
             a1.field_5C = v730;
             a1.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
             a1.uFacing = v687;
@@ -4620,8 +4620,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v161 *= 8;
-        LOBYTE(v161) = v161 | 4;
-        a1.field_58 = v161;
+        LOBYTE(v161) = v161 | OBJECT_Player;
+        a1.field_58_pid = v161;
         a1.uSoundID = LOWORD(v3->field_10);
         a2 = v1;
         if ( (signed int)v726 > v1 )
@@ -4759,8 +4759,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v187 = 8 * v3->uPlayerID;
-        LOBYTE(v187) = v187 | 4;
-        a1.field_58 = v187;
+        LOBYTE(v187) = v187 | OBJECT_Player;
+        a1.field_58_pid = v187;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uSoundID = LOWORD(v3->field_10);
@@ -4976,7 +4976,7 @@
           a1.uSectorID = v1;
           a1.vPosition.z = (int)((char *)_this + LODWORD(v725));
           a1.uSpriteFrameID = v1;
-          a1.field_58 = 8 * v3->uPlayerID | 4;
+          a1.field_58_pid = 8 * v3->uPlayerID | OBJECT_Player;
           a1.field_5C = v730;
           a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
           a1.uFacing = v685;
@@ -5071,8 +5071,8 @@
           a1.uSpriteFrameID = v1;
           a1.uSectorID = v52;
           v53 = 8 * v3->uPlayerID;
-          LOBYTE(v53) = v53 | 4;
-          a1.field_58 = v53;
+          LOBYTE(v53) = v53 | OBJECT_Player;
+          a1.field_58_pid = v53;
           a1.field_5C = a2;
           a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
           a1.uFacing = LOWORD(v715.uYawAngle);
@@ -5107,8 +5107,8 @@
                            pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
           a1.uSpriteFrameID = v1;
           v226 = 8 * v3->uPlayerID;
-          LOBYTE(v226) = v226 | 4;
-          a1.field_58 = v226;
+          LOBYTE(v226) = v226 | OBJECT_Player;
+          a1.field_58_pid = v226;
           a1.field_5C = a2;
           a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
           a1.uSoundID = LOWORD(v3->field_10);
@@ -5693,8 +5693,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v326 = 8 * v3->uPlayerID;
-        LOBYTE(v326) = v326 | 4;
-        a1.field_58 = v326;
+        LOBYTE(v326) = v326 | OBJECT_Player;
+        a1.field_58_pid = v326;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(pParty->sRotationY);
@@ -5723,9 +5723,9 @@
         a1.uSpriteFrameID = v1;
         a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v327 = 8 * v3->uPlayerID;
-        LOBYTE(v327) = v327 | 4;
+        LOBYTE(v327) = v327 | OBJECT_Player;
         a1.field_60_distance_related_prolly_lod = 0;
-        a1.field_58 = v327;
+        a1.field_58_pid = v327;
         a1.field_5C = a2;
         a1.uFacing = LOWORD(pParty->sRotationY);
         a1.uSoundID = LOWORD(v3->field_10);
@@ -5940,8 +5940,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v368 *= 8;
-        LOBYTE(v368) = v368 | 4;
-        a1.field_58 = v368;
+        LOBYTE(v368) = v368 | OBJECT_Player;
+        a1.field_58_pid = v368;
         a1.uSoundID = LOWORD(v3->field_10);
         for ( a2 = v1; a2 < (signed int)v726; ++a2 )
         {
@@ -6381,8 +6381,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v432 *= 8;
-        LOBYTE(v432) = v432 | 4;
-        a1.field_58 = v432;
+        LOBYTE(v432) = v432 | OBJECT_Player;
+        a1.field_58_pid = v432;
         a1.uSoundID = LOWORD(v3->field_10);
         for ( a2 = v1; a2 < (signed int)v726; ++a2 )
         {
@@ -6842,8 +6842,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v506 *= 8;
-        LOBYTE(v506) = v506 | 4;
-        a1.field_58 = v506;
+        LOBYTE(v506) = v506 | OBJECT_Player;
+        a1.field_58_pid = v506;
         a1.uSoundID = LOWORD(v3->field_10);
         a2 = v1;
         if ( SHIDWORD(v733) > v1 )
@@ -7012,8 +7012,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v532 *= 8;
-        LOBYTE(v532) = v532 | 4;
-        a1.field_58 = v532;
+        LOBYTE(v532) = v532 | OBJECT_Player;
+        a1.field_58_pid = v532;
         a1.uSoundID = LOWORD(v3->field_10);
         a2 = v1;
         if ( (signed int)v726 > v1 )
@@ -7284,9 +7284,9 @@
         a1.field_60_distance_related_prolly_lod = 0;
         v581 = v721;
         v580 *= 8;
-        LOBYTE(v580) = v580 | 4;
+        LOBYTE(v580) = v580 | OBJECT_Player;
         a1.uFacing = v1;
-        a1.field_58 = v580;
+        a1.field_58_pid = v580;
         a1.uSoundID = LOWORD(v3->field_10);
         a1.vPosition.x = *(short *)(v721 + 142);
         a1.vPosition.y = *(short *)(v721 + 144);
@@ -7386,8 +7386,8 @@
                          pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
         a1.uSpriteFrameID = v1;
         v595 = 8 * v3->uPlayerID;
-        LOBYTE(v595) = v595 | 4;
-        a1.field_58 = v595;
+        LOBYTE(v595) = v595 | OBJECT_Player;
+        a1.field_58_pid = v595;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uSoundID = LOWORD(v3->field_10);
@@ -7471,8 +7471,8 @@
         a1.uSectorID = pIndoor->GetSector(v657, v665, v676);
         a1.uSpriteFrameID = v1;
         v604 = 8 * v3->uPlayerID;
-        LOBYTE(v604) = v604 | 4;
-        a1.field_58 = v604;
+        LOBYTE(v604) = v604 | OBJECT_Player;
+        a1.field_58_pid = v604;
         a1.field_5C = a2;
         a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
         a1.uFacing = LOWORD(v715.uYawAngle);
@@ -7619,8 +7619,8 @@
         a1.field_60_distance_related_prolly_lod = 0;
         a1.uFacing = v1;
         v624 *= 8;
-        LOBYTE(v624) = v624 | 4;
-        a1.field_58 = v624;
+        LOBYTE(v624) = v624 | OBJECT_Player;
+        a1.field_58_pid = v624;
         a1.uSoundID = LOWORD(v3->field_10);
         a2 = v1;
         if ( SHIDWORD(v733) > v1 )
@@ -7961,55 +7961,38 @@
     if (!--player->pInventoryItems[main_hand_idx - 1].uNumCharges)
       player->pEquipment.uMainHand = 0;
   }
-  else if (target_type == OBJECT_Actor)
+  else if (target_type == OBJECT_Actor && actor_distance <= 407.2)
   {
-    if (actor_distance <= 407.2)
-    {
-      Vec3_int_ a3;
-      a3.x = actor->vPosition.x - pParty->vPosition.x;
-      a3.y = actor->vPosition.y - pParty->vPosition.y;
-      a3.z = actor->vPosition.z - pParty->vPosition.z;
-      Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
-
-      DamageMonsterFromParty((8 * uActiveCharacter - 8) | OBJECT_Player, target_id, &a3);
-      if (player->WearsItem(506, 1) || player->WearsItem(506, 0))
+    Vec3_int_ a3;
+    a3.x = actor->vPosition.x - pParty->vPosition.x;
+    a3.y = actor->vPosition.y - pParty->vPosition.y;
+    a3.z = actor->vPosition.z - pParty->vPosition.z;
+    Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
+
+    DamageMonsterFromParty((8 * (uActiveCharacter - 1)) | OBJECT_Player, target_id, &a3);
+    if (player->WearsItem(506, 1) || player->WearsItem(506, 0))
           _42FA66_do_explosive_impact(
             actor->vPosition.x,
             actor->vPosition.y,
             actor->vPosition.z + actor->uActorHeight / 2,
             0, 512, uActiveCharacter);
-    }
-    else if (bow_idx)
-    {
-      shooting_bow = true;
-
-      _42777D_CastSpell_UseWand_ShootArrow(100, uActiveCharacter - 1, 0, 0, 0);
-      if (!pParty->bTurnBasedModeOn)
-      {
-        int recovery = player->GetAttackRecoveryTime(0);
-        if (recovery < 30)
-          recovery = 30;
-        player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333);
-      }
-    }
+  }
+  else if (bow_idx)
+  {
+    shooting_bow = true;
+    _42777D_CastSpell_UseWand_ShootArrow(100, uActiveCharacter - 1, 0, 0, 0);
   }
   else
   {
-    if (bow_idx)
-    {
-      shooting_bow = true;
-      _42777D_CastSpell_UseWand_ShootArrow(100, uActiveCharacter - 1, 0, 0, 0);
-    }
-    else
-    {
-      if (!pParty->bTurnBasedModeOn)
-      {
-        int recovery = player->GetAttackRecoveryTime(0);
-        if (recovery < 30 )
-          recovery = 30;
-        player->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333));
-      }
-    }
+    ; // actor out of range or no actor; no ranged weapon so melee attacking air
+  }
+
+  if (!pParty->bTurnBasedModeOn)
+  {
+    int recovery = player->GetAttackRecoveryTime(0);
+    if (recovery < 30 )
+      recovery = 30;
+    player->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333));
   }
 
   
@@ -8508,7 +8491,7 @@
   a1a.uAttributes = attributes;
   a1a.uSectorID = pIndoor->GetSector(v21, y, z);
   a1a.uSpriteFrameID = 0;
-  a1a.field_58 = 0;
+  a1a.field_58_pid = 0;
   a1a.field_5C = 0;
   if ( !(a1a.uAttributes & 0x10) )
   {
@@ -8614,7 +8597,7 @@
   a1.uAttributes = 0;
   a1.uSectorID = pIndoor->GetSector(v3, v4, z);
   a1.uSpriteFrameID = 0;
-  a1.field_58 = 0;
+  a1.field_58_pid = 0;
   a1.field_5C = 0;
   v8 = a1.Create(0, 0, 0, 0);
   if ( v8 != -1 )
@@ -8714,12 +8697,12 @@
   if ( a6 >= 1 || a6 <= 4 )
   {
     v10 = 8 * a6 - 8;
-    LOBYTE(v10) = v10 | 4;
-    a1a.field_58 = v10;
+    LOBYTE(v10) = v10 | OBJECT_Player;
+    a1a.field_58_pid = v10;
   }
   else
   {
-    a1a.field_58 = 0;
+    a1a.field_58_pid = 0;
   }
   result = a1a.Create(0, 0, 0, 0);
   if ( result != -1 )