Mercurial > mm7
changeset 322:ce39b96acf5c
Killing friendly peasants subs
author | Nomad |
---|---|
date | Wed, 20 Feb 2013 04:36:14 +0200 |
parents | 15decc249a94 |
children | d720a13e2273 875ba5966ceb |
files | Actor.cpp Actor.h AudioPlayer.cpp Indoor.cpp Party.cpp Player.cpp TurnEngine.h mm7_2.cpp mm7_3.cpp mm7_5.cpp mm7_data.h |
diffstat | 11 files changed, 243 insertions(+), 266 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/Actor.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -1,3 +1,5 @@ +#include <assert.h> + #include "Actor.h" #include "LayingItem.h" #include "Math.h" @@ -1404,7 +1406,7 @@ //----- (0043ABB0) -------------------------------------------------------- -bool Actor::_43ABB0(Actor *a1, Actor *a2) +bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) { unsigned int v2; // esi@1 unsigned int v3; // edi@1 @@ -1427,50 +1429,34 @@ } //----- (0043AC45) -------------------------------------------------------- -void Actor::_43AC45(unsigned int uActorID, int a2) +void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2) { - Actor *v2; // esi@1 - Actor *v3; // edi@4 int v4; // ebx@8 int v5; // ST1C_4@8 int v6; // eax@8 - int v7; // [sp+4h] [bp-10h]@1 - unsigned int uActorID_; // [sp+Ch] [bp-8h]@1 - signed int v9; // [sp+10h] [bp-4h]@3 - uActorID_ = uActorID; - v2 = &pActors[uActorID]; - v7 = a2; + auto victim = pActors + uActorID; if ( a2 == 1 ) - BYTE2(v2->uAttributes) |= 8u; - v9 = 0; - if ( (signed int)uNumActors > 0 ) + BYTE2(victim->uAttributes) |= 8u; + + for (uint i = 0; i < uNumActors; ++i) { - v3 = pActors; - do + auto actor = pActors + i; + if (!actor->CanAct() || i == uActorID) + continue; + + if (Actor::ArePeasantsOfSameFaction(victim, actor)) { - if ( v3->CanAct() ) + v4 = abs(actor->vPosition.x - victim->vPosition.x); + v5 = abs(actor->vPosition.y - victim->vPosition.y); + v6 = abs(actor->vPosition.z - victim->vPosition.z); + if (int_get_vector_length(v4, v5, v6) < 4096) { - if ( v9 != uActorID_ ) - { - if ( Actor::_43ABB0(v2, v3) ) - { - v4 = abs(v3->vPosition.x - v2->vPosition.x); - v5 = abs(v3->vPosition.y - v2->vPosition.y); - v6 = abs(v3->vPosition.z - v2->vPosition.z); - if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 ) - { - v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4; - if ( v7 == 1 ) - BYTE2(v3->uAttributes) |= 8u; - } - } - } + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + if ( a2 == 1 ) + BYTE2(actor->uAttributes) |= 8u; } - ++v9; - ++v3; } - while ( v9 < (signed int)uNumActors ); } } @@ -1958,11 +1944,11 @@ //----- (00404030) -------------------------------------------------------- -unsigned int __fastcall Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) +void Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) { unsigned int v4; // edi@1 unsigned int v5; // esi@1 - unsigned int result; // eax@2 + //unsigned int result; // eax@2 AIDirection *v7; // eax@3 unsigned int v8; // ecx@3 Actor *v9; // ebx@3 @@ -1994,20 +1980,17 @@ v9->uPitchAngle = v11; v9->uCurrentActionLength = 256; v9->uAIState = Interacting; - result = v9->UpdateAnimation(); + v9->UpdateAnimation(); } else - { - result = Actor::_402F87(v5, v4, a4); - } - return result; + Actor::_402F87(v5, v4, a4); } //----- (00403F58) -------------------------------------------------------- -unsigned int __fastcall Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) +void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) { unsigned int v4; // esi@1 - unsigned int result; // eax@2 + //unsigned int result; // eax@2 AIDirection *v6; // eax@3 unsigned int v7; // edi@3 Actor *v8; // ebx@3 @@ -2020,10 +2003,10 @@ v4 = uActorID; if ( rand() % 2 ) { - result = Actor::_402F87(v4, a2, a4); + Actor::_402F87(v4, a2, a4); + return; } - else - { + v6 = a4; v7 = 0; v8 = &pActors[v4]; @@ -2045,15 +2028,13 @@ v8->vVelocity.z = v7; v8->vVelocity.y = v7; v8->vVelocity.x = v7; - result = v8->UpdateAnimation(); - } - return result; + v8->UpdateAnimation(); } //----- (00403EB6) -------------------------------------------------------- -unsigned int __fastcall Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4) +void Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4) { AIDirection *v4; // eax@1 unsigned int v5; // esi@1 @@ -2082,7 +2063,7 @@ v6->vVelocity.z = v5; v6->vVelocity.y = v5; v6->vVelocity.x = v5; - return v6->UpdateAnimation(); + v6->UpdateAnimation(); } @@ -2102,17 +2083,17 @@ } //----- (00403C6C) -------------------------------------------------------- -unsigned int __fastcall Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0) +void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0) { Actor *v3; // ebx@1 char v4; // zf@1 - unsigned int result; // eax@3 + //unsigned int result; // eax@3 AIDirection *v6; // esi@6 AIDirection *v7; // edi@6 signed int v8; // eax@7 double v9; // st7@9 Vec3_int_ v10; // ST04_12@9 - int v11; // eax@10 + //int v11; // eax@10 AIDirection *v12; // eax@11 unsigned int v13; // esi@11 AIDirection *v14; // esi@12 @@ -2134,11 +2115,11 @@ v24 = uActorID; if ( v4 && v3->pMonsterInfo.uAIType == 1 ) { - result = Actor::_403EB6(uActorID, edx0, 0, arg0); + Actor::_403EB6(uActorID, edx0, 0, arg0); + return; } - else - { - if ( (edx0 & 7) == OBJECT_Actor) + + if ( (edx0 & 7) == OBJECT_Actor) { v8 = edx0 >> 3; v6 = (AIDirection *)pActors[v8].vPosition.x; @@ -2198,31 +2179,28 @@ v3->vVelocity.z = v13; v3->vVelocity.y = v13; v3->vVelocity.x = v13; - result = v3->UpdateAnimation(); + v3->UpdateAnimation(); } else - { - v11 = rand(); - result = Actor::_402AD7(v24, a2, v11 % 2, 64, arg0); - } - } - return result; + Actor::_402AD7(v24, a2, rand() % 2, 64, arg0); } //----- (00438CF3) -------------------------------------------------------- -void Actor::_438CF3(unsigned int uActorID) +void Actor::ApplyFineForKillingPeasant(unsigned int uActorID) { unsigned int v1; // esi@1 unsigned int v2; // edi@2 char v3; // bl@3 - char *v4; // ecx@16 - signed int v5; // eax@18 + //char *v4; // ecx@16 + //signed int v5; // eax@18 Player **ppPlayers; // esi@20 v1 = uLevelMapStatsID; - if ( !uLevelMapStatsID || (v2 = uActorID, !pActors[uActorID]._438B9B()) ) + if ( !uLevelMapStatsID || !pActors[uActorID].IsPeasant()) return; + + v2 = uActorID; v3 = 1; if ( v1 != 5 ) { @@ -2243,20 +2221,24 @@ if ( v3 ) { LABEL_12: - pParty->uFine += 100 - * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm - + pActors[v2].pMonsterInfo.uLevel - + GetPartyReputation()); + pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + GetPartyReputation()); if ( pParty->uFine < 0 ) pParty->uFine = 0; if ( pParty->uFine > 4000000 ) pParty->uFine = 4000000; - v4 = (char *)&pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v4 = (char *)&pIndoor->dlv; - v5 = *((int *)v4 + 2); - if ( v5 < 10000 ) - *((int *)v4 + 2) = v5 + 1; + + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + if (pOutdoor->ddm.uReputation < 10000) + pOutdoor->ddm.uReputation++; + } + else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + if (pIndoor->dlv.uReputation < 10000) + pIndoor->dlv.uReputation++; + } + else assert(false); + ppPlayers = &pPlayers[1]; do { @@ -2273,7 +2255,7 @@ //----- (0043AE80) -------------------------------------------------------- -int Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) +void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) { int result; // eax@1 unsigned int v4; // esi@1 @@ -2297,7 +2279,7 @@ v5 = 904; goto LABEL_16; } - return result; + return; case 2: if ( a3 ) { @@ -2308,7 +2290,7 @@ v5 = 905; goto LABEL_16; } - return result; + return; case 3: if ( a3 ) { @@ -2319,7 +2301,7 @@ v5 = 906; goto LABEL_16; } - return result; + return; case 4: if ( a3 ) { @@ -2330,7 +2312,7 @@ v5 = 907; goto LABEL_16; } - return result; + return; case 5: v9 = 4; v8 = 65536; @@ -2376,9 +2358,9 @@ result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9); break; default: - return result; + return; } - return result; + return; } @@ -2457,7 +2439,7 @@ } //----- (00438B9B) -------------------------------------------------------- -char Actor::_438B9B() +bool Actor::IsPeasant() { unsigned int v1; // eax@1 @@ -2510,14 +2492,14 @@ //----- (00403A60) -------------------------------------------------------- -unsigned int __fastcall Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 AIDirection *v5; // edi@3 signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 - unsigned int result; // eax@7 + //unsigned int result; // eax@7 AIDirection *v9; // eax@8 unsigned int v10; // esi@8 AIDirection *v11; // esi@9 @@ -2605,31 +2587,26 @@ v3->uCurrentActionLength = 64; v3->uCurrentActionTime = v10; v3->uAIState = Fidgeting; - result = v3->UpdateAnimation(); + v3->UpdateAnimation(); v3->uAIState = AttackingRanged4; } else - { - result = v3->UpdateAnimation(); - } + v3->UpdateAnimation(); } else - { - result = Actor::_402AD7(v22, a2, v22, 64, pDir); - } - return result; + Actor::_402AD7(v22, a2, v22, 64, pDir); } //----- (00403854) -------------------------------------------------------- -unsigned int __fastcall Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 AIDirection *v5; // edi@3 signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 - unsigned int result; // eax@7 + //unsigned int result; // eax@7 AIDirection *v9; // eax@8 unsigned int v10; // esi@8 AIDirection *v11; // esi@9 @@ -2717,31 +2694,26 @@ v3->uCurrentActionLength = 64; v3->uCurrentActionTime = v10; v3->uAIState = Fidgeting; - result = v3->UpdateAnimation(); + v3->UpdateAnimation(); v3->uAIState = AttackingRanged3; } else - { - result = v3->UpdateAnimation(); - } + v3->UpdateAnimation(); } else - { - result = Actor::_402AD7(v22, a2, v22, 64, pDir); - } - return result; + Actor::_402AD7(v22, a2, v22, 64, pDir); } //----- (0040368B) -------------------------------------------------------- -unsigned int __fastcall Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 AIDirection *v5; // edi@3 signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 - unsigned int result; // eax@7 + //unsigned int result; // eax@7 AIDirection *v9; // eax@8 unsigned int v10; // esi@8 AIDirection *v11; // esi@9 @@ -2818,18 +2790,15 @@ v3->vVelocity.z = v10; v3->vVelocity.y = v10; v3->vVelocity.x = v10; - result = v3->UpdateAnimation(); + v3->UpdateAnimation(); } else - { - result = Actor::_402AD7(v21, a2, v21, 64, pDir); - } - return result; + Actor::_402AD7(v21, a2, v21, 64, pDir); } //----- (00403476) -------------------------------------------------------- -unsigned int __fastcall Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir) { Actor *v3; // ebx@1 int v4; // esi@3 @@ -2837,7 +2806,7 @@ signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 unsigned char v8[12]; // ST04_12@7 - unsigned int result; // eax@8 + //unsigned int result; // eax@8 AIDirection *v10; // eax@9 unsigned int v11; // esi@9 AIDirection *v12; // esi@10 @@ -2926,17 +2895,14 @@ v3->vVelocity.z = v11; v3->vVelocity.y = v11; v3->vVelocity.x = v11; - result = v3->UpdateAnimation(); + v3->UpdateAnimation(); } else - { - result = Actor::_402AD7(v21, a2, v21, 64, pDir); - } - return result; + Actor::_402AD7(v21, a2, v21, 64, pDir); } //----- (004032B2) -------------------------------------------------------- -void __fastcall Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength) +void Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength) { unsigned int v4; // edi@1 Actor *v5; // esi@1 @@ -3072,11 +3038,11 @@ //----- (004030AD) -------------------------------------------------------- -__int16 __fastcall Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0) +void Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0) { unsigned int v3; // edi@1 Actor *v4; // ebx@1 - __int16 result; // ax@10 + //__int16 result; // ax@10 SpriteFrame *v6; // ecx@16 __int16 v7; // ax@16 unsigned int v8; // ecx@16 @@ -3101,12 +3067,12 @@ if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 ) v4->pActorBuffs[4].Reset(); if ( arg0 - || (result = v4->uAIState, result != 8) - && result != 3 - && result != 12 - && result != 13 - && result != 18 - && result != 2 ) + || (v4->uAIState != 8 + && v4->uAIState != 3 + && v4->uAIState != 12 + && v4->uAIState != 13 + && v4->uAIState != 18 + && v4->uAIState != 2)) { memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10)); v6 = pSpriteFrameTable->pSpriteSFrames; @@ -3117,13 +3083,12 @@ v4->uAIState = Stunned; v4->uCurrentActionLength = 8 * v7; Actor::PlaySound(v8, 2u); - result = v4->UpdateAnimation(); + v4->UpdateAnimation(); } - return result; } //----- (00402F87) -------------------------------------------------------- -int __fastcall Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) +void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) { int v3; // edi@1 AIDirection *v4; // esi@1 @@ -3132,7 +3097,7 @@ unsigned int v7; // eax@3 int v8; // edx@3 unsigned int v9; // eax@3 - int result; // eax@4 + //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 @@ -3159,7 +3124,7 @@ v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; if ( BYTE1(v9) & 7 ) { - result = Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4); + Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4); } else { @@ -3170,13 +3135,12 @@ v5->vVelocity.x = 0; if ( rand() % 100 < 5 ) Actor::PlaySound(v3, 3u); - result = v5->UpdateAnimation(); + v5->UpdateAnimation(); } - return result; } //----- (00402F27) -------------------------------------------------------- -unsigned int __fastcall Actor::Resurrect(unsigned int uActorID) +void Actor::Resurrect(unsigned int uActorID) { Actor *pActor; // esi@1 SpriteFrame *v2; // edx@1 @@ -3191,7 +3155,7 @@ pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength; pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); Actor::PlaySound(uActorID, 1u); - return pActor->UpdateAnimation(); + pActor->UpdateAnimation(); } @@ -3259,7 +3223,7 @@ } //----- (00402CED) -------------------------------------------------------- -void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) +void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) { Actor *v2; // eax@1 unsigned __int16 v3; // dx@1 @@ -3321,7 +3285,7 @@ //----- (00402AD7) -------------------------------------------------------- -unsigned int __fastcall Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) +void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) { unsigned int v5; // edi@1 int v6; // eax@1 @@ -3364,16 +3328,21 @@ { if ( !uActionLength ) uActionLength = 256; - return Actor::_403F58(v5, 4, uActionLength, v10); + Actor::_403F58(v5, 4, uActionLength, v10); + return; } if ( (double)(signed int)v10->uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256; - return Actor::_403EB6(v5, v18, uActionLength, v10); + Actor::_403EB6(v5, v18, uActionLength, v10); + return; } if ( !v7->uMovementSpeed ) - return Actor::_403EB6(v5, v18, uActionLength, v10); + { + Actor::_403EB6(v5, v18, uActionLength, v10); + return; + } v18 = 16; if ( arg0 % 2 ) v18 = -16; @@ -3394,15 +3363,15 @@ v7->uCurrentActionLength = 128; v7->uPitchAngle = LOWORD(v10->uPitchAngle); v7->uAIState = Pursuing; - return v7->UpdateAnimation(); + v7->UpdateAnimation(); } //----- (00402968) -------------------------------------------------------- -unsigned int __fastcall Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4) +void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4) { unsigned int v4; // esi@1 Actor *v5; // ebx@1 - unsigned int result; // eax@1 + //unsigned int result; // eax@1 int v7; // ecx@2 signed __int16 v8; // cx@10 unsigned __int16 v9; // ax@15 @@ -3418,8 +3387,8 @@ a2 = edx0; v15 = uActorID; v5 = &pActors[uActorID]; - result = pActors[uActorID].CanAct(); - if ( result ) + //result = pActors[uActorID].CanAct(); + if ( pActors[uActorID].CanAct() ) { v7 = 8 * v4 | 3; a1 = 8 * v4 | 3; @@ -3436,7 +3405,7 @@ { if ( !uActionLength ) uActionLength = 256; - result = Actor::_403F58(v15, 4, uActionLength, &v13); + Actor::_403F58(v15, 4, uActionLength, &v13); } else { @@ -3453,15 +3422,14 @@ v5->uCurrentActionTime = 0; v5->uPitchAngle = v9; v5->uAIState = Fleeing; - result = v5->UpdateAnimation(); + v5->UpdateAnimation(); } } - return result; } //----- (0040281C) -------------------------------------------------------- -int __fastcall Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) +void Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) { unsigned int v5; // edi@1 int v6; // eax@1 @@ -3508,7 +3476,8 @@ v16 = v10; v15 = uActionLength; v11 = 4; - return Actor::_403F58(v5, v11, v15, v16); + Actor::_403F58(v5, v11, v15, v16); + return; } if ( (signed int)v10->uDistance < a5 ) { @@ -3517,7 +3486,8 @@ v11 = v19; v16 = v10; v15 = uActionLength; - return Actor::_403F58(v5, v11, v15, v16); + Actor::_403F58(v5, v11, v15, v16); + return; } if ( uActionLength ) { @@ -3538,12 +3508,12 @@ v7->uCurrentActionTime = 0; v7->uPitchAngle = v14; v7->uAIState = Pursuing; - return v7->UpdateAnimation(); + v7->UpdateAnimation(); } //----- (00402686) -------------------------------------------------------- -unsigned int __fastcall Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) +void Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) { unsigned int v4; // edi@1 int v5; // eax@1 @@ -3631,11 +3601,11 @@ v6->uAIState = Pursuing; if ( rand() % 100 < 2 ) Actor::PlaySound(v4, 2u); - return v6->UpdateAnimation(); + v6->UpdateAnimation(); } //----- (00401221) -------------------------------------------------------- -void __fastcall Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) +void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) { Actor *v3; // esi@1 unsigned int v4; // ebx@1 @@ -3913,61 +3883,72 @@ //----- (0045976D) -------------------------------------------------------- -unsigned int Actor::UpdateAnimation() +void Actor::UpdateAnimation() { - AIState state; // edx@1 - unsigned int result; // eax@1 + //AIState state; // edx@1 + //unsigned int result; // eax@1 - state = (AIState)this->uAIState; - BYTE2(this->uAttributes) &= 0xDFu; - result = this->uAttributes; - switch ( state ) + //state = (AIState)this->; + uAttributes &= 0xFFDFFFFF; + //result = this->uAttributes; + switch (uAIState) { case Tethered: - this->uCurrentActionAnimation = ANIM_Walking; - return result; + uCurrentActionAnimation = ANIM_Walking; + break; + case AttackingMelee: - this->uCurrentActionAnimation = ANIM_AtkMelee; - goto LABEL_10; + uCurrentActionAnimation = ANIM_AtkMelee; + uAttributes |= 0x200000u; + break; + case AttackingRanged1: case AttackingRanged2: case AttackingRanged3: case AttackingRanged4: - this->uCurrentActionAnimation = ANIM_AtkRanged; - goto LABEL_10; + uCurrentActionAnimation = ANIM_AtkRanged; + uAttributes |= 0x200000u; + break; + case Dying: case Resurrected: - this->uCurrentActionAnimation = ANIM_Dying; - goto LABEL_10; + uCurrentActionAnimation = ANIM_Dying; + uAttributes |= 0x200000u; + break; + case Pursuing: case Fleeing: - this->uCurrentActionAnimation = ANIM_Walking; - goto LABEL_10; + uCurrentActionAnimation = ANIM_Walking; + uAttributes |= 0x200000u; + break; + case Stunned: - this->uCurrentActionAnimation = ANIM_GotHit; - goto LABEL_10; + uCurrentActionAnimation = ANIM_GotHit; + uAttributes |= 0x200000u; + break; + case Fidgeting: - this->uCurrentActionAnimation = ANIM_Bored; - goto LABEL_10; + uCurrentActionAnimation = ANIM_Bored; + uAttributes |= 0x200000u; + break; + case Standing: case Interacting: case Summoned: - this->uCurrentActionAnimation = ANIM_Standing; -LABEL_10: - result |= 0x200000u; - this->uAttributes = result; - break; + uCurrentActionAnimation = ANIM_Standing; + uAttributes |= 0x200000u; + break; + case Dead: - result = 60 * this->pSpriteIDs[ANIM_Dead]; - if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 ) - this->uAIState = Removed; + if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0) + uAIState = Removed; else - this->uCurrentActionAnimation = ANIM_Dead; - break; + uCurrentActionAnimation = ANIM_Dead; + break; + default: - return result; + assert(false); } - return result; } //----- (00459671) --------------------------------------------------------
--- a/Actor.h Wed Feb 20 03:35:22 2013 +0200 +++ b/Actor.h Wed Feb 20 04:36:14 2013 +0200 @@ -190,49 +190,49 @@ void Reset(); void Remove(); void PrepareSprites(char load_sounds_if_bit1_set); - unsigned int UpdateAnimation(); + void UpdateAnimation(); signed int GetActorsRelation(Actor *a2); void SetRandomGoldIfTheresNoItem(); bool CanAct(); bool IsNotAlive(); void InitializeDialogue(int bPlayerSaysHello); - char _438B9B(); + bool IsPeasant(); - static void __fastcall _401221(unsigned int uActorID, int *a2, unsigned int a3); - static unsigned int __fastcall _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); - static int __fastcall _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); - static unsigned int __fastcall _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); - static unsigned int __fastcall _402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir); - static void __fastcall PlaySound(unsigned int uActorID, unsigned int uSoundID); + static void _401221(unsigned int uActorID, int *a2, unsigned int a3); + static void _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); + static void _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); + static void _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); + static void _402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir); + static void PlaySound(unsigned int uActorID, unsigned int uSoundID); static void Die(unsigned int uActorID); - static unsigned int __fastcall Resurrect(unsigned int uActorID); - static int __fastcall _402F87(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); - static __int16 __fastcall _4030AD(unsigned int uActorID, signed int edx0, int arg0); + static void Resurrect(unsigned int uActorID); + static void _402F87(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 __fastcall _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); - static unsigned int __fastcall _403476(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static unsigned int __fastcall _40368B(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static unsigned int __fastcall _403854(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static unsigned int __fastcall _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static unsigned int __fastcall _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); + static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); + static void _403476(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); + static void _40368B(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); + static void _403854(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); + static void _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); + static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); static void __fastcall StandAwhile(unsigned int uActorID); - static unsigned int __fastcall _403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, struct AIDirection *a4); - static unsigned int __fastcall _403F58(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); - static unsigned int __fastcall FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4); + static void _403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, struct AIDirection *a4); + static void _403F58(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); static char __fastcall _404874(unsigned int uActorID, struct AIDirection *a2, int a3, char a4); static void __fastcall _404AC7(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel); - static void _43AC45(unsigned int uActorID, int a2); - static bool _43ABB0(Actor *a1, Actor *a2); + static void AggroSurroundingPeasants(unsigned int uActorID, int a2); + static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID); static void GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive); static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle); - static void _438CF3(unsigned int uActorID); + static void ApplyFineForKillingPeasant(unsigned int uActorID); static void DrawHealthBar(Actor *a1, struct GUIWindow *a2); static int _43B3E0_CalcDamage(Actor *a1, signed int a2); - static int AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3); + static void AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3); char pActorName[32];
--- a/AudioPlayer.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/AudioPlayer.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -1197,7 +1197,7 @@ v27 = abs((signed __int64)v26); v28 = abs((signed __int64)v93); v29 = abs((signed __int64)*(float *)&varC); - v90 = sub_4621DA(v29, v28, v27); + v90 = int_get_vector_length(v29, v28, v27); sPlaybackRate = v12; if ( v12 > v25 ) goto LABEL_192; @@ -1208,7 +1208,7 @@ v31 = abs((signed __int64)*(float *)&uVolume); v32 = abs((signed __int64)v93); v33 = abs((signed __int64)*(float *)&varC); - v34 = sub_4621DA(v33, v32, v31); + v34 = int_get_vector_length(v33, v32, v31); v35 = v103 == v34; if ( v103 < v34 ) { @@ -1287,7 +1287,7 @@ v50 = abs((signed __int64)v49); v51 = abs(0); v52 = abs((signed __int64)v99); - if ( sub_4621DA(v52, v51, v50) <= 100 ) + if ( int_get_vector_length(v52, v51, v50) <= 100 ) { AIL_set_3D_position((void *)*(int *)v42, LODWORD(v99), 0.0, LODWORD(uNumRepeatsa)); v53 = -uNumRepeatsa; @@ -1559,7 +1559,7 @@ v23 = abs((signed __int64)v22); v24 = abs(0); v25 = abs((signed __int64)v58); - if ( sub_4621DA(v25, v24, v23) <= 100 ) + if ( int_get_vector_length(v25, v24, v23) <= 100 ) { AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); v26 = -*(float *)&uNumRepeats; @@ -1690,7 +1690,7 @@ v45 = abs(v44->vPosition.z - pParty->vPosition.z); v46 = abs(v44->vPosition.y - pParty->vPosition.y); v47 = abs(v44->vPosition.x - pParty->vPosition.x); - if ( sub_4621DA(v47, v46, v45) <= 8192 ) + if ( int_get_vector_length(v47, v46, v45) <= 8192 ) break; LABEL_89: ++v59; @@ -1772,7 +1772,6 @@ int v5; // ST08_4@1 int v6; // esi@1 int v7; // eax@1 - int result; // eax@2 int v9; // [sp+10h] [bp+8h]@1 v3 = a2; @@ -1780,12 +1779,11 @@ v5 = abs(a3 - pParty->vPosition.z); v6 = abs(v3 - pParty->vPosition.y); v7 = abs(v4 - pParty->vPosition.x); - v9 = sub_4621DA(v7, v6, v5); + v9 = int_get_vector_length(v7, v6, v5); if ( v9 <= 8192 ) - result = 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0); + return 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0); else - result = 0; - return result; + return 0; }
--- a/Indoor.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/Indoor.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -4157,7 +4157,7 @@ v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z); v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); - if ( sub_4621DA(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius + if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius && _46DF1A_collide_against_actor(v54, 40) ) ++v58; v22 = 0;
--- a/Party.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/Party.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -805,7 +805,7 @@ v1 = abs(v0->vPosition.x - pParty->vPosition.x); v2 = abs(v0->vPosition.y - pParty->vPosition.y); v3 = abs(v0->vPosition.z - pParty->vPosition.z); - if ( (double)sub_4621DA(v1, v2, v3) < 512.0 ) + if (int_get_vector_length(v1, v2, v3) < 512) Actor::_402968(v4, 4, 0, 0); } ++v4;
--- a/Player.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/Player.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -3509,7 +3509,7 @@ v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) ) { - Actor::_43AC45(uActorID, 1); + Actor::AggroSurroundingPeasants(uActorID, 1); _steal_perma = 0; v26 = (int)v31->pName; v25 = pGlobalTXT_LocalizationStrings[376];
--- a/TurnEngine.h Wed Feb 20 03:35:22 2013 +0200 +++ b/TurnEngine.h Wed Feb 20 04:36:14 2013 +0200 @@ -27,8 +27,8 @@ int _4063A1(); int _406457(int a2); void _40652A(); - __int16 _4065B0(); - __int16 _406648(unsigned int a2); + void _4065B0(); + void _406648(unsigned int a2); __int16 _40680F(int a2); void _406A63(); void _406AFE();
--- a/mm7_2.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/mm7_2.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -8401,7 +8401,7 @@ { v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y); v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x); - if ( sub_4621DA(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 ) + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 ) break; ++v23; ++v8; @@ -11466,7 +11466,7 @@ //----- (004621DA) -------------------------------------------------------- -int __fastcall sub_4621DA(signed int a1, signed int a2, signed int a3) +int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3) { signed int v3; // eax@2 signed int v4; // eax@3
--- a/mm7_3.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/mm7_3.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -6231,7 +6231,7 @@ v19 = v4 * v6 - v3 * v21; v7 = abs(v4); v8 = abs(v3); - v9 = sub_4621DA(v8, v7, 0); + v9 = int_get_vector_length(v8, v7, 0); v10 = v14 * 188; v22 = v9; *v16 = 0; @@ -14490,7 +14490,7 @@ pY = pOutdoor->pBModels[v4].vBoundingCenter.y - v20; v5 = abs((signed)pY); v6 = abs((signed)pX); - v7 = sub_4621DA(v6, v5, v2); + v7 = int_get_vector_length(v6, v5, v2); v8 = &pOutdoor->pBModels[0]; if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius ) { @@ -14591,7 +14591,7 @@ pY = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.y) - LODWORD(v19); v5 = abs((signed)pY); v6 = abs((signed)pX); - v7 = sub_4621DA(v6, v5, 0); + v7 = int_get_vector_length(v6, v5, 0); v8 = &pOutdoor->pBModels; if ( v7 < *(int *)((char *)&pOutdoor->pBModels[v4].sBoundingRadius) ) {
--- a/mm7_5.cpp Wed Feb 20 03:35:22 2013 +0200 +++ b/mm7_5.cpp Wed Feb 20 04:36:14 2013 +0200 @@ -5492,7 +5492,7 @@ if ( pMonster->sCurrentHP > 0 ) { Actor::_4030AD(uActorID_Monster_, a1, 0); - Actor::_43AC45(uActorID_Monster_, 1); + Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( bShowDamage ) { v50 = uDamageAmount; @@ -5537,8 +5537,8 @@ } } Actor::Die(uActorID_Monster_); - Actor::_438CF3(uActorID_Monster_); - Actor::_43AC45(uActorID_Monster_, 1); + Actor::ApplyFineForKillingPeasant(uActorID_Monster_); + Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( pMonster->pMonsterInfo.uExp ) sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); v40 = SPEECH_51; @@ -5827,8 +5827,8 @@ { if ( v7->sCurrentHP >= 1 ) { - Actor::_4030AD(uActorID, 8 * a4 | 4, 0); - Actor::_43AC45(uActorID, 1); + Actor::_4030AD(uActorID, 8 * a4 | OBJECT_Player, 0); + Actor::AggroSurroundingPeasants(uActorID, 1); } else { @@ -5854,8 +5854,8 @@ } } Actor::Die(uActorID); - Actor::_438CF3(uActorID); - Actor::_43AC45(uActorID, 1); + Actor::ApplyFineForKillingPeasant(uActorID); + Actor::AggroSurroundingPeasants(uActorID, 1); if ( v7->pMonsterInfo.uExp ) sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp); v34 = SPEECH_51; @@ -6013,8 +6013,8 @@ { if ( v44->sCurrentHP >= 1 ) { - Actor::_4030AD(uActorID, 8 * a4 | 4, 0); - Actor::_43AC45(uActorID, 1); + Actor::_4030AD(uActorID, 8 * a4 | OBJECT_Player, 0); + Actor::AggroSurroundingPeasants(uActorID, 1); } else { @@ -6040,8 +6040,8 @@ } } Actor::Die(uActorID); - Actor::_438CF3(uActorID); - Actor::_43AC45(uActorID, 1); + Actor::ApplyFineForKillingPeasant(uActorID); + Actor::AggroSurroundingPeasants(uActorID, 1); if ( v44->pMonsterInfo.uExp ) sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp); v64 = SPEECH_51; @@ -6348,7 +6348,7 @@ } //----- (0043B1B0) -------------------------------------------------------- -__int16 __fastcall sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4) +void sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4) { int v4; // ebx@1 LayingItem *v5; // eax@2 @@ -6432,7 +6432,7 @@ Actor::_4030AD(uActorID, v17, 0); else Actor::Die(uActorID); - Actor::_43AC45(uActorID, 0); + Actor::AggroSurroundingPeasants(uActorID, 0); v18 = 20 * v14 / (signed int)v7->pMonsterInfo.uHP; if ( 20 * v14 / (signed int)v7->pMonsterInfo.uHP > 10 ) v18 = 10; @@ -6445,13 +6445,13 @@ v7->vVelocity.y = 50 * LOWORD(pVelocity->y); v7->vVelocity.z = 50 * LOWORD(pVelocity->z); } - LOWORD(v6) = Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14); + Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14); } else { - LOWORD(v6) = Actor::_4030AD(uActorID, v17, 0); + Actor::_4030AD(uActorID, v17, 0); } - return v6; + return; } v13 = v7->pMonsterInfo.uSpell2ID; } @@ -6463,7 +6463,6 @@ } } } - return v6; } //----- (0043BCA7) -------------------------------------------------------- @@ -10237,7 +10236,7 @@ } //----- (004065B0) -------------------------------------------------------- -__int16 stru262_TurnBased::_4065B0() +void stru262_TurnBased::_4065B0() { stru262_TurnBased *v1; // esi@1 signed int v2; // eax@1 @@ -10277,14 +10276,13 @@ if ( v1->uActorQueueSize > 0 ) { do - LOWORD(v2) = v1->_406648(v5++); + v1->_406648(v5++); while ( (signed int)v5 < v1->uActorQueueSize ); } - return v2; } //----- (00406648) -------------------------------------------------------- -__int16 stru262_TurnBased::_406648(unsigned int a2) +void stru262_TurnBased::_406648(unsigned int a2) { TurnBased_QueueElem *v1; // ecx@1 int v3; // eax@1 @@ -10375,19 +10373,20 @@ v16 = a2a; if ( !(v14 % 2) ) { - LOWORD(v3) = Actor::_402F87(v4, a2a, &a4); - return v3; + Actor::_402F87(v4, a2a, &a4); + return; } v21 = 64; LABEL_26: - LOWORD(v3) = Actor::_403EB6(v15, v16, v21, v23); - return v3; + Actor::_403EB6(v15, v16, v21, v23); + return; } LABEL_21: v5->uCurrentActionTime = 0; v5->uCurrentActionLength = 0; v5->uAIState = Dead; - return pActors[v4].UpdateAnimation(); + pActors[v4].UpdateAnimation(); + return; } v24 = v5->pMonsterInfo.uSpellSkillAndMastery2; v22 = 3; @@ -10422,7 +10421,6 @@ } } } - return v3; } // 50FE08: using guessed type stru298 stru_50FE08; @@ -12392,7 +12390,7 @@ if (!v8 || v7) if (!v6 || v5) - if (actor->_438B9B()) + if (actor->IsPeasant()) BYTE2(actor->uAttributes) &= 0xF7u; BYTE2(actor->uAttributes) &= 0x7Fu;
--- a/mm7_data.h Wed Feb 20 03:35:22 2013 +0200 +++ b/mm7_data.h Wed Feb 20 04:36:14 2013 +0200 @@ -1963,7 +1963,7 @@ double __fastcall sub_43AE12(signed int a1); int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4); void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); -__int16 __fastcall sub_43B1B0(signed int a1, unsigned int a2, struct Vec3_int_ *pVelocity, signed int a4); +void sub_43B1B0(signed int a1, unsigned int a2, struct Vec3_int_ *pVelocity, signed int a4); int __stdcall DirectInputKeyboard_enumerator_43B9B9(int, int); // weak void Software_ResetNewEdges(); // int __cdecl crt_deconstruct_43B9E3(); @@ -2098,7 +2098,7 @@ void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2); void __cdecl sub_461103(); int __cdecl sub_4613C4(); -int __fastcall sub_4621DA(signed int a1, signed int a2, signed int a3); +int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3); int __cdecl sub_46224A(); int __cdecl crt_init_globals_462620(); void __cdecl crt_init_globals_462659();