Mercurial > mm7
changeset 414:d8b3056df4e2
AI_Bored
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 17:15:36 +0200 |
parents | 111f25d1cc04 |
children | 233f9cfc32a3 55684f4eda73 096c9a146ed0 |
files | Actor.cpp Actor.h Indoor.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp |
diffstat | 6 files changed, 66 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/Actor.cpp Sat Feb 23 17:15:36 2013 +0200 @@ -1991,37 +1991,16 @@ v9->UpdateAnimation(); } else - Actor::_402F87(v5, v4, a4); + Actor::AI_Bored(v5, v4, a4); } //----- (00403F58) -------------------------------------------------------- -void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) +void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) { if (rand() % 2) - { - Actor::_402F87(uActorID, uObjID, a4); - return; - } - - assert(uActorID < uNumActors); - auto actor = &pActors[uActorID]; - - AIDirection a3; - if (!a4) - a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); - - actor->uAIState = Standing; - if (!uActionLength) - actor->uCurrentActionLength = rand() % 256 + 256; + AI_Bored(uActorID, uObjID, a4); else - actor->uCurrentActionLength = uActionLength; - actor->uCurrentActionTime = 0; - actor->uYawAngle = a4->uYawAngle; - actor->uPitchAngle = a4->uPitchAngle; - actor->vVelocity.z = 0; - actor->vVelocity.y = 0; - actor->vVelocity.x = 0; - actor->UpdateAnimation(); + AI_Stand(uActorID, uObjID, uActionLength, a4); } @@ -2905,6 +2884,8 @@ unsigned int uActorID; // [sp+34h] [bp-8h]@1 int v19; // [sp+38h] [bp-4h]@1 + //v14 never filled, maybe it is passed to function but optimized away as local variable + uActorID = a1; v4 = a1; v5 = &pActors[a1]; @@ -2922,7 +2903,7 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(uActorID, 4, uActionLength, &v14); + Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); return; } if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) @@ -3072,54 +3053,59 @@ } //----- (00402F87) -------------------------------------------------------- -void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) +void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) { - int v3; // edi@1 - AIDirection *v4; // esi@1 - Actor *v5; // ebx@1 - SpriteFrame *v6; // ecx@3 + //int v3; // edi@1 + //AIDirection *v4; // esi@1 + //Actor *v5; // ebx@1 + //SpriteFrame *v6; // ecx@3 unsigned int v7; // eax@3 - int v8; // edx@3 + //int v8; // edx@3 unsigned int v9; // eax@3 //int result; // eax@4 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 - AIDirection v12; // [sp+28h] [bp-40h]@2 - AIDirection v13; // [sp+44h] [bp-24h]@2 - unsigned int v14; // [sp+60h] [bp-8h]@1 - unsigned int v15; // [sp+64h] [bp-4h]@1 + //AIDirection v12; // [sp+28h] [bp-40h]@2 + //AIDirection v13; // [sp+44h] [bp-24h]@2 + //unsigned int v14; // [sp+60h] [bp-8h]@1 + //unsigned int v15; // [sp+64h] [bp-4h]@1 + + assert(uActorID < uNumActors); + auto actor = pActors + uActorID; - v3 = uActorID; - v4 = a4; - v5 = &pActors[uActorID]; - v14 = uObjID; - v15 = uActorID; - if ( !a4 ) - { + //v3 = uActorID; + //v4 = a4; + //v5 = &pActors[uActorID]; + //v14 = uObjID; + //v15 = uActorID; + if (!a4) + a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); + /*{ memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); memcpy(&v12, &v13, sizeof(v12)); v3 = v15; v4 = &v12; - } - v6 = pSpriteFrameTable->pSpriteSFrames; - v5->uYawAngle = LOWORD(v4->uYawAngle); - v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[ANIM_Bored]].uAnimLength; - v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); - LOWORD(v8) = v5->uYawAngle; - v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; - if ( BYTE1(v9) & 7 ) + }*/ + + //v6 = pSpriteFrameTable->pSpriteSFrames; + actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; + + v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); + //LOWORD(v8) = actor->uYawAngle; + v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; + + if ( BYTE1(v9) & 7 ) // turned away - just stand + Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); + else // facing player - play bored anim { - Actor::AI_Stand(v3, v14, v5->uCurrentActionLength, v4); - } - else - { - v5->uAIState = Fidgeting; - v5->uCurrentActionTime = 0; - v5->vVelocity.z = 0; - v5->vVelocity.y = 0; - v5->vVelocity.x = 0; + actor->uAIState = Fidgeting; + actor->uCurrentActionTime = 0; + actor->uYawAngle = a4->uYawAngle; + actor->vVelocity.z = 0; + actor->vVelocity.y = 0; + actor->vVelocity.x = 0; if ( rand() % 100 < 5 ) - Actor::PlaySound(v3, 3u); - v5->UpdateAnimation(); + Actor::PlaySound(uActorID, 3); + actor->UpdateAnimation(); } } @@ -3311,7 +3297,7 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(v5, 4, uActionLength, v10); + Actor::AI_StandOrBored(v5, 4, uActionLength, v10); return; } if ( (double)(signed int)v10->uDistance < 307.2 ) @@ -3387,7 +3373,7 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(v15, 4, uActionLength, &v13); + Actor::AI_StandOrBored(v15, 4, uActionLength, &v13); } else { @@ -3458,7 +3444,7 @@ v16 = v10; v15 = uActionLength; v11 = 4; - Actor::_403F58(v5, v11, v15, v16); + Actor::AI_StandOrBored(v5, v11, v15, v16); return; } if ( (signed int)v10->uDistance < a5 ) @@ -3468,7 +3454,7 @@ v11 = v19; v16 = v10; v15 = uActionLength; - Actor::_403F58(v5, v11, v15, v16); + Actor::AI_StandOrBored(v5, v11, v15, v16); return; } if ( uActionLength ) @@ -3545,7 +3531,7 @@ v18 = v9; v17 = uActionLength; v10 = 4; - return Actor::_403F58(v4, v10, v17, v18); + return Actor::AI_StandOrBored(v4, v10, v17, v18); } if ( (double)(signed int)v9->uDistance < 307.2 ) { @@ -3554,7 +3540,7 @@ v10 = v21; v18 = v9; v17 = uActionLength; - return Actor::_403F58(v4, v10, v17, v18); + return Actor::AI_StandOrBored(v4, v10, v17, v18); } if ( uActionLength ) {
--- a/Actor.h Sat Feb 23 16:39:32 2013 +0200 +++ b/Actor.h Sat Feb 23 17:15:36 2013 +0200 @@ -209,7 +209,7 @@ static void PlaySound(unsigned int uActorID, unsigned int uSoundID); static void Die(unsigned int uActorID); static void Resurrect(unsigned int uActorID); - static void _402F87(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); + static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); static void _4030AD(unsigned int uActorID, signed int edx0, int arg0); static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3); static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); @@ -220,7 +220,7 @@ static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); static void __fastcall StandAwhile(unsigned int uActorID); static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4); - static void _403F58(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); + static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); static void FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4); static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); static signed int __fastcall Explode(unsigned int uActorID);
--- a/Indoor.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/Indoor.cpp Sat Feb 23 17:15:36 2013 +0200 @@ -4345,7 +4345,7 @@ goto LABEL_119; } } - Actor::_403F58(v63, 4, v22, &v53); + Actor::AI_StandOrBored(v63, 4, v22, &v53); goto LABEL_119; } if ( v0->vPosition.x & 1 ) @@ -4359,7 +4359,7 @@ goto LABEL_123; if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) { - Actor::_403F58(v63, 4, v22, &v52); + Actor::AI_StandOrBored(v63, 4, v22, &v52); goto LABEL_123; } }
--- a/mm7_3.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/mm7_3.cpp Sat Feb 23 17:15:36 2013 +0200 @@ -1229,7 +1229,7 @@ if ( v71 == v34 ) goto LABEL_99; LABEL_101: - Actor::_403F58(v75, 4, v34, (AIDirection *)v34); + Actor::AI_StandOrBored(v75, 4, v34, (AIDirection *)v34); break; } if ( v71 != v34 ) @@ -17911,7 +17911,7 @@ { if (actor->uAIState != Summoned) { - Actor::_403F58(i, OBJECT_Player, 256, nullptr); + Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); continue; } actor->uAIState = Standing; @@ -18702,7 +18702,7 @@ v33 = 8 * v5 | OBJECT_Actor; memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31)); memcpy(&v30, &v31, sizeof(v30)); - Actor::_403F58(v37, 4, 32, &v30); + Actor::AI_StandOrBored(v37, 4, 32, &v30); *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33; v1->pQueue[v1->uActorQueueSize].field_C = 2; v1->pQueue[v1->uActorQueueSize++].uActionLength = 0;
--- a/mm7_4.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/mm7_4.cpp Sat Feb 23 17:15:36 2013 +0200 @@ -14389,7 +14389,7 @@ if ( v10 ) { if ( v10 != 8 ) - Actor::_403F58(v20, v17, 32, &v14); + Actor::AI_StandOrBored(v20, v17, 32, &v14); } } }
--- a/mm7_5.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/mm7_5.cpp Sat Feb 23 17:15:36 2013 +0200 @@ -9721,7 +9721,7 @@ if ( v6 != 8 ) goto LABEL_19; v3 = 0; - Actor::_403F58(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0); + Actor::AI_StandOrBored(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0); } } } @@ -9755,7 +9755,7 @@ { v12 = dword_4F6E08[v10]; v9->uActionLength = v3; - Actor::_403F58(v10, v12, 32, (AIDirection *)v3); + Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); } } } @@ -10099,7 +10099,7 @@ v16 = a2a; if ( !(v14 % 2) ) { - Actor::_402F87(v4, a2a, &a4); + Actor::AI_Bored(v4, a2a, &a4); return; } v21 = 64; @@ -10744,7 +10744,7 @@ if ( rand() % 2 ) Actor::AI_Stand(uActorID, a2, 0x40u, &a4); else - Actor::_402F87(uActorID, a2, &a4); + Actor::AI_Bored(uActorID, a2, &a4); } } }