comparison Actor.cpp @ 322:ce39b96acf5c

Killing friendly peasants subs
author Nomad
date Wed, 20 Feb 2013 04:36:14 +0200
parents 15decc249a94
children d720a13e2273
comparison
equal deleted inserted replaced
321:15decc249a94 322:ce39b96acf5c
1 #include <assert.h>
2
1 #include "Actor.h" 3 #include "Actor.h"
2 #include "LayingItem.h" 4 #include "LayingItem.h"
3 #include "Math.h" 5 #include "Math.h"
4 #include "Party.h" 6 #include "Party.h"
5 #include "Outdoor.h" 7 #include "Outdoor.h"
1402 } 1404 }
1403 } 1405 }
1404 1406
1405 1407
1406 //----- (0043ABB0) -------------------------------------------------------- 1408 //----- (0043ABB0) --------------------------------------------------------
1407 bool Actor::_43ABB0(Actor *a1, Actor *a2) 1409 bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2)
1408 { 1410 {
1409 unsigned int v2; // esi@1 1411 unsigned int v2; // esi@1
1410 unsigned int v3; // edi@1 1412 unsigned int v3; // edi@1
1411 bool result; // eax@9 1413 bool result; // eax@9
1412 1414
1425 result = v2 == v3; 1427 result = v2 == v3;
1426 return result; 1428 return result;
1427 } 1429 }
1428 1430
1429 //----- (0043AC45) -------------------------------------------------------- 1431 //----- (0043AC45) --------------------------------------------------------
1430 void Actor::_43AC45(unsigned int uActorID, int a2) 1432 void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2)
1431 { 1433 {
1432 Actor *v2; // esi@1
1433 Actor *v3; // edi@4
1434 int v4; // ebx@8 1434 int v4; // ebx@8
1435 int v5; // ST1C_4@8 1435 int v5; // ST1C_4@8
1436 int v6; // eax@8 1436 int v6; // eax@8
1437 int v7; // [sp+4h] [bp-10h]@1 1437
1438 unsigned int uActorID_; // [sp+Ch] [bp-8h]@1 1438 auto victim = pActors + uActorID;
1439 signed int v9; // [sp+10h] [bp-4h]@3
1440
1441 uActorID_ = uActorID;
1442 v2 = &pActors[uActorID];
1443 v7 = a2;
1444 if ( a2 == 1 ) 1439 if ( a2 == 1 )
1445 BYTE2(v2->uAttributes) |= 8u; 1440 BYTE2(victim->uAttributes) |= 8u;
1446 v9 = 0; 1441
1447 if ( (signed int)uNumActors > 0 ) 1442 for (uint i = 0; i < uNumActors; ++i)
1448 { 1443 {
1449 v3 = pActors; 1444 auto actor = pActors + i;
1450 do 1445 if (!actor->CanAct() || i == uActorID)
1451 { 1446 continue;
1452 if ( v3->CanAct() ) 1447
1453 { 1448 if (Actor::ArePeasantsOfSameFaction(victim, actor))
1454 if ( v9 != uActorID_ ) 1449 {
1455 { 1450 v4 = abs(actor->vPosition.x - victim->vPosition.x);
1456 if ( Actor::_43ABB0(v2, v3) ) 1451 v5 = abs(actor->vPosition.y - victim->vPosition.y);
1457 { 1452 v6 = abs(actor->vPosition.z - victim->vPosition.z);
1458 v4 = abs(v3->vPosition.x - v2->vPosition.x); 1453 if (int_get_vector_length(v4, v5, v6) < 4096)
1459 v5 = abs(v3->vPosition.y - v2->vPosition.y); 1454 {
1460 v6 = abs(v3->vPosition.z - v2->vPosition.z); 1455 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
1461 if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 ) 1456 if ( a2 == 1 )
1462 { 1457 BYTE2(actor->uAttributes) |= 8u;
1463 v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4; 1458 }
1464 if ( v7 == 1 ) 1459 }
1465 BYTE2(v3->uAttributes) |= 8u;
1466 }
1467 }
1468 }
1469 }
1470 ++v9;
1471 ++v3;
1472 }
1473 while ( v9 < (signed int)uNumActors );
1474 } 1460 }
1475 } 1461 }
1476 1462
1477 1463
1478 //----- (00404874) -------------------------------------------------------- 1464 //----- (00404874) --------------------------------------------------------
1956 return result; 1942 return result;
1957 } 1943 }
1958 1944
1959 1945
1960 //----- (00404030) -------------------------------------------------------- 1946 //----- (00404030) --------------------------------------------------------
1961 unsigned int __fastcall Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) 1947 void Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4)
1962 { 1948 {
1963 unsigned int v4; // edi@1 1949 unsigned int v4; // edi@1
1964 unsigned int v5; // esi@1 1950 unsigned int v5; // esi@1
1965 unsigned int result; // eax@2 1951 //unsigned int result; // eax@2
1966 AIDirection *v7; // eax@3 1952 AIDirection *v7; // eax@3
1967 unsigned int v8; // ecx@3 1953 unsigned int v8; // ecx@3
1968 Actor *v9; // ebx@3 1954 Actor *v9; // ebx@3
1969 AIDirection *v10; // esi@4 1955 AIDirection *v10; // esi@4
1970 unsigned __int16 v11; // ax@5 1956 unsigned __int16 v11; // ax@5
1992 v9->vVelocity.y = v8; 1978 v9->vVelocity.y = v8;
1993 v9->vVelocity.x = v8; 1979 v9->vVelocity.x = v8;
1994 v9->uPitchAngle = v11; 1980 v9->uPitchAngle = v11;
1995 v9->uCurrentActionLength = 256; 1981 v9->uCurrentActionLength = 256;
1996 v9->uAIState = Interacting; 1982 v9->uAIState = Interacting;
1997 result = v9->UpdateAnimation(); 1983 v9->UpdateAnimation();
1998 } 1984 }
1999 else 1985 else
2000 { 1986 Actor::_402F87(v5, v4, a4);
2001 result = Actor::_402F87(v5, v4, a4);
2002 }
2003 return result;
2004 } 1987 }
2005 1988
2006 //----- (00403F58) -------------------------------------------------------- 1989 //----- (00403F58) --------------------------------------------------------
2007 unsigned int __fastcall Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) 1990 void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4)
2008 { 1991 {
2009 unsigned int v4; // esi@1 1992 unsigned int v4; // esi@1
2010 unsigned int result; // eax@2 1993 //unsigned int result; // eax@2
2011 AIDirection *v6; // eax@3 1994 AIDirection *v6; // eax@3
2012 unsigned int v7; // edi@3 1995 unsigned int v7; // edi@3
2013 Actor *v8; // ebx@3 1996 Actor *v8; // ebx@3
2014 AIDirection *v9; // esi@4 1997 AIDirection *v9; // esi@4
2015 AIDirection a3; // [sp+4h] [bp-3Ch]@4 1998 AIDirection a3; // [sp+4h] [bp-3Ch]@4
2018 2001
2019 a2 = uObjID; 2002 a2 = uObjID;
2020 v4 = uActorID; 2003 v4 = uActorID;
2021 if ( rand() % 2 ) 2004 if ( rand() % 2 )
2022 { 2005 {
2023 result = Actor::_402F87(v4, a2, a4); 2006 Actor::_402F87(v4, a2, a4);
2024 } 2007 return;
2025 else 2008 }
2026 { 2009
2027 v6 = a4; 2010 v6 = a4;
2028 v7 = 0; 2011 v7 = 0;
2029 v8 = &pActors[v4]; 2012 v8 = &pActors[v4];
2030 if ( !a4 ) 2013 if ( !a4 )
2031 { 2014 {
2043 v8->uCurrentActionTime = v7; 2026 v8->uCurrentActionTime = v7;
2044 v8->uAIState = Standing; 2027 v8->uAIState = Standing;
2045 v8->vVelocity.z = v7; 2028 v8->vVelocity.z = v7;
2046 v8->vVelocity.y = v7; 2029 v8->vVelocity.y = v7;
2047 v8->vVelocity.x = v7; 2030 v8->vVelocity.x = v7;
2048 result = v8->UpdateAnimation(); 2031 v8->UpdateAnimation();
2049 }
2050 return result;
2051 } 2032 }
2052 2033
2053 2034
2054 2035
2055 //----- (00403EB6) -------------------------------------------------------- 2036 //----- (00403EB6) --------------------------------------------------------
2056 unsigned int __fastcall Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4) 2037 void Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4)
2057 { 2038 {
2058 AIDirection *v4; // eax@1 2039 AIDirection *v4; // eax@1
2059 unsigned int v5; // esi@1 2040 unsigned int v5; // esi@1
2060 Actor *v6; // ebx@1 2041 Actor *v6; // ebx@1
2061 AIDirection *v7; // esi@2 2042 AIDirection *v7; // esi@2
2080 v6->uCurrentActionTime = v5; 2061 v6->uCurrentActionTime = v5;
2081 v6->uAIState = Standing; 2062 v6->uAIState = Standing;
2082 v6->vVelocity.z = v5; 2063 v6->vVelocity.z = v5;
2083 v6->vVelocity.y = v5; 2064 v6->vVelocity.y = v5;
2084 v6->vVelocity.x = v5; 2065 v6->vVelocity.x = v5;
2085 return v6->UpdateAnimation(); 2066 v6->UpdateAnimation();
2086 } 2067 }
2087 2068
2088 2069
2089 //----- (00403E61) -------------------------------------------------------- 2070 //----- (00403E61) --------------------------------------------------------
2090 void __fastcall Actor::StandAwhile(unsigned int uActorID) 2071 void __fastcall Actor::StandAwhile(unsigned int uActorID)
2100 v1->vVelocity.x = 0; 2081 v1->vVelocity.x = 0;
2101 v1->UpdateAnimation(); 2082 v1->UpdateAnimation();
2102 } 2083 }
2103 2084
2104 //----- (00403C6C) -------------------------------------------------------- 2085 //----- (00403C6C) --------------------------------------------------------
2105 unsigned int __fastcall Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0) 2086 void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
2106 { 2087 {
2107 Actor *v3; // ebx@1 2088 Actor *v3; // ebx@1
2108 char v4; // zf@1 2089 char v4; // zf@1
2109 unsigned int result; // eax@3 2090 //unsigned int result; // eax@3
2110 AIDirection *v6; // esi@6 2091 AIDirection *v6; // esi@6
2111 AIDirection *v7; // edi@6 2092 AIDirection *v7; // edi@6
2112 signed int v8; // eax@7 2093 signed int v8; // eax@7
2113 double v9; // st7@9 2094 double v9; // st7@9
2114 Vec3_int_ v10; // ST04_12@9 2095 Vec3_int_ v10; // ST04_12@9
2115 int v11; // eax@10 2096 //int v11; // eax@10
2116 AIDirection *v12; // eax@11 2097 AIDirection *v12; // eax@11
2117 unsigned int v13; // esi@11 2098 unsigned int v13; // esi@11
2118 AIDirection *v14; // esi@12 2099 AIDirection *v14; // esi@12
2119 SpriteFrame *v15; // ecx@13 2100 SpriteFrame *v15; // ecx@13
2120 __int16 v16; // ax@13 2101 __int16 v16; // ax@13
2132 a2 = edx0; 2113 a2 = edx0;
2133 v4 = v3->pMonsterInfo.uMovementType == 5; 2114 v4 = v3->pMonsterInfo.uMovementType == 5;
2134 v24 = uActorID; 2115 v24 = uActorID;
2135 if ( v4 && v3->pMonsterInfo.uAIType == 1 ) 2116 if ( v4 && v3->pMonsterInfo.uAIType == 1 )
2136 { 2117 {
2137 result = Actor::_403EB6(uActorID, edx0, 0, arg0); 2118 Actor::_403EB6(uActorID, edx0, 0, arg0);
2138 } 2119 return;
2139 else 2120 }
2140 { 2121
2141 if ( (edx0 & 7) == OBJECT_Actor) 2122 if ( (edx0 & 7) == OBJECT_Actor)
2142 { 2123 {
2143 v8 = edx0 >> 3; 2124 v8 = edx0 >> 3;
2144 v6 = (AIDirection *)pActors[v8].vPosition.x; 2125 v6 = (AIDirection *)pActors[v8].vPosition.x;
2145 v7 = (AIDirection *)pActors[v8].vPosition.y; 2126 v7 = (AIDirection *)pActors[v8].vPosition.y;
2146 v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); 2127 v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z);
2196 v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333); 2177 v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333);
2197 v3->pMonsterInfo.uRecoveryTime = v18; 2178 v3->pMonsterInfo.uRecoveryTime = v18;
2198 v3->vVelocity.z = v13; 2179 v3->vVelocity.z = v13;
2199 v3->vVelocity.y = v13; 2180 v3->vVelocity.y = v13;
2200 v3->vVelocity.x = v13; 2181 v3->vVelocity.x = v13;
2201 result = v3->UpdateAnimation(); 2182 v3->UpdateAnimation();
2202 } 2183 }
2203 else 2184 else
2204 { 2185 Actor::_402AD7(v24, a2, rand() % 2, 64, arg0);
2205 v11 = rand();
2206 result = Actor::_402AD7(v24, a2, v11 % 2, 64, arg0);
2207 }
2208 }
2209 return result;
2210 } 2186 }
2211 2187
2212 2188
2213 //----- (00438CF3) -------------------------------------------------------- 2189 //----- (00438CF3) --------------------------------------------------------
2214 void Actor::_438CF3(unsigned int uActorID) 2190 void Actor::ApplyFineForKillingPeasant(unsigned int uActorID)
2215 { 2191 {
2216 unsigned int v1; // esi@1 2192 unsigned int v1; // esi@1
2217 unsigned int v2; // edi@2 2193 unsigned int v2; // edi@2
2218 char v3; // bl@3 2194 char v3; // bl@3
2219 char *v4; // ecx@16 2195 //char *v4; // ecx@16
2220 signed int v5; // eax@18 2196 //signed int v5; // eax@18
2221 Player **ppPlayers; // esi@20 2197 Player **ppPlayers; // esi@20
2222 2198
2223 v1 = uLevelMapStatsID; 2199 v1 = uLevelMapStatsID;
2224 if ( !uLevelMapStatsID || (v2 = uActorID, !pActors[uActorID]._438B9B()) ) 2200 if ( !uLevelMapStatsID || !pActors[uActorID].IsPeasant())
2225 return; 2201 return;
2202
2203 v2 = uActorID;
2226 v3 = 1; 2204 v3 = 1;
2227 if ( v1 != 5 ) 2205 if ( v1 != 5 )
2228 { 2206 {
2229 if ( v1 == 6 || v1 == 7 ) 2207 if ( v1 == 6 || v1 == 7 )
2230 { 2208 {
2241 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 100) ) 2219 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 100) )
2242 v3 = 1; 2220 v3 = 1;
2243 if ( v3 ) 2221 if ( v3 )
2244 { 2222 {
2245 LABEL_12: 2223 LABEL_12:
2246 pParty->uFine += 100 2224 pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + GetPartyReputation());
2247 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm
2248 + pActors[v2].pMonsterInfo.uLevel
2249 + GetPartyReputation());
2250 if ( pParty->uFine < 0 ) 2225 if ( pParty->uFine < 0 )
2251 pParty->uFine = 0; 2226 pParty->uFine = 0;
2252 if ( pParty->uFine > 4000000 ) 2227 if ( pParty->uFine > 4000000 )
2253 pParty->uFine = 4000000; 2228 pParty->uFine = 4000000;
2254 v4 = (char *)&pOutdoor->ddm; 2229
2255 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) 2230 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
2256 v4 = (char *)&pIndoor->dlv; 2231 {
2257 v5 = *((int *)v4 + 2); 2232 if (pOutdoor->ddm.uReputation < 10000)
2258 if ( v5 < 10000 ) 2233 pOutdoor->ddm.uReputation++;
2259 *((int *)v4 + 2) = v5 + 1; 2234 }
2235 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
2236 {
2237 if (pIndoor->dlv.uReputation < 10000)
2238 pIndoor->dlv.uReputation++;
2239 }
2240 else assert(false);
2241
2260 ppPlayers = &pPlayers[1]; 2242 ppPlayers = &pPlayers[1];
2261 do 2243 do
2262 { 2244 {
2263 if ( pParty->uFine ) 2245 if ( pParty->uFine )
2264 { 2246 {
2271 } 2253 }
2272 } 2254 }
2273 2255
2274 2256
2275 //----- (0043AE80) -------------------------------------------------------- 2257 //----- (0043AE80) --------------------------------------------------------
2276 int Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) 2258 void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3)
2277 { 2259 {
2278 int result; // eax@1 2260 int result; // eax@1
2279 unsigned int v4; // esi@1 2261 unsigned int v4; // esi@1
2280 int v5; // [sp-14h] [bp-18h]@3 2262 int v5; // [sp-14h] [bp-18h]@3
2281 unsigned int v6; // [sp-10h] [bp-14h]@3 2263 unsigned int v6; // [sp-10h] [bp-14h]@3
2295 v7 = 0; 2277 v7 = 0;
2296 LOWORD(v6) = v4; 2278 LOWORD(v6) = v4;
2297 v5 = 904; 2279 v5 = 904;
2298 goto LABEL_16; 2280 goto LABEL_16;
2299 } 2281 }
2300 return result; 2282 return;
2301 case 2: 2283 case 2:
2302 if ( a3 ) 2284 if ( a3 )
2303 { 2285 {
2304 v9 = 0; 2286 v9 = 0;
2305 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); 2287 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
2306 v7 = 0; 2288 v7 = 0;
2307 LOWORD(v6) = v4; 2289 LOWORD(v6) = v4;
2308 v5 = 905; 2290 v5 = 905;
2309 goto LABEL_16; 2291 goto LABEL_16;
2310 } 2292 }
2311 return result; 2293 return;
2312 case 3: 2294 case 3:
2313 if ( a3 ) 2295 if ( a3 )
2314 { 2296 {
2315 v9 = 0; 2297 v9 = 0;
2316 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); 2298 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
2317 v7 = 0; 2299 v7 = 0;
2318 LOWORD(v6) = v4; 2300 LOWORD(v6) = v4;
2319 v5 = 906; 2301 v5 = 906;
2320 goto LABEL_16; 2302 goto LABEL_16;
2321 } 2303 }
2322 return result; 2304 return;
2323 case 4: 2305 case 4:
2324 if ( a3 ) 2306 if ( a3 )
2325 { 2307 {
2326 v9 = 0; 2308 v9 = 0;
2327 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); 2309 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
2328 v7 = 0; 2310 v7 = 0;
2329 LOWORD(v6) = v4; 2311 LOWORD(v6) = v4;
2330 v5 = 907; 2312 v5 = 907;
2331 goto LABEL_16; 2313 goto LABEL_16;
2332 } 2314 }
2333 return result; 2315 return;
2334 case 5: 2316 case 5:
2335 v9 = 4; 2317 v9 = 4;
2336 v8 = 65536; 2318 v8 = 65536;
2337 v7 = 0; 2319 v7 = 0;
2338 v6 = 8 * uActorID | 3; 2320 v6 = 8 * uActorID | 3;
2374 v5 = 908; 2356 v5 = 908;
2375 LABEL_16: 2357 LABEL_16:
2376 result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9); 2358 result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9);
2377 break; 2359 break;
2378 default: 2360 default:
2379 return result; 2361 return;
2380 } 2362 }
2381 return result; 2363 return;
2382 } 2364 }
2383 2365
2384 2366
2385 //----- (0043B3E0) -------------------------------------------------------- 2367 //----- (0043B3E0) --------------------------------------------------------
2386 int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2) 2368 int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2)
2455 } 2437 }
2456 return v11 + v5 + v2; 2438 return v11 + v5 + v2;
2457 } 2439 }
2458 2440
2459 //----- (00438B9B) -------------------------------------------------------- 2441 //----- (00438B9B) --------------------------------------------------------
2460 char Actor::_438B9B() 2442 bool Actor::IsPeasant()
2461 { 2443 {
2462 unsigned int v1; // eax@1 2444 unsigned int v1; // eax@1
2463 2445
2464 v1 = this->uAlly; 2446 v1 = this->uAlly;
2465 if ( !v1 ) 2447 if ( !v1 )
2508 return result; 2490 return result;
2509 } 2491 }
2510 2492
2511 2493
2512 //----- (00403A60) -------------------------------------------------------- 2494 //----- (00403A60) --------------------------------------------------------
2513 unsigned int __fastcall Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir) 2495 void Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir)
2514 { 2496 {
2515 Actor *v3; // ebx@1 2497 Actor *v3; // ebx@1
2516 AIDirection *v4; // esi@3 2498 AIDirection *v4; // esi@3
2517 AIDirection *v5; // edi@3 2499 AIDirection *v5; // edi@3
2518 signed int v6; // eax@4 2500 signed int v6; // eax@4
2519 Vec3_int_ v7; // ST04_12@6 2501 Vec3_int_ v7; // ST04_12@6
2520 unsigned int result; // eax@7 2502 //unsigned int result; // eax@7
2521 AIDirection *v9; // eax@8 2503 AIDirection *v9; // eax@8
2522 unsigned int v10; // esi@8 2504 unsigned int v10; // esi@8
2523 AIDirection *v11; // esi@9 2505 AIDirection *v11; // esi@9
2524 SpriteFrame *v12; // ecx@10 2506 SpriteFrame *v12; // ecx@10
2525 __int16 v13; // ax@10 2507 __int16 v13; // ax@10
2603 if ( sub_42FB5C(v16) ) 2585 if ( sub_42FB5C(v16) )
2604 { 2586 {
2605 v3->uCurrentActionLength = 64; 2587 v3->uCurrentActionLength = 64;
2606 v3->uCurrentActionTime = v10; 2588 v3->uCurrentActionTime = v10;
2607 v3->uAIState = Fidgeting; 2589 v3->uAIState = Fidgeting;
2608 result = v3->UpdateAnimation(); 2590 v3->UpdateAnimation();
2609 v3->uAIState = AttackingRanged4; 2591 v3->uAIState = AttackingRanged4;
2610 } 2592 }
2611 else 2593 else
2612 { 2594 v3->UpdateAnimation();
2613 result = v3->UpdateAnimation();
2614 }
2615 } 2595 }
2616 else 2596 else
2617 { 2597 Actor::_402AD7(v22, a2, v22, 64, pDir);
2618 result = Actor::_402AD7(v22, a2, v22, 64, pDir);
2619 }
2620 return result;
2621 } 2598 }
2622 2599
2623 2600
2624 //----- (00403854) -------------------------------------------------------- 2601 //----- (00403854) --------------------------------------------------------
2625 unsigned int __fastcall Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir) 2602 void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir)
2626 { 2603 {
2627 Actor *v3; // ebx@1 2604 Actor *v3; // ebx@1
2628 AIDirection *v4; // esi@3 2605 AIDirection *v4; // esi@3
2629 AIDirection *v5; // edi@3 2606 AIDirection *v5; // edi@3
2630 signed int v6; // eax@4 2607 signed int v6; // eax@4
2631 Vec3_int_ v7; // ST04_12@6 2608 Vec3_int_ v7; // ST04_12@6
2632 unsigned int result; // eax@7 2609 //unsigned int result; // eax@7
2633 AIDirection *v9; // eax@8 2610 AIDirection *v9; // eax@8
2634 unsigned int v10; // esi@8 2611 unsigned int v10; // esi@8
2635 AIDirection *v11; // esi@9 2612 AIDirection *v11; // esi@9
2636 SpriteFrame *v12; // ecx@10 2613 SpriteFrame *v12; // ecx@10
2637 __int16 v13; // ax@10 2614 __int16 v13; // ax@10
2715 if ( sub_42FB5C(v16) ) 2692 if ( sub_42FB5C(v16) )
2716 { 2693 {
2717 v3->uCurrentActionLength = 64; 2694 v3->uCurrentActionLength = 64;
2718 v3->uCurrentActionTime = v10; 2695 v3->uCurrentActionTime = v10;
2719 v3->uAIState = Fidgeting; 2696 v3->uAIState = Fidgeting;
2720 result = v3->UpdateAnimation(); 2697 v3->UpdateAnimation();
2721 v3->uAIState = AttackingRanged3; 2698 v3->uAIState = AttackingRanged3;
2722 } 2699 }
2723 else 2700 else
2724 { 2701 v3->UpdateAnimation();
2725 result = v3->UpdateAnimation();
2726 }
2727 } 2702 }
2728 else 2703 else
2729 { 2704 Actor::_402AD7(v22, a2, v22, 64, pDir);
2730 result = Actor::_402AD7(v22, a2, v22, 64, pDir);
2731 }
2732 return result;
2733 } 2705 }
2734 2706
2735 2707
2736 //----- (0040368B) -------------------------------------------------------- 2708 //----- (0040368B) --------------------------------------------------------
2737 unsigned int __fastcall Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir) 2709 void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir)
2738 { 2710 {
2739 Actor *v3; // ebx@1 2711 Actor *v3; // ebx@1
2740 AIDirection *v4; // esi@3 2712 AIDirection *v4; // esi@3
2741 AIDirection *v5; // edi@3 2713 AIDirection *v5; // edi@3
2742 signed int v6; // eax@4 2714 signed int v6; // eax@4
2743 Vec3_int_ v7; // ST04_12@6 2715 Vec3_int_ v7; // ST04_12@6
2744 unsigned int result; // eax@7 2716 //unsigned int result; // eax@7
2745 AIDirection *v9; // eax@8 2717 AIDirection *v9; // eax@8
2746 unsigned int v10; // esi@8 2718 unsigned int v10; // esi@8
2747 AIDirection *v11; // esi@9 2719 AIDirection *v11; // esi@9
2748 SpriteFrame *v12; // ecx@10 2720 SpriteFrame *v12; // ecx@10
2749 __int16 v13; // ax@10 2721 __int16 v13; // ax@10
2816 v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333); 2788 v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333);
2817 v3->pMonsterInfo.uRecoveryTime = v15; 2789 v3->pMonsterInfo.uRecoveryTime = v15;
2818 v3->vVelocity.z = v10; 2790 v3->vVelocity.z = v10;
2819 v3->vVelocity.y = v10; 2791 v3->vVelocity.y = v10;
2820 v3->vVelocity.x = v10; 2792 v3->vVelocity.x = v10;
2821 result = v3->UpdateAnimation(); 2793 v3->UpdateAnimation();
2822 } 2794 }
2823 else 2795 else
2824 { 2796 Actor::_402AD7(v21, a2, v21, 64, pDir);
2825 result = Actor::_402AD7(v21, a2, v21, 64, pDir);
2826 }
2827 return result;
2828 } 2797 }
2829 2798
2830 2799
2831 //----- (00403476) -------------------------------------------------------- 2800 //----- (00403476) --------------------------------------------------------
2832 unsigned int __fastcall Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir) 2801 void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
2833 { 2802 {
2834 Actor *v3; // ebx@1 2803 Actor *v3; // ebx@1
2835 int v4; // esi@3 2804 int v4; // esi@3
2836 int v5; // edi@3 2805 int v5; // edi@3
2837 signed int v6; // eax@4 2806 signed int v6; // eax@4
2838 Vec3_int_ v7; // ST04_12@6 2807 Vec3_int_ v7; // ST04_12@6
2839 unsigned char v8[12]; // ST04_12@7 2808 unsigned char v8[12]; // ST04_12@7
2840 unsigned int result; // eax@8 2809 //unsigned int result; // eax@8
2841 AIDirection *v10; // eax@9 2810 AIDirection *v10; // eax@9
2842 unsigned int v11; // esi@9 2811 unsigned int v11; // esi@9
2843 AIDirection *v12; // esi@10 2812 AIDirection *v12; // esi@10
2844 SpriteFrame *v13; // ecx@11 2813 SpriteFrame *v13; // ecx@11
2845 __int16 v14; // ax@11 2814 __int16 v14; // ax@11
2924 * (double)(signed int)pDira 2893 * (double)(signed int)pDira
2925 * -2.133333333333333); 2894 * -2.133333333333333);
2926 v3->vVelocity.z = v11; 2895 v3->vVelocity.z = v11;
2927 v3->vVelocity.y = v11; 2896 v3->vVelocity.y = v11;
2928 v3->vVelocity.x = v11; 2897 v3->vVelocity.x = v11;
2929 result = v3->UpdateAnimation(); 2898 v3->UpdateAnimation();
2930 } 2899 }
2931 else 2900 else
2932 { 2901 Actor::_402AD7(v21, a2, v21, 64, pDir);
2933 result = Actor::_402AD7(v21, a2, v21, 64, pDir);
2934 }
2935 return result;
2936 } 2902 }
2937 2903
2938 //----- (004032B2) -------------------------------------------------------- 2904 //----- (004032B2) --------------------------------------------------------
2939 void __fastcall Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength) 2905 void Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
2940 { 2906 {
2941 unsigned int v4; // edi@1 2907 unsigned int v4; // edi@1
2942 Actor *v5; // esi@1 2908 Actor *v5; // esi@1
2943 int v6; // ebx@1 2909 int v6; // ebx@1
2944 int v7; // ST08_4@1 2910 int v7; // ST08_4@1
3070 return (char)v5; 3036 return (char)v5;
3071 } 3037 }
3072 3038
3073 3039
3074 //----- (004030AD) -------------------------------------------------------- 3040 //----- (004030AD) --------------------------------------------------------
3075 __int16 __fastcall Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0) 3041 void Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0)
3076 { 3042 {
3077 unsigned int v3; // edi@1 3043 unsigned int v3; // edi@1
3078 Actor *v4; // ebx@1 3044 Actor *v4; // ebx@1
3079 __int16 result; // ax@10 3045 //__int16 result; // ax@10
3080 SpriteFrame *v6; // ecx@16 3046 SpriteFrame *v6; // ecx@16
3081 __int16 v7; // ax@16 3047 __int16 v7; // ax@16
3082 unsigned int v8; // ecx@16 3048 unsigned int v8; // ecx@16
3083 AIDirection a3; // [sp+Ch] [bp-40h]@16 3049 AIDirection a3; // [sp+Ch] [bp-40h]@16
3084 AIDirection v10; // [sp+28h] [bp-24h]@16 3050 AIDirection v10; // [sp+28h] [bp-24h]@16
3099 if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 ) 3065 if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 )
3100 v4->pActorBuffs[1].Reset(); 3066 v4->pActorBuffs[1].Reset();
3101 if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 ) 3067 if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
3102 v4->pActorBuffs[4].Reset(); 3068 v4->pActorBuffs[4].Reset();
3103 if ( arg0 3069 if ( arg0
3104 || (result = v4->uAIState, result != 8) 3070 || (v4->uAIState != 8
3105 && result != 3 3071 && v4->uAIState != 3
3106 && result != 12 3072 && v4->uAIState != 12
3107 && result != 13 3073 && v4->uAIState != 13
3108 && result != 18 3074 && v4->uAIState != 18
3109 && result != 2 ) 3075 && v4->uAIState != 2))
3110 { 3076 {
3111 memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10)); 3077 memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10));
3112 v6 = pSpriteFrameTable->pSpriteSFrames; 3078 v6 = pSpriteFrameTable->pSpriteSFrames;
3113 v4->uYawAngle = LOWORD(v10.uYawAngle); 3079 v4->uYawAngle = LOWORD(v10.uYawAngle);
3114 v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength; 3080 v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
3115 v8 = v11; 3081 v8 = v11;
3116 v4->uCurrentActionTime = 0; 3082 v4->uCurrentActionTime = 0;
3117 v4->uAIState = Stunned; 3083 v4->uAIState = Stunned;
3118 v4->uCurrentActionLength = 8 * v7; 3084 v4->uCurrentActionLength = 8 * v7;
3119 Actor::PlaySound(v8, 2u); 3085 Actor::PlaySound(v8, 2u);
3120 result = v4->UpdateAnimation(); 3086 v4->UpdateAnimation();
3121 } 3087 }
3122 return result;
3123 } 3088 }
3124 3089
3125 //----- (00402F87) -------------------------------------------------------- 3090 //----- (00402F87) --------------------------------------------------------
3126 int __fastcall Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) 3091 void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
3127 { 3092 {
3128 int v3; // edi@1 3093 int v3; // edi@1
3129 AIDirection *v4; // esi@1 3094 AIDirection *v4; // esi@1
3130 Actor *v5; // ebx@1 3095 Actor *v5; // ebx@1
3131 SpriteFrame *v6; // ecx@3 3096 SpriteFrame *v6; // ecx@3
3132 unsigned int v7; // eax@3 3097 unsigned int v7; // eax@3
3133 int v8; // edx@3 3098 int v8; // edx@3
3134 unsigned int v9; // eax@3 3099 unsigned int v9; // eax@3
3135 int result; // eax@4 3100 //int result; // eax@4
3136 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 3101 AIDirection a3; // [sp+Ch] [bp-5Ch]@2
3137 AIDirection v12; // [sp+28h] [bp-40h]@2 3102 AIDirection v12; // [sp+28h] [bp-40h]@2
3138 AIDirection v13; // [sp+44h] [bp-24h]@2 3103 AIDirection v13; // [sp+44h] [bp-24h]@2
3139 unsigned int v14; // [sp+60h] [bp-8h]@1 3104 unsigned int v14; // [sp+60h] [bp-8h]@1
3140 unsigned int v15; // [sp+64h] [bp-4h]@1 3105 unsigned int v15; // [sp+64h] [bp-4h]@1
3157 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); 3122 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y);
3158 LOWORD(v8) = v5->uYawAngle; 3123 LOWORD(v8) = v5->uYawAngle;
3159 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; 3124 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
3160 if ( BYTE1(v9) & 7 ) 3125 if ( BYTE1(v9) & 7 )
3161 { 3126 {
3162 result = Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4); 3127 Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4);
3163 } 3128 }
3164 else 3129 else
3165 { 3130 {
3166 v5->uAIState = Fidgeting; 3131 v5->uAIState = Fidgeting;
3167 v5->uCurrentActionTime = 0; 3132 v5->uCurrentActionTime = 0;
3168 v5->vVelocity.z = 0; 3133 v5->vVelocity.z = 0;
3169 v5->vVelocity.y = 0; 3134 v5->vVelocity.y = 0;
3170 v5->vVelocity.x = 0; 3135 v5->vVelocity.x = 0;
3171 if ( rand() % 100 < 5 ) 3136 if ( rand() % 100 < 5 )
3172 Actor::PlaySound(v3, 3u); 3137 Actor::PlaySound(v3, 3u);
3173 result = v5->UpdateAnimation(); 3138 v5->UpdateAnimation();
3174 } 3139 }
3175 return result;
3176 } 3140 }
3177 3141
3178 //----- (00402F27) -------------------------------------------------------- 3142 //----- (00402F27) --------------------------------------------------------
3179 unsigned int __fastcall Actor::Resurrect(unsigned int uActorID) 3143 void Actor::Resurrect(unsigned int uActorID)
3180 { 3144 {
3181 Actor *pActor; // esi@1 3145 Actor *pActor; // esi@1
3182 SpriteFrame *v2; // edx@1 3146 SpriteFrame *v2; // edx@1
3183 int v3; // eax@1 3147 int v3; // eax@1
3184 3148
3189 pActor->uAIState = Resurrected; 3153 pActor->uAIState = Resurrected;
3190 pActor->uCurrentActionAnimation = ANIM_Dying; 3154 pActor->uCurrentActionAnimation = ANIM_Dying;
3191 pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength; 3155 pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength;
3192 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); 3156 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP);
3193 Actor::PlaySound(uActorID, 1u); 3157 Actor::PlaySound(uActorID, 1u);
3194 return pActor->UpdateAnimation(); 3158 pActor->UpdateAnimation();
3195 } 3159 }
3196 3160
3197 3161
3198 //----- (00402D6E) -------------------------------------------------------- 3162 //----- (00402D6E) --------------------------------------------------------
3199 void Actor::Die(unsigned int uActorID) 3163 void Actor::Die(unsigned int uActorID)
3257 if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE) 3221 if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE)
3258 Actor::Explode(uActorID); 3222 Actor::Explode(uActorID);
3259 } 3223 }
3260 3224
3261 //----- (00402CED) -------------------------------------------------------- 3225 //----- (00402CED) --------------------------------------------------------
3262 void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) 3226 void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID)
3263 { 3227 {
3264 Actor *v2; // eax@1 3228 Actor *v2; // eax@1
3265 unsigned __int16 v3; // dx@1 3229 unsigned __int16 v3; // dx@1
3266 int v4; // eax@3 3230 int v4; // eax@3
3267 int v5; // eax@4 3231 int v5; // eax@4
3319 } 3283 }
3320 } 3284 }
3321 3285
3322 3286
3323 //----- (00402AD7) -------------------------------------------------------- 3287 //----- (00402AD7) --------------------------------------------------------
3324 unsigned int __fastcall Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) 3288 void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
3325 { 3289 {
3326 unsigned int v5; // edi@1 3290 unsigned int v5; // edi@1
3327 int v6; // eax@1 3291 int v6; // eax@1
3328 Actor *v7; // ebx@1 3292 Actor *v7; // ebx@1
3329 unsigned int v8; // ecx@1 3293 unsigned int v8; // ecx@1
3362 } 3326 }
3363 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) 3327 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
3364 { 3328 {
3365 if ( !uActionLength ) 3329 if ( !uActionLength )
3366 uActionLength = 256; 3330 uActionLength = 256;
3367 return Actor::_403F58(v5, 4, uActionLength, v10); 3331 Actor::_403F58(v5, 4, uActionLength, v10);
3332 return;
3368 } 3333 }
3369 if ( (double)(signed int)v10->uDistance < 307.2 ) 3334 if ( (double)(signed int)v10->uDistance < 307.2 )
3370 { 3335 {
3371 if ( !uActionLength ) 3336 if ( !uActionLength )
3372 uActionLength = 256; 3337 uActionLength = 256;
3373 return Actor::_403EB6(v5, v18, uActionLength, v10); 3338 Actor::_403EB6(v5, v18, uActionLength, v10);
3339 return;
3374 } 3340 }
3375 if ( !v7->uMovementSpeed ) 3341 if ( !v7->uMovementSpeed )
3376 return Actor::_403EB6(v5, v18, uActionLength, v10); 3342 {
3343 Actor::_403EB6(v5, v18, uActionLength, v10);
3344 return;
3345 }
3377 v18 = 16; 3346 v18 = 16;
3378 if ( arg0 % 2 ) 3347 if ( arg0 % 2 )
3379 v18 = -16; 3348 v18 = -16;
3380 v12 = ((unsigned __int64)(stru_5C6E00->SinCos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle) 3349 v12 = ((unsigned __int64)(stru_5C6E00->SinCos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle)
3381 * (signed __int64)v10->uDistanceXZ) >> 16) 3350 * (signed __int64)v10->uDistanceXZ) >> 16)
3392 v7->uCurrentActionLength = uActionLength; 3361 v7->uCurrentActionLength = uActionLength;
3393 else 3362 else
3394 v7->uCurrentActionLength = 128; 3363 v7->uCurrentActionLength = 128;
3395 v7->uPitchAngle = LOWORD(v10->uPitchAngle); 3364 v7->uPitchAngle = LOWORD(v10->uPitchAngle);
3396 v7->uAIState = Pursuing; 3365 v7->uAIState = Pursuing;
3397 return v7->UpdateAnimation(); 3366 v7->UpdateAnimation();
3398 } 3367 }
3399 3368
3400 //----- (00402968) -------------------------------------------------------- 3369 //----- (00402968) --------------------------------------------------------
3401 unsigned int __fastcall Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4) 3370 void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4)
3402 { 3371 {
3403 unsigned int v4; // esi@1 3372 unsigned int v4; // esi@1
3404 Actor *v5; // ebx@1 3373 Actor *v5; // ebx@1
3405 unsigned int result; // eax@1 3374 //unsigned int result; // eax@1
3406 int v7; // ecx@2 3375 int v7; // ecx@2
3407 signed __int16 v8; // cx@10 3376 signed __int16 v8; // cx@10
3408 unsigned __int16 v9; // ax@15 3377 unsigned __int16 v9; // ax@15
3409 AIDirection v10; // [sp+8h] [bp-7Ch]@4 3378 AIDirection v10; // [sp+8h] [bp-7Ch]@4
3410 AIDirection a3; // [sp+24h] [bp-60h]@3 3379 AIDirection a3; // [sp+24h] [bp-60h]@3
3416 3385
3417 v4 = uActorID; 3386 v4 = uActorID;
3418 a2 = edx0; 3387 a2 = edx0;
3419 v15 = uActorID; 3388 v15 = uActorID;
3420 v5 = &pActors[uActorID]; 3389 v5 = &pActors[uActorID];
3421 result = pActors[uActorID].CanAct(); 3390 //result = pActors[uActorID].CanAct();
3422 if ( result ) 3391 if ( pActors[uActorID].CanAct() )
3423 { 3392 {
3424 v7 = 8 * v4 | 3; 3393 v7 = 8 * v4 | 3;
3425 a1 = 8 * v4 | 3; 3394 a1 = 8 * v4 | 3;
3426 if ( !a4 ) 3395 if ( !a4 )
3427 { 3396 {
3434 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) 3403 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)
3435 || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) 3404 || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
3436 { 3405 {
3437 if ( !uActionLength ) 3406 if ( !uActionLength )
3438 uActionLength = 256; 3407 uActionLength = 256;
3439 result = Actor::_403F58(v15, 4, uActionLength, &v13); 3408 Actor::_403F58(v15, 4, uActionLength, &v13);
3440 } 3409 }
3441 else 3410 else
3442 { 3411 {
3443 v8 = v5->uMovementSpeed; 3412 v8 = v5->uMovementSpeed;
3444 if ( v8 ) 3413 if ( v8 )
3451 v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi); 3420 v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi);
3452 v9 = LOWORD(a4->uPitchAngle); 3421 v9 = LOWORD(a4->uPitchAngle);
3453 v5->uCurrentActionTime = 0; 3422 v5->uCurrentActionTime = 0;
3454 v5->uPitchAngle = v9; 3423 v5->uPitchAngle = v9;
3455 v5->uAIState = Fleeing; 3424 v5->uAIState = Fleeing;
3456 result = v5->UpdateAnimation(); 3425 v5->UpdateAnimation();
3457 } 3426 }
3458 } 3427 }
3459 return result;
3460 } 3428 }
3461 3429
3462 3430
3463 //----- (0040281C) -------------------------------------------------------- 3431 //----- (0040281C) --------------------------------------------------------
3464 int __fastcall Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) 3432 void Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
3465 { 3433 {
3466 unsigned int v5; // edi@1 3434 unsigned int v5; // edi@1
3467 int v6; // eax@1 3435 int v6; // eax@1
3468 Actor *v7; // ebx@1 3436 Actor *v7; // ebx@1
3469 unsigned int v8; // ecx@1 3437 unsigned int v8; // ecx@1
3506 if ( !uActionLength ) 3474 if ( !uActionLength )
3507 uActionLength = 256; 3475 uActionLength = 256;
3508 v16 = v10; 3476 v16 = v10;
3509 v15 = uActionLength; 3477 v15 = uActionLength;
3510 v11 = 4; 3478 v11 = 4;
3511 return Actor::_403F58(v5, v11, v15, v16); 3479 Actor::_403F58(v5, v11, v15, v16);
3480 return;
3512 } 3481 }
3513 if ( (signed int)v10->uDistance < a5 ) 3482 if ( (signed int)v10->uDistance < a5 )
3514 { 3483 {
3515 if ( !uActionLength ) 3484 if ( !uActionLength )
3516 uActionLength = 256; 3485 uActionLength = 256;
3517 v11 = v19; 3486 v11 = v19;
3518 v16 = v10; 3487 v16 = v10;
3519 v15 = uActionLength; 3488 v15 = uActionLength;
3520 return Actor::_403F58(v5, v11, v15, v16); 3489 Actor::_403F58(v5, v11, v15, v16);
3490 return;
3521 } 3491 }
3522 if ( uActionLength ) 3492 if ( uActionLength )
3523 { 3493 {
3524 v7->uCurrentActionLength = uActionLength; 3494 v7->uCurrentActionLength = uActionLength;
3525 } 3495 }
3536 v7->uYawAngle = LOWORD(v10->uYawAngle); 3506 v7->uYawAngle = LOWORD(v10->uYawAngle);
3537 v14 = LOWORD(v10->uPitchAngle); 3507 v14 = LOWORD(v10->uPitchAngle);
3538 v7->uCurrentActionTime = 0; 3508 v7->uCurrentActionTime = 0;
3539 v7->uPitchAngle = v14; 3509 v7->uPitchAngle = v14;
3540 v7->uAIState = Pursuing; 3510 v7->uAIState = Pursuing;
3541 return v7->UpdateAnimation(); 3511 v7->UpdateAnimation();
3542 } 3512 }
3543 3513
3544 3514
3545 //----- (00402686) -------------------------------------------------------- 3515 //----- (00402686) --------------------------------------------------------
3546 unsigned int __fastcall Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) 3516 void Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
3547 { 3517 {
3548 unsigned int v4; // edi@1 3518 unsigned int v4; // edi@1
3549 int v5; // eax@1 3519 int v5; // eax@1
3550 Actor *v6; // ebx@1 3520 Actor *v6; // ebx@1
3551 int v7; // ecx@1 3521 int v7; // ecx@1
3629 v6->uCurrentActionTime = 0; 3599 v6->uCurrentActionTime = 0;
3630 v6->uPitchAngle = v16; 3600 v6->uPitchAngle = v16;
3631 v6->uAIState = Pursuing; 3601 v6->uAIState = Pursuing;
3632 if ( rand() % 100 < 2 ) 3602 if ( rand() % 100 < 2 )
3633 Actor::PlaySound(v4, 2u); 3603 Actor::PlaySound(v4, 2u);
3634 return v6->UpdateAnimation(); 3604 v6->UpdateAnimation();
3635 } 3605 }
3636 3606
3637 //----- (00401221) -------------------------------------------------------- 3607 //----- (00401221) --------------------------------------------------------
3638 void __fastcall Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) 3608 void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3)
3639 { 3609 {
3640 Actor *v3; // esi@1 3610 Actor *v3; // esi@1
3641 unsigned int v4; // ebx@1 3611 unsigned int v4; // ebx@1
3642 int v5; // ecx@1 3612 int v5; // ecx@1
3643 unsigned int v6; // eax@1 3613 unsigned int v6; // eax@1
3911 return 0; 3881 return 0;
3912 } 3882 }
3913 3883
3914 3884
3915 //----- (0045976D) -------------------------------------------------------- 3885 //----- (0045976D) --------------------------------------------------------
3916 unsigned int Actor::UpdateAnimation() 3886 void Actor::UpdateAnimation()
3917 { 3887 {
3918 AIState state; // edx@1 3888 //AIState state; // edx@1
3919 unsigned int result; // eax@1 3889 //unsigned int result; // eax@1
3920 3890
3921 state = (AIState)this->uAIState; 3891 //state = (AIState)this->;
3922 BYTE2(this->uAttributes) &= 0xDFu; 3892 uAttributes &= 0xFFDFFFFF;
3923 result = this->uAttributes; 3893 //result = this->uAttributes;
3924 switch ( state ) 3894 switch (uAIState)
3925 { 3895 {
3926 case Tethered: 3896 case Tethered:
3927 this->uCurrentActionAnimation = ANIM_Walking; 3897 uCurrentActionAnimation = ANIM_Walking;
3928 return result; 3898 break;
3899
3929 case AttackingMelee: 3900 case AttackingMelee:
3930 this->uCurrentActionAnimation = ANIM_AtkMelee; 3901 uCurrentActionAnimation = ANIM_AtkMelee;
3931 goto LABEL_10; 3902 uAttributes |= 0x200000u;
3903 break;
3904
3932 case AttackingRanged1: 3905 case AttackingRanged1:
3933 case AttackingRanged2: 3906 case AttackingRanged2:
3934 case AttackingRanged3: 3907 case AttackingRanged3:
3935 case AttackingRanged4: 3908 case AttackingRanged4:
3936 this->uCurrentActionAnimation = ANIM_AtkRanged; 3909 uCurrentActionAnimation = ANIM_AtkRanged;
3937 goto LABEL_10; 3910 uAttributes |= 0x200000u;
3911 break;
3912
3938 case Dying: 3913 case Dying:
3939 case Resurrected: 3914 case Resurrected:
3940 this->uCurrentActionAnimation = ANIM_Dying; 3915 uCurrentActionAnimation = ANIM_Dying;
3941 goto LABEL_10; 3916 uAttributes |= 0x200000u;
3917 break;
3918
3942 case Pursuing: 3919 case Pursuing:
3943 case Fleeing: 3920 case Fleeing:
3944 this->uCurrentActionAnimation = ANIM_Walking; 3921 uCurrentActionAnimation = ANIM_Walking;
3945 goto LABEL_10; 3922 uAttributes |= 0x200000u;
3923 break;
3924
3946 case Stunned: 3925 case Stunned:
3947 this->uCurrentActionAnimation = ANIM_GotHit; 3926 uCurrentActionAnimation = ANIM_GotHit;
3948 goto LABEL_10; 3927 uAttributes |= 0x200000u;
3928 break;
3929
3949 case Fidgeting: 3930 case Fidgeting:
3950 this->uCurrentActionAnimation = ANIM_Bored; 3931 uCurrentActionAnimation = ANIM_Bored;
3951 goto LABEL_10; 3932 uAttributes |= 0x200000u;
3933 break;
3934
3952 case Standing: 3935 case Standing:
3953 case Interacting: 3936 case Interacting:
3954 case Summoned: 3937 case Summoned:
3955 this->uCurrentActionAnimation = ANIM_Standing; 3938 uCurrentActionAnimation = ANIM_Standing;
3956 LABEL_10: 3939 uAttributes |= 0x200000u;
3957 result |= 0x200000u; 3940 break;
3958 this->uAttributes = result; 3941
3959 break;
3960 case Dead: 3942 case Dead:
3961 result = 60 * this->pSpriteIDs[ANIM_Dead]; 3943 if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0)
3962 if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 ) 3944 uAIState = Removed;
3963 this->uAIState = Removed;
3964 else 3945 else
3965 this->uCurrentActionAnimation = ANIM_Dead; 3946 uCurrentActionAnimation = ANIM_Dead;
3966 break; 3947 break;
3948
3967 default: 3949 default:
3968 return result; 3950 assert(false);
3969 } 3951 }
3970 return result;
3971 } 3952 }
3972 3953
3973 //----- (00459671) -------------------------------------------------------- 3954 //----- (00459671) --------------------------------------------------------
3974 void Actor::Reset() 3955 void Actor::Reset()
3975 { 3956 {