changeset 1457:9dc33590f93e

Merge
author Gloval
date Wed, 14 Aug 2013 00:40:51 +0400
parents 5c95f2246c2a (diff) bfe342ae0c1f (current diff)
children 934074e7fcc1 ff2118028c71
files
diffstat 7 files changed, 75 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Aug 09 17:30:33 2013 +0600
+++ b/Actor.cpp	Wed Aug 14 00:40:51 2013 +0400
@@ -1955,7 +1955,7 @@
 
   v3 = &pActors[uActorID];
   //a2 = edx0;
-  v4 = v3->pMonsterInfo.uMovementType == 5;
+  v4 = v3->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY;
   v24 = uActorID;
   if ( v4 && v3->pMonsterInfo.uAIType == 1 )
   {
@@ -2736,8 +2736,8 @@
 }
 
 //----- (004032B2) --------------------------------------------------------
-void Actor::AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
-{
+void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength )
+    {
   unsigned int v4; // edi@1
   Actor *v5; // esi@1
   int v6; // ebx@1
@@ -2757,10 +2757,10 @@
 
   //v14 never filled, maybe it is passed to function but optimized away as local variable
 
-  uActorID = a1;
-  v4 = a1;
-  v5 = &pActors[a1];
-  v16 = a2;
+  uActorID = uActor_id;
+  v4 = uActor_id;
+  v5 = &pActors[uActor_id];
+  v16 = uTarget_id;
   v6 = v5->vInitialPosition.x - v5->vPosition.x;
   v7 = v5->vInitialPosition.x - v5->vPosition.x;
   y = v5->vInitialPosition.y - v5->vPosition.y;
@@ -2779,13 +2779,11 @@
   }
   if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 )
   {
-    v13 = &v14;
-    v12 = 256;
-    Actor::AI_Stand(uActorID, v16, v12, v13);
+    Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
     return;
   }
   v15 = (rand() & 0xF) << 12;
-  v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16;
+  v19 += (unsigned __int64)(v15 * (signed __int64)radius) >> 16;
   v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y);
   if ( rand() % 100 < 25 )
   {
@@ -2793,17 +2791,14 @@
     return;
   }
   v10 = v9 + rand() % 256 - 128;
-  if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) )
+  if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) )
   {
-    v13 = &v14;
-    v12 = 256;
-    Actor::AI_Stand(uActorID, v16, v12, v13);
+    Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
     return;
   }
-  v11 = v5->uMovementSpeed;
   v5->uYawAngle = v10;
-  if ( v11 )
-    v5->uCurrentActionLength = 32 * v19 / v11;
+  if ( v5->uMovementSpeed)
+    v5->uCurrentActionLength = 32 * v19 / v5->uMovementSpeed;
   else
     v5->uCurrentActionLength = 0;
   v5->uCurrentActionTime = 0;
@@ -2858,7 +2853,7 @@
       v10 = v5->vPos.z;
       v4->vInitialPosition.z = v10;
       LOBYTE(v5) = v5->uAction;
-      v4->pMonsterInfo.uMovementType = (unsigned __int8)v5;
+      v4->pMonsterInfo.uMovementType = MONSTER_MOVEMENT_TYPE_STAIONARY;
       if ( a3 == 1 )
       {
         v4->vPosition.x = v4->vInitialPosition.x;
@@ -4417,7 +4412,7 @@
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
-					Actor::AI_4032B2(actor_id, target_pid, 1024, 0);
+					Actor::AI_RandomMove(actor_id, target_pid, 1024, 0);
 				}
 				else
 				{
@@ -4433,7 +4428,7 @@
 
 				if ( pActor->pMonsterInfo.uAIType == 1 )
 				{
-					if ( pActor->pMonsterInfo.uMovementType == 5 )
+					if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
 						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
 					}
@@ -4480,7 +4475,7 @@
 							{
 								Actor::AI_MissileAttack1(actor_id, target_pid, &pDir);
 							}
-							else if ( pActor->pMonsterInfo.uMovementType == 5 )
+							else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
 								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
@@ -4506,7 +4501,7 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( pActor->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
 										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
@@ -4518,7 +4513,7 @@
 										Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir);
 									}
 								}
-								else if ( pActor->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
 									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
@@ -4562,7 +4557,7 @@
 								else
 									Actor::AI_SpellAttack2(actor_id, target_pid, &pDir);
 							}
-							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
+							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
 								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
@@ -4580,7 +4575,7 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( pActor->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
 										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
@@ -4591,7 +4586,7 @@
 										Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 									}
 								}
-								else if ( pActor->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
 									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
@@ -4621,23 +4616,23 @@
 			
 			if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
 			{
-				if ( !pActor->pMonsterInfo.uMovementType )
+				if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT )
 				{
-					Actor::AI_4032B2(actor_id, 4, 1024, 0);
+					Actor::AI_RandomMove(actor_id, 4, 1024, 0);
 				}
 				else if ( pActor->pMonsterInfo.uMovementType == 1 )
 				{
-					Actor::AI_4032B2(actor_id, 4, 2560, 0);
+					Actor::AI_RandomMove(actor_id, 4, 2560, 0);
 				}
 				else if ( pActor->pMonsterInfo.uMovementType == 2 )
 				{
-					Actor::AI_4032B2(actor_id, 4, 5120, 0);
+					Actor::AI_RandomMove(actor_id, 4, 5120, 0);
 				}
 				else if ( pActor->pMonsterInfo.uMovementType == 4 )
 				{
-					Actor::AI_4032B2(actor_id, 4, 10240, 0);
+					Actor::AI_RandomMove(actor_id, 4, 10240, 0);
 				}
-				else if ( pActor->pMonsterInfo.uMovementType == 5 )
+				else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 				{
 					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
 					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
@@ -4653,7 +4648,7 @@
 				{
 					if ( v81 >= 1024 )
 					{
-						if ( pActor->pMonsterInfo.uMovementType == 5 )
+						if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 						{
 							v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 							v64 = (signed __int64)v47;
@@ -4664,7 +4659,7 @@
 							Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 						}
 					}
-					else if ( pActor->pMonsterInfo.uMovementType == 5 )
+					else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
 						v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 						v64 = (signed __int64)v47;
@@ -4690,7 +4685,7 @@
 			else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 			{
 				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
+				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 				{
 					v64 = (signed __int64)v47;
 					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
--- a/Actor.h	Fri Aug 09 17:30:33 2013 +0600
+++ b/Actor.h	Wed Aug 14 00:40:51 2013 +0400
@@ -201,7 +201,7 @@
   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 void AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength);
+  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);
   static void AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
--- a/Monsters.cpp	Fri Aug 09 17:30:33 2013 +0600
+++ b/Monsters.cpp	Wed Aug 14 00:40:51 2013 +0400
@@ -800,9 +800,9 @@
                     {
                     switch(tolower(test_string[0]))
                         {
-                    case 's': pInfos[curr_rec_num].uMovementType=0;// short
+                    case 's': pInfos[curr_rec_num].uMovementType=MONSTER_MOVEMENT_TYPE_SHORT;// short
                         if (tolower(test_string[1])!='h')
-                            pInfos[curr_rec_num].uMovementType=5; //stationary?
+                            pInfos[curr_rec_num].uMovementType=MONSTER_MOVEMENT_TYPE_STAIONARY; //stationary
                         break;  //short
                     case 'l': pInfos[curr_rec_num].uMovementType=2;  break; //long
                     case 'm': pInfos[curr_rec_num].uMovementType=1; break; //med
--- a/Monsters.h	Fri Aug 09 17:30:33 2013 +0600
+++ b/Monsters.h	Wed Aug 14 00:40:51 2013 +0400
@@ -58,6 +58,17 @@
   MONSTER_SPECIAL_ABILITY_EXPLODE = 0x3,
 };
 
+enum MONSTER_MOVEMENT_TYPE
+    {
+    MONSTER_MOVEMENT_TYPE_SHORT   = 0x0,
+    MONSTER_MOVEMENT_TYPE_MEDIUM  = 0x1,
+    MONSTER_MOVEMENT_TYPE_LONG    = 0x2,
+    MONSTER_MOVEMENT_TYPE_GLOBAL  = 0x3,
+    MONSTER_MOVEMENT_TYPE_FREE    = 0x4,
+    MONSTER_MOVEMENT_TYPE_STAIONARY = 0x5,
+    };
+
+
 /*  336 */
 enum MONSTER_SUPERTYPE
 {
--- a/TurnEngine.cpp	Fri Aug 09 17:30:33 2013 +0600
+++ b/TurnEngine.cpp	Wed Aug 14 00:40:51 2013 +0400
@@ -357,7 +357,7 @@
         }
     else if ( turn_stage == 2 )
         {
-        if ( field_18 == TE_FLAG_1)
+        if ( !(field_18 &TE_FLAG_1))
             {
             if ( turn_initiative == 100 )
                 {
@@ -375,7 +375,7 @@
         }
     else if ( turn_stage == 3 )
         {
-        if ( (uActionPointsLeft > 0) && (field_18 == TE_FLAG_8) )
+        if ( (uActionPointsLeft > 0) && (!(field_18 & TE_FLAG_8)) )
            ActorAIChooseNewTargets();
         else
             { 
@@ -625,18 +625,16 @@
     else
         uActiveCharacter = 0;
     viewparams->bRedrawGameUI = 1;
-    if (pQueue[0].actor_initiative > 0)
+
+    while ( (pQueue[0].actor_initiative > 0)&&(turn_initiative > 0) )
         {
-        while(turn_initiative > 0)
+        for (i=0; i<uActorQueueSize; ++i)
             {
-            for (i=0; i<uActorQueueSize; ++i)
-                {
-                --pQueue[i].actor_initiative;
-                if (pQueue[i].actor_initiative==0)
-                    pQueue[i].uActionLength=0;
-                }
-            --turn_initiative;
+            --pQueue[i].actor_initiative;
+            if (pQueue[i].actor_initiative==0)
+                pQueue[i].uActionLength=0;
             }
+        --turn_initiative;
         }
     }
 
@@ -1072,7 +1070,7 @@
             }
         else
             {
-             Actor::AI_4032B2(uActorID, a2a, 1024, 0);
+             Actor::AI_RandomMove(uActorID, a2a, 1024, 0);
              v29->AI_action_type = TE_AI_PURSUE;
             }         
     
@@ -1086,11 +1084,11 @@
         {
         if ( actor->pMonsterInfo.uAIType == 1 )
             {
-            if ( actor->pMonsterInfo.uMovementType == 5 )
+            if ( actor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
                 Actor::AI_Stand(uActorID, a2a, 32, 0);
             else
                 Actor::AI_Flee(uActorID, a2a, 32, 0);
-            v29->AI_action_type = 4;
+            v29->AI_action_type = TE_AI_FLEE;
             v29->uActionLength = actor->uCurrentActionLength;
             return 1;
             }
@@ -1099,11 +1097,11 @@
            
             if (((double)actor->pMonsterInfo.uHP * 0.2) > (double)actor->sCurrentHP && (v11 < 10240 ) )
                 {
-                if ( actor->pMonsterInfo.uMovementType == 5 )
+                if ( actor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
                     Actor::AI_Stand(uActorID, a2a, 32, 0);
                 else
                      Actor::AI_Flee(uActorID, a2a, 32, 0);
-                v29->AI_action_type = 4;
+                v29->AI_action_type = TE_AI_FLEE;
                 v29->uActionLength = actor->uCurrentActionLength;
                 return 1;
                 }
@@ -1113,11 +1111,11 @@
 
             if ( ((double)actor->pMonsterInfo.uHP * 0.1) > (double)actor->sCurrentHP && (v11 < 10240 ))
                 {
-                if ( actor->pMonsterInfo.uMovementType == 5 )
+                if ( actor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
                     Actor::AI_Stand(uActorID, a2a, 32, 0);
                 else
                      Actor::AI_Flee(uActorID, a2a, 32, 0);
-                v29->AI_action_type = 4;
+                v29->AI_action_type = TE_AI_FLEE;
                 v29->uActionLength = actor->uCurrentActionLength;
                 return 1;
                 }
@@ -1140,19 +1138,19 @@
         }
     switch(actor->pMonsterInfo.uMovementType)
         {
-        case 0: 
-            Actor::AI_4032B2(uActorID, a2a, 1024, 32);
+        case MONSTER_MOVEMENT_TYPE_SHORT: 
+            Actor::AI_RandomMove(uActorID, a2a, 1024, 32);
             break;
-        case 1:
-             Actor::AI_4032B2(uActorID, a2a, 2560, 32);
+        case MONSTER_MOVEMENT_TYPE_MEDIUM:
+             Actor::AI_RandomMove(uActorID, a2a, 2560, 32);
              break;
-         case 2:
-             Actor::AI_4032B2(uActorID, a2a, 5120, 32);
+         case MONSTER_MOVEMENT_TYPE_LONG:
+             Actor::AI_RandomMove(uActorID, a2a, 5120, 32);
              break;
-         case 4:
-             Actor::AI_4032B2(uActorID, a2a, 10240, 32);
+         case MONSTER_MOVEMENT_TYPE_FREE:
+             Actor::AI_RandomMove(uActorID, a2a, 10240, 32);
              break;
-         case 5:
+         case MONSTER_MOVEMENT_TYPE_STAIONARY:
              Actor::AI_Stand(uActorID, a2a, 32, 0);
               break;
          default:
--- a/TurnEngine.h	Fri Aug 09 17:30:33 2013 +0600
+++ b/TurnEngine.h	Wed Aug 14 00:40:51 2013 +0400
@@ -82,7 +82,7 @@
   int uActionPointsLeft; //14
   int field_18;
   int pending_actions;
-  TurnBased_QueueElem pQueue[504]; //20
+  TurnBased_QueueElem pQueue[530]; //20
 };
 #pragma pack(pop)
 
--- a/mm7_2.cpp	Fri Aug 09 17:30:33 2013 +0600
+++ b/mm7_2.cpp	Wed Aug 14 00:40:51 2013 +0400
@@ -6766,7 +6766,7 @@
               v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
             v124 = 8 * v153;
             LOBYTE(v124) = v124 | 2;
-            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
             pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
             return 0;
           }
@@ -6823,7 +6823,7 @@
             v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
           v124 = 8 * v153;
           LOBYTE(v124) = v124 | 2;
-          v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+          v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
           pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
           return 0;
         }
@@ -6924,7 +6924,7 @@
           v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
         v124 = 8 * v153;
         LOBYTE(v124) = v124 | 2;
-        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id-1] + 1;
         pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
         return 0;
       }
@@ -7058,7 +7058,7 @@
               v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
             v124 = 8 * v153;
             LOBYTE(v124) = v124 | 2;
-            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
             pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
             return 0;
           }