Mercurial > mm7
comparison Actor.cpp @ 414:d8b3056df4e2
AI_Bored
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 17:15:36 +0200 |
parents | 111f25d1cc04 |
children | 55684f4eda73 |
comparison
equal
deleted
inserted
replaced
413:111f25d1cc04 | 414:d8b3056df4e2 |
---|---|
1989 v9->uCurrentActionLength = 256; | 1989 v9->uCurrentActionLength = 256; |
1990 v9->uAIState = Interacting; | 1990 v9->uAIState = Interacting; |
1991 v9->UpdateAnimation(); | 1991 v9->UpdateAnimation(); |
1992 } | 1992 } |
1993 else | 1993 else |
1994 Actor::_402F87(v5, v4, a4); | 1994 Actor::AI_Bored(v5, v4, a4); |
1995 } | 1995 } |
1996 | 1996 |
1997 //----- (00403F58) -------------------------------------------------------- | 1997 //----- (00403F58) -------------------------------------------------------- |
1998 void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) | 1998 void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) |
1999 { | 1999 { |
2000 if (rand() % 2) | 2000 if (rand() % 2) |
2001 { | 2001 AI_Bored(uActorID, uObjID, a4); |
2002 Actor::_402F87(uActorID, uObjID, a4); | |
2003 return; | |
2004 } | |
2005 | |
2006 assert(uActorID < uNumActors); | |
2007 auto actor = &pActors[uActorID]; | |
2008 | |
2009 AIDirection a3; | |
2010 if (!a4) | |
2011 a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); | |
2012 | |
2013 actor->uAIState = Standing; | |
2014 if (!uActionLength) | |
2015 actor->uCurrentActionLength = rand() % 256 + 256; | |
2016 else | 2002 else |
2017 actor->uCurrentActionLength = uActionLength; | 2003 AI_Stand(uActorID, uObjID, uActionLength, a4); |
2018 actor->uCurrentActionTime = 0; | |
2019 actor->uYawAngle = a4->uYawAngle; | |
2020 actor->uPitchAngle = a4->uPitchAngle; | |
2021 actor->vVelocity.z = 0; | |
2022 actor->vVelocity.y = 0; | |
2023 actor->vVelocity.x = 0; | |
2024 actor->UpdateAnimation(); | |
2025 } | 2004 } |
2026 | 2005 |
2027 | 2006 |
2028 | 2007 |
2029 //----- (00403EB6) -------------------------------------------------------- | 2008 //----- (00403EB6) -------------------------------------------------------- |
2903 unsigned int v16; // [sp+2Ch] [bp-10h]@1 | 2882 unsigned int v16; // [sp+2Ch] [bp-10h]@1 |
2904 int y; // [sp+30h] [bp-Ch]@1 | 2883 int y; // [sp+30h] [bp-Ch]@1 |
2905 unsigned int uActorID; // [sp+34h] [bp-8h]@1 | 2884 unsigned int uActorID; // [sp+34h] [bp-8h]@1 |
2906 int v19; // [sp+38h] [bp-4h]@1 | 2885 int v19; // [sp+38h] [bp-4h]@1 |
2907 | 2886 |
2887 //v14 never filled, maybe it is passed to function but optimized away as local variable | |
2888 | |
2908 uActorID = a1; | 2889 uActorID = a1; |
2909 v4 = a1; | 2890 v4 = a1; |
2910 v5 = &pActors[a1]; | 2891 v5 = &pActors[a1]; |
2911 v16 = a2; | 2892 v16 = a2; |
2912 v6 = v5->vInitialPosition.x - v5->vPosition.x; | 2893 v6 = v5->vInitialPosition.x - v5->vPosition.x; |
2920 v19 += v8 >> 1; | 2901 v19 += v8 >> 1; |
2921 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | 2902 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) |
2922 { | 2903 { |
2923 if ( !uActionLength ) | 2904 if ( !uActionLength ) |
2924 uActionLength = 256; | 2905 uActionLength = 256; |
2925 Actor::_403F58(uActorID, 4, uActionLength, &v14); | 2906 Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); |
2926 return; | 2907 return; |
2927 } | 2908 } |
2928 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) | 2909 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) |
2929 { | 2910 { |
2930 v13 = &v14; | 2911 v13 = &v14; |
3070 v4->UpdateAnimation(); | 3051 v4->UpdateAnimation(); |
3071 } | 3052 } |
3072 } | 3053 } |
3073 | 3054 |
3074 //----- (00402F87) -------------------------------------------------------- | 3055 //----- (00402F87) -------------------------------------------------------- |
3075 void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) | 3056 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) |
3076 { | 3057 { |
3077 int v3; // edi@1 | 3058 //int v3; // edi@1 |
3078 AIDirection *v4; // esi@1 | 3059 //AIDirection *v4; // esi@1 |
3079 Actor *v5; // ebx@1 | 3060 //Actor *v5; // ebx@1 |
3080 SpriteFrame *v6; // ecx@3 | 3061 //SpriteFrame *v6; // ecx@3 |
3081 unsigned int v7; // eax@3 | 3062 unsigned int v7; // eax@3 |
3082 int v8; // edx@3 | 3063 //int v8; // edx@3 |
3083 unsigned int v9; // eax@3 | 3064 unsigned int v9; // eax@3 |
3084 //int result; // eax@4 | 3065 //int result; // eax@4 |
3085 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 | 3066 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 |
3086 AIDirection v12; // [sp+28h] [bp-40h]@2 | 3067 //AIDirection v12; // [sp+28h] [bp-40h]@2 |
3087 AIDirection v13; // [sp+44h] [bp-24h]@2 | 3068 //AIDirection v13; // [sp+44h] [bp-24h]@2 |
3088 unsigned int v14; // [sp+60h] [bp-8h]@1 | 3069 //unsigned int v14; // [sp+60h] [bp-8h]@1 |
3089 unsigned int v15; // [sp+64h] [bp-4h]@1 | 3070 //unsigned int v15; // [sp+64h] [bp-4h]@1 |
3090 | 3071 |
3091 v3 = uActorID; | 3072 assert(uActorID < uNumActors); |
3092 v4 = a4; | 3073 auto actor = pActors + uActorID; |
3093 v5 = &pActors[uActorID]; | 3074 |
3094 v14 = uObjID; | 3075 //v3 = uActorID; |
3095 v15 = uActorID; | 3076 //v4 = a4; |
3096 if ( !a4 ) | 3077 //v5 = &pActors[uActorID]; |
3097 { | 3078 //v14 = uObjID; |
3079 //v15 = uActorID; | |
3080 if (!a4) | |
3081 a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); | |
3082 /*{ | |
3098 memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); | 3083 memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); |
3099 memcpy(&v12, &v13, sizeof(v12)); | 3084 memcpy(&v12, &v13, sizeof(v12)); |
3100 v3 = v15; | 3085 v3 = v15; |
3101 v4 = &v12; | 3086 v4 = &v12; |
3102 } | 3087 }*/ |
3103 v6 = pSpriteFrameTable->pSpriteSFrames; | 3088 |
3104 v5->uYawAngle = LOWORD(v4->uYawAngle); | 3089 //v6 = pSpriteFrameTable->pSpriteSFrames; |
3105 v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[ANIM_Bored]].uAnimLength; | 3090 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; |
3106 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); | 3091 |
3107 LOWORD(v8) = v5->uYawAngle; | 3092 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); |
3108 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; | 3093 //LOWORD(v8) = actor->uYawAngle; |
3109 if ( BYTE1(v9) & 7 ) | 3094 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; |
3110 { | 3095 |
3111 Actor::AI_Stand(v3, v14, v5->uCurrentActionLength, v4); | 3096 if ( BYTE1(v9) & 7 ) // turned away - just stand |
3112 } | 3097 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); |
3113 else | 3098 else // facing player - play bored anim |
3114 { | 3099 { |
3115 v5->uAIState = Fidgeting; | 3100 actor->uAIState = Fidgeting; |
3116 v5->uCurrentActionTime = 0; | 3101 actor->uCurrentActionTime = 0; |
3117 v5->vVelocity.z = 0; | 3102 actor->uYawAngle = a4->uYawAngle; |
3118 v5->vVelocity.y = 0; | 3103 actor->vVelocity.z = 0; |
3119 v5->vVelocity.x = 0; | 3104 actor->vVelocity.y = 0; |
3105 actor->vVelocity.x = 0; | |
3120 if ( rand() % 100 < 5 ) | 3106 if ( rand() % 100 < 5 ) |
3121 Actor::PlaySound(v3, 3u); | 3107 Actor::PlaySound(uActorID, 3); |
3122 v5->UpdateAnimation(); | 3108 actor->UpdateAnimation(); |
3123 } | 3109 } |
3124 } | 3110 } |
3125 | 3111 |
3126 //----- (00402F27) -------------------------------------------------------- | 3112 //----- (00402F27) -------------------------------------------------------- |
3127 void Actor::Resurrect(unsigned int uActorID) | 3113 void Actor::Resurrect(unsigned int uActorID) |
3309 } | 3295 } |
3310 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | 3296 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) |
3311 { | 3297 { |
3312 if ( !uActionLength ) | 3298 if ( !uActionLength ) |
3313 uActionLength = 256; | 3299 uActionLength = 256; |
3314 Actor::_403F58(v5, 4, uActionLength, v10); | 3300 Actor::AI_StandOrBored(v5, 4, uActionLength, v10); |
3315 return; | 3301 return; |
3316 } | 3302 } |
3317 if ( (double)(signed int)v10->uDistance < 307.2 ) | 3303 if ( (double)(signed int)v10->uDistance < 307.2 ) |
3318 { | 3304 { |
3319 if ( !uActionLength ) | 3305 if ( !uActionLength ) |
3385 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) | 3371 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) |
3386 || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) | 3372 || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) |
3387 { | 3373 { |
3388 if ( !uActionLength ) | 3374 if ( !uActionLength ) |
3389 uActionLength = 256; | 3375 uActionLength = 256; |
3390 Actor::_403F58(v15, 4, uActionLength, &v13); | 3376 Actor::AI_StandOrBored(v15, 4, uActionLength, &v13); |
3391 } | 3377 } |
3392 else | 3378 else |
3393 { | 3379 { |
3394 v8 = v5->uMovementSpeed; | 3380 v8 = v5->uMovementSpeed; |
3395 if ( v8 ) | 3381 if ( v8 ) |
3456 if ( !uActionLength ) | 3442 if ( !uActionLength ) |
3457 uActionLength = 256; | 3443 uActionLength = 256; |
3458 v16 = v10; | 3444 v16 = v10; |
3459 v15 = uActionLength; | 3445 v15 = uActionLength; |
3460 v11 = 4; | 3446 v11 = 4; |
3461 Actor::_403F58(v5, v11, v15, v16); | 3447 Actor::AI_StandOrBored(v5, v11, v15, v16); |
3462 return; | 3448 return; |
3463 } | 3449 } |
3464 if ( (signed int)v10->uDistance < a5 ) | 3450 if ( (signed int)v10->uDistance < a5 ) |
3465 { | 3451 { |
3466 if ( !uActionLength ) | 3452 if ( !uActionLength ) |
3467 uActionLength = 256; | 3453 uActionLength = 256; |
3468 v11 = v19; | 3454 v11 = v19; |
3469 v16 = v10; | 3455 v16 = v10; |
3470 v15 = uActionLength; | 3456 v15 = uActionLength; |
3471 Actor::_403F58(v5, v11, v15, v16); | 3457 Actor::AI_StandOrBored(v5, v11, v15, v16); |
3472 return; | 3458 return; |
3473 } | 3459 } |
3474 if ( uActionLength ) | 3460 if ( uActionLength ) |
3475 { | 3461 { |
3476 v7->uCurrentActionLength = uActionLength; | 3462 v7->uCurrentActionLength = uActionLength; |
3543 if ( !uActionLength ) | 3529 if ( !uActionLength ) |
3544 uActionLength = 256; | 3530 uActionLength = 256; |
3545 v18 = v9; | 3531 v18 = v9; |
3546 v17 = uActionLength; | 3532 v17 = uActionLength; |
3547 v10 = 4; | 3533 v10 = 4; |
3548 return Actor::_403F58(v4, v10, v17, v18); | 3534 return Actor::AI_StandOrBored(v4, v10, v17, v18); |
3549 } | 3535 } |
3550 if ( (double)(signed int)v9->uDistance < 307.2 ) | 3536 if ( (double)(signed int)v9->uDistance < 307.2 ) |
3551 { | 3537 { |
3552 if ( !uActionLength ) | 3538 if ( !uActionLength ) |
3553 uActionLength = 256; | 3539 uActionLength = 256; |
3554 v10 = v21; | 3540 v10 = v21; |
3555 v18 = v9; | 3541 v18 = v9; |
3556 v17 = uActionLength; | 3542 v17 = uActionLength; |
3557 return Actor::_403F58(v4, v10, v17, v18); | 3543 return Actor::AI_StandOrBored(v4, v10, v17, v18); |
3558 } | 3544 } |
3559 if ( uActionLength ) | 3545 if ( uActionLength ) |
3560 { | 3546 { |
3561 v6->uCurrentActionLength = uActionLength + rand() % uActionLength; | 3547 v6->uCurrentActionLength = uActionLength + rand() % uActionLength; |
3562 } | 3548 } |