From 2a00159b4ea41237c286048a1f60478fea12710e Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Tue, 19 Sep 2023 12:16:37 +0800 Subject: [PATCH] Moved MonsterHostility to MonsterEnums.h --- src/Engine/Graphics/Collisions.cpp | 14 +-- src/Engine/Graphics/Indoor.cpp | 2 +- src/Engine/Graphics/Outdoor.cpp | 4 +- src/Engine/Graphics/Viewport.cpp | 2 +- src/Engine/Graphics/Vis.cpp | 2 +- src/Engine/Objects/Actor.cpp | 106 +++++++++++------------ src/Engine/Objects/Actor.h | 2 +- src/Engine/Objects/MonsterEnums.h | 9 ++ src/Engine/Objects/Monsters.cpp | 2 +- src/Engine/Objects/Monsters.h | 10 --- src/Engine/Objects/SpriteObject.cpp | 4 +- src/Engine/Party.cpp | 2 +- src/Engine/Snapshots/EntitySnapshots.cpp | 2 +- src/Engine/Spells/CastSpellInfo.cpp | 2 +- src/Engine/Tables/FactionTable.cpp | 2 +- src/Engine/Tables/FactionTable.h | 2 +- src/Engine/TurnEngine/TurnEngine.cpp | 46 +++++----- 17 files changed, 106 insertions(+), 107 deletions(-) diff --git a/src/Engine/Graphics/Collisions.cpp b/src/Engine/Graphics/Collisions.cpp index 17fa770b66ba..13f43e6efae1 100644 --- a/src/Engine/Graphics/Collisions.cpp +++ b/src/Engine/Graphics/Collisions.cpp @@ -504,7 +504,7 @@ void ProcessActorCollisionsBLV(Actor &actor, bool isAboveGround, bool isFlying) } if (!isAboveGround && !isFlying) { - if (actor.monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY || isInCrowd) + if (actor.monsterInfo.uHostilityType == HOSTILITY_FRIENDLY || isInCrowd) Actor::AI_StandOrBored(actor.id, Pid(OBJECT_Character, 0), 0, nullptr); break; // Trying to walk into indoor sky, bad idea! @@ -532,8 +532,8 @@ void ProcessActorCollisionsBLV(Actor &actor, bool isAboveGround, bool isFlying) if (type == OBJECT_Actor) { if (!pParty->bTurnBasedModeOn || (pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->turn_stage != TE_MOVEMENT)) { - bool isFriendly = actor.monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY; - bool otherFriendly = pActors[id].monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY; + bool isFriendly = actor.monsterInfo.uHostilityType == HOSTILITY_FRIENDLY; + bool otherFriendly = pActors[id].monsterInfo.uHostilityType == HOSTILITY_FRIENDLY; if (isInCrowd) { Actor::AI_StandOrBored(actor.id, Pid(OBJECT_Character, 0), 0, nullptr); } else if (isFriendly && otherFriendly) { @@ -545,7 +545,7 @@ void ProcessActorCollisionsBLV(Actor &actor, bool isAboveGround, bool isFlying) } if (type == OBJECT_Character) { - if (actor.GetActorsRelation(0) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (actor.GetActorsRelation(0) != HOSTILITY_FRIENDLY) { actor.speed.y = 0; actor.speed.x = 0; @@ -654,8 +654,8 @@ void ProcessActorCollisionsODM(Actor &actor, bool isFlying) { if (type == OBJECT_Actor) { if (!pParty->bTurnBasedModeOn || (pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->turn_stage != TE_MOVEMENT)) { - bool isFriendly = actor.monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY; - bool otherFriendly = pActors[id].monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY; + bool isFriendly = actor.monsterInfo.uHostilityType == HOSTILITY_FRIENDLY; + bool otherFriendly = pActors[id].monsterInfo.uHostilityType == HOSTILITY_FRIENDLY; if (isInCrowd) { Actor::AI_StandOrBored(actor.id, Pid(OBJECT_Character, 0), 0, nullptr); } else if (isFriendly && otherFriendly) { @@ -667,7 +667,7 @@ void ProcessActorCollisionsODM(Actor &actor, bool isFlying) { } if (type == OBJECT_Character) { - if (actor.GetActorsRelation(0) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (actor.GetActorsRelation(0) != HOSTILITY_FRIENDLY) { actor.speed.y = 0; actor.speed.x = 0; diff --git a/src/Engine/Graphics/Indoor.cpp b/src/Engine/Graphics/Indoor.cpp index 609f9b5abcd3..01b7f0c8386c 100644 --- a/src/Engine/Graphics/Indoor.cpp +++ b/src/Engine/Graphics/Indoor.cpp @@ -1004,7 +1004,7 @@ void PrepareToLoadBLV(bool bLoading) { if (!v28) { pActors[i].PrepareSprites(0); - pActors[i].monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + pActors[i].monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; if (pActors[i].monsterInfo.field_3E != 11 && pActors[i].monsterInfo.field_3E != 19 && (!pActors[i].currentHP || !pActors[i].monsterInfo.uHP)) { diff --git a/src/Engine/Graphics/Outdoor.cpp b/src/Engine/Graphics/Outdoor.cpp index 5a5cf4e14cc5..7fcde411118f 100644 --- a/src/Engine/Graphics/Outdoor.cpp +++ b/src/Engine/Graphics/Outdoor.cpp @@ -1222,7 +1222,7 @@ bool OutdoorLocation::InitalizeActors(MapId a1) { pActors[i].speed.z = 0; pActors[i].UpdateAnimation(); pActors[i].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_FRIENDLY; + HOSTILITY_FRIENDLY; pActors[i].PrepareSprites(0); } else { pActors[i].aiState = AIState::Disabled; @@ -1246,7 +1246,7 @@ bool OutdoorLocation::InitalizeActors(MapId a1) { pActors[i].speed.z = 0; pActors[i].UpdateAnimation(); pActors[i].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_FRIENDLY; + HOSTILITY_FRIENDLY; pActors[i].PrepareSprites(0); } else { pActors[i].aiState = AIState::Disabled; diff --git a/src/Engine/Graphics/Viewport.cpp b/src/Engine/Graphics/Viewport.cpp index 353ad065054b..1cb3c20e13b1 100644 --- a/src/Engine/Graphics/Viewport.cpp +++ b/src/Engine/Graphics/Viewport.cpp @@ -246,7 +246,7 @@ void ItemInteraction(unsigned int item_id) { } bool CanInteractWithActor(unsigned int id) { - return pActors[id].GetActorsRelation(0) == MonsterInfo::HOSTILITY_FRIENDLY && pActors[id].ActorFriend() && pActors[id].CanAct(); + return pActors[id].GetActorsRelation(0) == HOSTILITY_FRIENDLY && pActors[id].ActorFriend() && pActors[id].CanAct(); } void InteractWithActor(unsigned int id) { diff --git a/src/Engine/Graphics/Vis.cpp b/src/Engine/Graphics/Vis.cpp index b117d35c2962..63927359ce60 100644 --- a/src/Engine/Graphics/Vis.cpp +++ b/src/Engine/Graphics/Vis.cpp @@ -800,7 +800,7 @@ bool Vis::isBillboardPartOfSelection(int billboardId, Vis_SelectionFilter *filte return true; auto relation = pActors[object_idx].GetActorsRelation(nullptr); - if (relation == MonsterInfo::HOSTILITY_FRIENDLY) return false; + if (relation == HOSTILITY_FRIENDLY) return false; return true; } diff --git a/src/Engine/Objects/Actor.cpp b/src/Engine/Objects/Actor.cpp index cda90c297cab..912bb7bacc4d 100644 --- a/src/Engine/Objects/Actor.cpp +++ b/src/Engine/Objects/Actor.cpp @@ -52,12 +52,12 @@ std::vector pActors; stru319 stru_50C198; // idb // TODO(captainurist): HOSTILITY_FIRST, HOSTILITY_LAST -static constexpr IndexedArray _4DF380_hostilityRanges = { - {MonsterInfo::HOSTILITY_FRIENDLY, 0}, - {MonsterInfo::HOSTILITY_CLOSE, 1024}, - {MonsterInfo::HOSTILITY_SHORT, 2560}, - {MonsterInfo::HOSTILITY_MEDIUM, 5120}, - {MonsterInfo::HOSTILITY_LONG, 10240} +static constexpr IndexedArray _4DF380_hostilityRanges = { + {HOSTILITY_FRIENDLY, 0}, + {HOSTILITY_CLOSE, 1024}, + {HOSTILITY_SHORT, 2560}, + {HOSTILITY_MEDIUM, 5120}, + {HOSTILITY_LONG, 10240} }; std::array word_4E8152 = {{0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}}; // level spawn monster levels ABC @@ -736,7 +736,7 @@ void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2) { v6 = std::abs(actor->pos.z - victim->pos.z); if (int_get_vector_length(v4, v5, v6) < 4096) { actor->monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; if (a2 == 1) actor->attributes |= ACTOR_AGGRESSOR; } } @@ -1733,9 +1733,9 @@ void Actor::AI_Stun(unsigned int uActorID, Pid edx0, if (pActors[uActorID].aiState == Fleeing) pActors[uActorID].attributes |= ACTOR_FLEEING; - if (pActors[uActorID].monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_LONG) { + if (pActors[uActorID].monsterInfo.uHostilityType != HOSTILITY_LONG) { pActors[uActorID].attributes &= ~ACTOR_UNKNOWN_4; - pActors[uActorID].monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_LONG; + pActors[uActorID].monsterInfo.uHostilityType = HOSTILITY_LONG; } if (pActors[uActorID].buffs[ACTOR_BUFF_CHARM].Active()) pActors[uActorID].buffs[ACTOR_BUFF_CHARM].Reset(); @@ -1814,7 +1814,7 @@ void Actor::resurrect(unsigned int uActorID) { Actor::playSound(uActorID, ACTOR_DEATH_SOUND); pActor->UpdateAnimation(); - pActor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + pActor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; // TODO(pskelton): vanilla behaviour but does it make sense to drop all carried treasure pActor->monsterInfo.uTreasureDropChance = 0; pActor->monsterInfo.uTreasureDiceRolls = 0; @@ -2144,10 +2144,10 @@ void Actor::AI_Pursue3(unsigned int uActorID, Pid a2, void Actor::_SelectTarget(unsigned int uActorID, Pid *OutTargetPID, bool can_target_party) { int v5; // ecx@1 - MonsterInfo::MonsterHostility v10; // eax@13 + MonsterHostility v10; // eax@13 uint v11; // ebx@16 uint v12; // eax@16 - MonsterInfo::MonsterHostility v14; // eax@31 + MonsterHostility v14; // eax@31 uint v15; // edi@43 //uint v16; // ebx@45 //uint v17; // eax@45 @@ -2174,18 +2174,18 @@ void Actor::_SelectTarget(unsigned int uActorID, Pid *OutTargetPID, if (!thisActor->lastCharacterIdToHit || Pid(OBJECT_Actor, v5) != thisActor->lastCharacterIdToHit) { v10 = thisActor->GetActorsRelation(actor); - if (v10 == MonsterInfo::HOSTILITY_FRIENDLY) continue; + if (v10 == HOSTILITY_FRIENDLY) continue; } else if (thisActor->IsNotAlive()) { thisActor->lastCharacterIdToHit = Pid(); v10 = thisActor->GetActorsRelation(actor); - if (v10 == MonsterInfo::HOSTILITY_FRIENDLY) continue; + if (v10 == HOSTILITY_FRIENDLY) continue; } else { if ((actor->group != 0 || thisActor->group != 0) && actor->group == thisActor->group) continue; - v10 = MonsterInfo::HOSTILITY_LONG; + v10 = HOSTILITY_LONG; } - if (thisActor->monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_FRIENDLY) + if (thisActor->monsterInfo.uHostilityType != HOSTILITY_FRIENDLY) v10 = pMonsterStats->pInfos[thisActor->monsterInfo.uID] .uHostilityType; v11 = _4DF380_hostilityRanges[v10]; @@ -2210,14 +2210,14 @@ void Actor::_SelectTarget(unsigned int uActorID, Pid *OutTargetPID, !thisActor->buffs[ACTOR_BUFF_ENSLAVED].Active() && !thisActor->buffs[ACTOR_BUFF_CHARM].Active() && !thisActor->buffs[ACTOR_BUFF_SUMMONED].Active()) - v14 = MonsterInfo::HOSTILITY_LONG; + v14 = HOSTILITY_LONG; else v14 = thisActor->GetActorsRelation(0); - if (v14 != MonsterInfo::HOSTILITY_FRIENDLY) { - if (thisActor->monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY) + if (v14 != HOSTILITY_FRIENDLY) { + if (thisActor->monsterInfo.uHostilityType == HOSTILITY_FRIENDLY) v15 = _4DF380_hostilityRanges[v14]; else - v15 = _4DF380_hostilityRanges[MonsterInfo::HOSTILITY_LONG]; + v15 = _4DF380_hostilityRanges[HOSTILITY_LONG]; uint v16 = std::abs(thisActor->pos.x - pParty->pos.x); uint v28 = std::abs(thisActor->pos.y - pParty->pos.y); uint v17 = std::abs(thisActor->pos.z - pParty->pos.z); @@ -2230,7 +2230,7 @@ void Actor::_SelectTarget(unsigned int uActorID, Pid *OutTargetPID, } //----- (0040104C) -------------------------------------------------------- -MonsterInfo::MonsterHostility Actor::GetActorsRelation(Actor *otherActPtr) { +MonsterHostility Actor::GetActorsRelation(Actor *otherActPtr) { unsigned int thisGroup; // ebp@19 int otherGroup; // eax@22 unsigned int thisAlly; // edx@25 @@ -2239,10 +2239,10 @@ MonsterInfo::MonsterHostility Actor::GetActorsRelation(Actor *otherActPtr) { if (otherActPtr) { if (otherActPtr->group != 0 && this->group != 0 && otherActPtr->group == this->group) - return MonsterInfo::HOSTILITY_FRIENDLY; + return HOSTILITY_FRIENDLY; } - if (this->buffs[ACTOR_BUFF_BERSERK].Active()) return MonsterInfo::HOSTILITY_LONG; + if (this->buffs[ACTOR_BUFF_BERSERK].Active()) return HOSTILITY_LONG; thisAlly = this->ally; if (this->buffs[ACTOR_BUFF_ENSLAVED].Active() || thisAlly == 9999) thisGroup = 0; @@ -2252,7 +2252,7 @@ MonsterInfo::MonsterHostility Actor::GetActorsRelation(Actor *otherActPtr) { thisGroup = (std::to_underlying(this->monsterInfo.uID) - 1) / 3 + 1; // TODO(captainurist): encapsulate enum arithmetic. if (otherActPtr) { - if (otherActPtr->buffs[ACTOR_BUFF_BERSERK].Active()) return MonsterInfo::HOSTILITY_LONG; + if (otherActPtr->buffs[ACTOR_BUFF_BERSERK].Active()) return HOSTILITY_LONG; otherAlly = otherActPtr->ally; if (otherActPtr->buffs[ACTOR_BUFF_ENSLAVED].Active() || otherAlly == 9999) @@ -2268,19 +2268,19 @@ MonsterInfo::MonsterHostility Actor::GetActorsRelation(Actor *otherActPtr) { if (this->buffs[ACTOR_BUFF_CHARM].Active() && !otherGroup || otherActPtr && otherActPtr->buffs[ACTOR_BUFF_CHARM].Active() && !thisGroup) - return MonsterInfo::HOSTILITY_FRIENDLY; + return HOSTILITY_FRIENDLY; if (!this->buffs[ACTOR_BUFF_ENSLAVED].Active() && this->ActorEnemy() && !otherGroup) - return MonsterInfo::HOSTILITY_LONG; - if (thisGroup >= 89 || otherGroup >= 89) return MonsterInfo::HOSTILITY_FRIENDLY; + return HOSTILITY_LONG; + if (thisGroup >= 89 || otherGroup >= 89) return HOSTILITY_FRIENDLY; if (thisGroup == 0) { if ((!otherActPtr || this->buffs[ACTOR_BUFF_ENSLAVED].Active() && otherActPtr->ActorFriend()) && - pFactionTable->relations[otherGroup][0] == MonsterInfo::HOSTILITY_FRIENDLY) + pFactionTable->relations[otherGroup][0] == HOSTILITY_FRIENDLY) return pFactionTable->relations[0][otherGroup]; else - return MonsterInfo::HOSTILITY_LONG; + return HOSTILITY_LONG; } else { return pFactionTable->relations[thisGroup][otherGroup]; } @@ -2563,7 +2563,7 @@ void Actor::SummonMinion(int summonerId) { actor->tetherDistance = 256; actor->sectorId = actorSector; actor->PrepareSprites(0); - actor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + actor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; actor->ally = v19; actor->currentActionTime = 0; actor->group = this->group; @@ -2637,7 +2637,7 @@ void Actor::UpdateActorAI() { // If Charm still active: make actor friendly if (pActor->buffs[ACTOR_BUFF_CHARM].Active()) { - pActor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + pActor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; } else if (pActor->buffs[ACTOR_BUFF_CHARM].Expired()) { // Else: reset hostilty pActor->monsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->monsterInfo.uID].uHostilityType; @@ -2687,8 +2687,8 @@ void Actor::UpdateActorAI() { Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); - if (pActor->monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_FRIENDLY && !ai_near_actors_targets_pid[actor_id]) - pActor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + if (pActor->monsterInfo.uHostilityType != HOSTILITY_FRIENDLY && !ai_near_actors_targets_pid[actor_id]) + pActor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; target_pid = ai_near_actors_targets_pid[actor_id]; target_pid_type = target_pid.type(); @@ -2713,7 +2713,7 @@ void Actor::UpdateActorAI() { } if (pActor->buffs[ACTOR_BUFF_CHARM].Active()) { - pActor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + pActor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; } else if (pActor->buffs[ACTOR_BUFF_CHARM].Expired()) { pActor->monsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->monsterInfo.uID].uHostilityType; pActor->buffs[ACTOR_BUFF_CHARM].Reset(); @@ -2744,7 +2744,7 @@ void Actor::UpdateActorAI() { // TODO(captainurist): this check makes no sense, it fails only for monsters that are: // stunned && non-friendly && recovering && far from target && don't have missile attack. Seriously? - if (pActor->monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY || + if (pActor->monsterInfo.uHostilityType == HOSTILITY_FRIENDLY || pActor->monsterInfo.uRecoveryTime > 0 || radiusMultiplier * 307.2 < pDir->uDistance || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting && !pActor->monsterInfo.uMissleAttack1Type || @@ -2768,24 +2768,24 @@ void Actor::UpdateActorAI() { int distanceToTarget = pDir->uDistance; - MonsterInfo::MonsterHostility relationToTarget; - if (pActor->monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_FRIENDLY) { + MonsterHostility relationToTarget; + if (pActor->monsterInfo.uHostilityType == HOSTILITY_FRIENDLY) { if (target_pid_type == OBJECT_Actor) { // TODO(captainurist): encapsulate enum arithmetic. relationToTarget = pFactionTable->relations[(std::to_underlying(pActor->monsterInfo.uID) - 1) / 3 + 1] [(std::to_underlying(pActors[target_pid.id()].monsterInfo.uID) - 1) / 3 + 1]; } else { - relationToTarget = MonsterInfo::HOSTILITY_LONG; + relationToTarget = HOSTILITY_LONG; } v38 = 0; - if (relationToTarget == MonsterInfo::HOSTILITY_SHORT) + if (relationToTarget == HOSTILITY_SHORT) v38 = 1024; - else if (relationToTarget == MonsterInfo::HOSTILITY_MEDIUM) + else if (relationToTarget == HOSTILITY_MEDIUM) v38 = 2560; - else if (relationToTarget == MonsterInfo::HOSTILITY_LONG) + else if (relationToTarget == HOSTILITY_LONG) v38 = 5120; - if (relationToTarget >= MonsterInfo::HOSTILITY_CLOSE && relationToTarget <= MonsterInfo::HOSTILITY_LONG && distanceToTarget < v38 || relationToTarget == MonsterInfo::HOSTILITY_CLOSE) - pActor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_LONG; + if (relationToTarget >= HOSTILITY_CLOSE && relationToTarget <= HOSTILITY_LONG && distanceToTarget < v38 || relationToTarget == HOSTILITY_CLOSE) + pActor->monsterInfo.uHostilityType = HOSTILITY_LONG; } // If actor afraid: flee or if out of range random move @@ -2797,7 +2797,7 @@ void Actor::UpdateActorAI() { continue; } - if (pActor->monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_LONG && + if (pActor->monsterInfo.uHostilityType == HOSTILITY_LONG && target_pid) { if (pActor->monsterInfo.uAIType == 1) { if (pActor->monsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STATIONARY) { @@ -2901,7 +2901,7 @@ void Actor::UpdateActorAI() { } } - if (pActor->monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_LONG || + if (pActor->monsterInfo.uHostilityType != HOSTILITY_LONG || !target_pid || v81 >= 5120 || v45 != ABILITY_ATTACK2) { if (pActor->monsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT) { Actor::AI_RandomMove(actor_id, Pid::character(0), 1024, 0); @@ -3063,7 +3063,7 @@ void Actor::InitializeActors() { } } - actor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + actor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; if (!bCelestia || good) if (!bPit || evil) @@ -3374,7 +3374,7 @@ void Actor::Arena_summon_actor(MONSTER_TYPE monster_id, Vec3i pos) { actor->tetherDistance = 256; actor->sectorId = v16; actor->group = 1; - actor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_LONG; + actor->monsterInfo.uHostilityType = HOSTILITY_LONG; actor->PrepareSprites(0); // for ( int i = 0; i < 4; i++) // pSoundList->LoadSound(pMonsterList->pMonsters[monster_id - @@ -3674,7 +3674,7 @@ bool CheckActors_proximity() { pActors[i].aiState != Disabled && pActors[i].aiState != Summoned && (pActors[i].ActorEnemy() || - pActors[i].GetActorsRelation(0) != MonsterInfo::HOSTILITY_FRIENDLY)) + pActors[i].GetActorsRelation(0) != HOSTILITY_FRIENDLY)) return true; } } @@ -4076,7 +4076,7 @@ void Actor::MakeActorAIList_ODM() { if (distance < 5632) { actor.ResetHostile(); - if (actor.ActorEnemy() || actor.GetActorsRelation(0) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (actor.ActorEnemy() || actor.GetActorsRelation(0) != HOSTILITY_FRIENDLY) { actor.attributes |= ACTOR_HOSTILE; if (distance < 5120) pParty->SetYellowAlert(); @@ -4130,7 +4130,7 @@ int Actor::MakeActorAIList_BLV() { // actor is in range if (distance < 10240) { actor.ResetHostile(); - if (actor.ActorEnemy() || actor.GetActorsRelation(0) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (actor.ActorEnemy() || actor.GetActorsRelation(0) != HOSTILITY_FRIENDLY) { actor.attributes |= ACTOR_HOSTILE; if (!(pParty->GetRedAlert()) && (double)distance < 307.2) pParty->SetRedAlert(); @@ -4393,7 +4393,7 @@ void Spawn_Light_Elemental(int spell_power, CharacterSkillMastery caster_skill_m actor->tetherDistance = 256; actor->sectorId = partySectorId; actor->PrepareSprites(0); - actor->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + actor->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; actor->ally = 9999; actor->group = 0; actor->currentActionTime = 0; @@ -4633,7 +4633,7 @@ void SpawnEncounter(MapInfo *pMapInfo, SpawnPoint *spawn, int a3, int a4, int a5 pMonster->sectorId = pSector; pMonster->group = spawn->uGroup; pMonster->PrepareSprites(0); - pMonster->monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_FRIENDLY; + pMonster->monsterInfo.uHostilityType = HOSTILITY_FRIENDLY; v32 = grng->random(2048); a3 = TrigLUT.cos(v32) * v52; pPosX = a3 + spawn->vPosition.x; @@ -4754,7 +4754,7 @@ void evaluateAoeDamage() { Actor::DamageMonsterFromParty(attack.pid, actorID, &attackVector); break; case OBJECT_Actor: - if (pSpriteObj && pActors[attackerId].GetActorsRelation(&pActors[actorID]) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (pSpriteObj && pActors[attackerId].GetActorsRelation(&pActors[actorID]) != HOSTILITY_FRIENDLY) { Actor::ActorDamageFromMonster(attack.pid, actorID, &attackVector, pSpriteObj->spellCasterAbility); } break; diff --git a/src/Engine/Objects/Actor.h b/src/Engine/Objects/Actor.h index a3e908e67e91..402e3029ee09 100644 --- a/src/Engine/Objects/Actor.h +++ b/src/Engine/Objects/Actor.h @@ -61,7 +61,7 @@ class Actor { void Remove(); void PrepareSprites(char load_sounds_if_bit1_set); void UpdateAnimation(); - MonsterInfo::MonsterHostility GetActorsRelation(Actor *a2); + MonsterHostility GetActorsRelation(Actor *a2); void SetRandomGoldIfTheresNoItem(); bool CanAct(); bool IsNotAlive(); diff --git a/src/Engine/Objects/MonsterEnums.h b/src/Engine/Objects/MonsterEnums.h index 1f9a8a70338b..d43913382571 100644 --- a/src/Engine/Objects/MonsterEnums.h +++ b/src/Engine/Objects/MonsterEnums.h @@ -127,3 +127,12 @@ enum class SPECIAL_ATTACK_TYPE : uint8_t { SPECIAL_ATTACK_FEAR = 23, }; using enum SPECIAL_ATTACK_TYPE; + +enum class MonsterHostility { + HOSTILITY_FRIENDLY = 0, + HOSTILITY_CLOSE = 1, + HOSTILITY_SHORT = 2, + HOSTILITY_MEDIUM = 3, + HOSTILITY_LONG = 4 +}; +using enum MonsterHostility; diff --git a/src/Engine/Objects/Monsters.cpp b/src/Engine/Objects/Monsters.cpp index b2afc9d640f9..a2cc7899df2e 100644 --- a/src/Engine/Objects/Monsters.cpp +++ b/src/Engine/Objects/Monsters.cpp @@ -708,7 +708,7 @@ void MonsterStats::Initialize(const Blob &monsters) { } break; case 12: pInfos[curr_rec_num].uHostilityType = - (MonsterInfo::MonsterHostility)atoi(test_string); + (MonsterHostility)atoi(test_string); break; case 13: pInfos[curr_rec_num].uBaseSpeed = atoi(test_string); diff --git a/src/Engine/Objects/Monsters.h b/src/Engine/Objects/Monsters.h index cec40dd86b39..ddf93017d656 100644 --- a/src/Engine/Objects/Monsters.h +++ b/src/Engine/Objects/Monsters.h @@ -21,16 +21,6 @@ class Blob; struct MonsterInfo { - // TODO(captainurist): move into global namespace. - enum class MonsterHostility { - HOSTILITY_FRIENDLY = 0, - HOSTILITY_CLOSE = 1, - HOSTILITY_SHORT = 2, - HOSTILITY_MEDIUM = 3, - HOSTILITY_LONG = 4 - }; - using enum MonsterHostility; - std::string pName; std::string pPictureName; uint8_t uLevel = 0; diff --git a/src/Engine/Objects/SpriteObject.cpp b/src/Engine/Objects/SpriteObject.cpp index d9f84b49fa6e..ed7f41ae903e 100644 --- a/src/Engine/Objects/SpriteObject.cpp +++ b/src/Engine/Objects/SpriteObject.cpp @@ -243,7 +243,7 @@ void SpriteObject::updateObjectODM(unsigned int uLayingItemID) { // TODO: why pActors.size() - 1? Should just check for .size() if ((actorId >= 0) && (actorId < (pActors.size() - 1))) { for (int j = 0; j < pActors.size(); ++j) { - if (pActors[actorId].GetActorsRelation(&pActors[j]) != MonsterInfo::HOSTILITY_FRIENDLY) { + if (pActors[actorId].GetActorsRelation(&pActors[j]) != HOSTILITY_FRIENDLY) { CollideWithActor(j, 0); } } @@ -724,7 +724,7 @@ bool processSpellImpact(unsigned int uLayingItemID, Pid pid) { ObjectDesc *objectDesc = &pObjectList->pObjects[object->uObjectDescID]; if (pid.type() == OBJECT_Actor) { - if (object->spell_caster_pid.type() == OBJECT_Actor && pActors[object->spell_caster_pid.id()].GetActorsRelation(&pActors[pid.id()]) == MonsterInfo::HOSTILITY_FRIENDLY) { + if (object->spell_caster_pid.type() == OBJECT_Actor && pActors[object->spell_caster_pid.id()].GetActorsRelation(&pActors[pid.id()]) == HOSTILITY_FRIENDLY) { return 1; } } else { diff --git a/src/Engine/Party.cpp b/src/Engine/Party.cpp index 899b988dfda2..d0dde5284c02 100644 --- a/src/Engine/Party.cpp +++ b/src/Engine/Party.cpp @@ -707,7 +707,7 @@ void Party::yell() { for (int i = 0; i < pActors.size(); i++) { Actor &actor = pActors[i]; if (actor.CanAct() && - actor.monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_LONG && + actor.monsterInfo.uHostilityType != HOSTILITY_LONG && actor.monsterInfo.uMovementType != MONSTER_MOVEMENT_TYPE_STATIONARY) { if ((actor.pos - pParty->pos).length() < 512) { Actor::AI_Flee(i, Pid::character(0), 0, 0); diff --git a/src/Engine/Snapshots/EntitySnapshots.cpp b/src/Engine/Snapshots/EntitySnapshots.cpp index 8fe041ef4159..fd2b4520ee2b 100644 --- a/src/Engine/Snapshots/EntitySnapshots.cpp +++ b/src/Engine/Snapshots/EntitySnapshots.cpp @@ -1248,7 +1248,7 @@ void reconstruct(const Actor_MM7 &src, Actor *dst) { dst->monsterInfo.uFlying = src.pMonsterInfo.flying; dst->monsterInfo.uMovementType = static_cast(src.pMonsterInfo.movementType); dst->monsterInfo.uAIType = src.pMonsterInfo.aiType; - dst->monsterInfo.uHostilityType = static_cast(src.pMonsterInfo.hostilityType); + dst->monsterInfo.uHostilityType = static_cast(src.pMonsterInfo.hostilityType); dst->monsterInfo.uSpecialAttackType = static_cast(src.pMonsterInfo.specialAttackType); dst->monsterInfo.uSpecialAttackLevel = src.pMonsterInfo.specialAttackLevel; dst->monsterInfo.uAttack1Type = static_cast(src.pMonsterInfo.attack1Type); diff --git a/src/Engine/Spells/CastSpellInfo.cpp b/src/Engine/Spells/CastSpellInfo.cpp index 9aa083bde5ef..93f82f3d7ece 100644 --- a/src/Engine/Spells/CastSpellInfo.cpp +++ b/src/Engine/Spells/CastSpellInfo.cpp @@ -2033,7 +2033,7 @@ void CastSpellInfoHelpers::castSpell() { pActors[monster_id].buffs[ACTOR_BUFF_ENSLAVED].Reset(); pActors[monster_id].buffs[ACTOR_BUFF_BERSERK] .Apply(pParty->GetPlayingTime() + spell_duration, spell_mastery, 0, 0, 0); - pActors[monster_id].monsterInfo.uHostilityType = MonsterInfo::HOSTILITY_LONG; + pActors[monster_id].monsterInfo.uHostilityType = HOSTILITY_LONG; } initSpellSprite(&pSpellSprite, spell_level, spell_mastery, pCastSpell); pSpellSprite.vPosition = pActors[monster_id].pos + Vec3i(0, 0, pActors[monster_id].height); diff --git a/src/Engine/Tables/FactionTable.cpp b/src/Engine/Tables/FactionTable.cpp index 155655ef0936..4678e2be472d 100644 --- a/src/Engine/Tables/FactionTable.cpp +++ b/src/Engine/Tables/FactionTable.cpp @@ -36,7 +36,7 @@ void FactionTable::Initialize(const Blob &factions) { *tmp_pos = 0; if (temp_str_len) { if (decode_step >= 1 && decode_step < 90) - relations[decode_step - 1][i] = static_cast(atoi(test_string)); + relations[decode_step - 1][i] = static_cast(atoi(test_string)); } else { break_loop = true; } diff --git a/src/Engine/Tables/FactionTable.h b/src/Engine/Tables/FactionTable.h index c5d5402ce4e4..9c0cb79ce848 100644 --- a/src/Engine/Tables/FactionTable.h +++ b/src/Engine/Tables/FactionTable.h @@ -7,7 +7,7 @@ class Blob; struct FactionTable { void Initialize(const Blob &factions); - MonsterInfo::MonsterHostility relations[89][89]; // TODO(captainurist): index is 1 + MONSTER_TYPE / 3? + MonsterHostility relations[89][89]; // TODO(captainurist): index is 1 + MONSTER_TYPE / 3? }; extern FactionTable *pFactionTable; diff --git a/src/Engine/TurnEngine/TurnEngine.cpp b/src/Engine/TurnEngine/TurnEngine.cpp index 3c93c0fca7eb..f868b1937aa5 100644 --- a/src/Engine/TurnEngine/TurnEngine.cpp +++ b/src/Engine/TurnEngine/TurnEngine.cpp @@ -641,7 +641,7 @@ void stru262_TurnBased::AI_Action_(int queue_index) { unsigned int actor_id; // edi@2 AIDirection v7; // esi@10 int v9; // ecx@10 - MonsterInfo::MonsterHostility v10; // eax@13 + MonsterHostility v10; // eax@13 ABILITY_INDEX v14; // eax@29 AIDirection a3; // [sp+Ch] [bp-44h]@10 AIDirection v18; // [sp+28h] [bp-28h]@10 @@ -658,9 +658,9 @@ void stru262_TurnBased::AI_Action_(int queue_index) { Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); v22 = ai_near_actors_targets_pid[actor_id]; - if (pActors[actor_id].monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_FRIENDLY && !v22) + if (pActors[actor_id].monsterInfo.uHostilityType != HOSTILITY_FRIENDLY && !v22) pActors[actor_id].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_FRIENDLY; + HOSTILITY_FRIENDLY; Actor::GetDirectionInfo(Pid(OBJECT_Actor, actor_id), v22, &v7, 0); memcpy(&a3, &v7, sizeof(AIDirection)); memcpy(&v18, &a3, sizeof(AIDirection)); @@ -674,30 +674,30 @@ void stru262_TurnBased::AI_Action_(int queue_index) { [(std::to_underlying(pMonsterStats->pInfos[pActors[v22.id()].monsterInfo.uID].uID) - 1) / 3 + 1] // Was w/o -1 here, probably was a bug. [(std::to_underlying(pActors[actor_id].monsterInfo.uID) - 1) / 3 + 1]; else - v10 = MonsterInfo::HOSTILITY_LONG; + v10 = HOSTILITY_LONG; switch (v10) { - case MonsterInfo::HOSTILITY_CLOSE: + case HOSTILITY_CLOSE: if ((double)(signed int)v9 < 307.2) pActors[actor_id].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; - case MonsterInfo::HOSTILITY_SHORT: + case HOSTILITY_SHORT: if (v9 < 1024) pActors[actor_id].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; - case MonsterInfo::HOSTILITY_MEDIUM: + case HOSTILITY_MEDIUM: if (v9 < 2560) pActors[actor_id].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; - case MonsterInfo::HOSTILITY_LONG: + case HOSTILITY_LONG: if (v9 < 5120) pActors[actor_id].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; } - if (pActors[actor_id].monsterInfo.uHostilityType == MonsterInfo::HOSTILITY_LONG && v22 && + if (pActors[actor_id].monsterInfo.uHostilityType == HOSTILITY_LONG && v22 && (signed int)v9 < 5120) { v14 = pActors[actor_id].special_ability_use_check(actor_id); pQueue[queue_index].AI_action_type = TE_AI_STAND; @@ -846,7 +846,7 @@ void stru262_TurnBased::ActorAIDoAdditionalMove() { bool stru262_TurnBased::ActorMove(signed int queue_position) { AIDirection v9; // esi@10 int v11; // ecx@10 - MonsterInfo::MonsterHostility pHostileType; // al@12 + MonsterHostility pHostileType; // al@12 AIDirection a3; // [sp+Ch] [bp-48h]@10 AIDirection pDir; // [sp+28h] [bp-2Ch]@10 unsigned int uActorID; // [sp+50h] [bp-4h]@2 @@ -860,10 +860,10 @@ bool stru262_TurnBased::ActorMove(signed int queue_position) { pActors[uActorID].aiState == Summoned) return 1; Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); - if (pActors[uActorID].monsterInfo.uHostilityType != MonsterInfo::HOSTILITY_FRIENDLY && + if (pActors[uActorID].monsterInfo.uHostilityType != HOSTILITY_FRIENDLY && !ai_near_actors_targets_pid[uActorID]) pActors[uActorID].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_FRIENDLY; + HOSTILITY_FRIENDLY; Actor::GetDirectionInfo(pQueue[queue_position].uPackedID, ai_near_actors_targets_pid[uActorID], &v9, 0); memcpy(&a3, &v9, sizeof(AIDirection)); @@ -872,20 +872,20 @@ bool stru262_TurnBased::ActorMove(signed int queue_position) { if (v11 < 0) v11 = 0; pHostileType = pActors[uActorID].monsterInfo.uHostilityType; switch (pHostileType) { - case MonsterInfo::HOSTILITY_CLOSE: + case HOSTILITY_CLOSE: if ((double)v11 < 307.2) pActors[uActorID].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; - case MonsterInfo::HOSTILITY_SHORT: + case HOSTILITY_SHORT: if (v11 < 1024) pActors[uActorID].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; - case MonsterInfo::HOSTILITY_MEDIUM: + case HOSTILITY_MEDIUM: if (v11 < 2560) pActors[uActorID].monsterInfo.uHostilityType = - MonsterInfo::HOSTILITY_LONG; + HOSTILITY_LONG; break; } if (pActors[uActorID].buffs[ACTOR_BUFF_AFRAID].Active()) { @@ -903,7 +903,7 @@ bool stru262_TurnBased::ActorMove(signed int queue_position) { return true; } if (pActors[uActorID].monsterInfo.uHostilityType == - MonsterInfo::HOSTILITY_LONG) { + HOSTILITY_LONG) { if (!(pActors[uActorID].attributes & ACTOR_FLEEING) || pActors[uActorID].monsterInfo.uAIType == 1) { if (pActors[uActorID].monsterInfo.uAIType == 1) {