diff mm7_3.cpp @ 1060:b79139c3b5c8

some AI cleaning
author zipi
date Thu, 23 May 2013 20:51:27 +0100
parents 1c10b24a4159
children 89422dd58318
line wrap: on
line diff
--- a/mm7_3.cpp	Fri May 24 00:53:48 2013 +0600
+++ b/mm7_3.cpp	Thu May 23 20:51:27 2013 +0100
@@ -1178,7 +1178,7 @@
             {
               if ( v71 == 0 )
 			  {
-				  Actor::Flee(v75, v38, 0, (AIDirection *)0);
+				  Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
 			  }
 			  else
 			  {
@@ -1191,11 +1191,11 @@
 			}
 			else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
             {
-              Actor::Flee(v75, v38, 0, (AIDirection *)0);
+              Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
             }
 			else
 			{
-				Actor::FaceObject(v75, v38, 0, (AIDirection *)0);
+				Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
 			}
           }
           break;
@@ -1203,7 +1203,7 @@
           if ( !v0->GetActorsRelation(0) )
           {
             v38 = stru_721530.uFaceID;
-            Actor::FaceObject(v75, v38, 0, (AIDirection *)0);
+            Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
             break;
           }
           //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
@@ -14385,15 +14385,15 @@
 {
 	//unsigned int v0; // esi@4
 	int v1; // eax@7
-	int v2; // ecx@7
-	int v3; // eax@7
+	//int v2; // ecx@7
+	//int v3; // eax@7
 	signed int v4; // edi@10
 	Actor *v5; // esi@12
-	signed int v6; // eax@14
+	signed int sDmg; // eax@14
 	__int16 v7; // cx@14
-	Player **v8; // esi@20
+	//Player **v8; // esi@20
 	Player *pPlayer; // ecx@21
-	//Actor *pActor; // esi@34
+	Actor *pActor; // esi@34
 	//__int16 v11; // ax@34
 	//unsigned int v12; // eax@47
 	//signed int v13; // edi@47
@@ -14404,7 +14404,7 @@
 	//unsigned int v18; // ecx@67
 	//unsigned __int16 v19; // ax@72
 	//int *v20; // esi@80
-	Actor *v21; // ebx@80
+	//Actor *v21; // ebx@80
 	unsigned __int16 v22; // ax@86
 	//signed int v23; // eax@94
 	//unsigned int v24; // eax@102
@@ -14487,58 +14487,48 @@
 		else
 		{
 			pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8);
-			v1 = rand();
-			v2 = 128;
-			v3 = pParty->sRotationX + v1 % 16 - 8;
-			pParty->sRotationX = v3;
-			if ( v3 > 128 || (v2 = -128, v3 < -128) )
-				pParty->sRotationX = v2;
+			pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8;
+			if ( pParty->sRotationX > 128) 
+				pParty->sRotationX = 128;
+			else if ( pParty->sRotationX < -128 )
+				pParty->sRotationX = -128;
+				
 			pParty->uFlags |= 2u;
 			pParty->armageddon_timer -= pMiscTimer->uTimeElapsed;
 			v4 = pParty->field_16140 + 50;
 			if ( pParty->armageddon_timer <= 0 )
 			{
 				pParty->armageddon_timer = 0;
-				v84 = 0;
-				if ( (signed int)uNumActors > 0 )
+				for(int i = 0; i < uNumActors; i++)
 				{
-					v5 = pActors;//[0].sCurrentHP;
-					do
+					pActor=&pActors[i];
+					if ( pActor->CanAct() )
 					{
-						if ( v5->CanAct() )
+						sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4);
+						pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4);
+						if ( sDmg )
 						{
-							v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4);
-							v7 = v5->sCurrentHP - v6;
-							v5->sCurrentHP = v7;
-							if ( v6 )
+							if ( pActor->sCurrentHP >= 0 )
 							{
-								if ( v7 >= 0 )
-								{
-									Actor::Stun(v84, 4, 0);
-								}
-								else
-								{
-									Actor::Die(v84);
-									if ( v5->pMonsterInfo.uExp )
-										GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp);
-								}
+								Actor::AI_Stun(i, 4, 0);
+							}
+							else
+							{
+								Actor::Die(i);
+								if ( pActor->pMonsterInfo.uExp )
+									GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp);
 							}
 						}
-						++v84;
-						++v5;
 					}
-					while ( (signed int)v84 < (signed int)uNumActors );
+					++v84;
+					++v5;
 				}
-				v8 = &pPlayers[1];
-				do
+				for(int i = 1; i <= 4; i++)
 				{
-					pPlayer = *v8;
-					if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
+					pPlayer = pPlayers[i];
+					if ( !pPlayer->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
 						pPlayer->ReceiveDamage(v4, DMGT_5);
-					++v8;
 				}
-				while ( (signed int)v8 <= (signed int)&pPlayers[4] );
-				//v0 = 0;
 			}
 			if (pTurnEngine->field_1C)
 				--pTurnEngine->field_1C;
@@ -14555,7 +14545,7 @@
 	//uActorID = v0;
 	for (uint i = 0; i < uNumActors; ++i)
 	{
-		auto actor = pActors + i;
+		pActor = &pActors[i];
 		//LODWORD(v80) = (int)(char *)pActors + 176; // uAIState
 		//do
 		//{
@@ -14563,10 +14553,10 @@
 			//v11 = *(unsigned int *)LODWORD(v80);
 			//v49 = *(unsigned int *)LODWORD(v80) == 5;
 			ai_near_actors_targets_pid[i] = OBJECT_Player;
-			if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400)
+			if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & 0x0400)
 				continue;
 			
-			if (!actor->sCurrentHP && actor->uAIState != Dying)
+			if (!pActor->sCurrentHP && pActor->uAIState != Dying)
 				Actor::Die(i);
 			
 			//v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
@@ -14577,7 +14567,7 @@
 			for (uint j = 0; j < 22; ++j)
 			{
 				if (j != 10)
-				actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
+				pActor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
 			}
 			/*do
 			{
@@ -14590,52 +14580,52 @@
 				++v14;
 			}
 			while ( v13 < 22 );*/
-			if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
 			//&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12
 			// || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) )
-				actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
-				actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else  if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
-				actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType;
+			else  if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
 			
-			if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
-				|| (signed __int64)actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
+			if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
+				|| (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
 				continue;
 			
 			//v15 = pMiscTimer->uTimeElapsed;
 			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
 			//v17 = pActor->uCurrentActionTime;
 			//v18 = pActor->pMonsterInfo.uRecoveryTime;
-			if (actor->pMonsterInfo.uRecoveryTime)
+			if (pActor->pMonsterInfo.uRecoveryTime)
 			{
-				if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
-					actor->pMonsterInfo.uRecoveryTime = 0;
+				if (pActor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
+					pActor->pMonsterInfo.uRecoveryTime = 0;
 				else 
-					actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
+					pActor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
 			}
 			
-			actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
-			if (actor->uCurrentActionTime < actor->uCurrentActionLength)
+			pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+			if (pActor->uCurrentActionTime < pActor->uCurrentActionLength)
 				continue;
 			
 			//v19 = actor->uAIState;
-			if (actor->uAIState == Dying)
-				actor->uAIState = Dead;
+			if (pActor->uAIState == Dying)
+				pActor->uAIState = Dead;
 			else
 			{
-				if (actor->uAIState != Summoned)
+				if (pActor->uAIState != Summoned)
 				{
 					Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr);
 					continue;
 				}
-				actor->uAIState = Standing;
+				pActor->uAIState = Standing;
 			}
 			
-			actor->uCurrentActionTime = 0;
-			actor->uCurrentActionLength = 0;
-			actor->UpdateAnimation();
+			pActor->uCurrentActionTime = 0;
+			pActor->uCurrentActionLength = 0;
+			pActor->UpdateAnimation();
 			//LABEL_78:
 			//++uActorID;
 			//LODWORD(v80) += 836;
@@ -14655,61 +14645,61 @@
 			assert(actor_id < uNumActors);
 			
 			//v20 = &ai_near_actors_targets_pid[actor_id];
-			v21 = &pActors[actor_id];
+			pActor = &pActors[actor_id];
 			Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true);
-			if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
-				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+			if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			target_pid = ai_near_actors_targets_pid[actor_id];
 			target_pid_type = PID_TYPE(target_pid);
 			if ( target_pid_type == OBJECT_Actor)
 				v80 = 0.5;
 			else
 				v80 = 1.0;
-			v22 = v21->uAIState;
+			v22 = pActor->uAIState;
 			if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned)
 			{
 				continue;
 			}
-			if ( !v21->sCurrentHP )
+			if ( !pActor->sCurrentHP )
 				Actor::Die(actor_id);
 			for(int i=0;i<22;i++)
 			{
 				if ( i != 10 )
 				{
-					v21->pActorBuffs[i]._4585CA(pParty->uTimePlayed);
+					pActor->pActorBuffs[i]._4585CA(pParty->uTimePlayed);
 				}
 			}
-			if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
-				v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
-				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
-				v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
-			if ( (signed __int64)v21->pActorBuffs[2].uExpireTime < 0 )
+			else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
+			if ( (signed __int64)pActor->pActorBuffs[2].uExpireTime < 0 )
 			{
-				v21->uAIState = Removed;
+				pActor->uAIState = Removed;
 				continue;
 			}
-			if ( (signed __int64)v21->pActorBuffs[5].uExpireTime > 0
-				|| (signed __int64)v21->pActorBuffs[6].uExpireTime > 0)
+			if ( (signed __int64)pActor->pActorBuffs[5].uExpireTime > 0
+				|| (signed __int64)pActor->pActorBuffs[6].uExpireTime > 0)
 			{
 				continue;
 			}
 			v27 = pMiscTimer->uTimeElapsed;
-			v28 = v21->pMonsterInfo.uRecoveryTime;
-			v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+			v28 = pActor->pMonsterInfo.uRecoveryTime;
+			pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
 			if ( (signed int)v28 > 0 )
-				v21->pMonsterInfo.uRecoveryTime = v28 - v27;
-			if ( v21->pMonsterInfo.uRecoveryTime < 0 )
-				v21->pMonsterInfo.uRecoveryTime = 0;
-			if ( !(v21->uAttributes & 0x8000) )
-				v21->uAttributes |= 0x8000;
+				pActor->pMonsterInfo.uRecoveryTime = v28 - v27;
+			if ( pActor->pMonsterInfo.uRecoveryTime < 0 )
+				pActor->pMonsterInfo.uRecoveryTime = 0;
+			if ( !(pActor->uAttributes & 0x8000) )
+				pActor->uAttributes |= 0x8000;
 			a1 = PID(OBJECT_Actor,actor_id);
 			v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0);
 			memcpy(&v75, v30, sizeof(v75));
 			memcpy(&pDir, &v75, sizeof(pDir));
-			uAIState = v21->uAIState; 
+			uAIState = pActor->uAIState; 
 			/*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly
 				&& (signed int)v21->pMonsterInfo.uRecoveryTime <= 0
 				&& v80 * 307.2 >= (double)(signed int)v75.uDistance
@@ -14720,60 +14710,60 @@
 			}
 			else
 			*/
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
-				|| (signed int)v21->pMonsterInfo.uRecoveryTime > 0
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
+				|| (signed int)pActor->pMonsterInfo.uRecoveryTime > 0
 				|| v80 * 307.2 < (double)(signed int)v75.uDistance
 				|| uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting
-				&&  !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
+				&&  !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
 			{
-				if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
+				if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength )
 				{
 					continue;
 				}
-				else if ( v21->uAIState == AttackingMelee )
+				else if ( pActor->uAIState == AttackingMelee )
 				{
-					v35 = stru_50C198.special_ability_use_check(v21, actor_id);
+					v35 = stru_50C198.special_ability_use_check(pActor, actor_id);
 					stru_50FE08.Add(
 						a1,
 						5120,
-						v21->vPosition.x,
-						v21->vPosition.y,
-						v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
+						pActor->vPosition.x,
+						pActor->vPosition.y,
+						pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1),
 						v35,
 						1
 					);
 				}
-				else if ( v21->uAIState == AttackingRanged1 )
+				else if ( pActor->uAIState == AttackingRanged1 )
 				{
-					v34 = v21->pMonsterInfo.uMissleAttack1Type;
-					Actor::RangedAttack(actor_id, &pDir, v34, 0);
+					v34 = pActor->pMonsterInfo.uMissleAttack1Type;
+					Actor::AI_RangedAttack(actor_id, &pDir, v34, 0);
 				}
-				else if ( v21->uAIState == AttackingRanged2 )
+				else if ( pActor->uAIState == AttackingRanged2 )
 				{
-					v34 = v21->pMonsterInfo.uMissleAttack2Type;
-					Actor::RangedAttack(actor_id, &pDir, v34, 1);
+					v34 = pActor->pMonsterInfo.uMissleAttack2Type;
+					Actor::AI_RangedAttack(actor_id, &pDir, v34, 1);
 				}
-				else if ( v21->uAIState == AttackingRanged3 )
+				else if ( pActor->uAIState == AttackingRanged3 )
 				{
-					v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
-					v33 = v21->pMonsterInfo.uSpell1ID;
-					Actor::SpellAttack(actor_id, &pDir, v33, 2, v65);
+					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1;
+					v33 = pActor->pMonsterInfo.uSpell1ID;
+					Actor::AI_SpellAttack(actor_id, &pDir, v33, 2, v65);
 				}
-				else if ( v21->uAIState == AttackingRanged4 )
+				else if ( pActor->uAIState == AttackingRanged4 )
 				{
-					v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
-					v33 = v21->pMonsterInfo.uSpell2ID;
-					Actor::SpellAttack(actor_id, &pDir, v33, 3, v65);
+					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2;
+					v33 = pActor->pMonsterInfo.uSpell2ID;
+					Actor::AI_SpellAttack(actor_id, &pDir, v33, 3, v65);
 				}
 			}
 
 			v36 = v75.uDistance;
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
 			{
 				if ( target_pid_type == OBJECT_Actor )
 				{
 					v36 = v75.uDistance;
-					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
+					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3]
 						+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
 				}
 				else
@@ -14800,85 +14790,85 @@
 					v38 = 5120;
 				}
 				if ( v37 >= 1 && v37 <= 4 && v36 < v38  || v37 == 1 )
-					v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+					pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 			}
 
-			if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
+			if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 )
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
-					Actor::_4032B2(actor_id, target_pid, 1024, 0);
+					Actor::AI_4032B2(actor_id, target_pid, 1024, 0);
 				}
 				else
 				{
 					//peasents after attacked
 					//guard after attacked
-					Actor::Flee(actor_id, target_pid, 0, &pDir);
+					Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 				}
 				continue;
 			}
 
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
 			{
 
-				if ( v21->pMonsterInfo.uAIType == 1 )
+				if ( pActor->pMonsterInfo.uAIType == 1 )
 				{
-					if ( v21->pMonsterInfo.uMovementType == 5 )
+					if ( pActor->pMonsterInfo.uMovementType == 5 )
 					{
-						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
 					}
 					else
 					{
-						Actor::Flee(actor_id, target_pid, 0, &pDir);
+						Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 						continue;
 					}
 						
 				}
-				if ( !(v21->uAttributes & 0x020000) )
+				if ( !(pActor->uAttributes & 0x020000) )
 				{
-					if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3)
+					if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3)
 					{
-						if ( v21->pMonsterInfo.uAIType == 2 )
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
-						if ( v21->pMonsterInfo.uAIType == 3 )
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
-						v84 = v21->sCurrentHP;
+						if ( pActor->pMonsterInfo.uAIType == 2 )
+							v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2;
+						if ( pActor->pMonsterInfo.uAIType == 3 )
+							v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1;
+						v84 = pActor->sCurrentHP;
 						v42 = (double)(signed int)v84;
 						if ( v43 > v42 && (signed int)v36 < 10240 )
 						{
-							Actor::Flee(actor_id, target_pid, 0, &pDir);
+							Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 							continue;
 						}
 					}
 				}
 				
-				v81 = v36 - v21->uActorRadius;
+				v81 = v36 - pActor->uActorRadius;
 				if ( target_pid_type == OBJECT_Actor )
 					v81 -= pActors[PID_ID(target_pid)].uActorRadius;
 				if ( v81 < 0 )
 					v81 = 0;
 				rand();
-				v21->uAttributes &= 0xFBFFFF;
+				pActor->uAttributes &= 0xFBFFFF;
 				if ( v81 < 5120 )
 				{
-					v45 = stru_50C198.special_ability_use_check(v21, actor_id);
+					v45 = stru_50C198.special_ability_use_check(pActor, actor_id);
 					if ( v45 == 0 )
 					{
-						if ( v21->pMonsterInfo.uMissleAttack1Type )
+						if ( pActor->pMonsterInfo.uMissleAttack1Type )
 						{
-							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
+							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
-								Actor::MissileAttack1(actor_id, target_pid, &pDir);
+								Actor::AI_MissileAttack1(actor_id, target_pid, &pDir);
 							}
-							else if ( v21->pMonsterInfo.uMovementType == 5 )
+							else if ( pActor->pMonsterInfo.uMovementType == 5 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								if ( v80 * 307.2 > (double)v81 )
 								{
 									v64 = (signed __int64)v47;
@@ -14886,7 +14876,7 @@
 								}
 								else
 								{
-									Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+									Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 								}
 							}
 						}
@@ -14896,21 +14886,21 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( v21->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == 5 )
 									{
-										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
 										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
 										//monsters
-										Actor::Pursue3(actor_id, target_pid, 0, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir);
 									}
 								}
-								else if ( v21->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == 5 )
 								{
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
 									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
@@ -14920,19 +14910,19 @@
 									//monsters
 									//guard after player runs away
 									// follow player
-									Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
-							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
 								//monsters
-								Actor::MeleeAttack(actor_id, target_pid, &pDir);
+								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
@@ -14940,28 +14930,28 @@
 					else if ( v45 == 2 || v45 == 3 )
 					{
 						if ( v45 == 2 )
-							v46 = v21->pMonsterInfo.uSpell1ID;
+							v46 = pActor->pMonsterInfo.uSpell1ID;
 						else
-							v46 = v21->pMonsterInfo.uSpell2ID;
+							v46 = pActor->pMonsterInfo.uSpell2ID;
 						if ( v46 )
 						{
-							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
+							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
 								if ( v45 == 2 )
-									Actor::SpellAttack1(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack1(actor_id, target_pid, &pDir);
 								else
-									Actor::SpellAttack2(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack2(actor_id, target_pid, &pDir);
 							}
-							else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 )
+							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 							}
 						}
 						else
@@ -14970,130 +14960,130 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( v21->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == 5 )
 									{
-										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
 										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
-										Actor::Pursue3(actor_id, target_pid, 256, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 									}
 								}
-								else if ( v21->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == 5 )
 								{
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
 									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
 								else
 								{
 									v70 = (signed __int64)v80 * 307.2;
-									Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
-							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								Actor::MeleeAttack(actor_id, target_pid, &pDir);
+								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
 					}
 				}
 			}
-
-			if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
+			
+			if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
 			{
-				if ( !v21->pMonsterInfo.uMovementType )
+				if ( !pActor->pMonsterInfo.uMovementType )
 				{
-					Actor::_4032B2(actor_id, 4, 1024, 0);
+					Actor::AI_4032B2(actor_id, 4, 1024, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 1 )
+				else if ( pActor->pMonsterInfo.uMovementType == 1 )
 				{
-					Actor::_4032B2(actor_id, 4, 2560, 0);
+					Actor::AI_4032B2(actor_id, 4, 2560, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 2 )
+				else if ( pActor->pMonsterInfo.uMovementType == 2 )
 				{
-					Actor::_4032B2(actor_id, 4, 5120, 0);
+					Actor::AI_4032B2(actor_id, 4, 5120, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 4 )
+				else if ( pActor->pMonsterInfo.uMovementType == 4 )
 				{
-					Actor::_4032B2(actor_id, 4, 10240, 0);
+					Actor::AI_4032B2(actor_id, 4, 10240, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 5 )
+				else if ( pActor->pMonsterInfo.uMovementType == 5 )
 				{
 					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
-					v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					memcpy(&v74, v57, sizeof(v74));
 					memcpy(&pDir, &v74, sizeof(pDir));
 					v64 = (signed __int64)v58;
 					Actor::AI_Stand(actor_id, 4, v64, &pDir);
 				}				
 			}
-			else if ( !v21->pMonsterInfo.uMissleAttack2Type )
+			else if ( !pActor->pMonsterInfo.uMissleAttack2Type )
 			{
 				if ( (double)v81 >= v80 * 307.2 )
 				{
 					if ( v81 >= 1024 )
 					{
-						if ( v21->pMonsterInfo.uMovementType == 5 )
+						if ( pActor->pMonsterInfo.uMovementType == 5 )
 						{
-							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 							v64 = (signed __int64)v47;
 							Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 						}
 						else
 						{
-							Actor::Pursue3(actor_id, target_pid, 256, &pDir);
+							Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 						}
 					}
-					else if ( v21->pMonsterInfo.uMovementType == 5 )
+					else if ( pActor->pMonsterInfo.uMovementType == 5 )
 					{
-						v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+						v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 						v64 = (signed __int64)v47;
 						Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 					}
 					else
 					{
 						v70 = (signed __int64)v80 * 307.2;
-						Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+						Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 					}
 				}
-				else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+				else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 				{
-					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					v64 = (signed __int64)v47;
 					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::MeleeAttack(actor_id, target_pid, &pDir);
+					Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 				}
 			}
-			else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+			else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 			{
-				v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-				if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 )
+				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
 				{
 					v64 = (signed __int64)v47;
 					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+					Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 				}
 			}
 			else
 			{
-				Actor::MissileAttack2(actor_id, target_pid, &pDir);
-			}
+				Actor::AI_MissileAttack2(actor_id, target_pid, &pDir);
+			}		
 		}
 	}
 }