Mercurial > mm7
comparison Actor.cpp @ 413:111f25d1cc04
AI_Stand
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 16:39:32 +0200 |
parents | 74205b91647b |
children | d8b3056df4e2 |
comparison
equal
deleted
inserted
replaced
412:bbd8888534dc | 413:111f25d1cc04 |
---|---|
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::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) |
1999 { | 1999 { |
2000 unsigned int v4; // esi@1 | 2000 if (rand() % 2) |
2001 //unsigned int result; // eax@2 | 2001 { |
2002 AIDirection *v6; // eax@3 | 2002 Actor::_402F87(uActorID, uObjID, a4); |
2003 unsigned int v7; // edi@3 | |
2004 Actor *v8; // ebx@3 | |
2005 AIDirection *v9; // esi@4 | |
2006 AIDirection a3; // [sp+4h] [bp-3Ch]@4 | |
2007 AIDirection v11; // [sp+20h] [bp-20h]@4 | |
2008 signed int a2; // [sp+3Ch] [bp-4h]@1 | |
2009 | |
2010 a2 = uObjID; | |
2011 v4 = uActorID; | |
2012 if ( rand() % 2 ) | |
2013 { | |
2014 Actor::_402F87(v4, a2, a4); | |
2015 return; | 2003 return; |
2016 } | 2004 } |
2017 | 2005 |
2018 v6 = a4; | 2006 assert(uActorID < uNumActors); |
2019 v7 = 0; | 2007 auto actor = &pActors[uActorID]; |
2020 v8 = &pActors[v4]; | 2008 |
2021 if ( !a4 ) | 2009 AIDirection a3; |
2022 { | 2010 if (!a4) |
2023 v9 = Actor::GetDirectionInfo(8 * v4 | 3, a2, &a3, 0); | 2011 a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); |
2024 v6 = &v11; | 2012 |
2025 memcpy(&v11, v9, sizeof(v11)); | 2013 actor->uAIState = Standing; |
2026 v7 = 0; | 2014 if (!uActionLength) |
2027 } | 2015 actor->uCurrentActionLength = rand() % 256 + 256; |
2028 v8->uYawAngle = LOWORD(v6->uYawAngle); | 2016 else |
2029 v8->uPitchAngle = LOWORD(v6->uPitchAngle); | 2017 actor->uCurrentActionLength = uActionLength; |
2030 if ( uActionLength == v7 ) | 2018 actor->uCurrentActionTime = 0; |
2031 v8->uCurrentActionLength = rand() % 256 + 256; | 2019 actor->uYawAngle = a4->uYawAngle; |
2032 else | 2020 actor->uPitchAngle = a4->uPitchAngle; |
2033 v8->uCurrentActionLength = uActionLength; | 2021 actor->vVelocity.z = 0; |
2034 v8->uCurrentActionTime = v7; | 2022 actor->vVelocity.y = 0; |
2035 v8->uAIState = Standing; | 2023 actor->vVelocity.x = 0; |
2036 v8->vVelocity.z = v7; | 2024 actor->UpdateAnimation(); |
2037 v8->vVelocity.y = v7; | |
2038 v8->vVelocity.x = v7; | |
2039 v8->UpdateAnimation(); | |
2040 } | 2025 } |
2041 | 2026 |
2042 | 2027 |
2043 | 2028 |
2044 //----- (00403EB6) -------------------------------------------------------- | 2029 //----- (00403EB6) -------------------------------------------------------- |
2045 void Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4) | 2030 void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) |
2046 { | 2031 { |
2047 AIDirection *v4; // eax@1 | 2032 assert(uActorID < uNumActors); |
2048 unsigned int v5; // esi@1 | 2033 auto actor = pActors + uActorID; |
2049 Actor *v6; // ebx@1 | 2034 |
2050 AIDirection *v7; // esi@2 | 2035 AIDirection a3; |
2051 AIDirection a3; // [sp+Ch] [bp-38h]@2 | 2036 if (!a4) |
2052 AIDirection v10; // [sp+28h] [bp-1Ch]@2 | 2037 a4 = Actor::GetDirectionInfo(8 * uActorID | 3, object_to_face_pid, &a3, 0); |
2053 | 2038 |
2054 v4 = a4; | 2039 actor->uAIState = Standing; |
2055 v5 = 0; | 2040 if (!uActionLength) |
2056 v6 = &pActors[uActorID]; | 2041 actor->uCurrentActionLength = rand() % 256 + 256; |
2057 if ( !a4 ) | |
2058 { | |
2059 v7 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0); | |
2060 v4 = &v10; | |
2061 memcpy(&v10, v7, sizeof(v10)); | |
2062 v5 = 0; | |
2063 } | |
2064 v6->uYawAngle = LOWORD(v4->uYawAngle); | |
2065 if ( uActionLength == v5 ) | |
2066 v6->uCurrentActionLength = rand() % 256 + 256; | |
2067 else | 2042 else |
2068 v6->uCurrentActionLength = uActionLength; | 2043 actor->uCurrentActionLength = uActionLength; |
2069 v6->uCurrentActionTime = v5; | 2044 actor->uCurrentActionTime = 0; |
2070 v6->uAIState = Standing; | 2045 actor->uYawAngle = a4->uYawAngle; |
2071 v6->vVelocity.z = v5; | 2046 actor->uPitchAngle = a4->uPitchAngle; |
2072 v6->vVelocity.y = v5; | 2047 actor->vVelocity.z = 0; |
2073 v6->vVelocity.x = v5; | 2048 actor->vVelocity.y = 0; |
2074 v6->UpdateAnimation(); | 2049 actor->vVelocity.x = 0; |
2050 actor->UpdateAnimation(); | |
2075 } | 2051 } |
2076 | 2052 |
2077 | 2053 |
2078 //----- (00403E61) -------------------------------------------------------- | 2054 //----- (00403E61) -------------------------------------------------------- |
2079 void __fastcall Actor::StandAwhile(unsigned int uActorID) | 2055 void __fastcall Actor::StandAwhile(unsigned int uActorID) |
2121 a2 = edx0; | 2097 a2 = edx0; |
2122 v4 = v3->pMonsterInfo.uMovementType == 5; | 2098 v4 = v3->pMonsterInfo.uMovementType == 5; |
2123 v24 = uActorID; | 2099 v24 = uActorID; |
2124 if ( v4 && v3->pMonsterInfo.uAIType == 1 ) | 2100 if ( v4 && v3->pMonsterInfo.uAIType == 1 ) |
2125 { | 2101 { |
2126 Actor::_403EB6(uActorID, edx0, 0, arg0); | 2102 Actor::AI_Stand(uActorID, edx0, 0, arg0); |
2127 return; | 2103 return; |
2128 } | 2104 } |
2129 | 2105 |
2130 if ( (edx0 & 7) == OBJECT_Actor) | 2106 if ( (edx0 & 7) == OBJECT_Actor) |
2131 { | 2107 { |
2951 } | 2927 } |
2952 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) | 2928 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) |
2953 { | 2929 { |
2954 v13 = &v14; | 2930 v13 = &v14; |
2955 v12 = 256; | 2931 v12 = 256; |
2956 Actor::_403EB6(uActorID, v16, v12, v13); | 2932 Actor::AI_Stand(uActorID, v16, v12, v13); |
2957 return; | 2933 return; |
2958 } | 2934 } |
2959 v15 = (rand() & 0xF) << 12; | 2935 v15 = (rand() & 0xF) << 12; |
2960 v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16; | 2936 v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16; |
2961 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y); | 2937 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y); |
2967 v10 = v9 + rand() % 256 - 128; | 2943 v10 = v9 + rand() % 256 - 128; |
2968 if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) ) | 2944 if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) ) |
2969 { | 2945 { |
2970 v13 = &v14; | 2946 v13 = &v14; |
2971 v12 = 256; | 2947 v12 = 256; |
2972 Actor::_403EB6(uActorID, v16, v12, v13); | 2948 Actor::AI_Stand(uActorID, v16, v12, v13); |
2973 return; | 2949 return; |
2974 } | 2950 } |
2975 v11 = v5->uMovementSpeed; | 2951 v11 = v5->uMovementSpeed; |
2976 v5->uYawAngle = v10; | 2952 v5->uYawAngle = v10; |
2977 if ( v11 ) | 2953 if ( v11 ) |
3117 v5 = &pActors[uActorID]; | 3093 v5 = &pActors[uActorID]; |
3118 v14 = uObjID; | 3094 v14 = uObjID; |
3119 v15 = uActorID; | 3095 v15 = uActorID; |
3120 if ( !a4 ) | 3096 if ( !a4 ) |
3121 { | 3097 { |
3122 memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | AI_OBJECT_ACTOR, uObjID, &a3, (int)a4), sizeof(v13)); | 3098 memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); |
3123 memcpy(&v12, &v13, sizeof(v12)); | 3099 memcpy(&v12, &v13, sizeof(v12)); |
3124 v3 = v15; | 3100 v3 = v15; |
3125 v4 = &v12; | 3101 v4 = &v12; |
3126 } | 3102 } |
3127 v6 = pSpriteFrameTable->pSpriteSFrames; | 3103 v6 = pSpriteFrameTable->pSpriteSFrames; |
3130 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); | 3106 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); |
3131 LOWORD(v8) = v5->uYawAngle; | 3107 LOWORD(v8) = v5->uYawAngle; |
3132 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; | 3108 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; |
3133 if ( BYTE1(v9) & 7 ) | 3109 if ( BYTE1(v9) & 7 ) |
3134 { | 3110 { |
3135 Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4); | 3111 Actor::AI_Stand(v3, v14, v5->uCurrentActionLength, v4); |
3136 } | 3112 } |
3137 else | 3113 else |
3138 { | 3114 { |
3139 v5->uAIState = Fidgeting; | 3115 v5->uAIState = Fidgeting; |
3140 v5->uCurrentActionTime = 0; | 3116 v5->uCurrentActionTime = 0; |
3340 } | 3316 } |
3341 if ( (double)(signed int)v10->uDistance < 307.2 ) | 3317 if ( (double)(signed int)v10->uDistance < 307.2 ) |
3342 { | 3318 { |
3343 if ( !uActionLength ) | 3319 if ( !uActionLength ) |
3344 uActionLength = 256; | 3320 uActionLength = 256; |
3345 Actor::_403EB6(v5, v18, uActionLength, v10); | 3321 Actor::AI_Stand(v5, v18, uActionLength, v10); |
3346 return; | 3322 return; |
3347 } | 3323 } |
3348 if ( !v7->uMovementSpeed ) | 3324 if ( !v7->uMovementSpeed ) |
3349 { | 3325 { |
3350 Actor::_403EB6(v5, v18, uActionLength, v10); | 3326 Actor::AI_Stand(v5, v18, uActionLength, v10); |
3351 return; | 3327 return; |
3352 } | 3328 } |
3353 v18 = 16; | 3329 v18 = 16; |
3354 if ( arg0 % 2 ) | 3330 if ( arg0 % 2 ) |
3355 v18 = -16; | 3331 v18 = -16; |