changeset 1882:b3191dddab9f

Actor::AI_Stun cleaned up, commented out the body of _4031C1_update_job
author Grumpy7
date Sat, 19 Oct 2013 06:27:07 +0200
parents fa3d4b400b8d
children 7d334cc596e0
files Actor.cpp Actor.h
diffstat 2 files changed, 26 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Oct 18 09:31:35 2013 +0200
+++ b/Actor.cpp	Sat Oct 19 06:27:07 2013 +0200
@@ -1825,7 +1825,7 @@
   int absy; // eax@1
   unsigned int v9; // ebx@11
   int v10; // ebx@13
-  AIDirection notInitializedBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7
+  AIDirection doNotInitializeBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7
   unsigned int v16; // [sp+2Ch] [bp-10h]@1
   int y; // [sp+30h] [bp-Ch]@1
   int absx; // [sp+38h] [bp-4h]@1
@@ -1844,12 +1844,12 @@
   {
     if ( !uActionLength )
       uActionLength = 256;
-    Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, &notInitializedBecauseShouldBeRandom);
+    Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
   if ( pActors[uActor_id].pMonsterInfo.uMovementType == 3 && absx < 128 )
   {
-    Actor::AI_Stand(uActor_id, uTarget_id, 256, &notInitializedBecauseShouldBeRandom);
+    Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
   absx += ((rand() & 0xF) * radius) / 16;
@@ -1862,7 +1862,7 @@
   v10 = v9 + rand() % 256 - 128;
   if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) )
   {
-    Actor::AI_Stand(uActor_id, uTarget_id, 256, &notInitializedBecauseShouldBeRandom);
+    Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
   v5->uYawAngle = v10;
@@ -1878,9 +1878,10 @@
 }
 
 //----- (004031C1) --------------------------------------------------------
-char __fastcall Actor::_4031C1_update_job(unsigned int uActorID, signed int a2, int a3)
+char __fastcall Actor::_4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3)   //attempted to implement something like jobs for actors, but apparently was never finished
 {
-  unsigned int v3; // edi@1
+  return 0;
+  /*unsigned int v3; // edi@1
   Actor *v4; // esi@1
   ActorJob *v5; // eax@1
   signed int v6; // edx@2
@@ -1932,55 +1933,44 @@
       }
     }
   }
-  return (char)v5;
+  return (char)v5;*/
 }
 
 //----- (004030AD) --------------------------------------------------------
-void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int arg0)
+void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState)
 {
-  unsigned int v3; // edi@1
   Actor *v4; // ebx@1
-  //__int16 result; // ax@10
-  SpriteFrame *v6; // ecx@16
   __int16 v7; // ax@16
-  unsigned int v8; // ecx@16
   AIDirection a3; // [sp+Ch] [bp-40h]@16
-  AIDirection v10; // [sp+28h] [bp-24h]@16
-  unsigned int v11; // [sp+44h] [bp-8h]@1
-  signed int a2; // [sp+48h] [bp-4h]@1
+  AIDirection* v10; // [sp+28h] [bp-24h]@16
 
-  v3 = uActorID;
-  a2 = edx0;
   v4 = &pActors[uActorID];
-  v11 = uActorID;
-  if ( v4->uAIState == 7 )
+  if ( v4->uAIState == Fleeing )
     BYTE2(v4->uAttributes) |= 2u;
   if ( v4->pMonsterInfo.uHostilityType != 4 )
   {
     v4->uAttributes &= 0xFFFFFFFBu;
     v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
   }
-  if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 )
+  if ( v4->pActorBuffs[1].uExpireTime > 0 )
     v4->pActorBuffs[1].Reset();
-  if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
+  if ( v4->pActorBuffs[4].uExpireTime > 0 )
     v4->pActorBuffs[4].Reset();
-  if ( arg0
-    || (v4->uAIState != 8
-    && v4->uAIState != 3
-    && v4->uAIState != 12
-    && v4->uAIState != 13
-    && v4->uAIState != 18
-    && v4->uAIState != 2))
+  if ( stunRegardlessOfState
+    || (v4->uAIState != Stunned
+    && v4->uAIState != AttackingRanged1
+    && v4->uAIState != AttackingRanged2
+    && v4->uAIState != AttackingRanged3
+    && v4->uAIState != AttackingRanged4
+    && v4->uAIState != AttackingMelee))
   {
-    memcpy(&v10, Actor::GetDirectionInfo(PID(OBJECT_Actor,v3), a2, &a3, 0), sizeof(v10));
-    v6 = pSpriteFrameTable->pSpriteSFrames;
-    v4->uYawAngle = LOWORD(v10.uYawAngle);
-    v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
-    v8 = v11;
+    v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0), sizeof(v10);
+    v4->uYawAngle = LOWORD(v10->uYawAngle);
+    v7 = pSpriteFrameTable->pSpriteSFrames[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
     v4->uCurrentActionTime = 0;
     v4->uAIState = Stunned;
     v4->uCurrentActionLength = 8 * v7;
-    Actor::PlaySound(v8, 2u);
+    Actor::PlaySound(uActorID, 2u);
     v4->UpdateAnimation();
   }
 }
@@ -3979,7 +3969,7 @@
 
     BYTE2(actor->uAttributes) &= 0x7Fu;
     if (BYTE2(actor->uAttributes) & 0x40)
-        Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1);
+        Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1);
   }
 }
 //----- (00439474) --------------------------------------------------------
--- a/Actor.h	Fri Oct 18 09:31:35 2013 +0200
+++ b/Actor.h	Sat Oct 19 06:27:07 2013 +0200
@@ -217,7 +217,7 @@
   static void Resurrect(unsigned int uActorID);
   static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4);
   static void AI_Stun(unsigned int uActorID, signed int edx0, int arg0);
-  static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3);
+  static char __fastcall _4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3);
   static void AI_RandomMove(unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength);
   static void AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
   static void AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);