Skip to content

Commit

Permalink
fix: Correctly apply actor values in SetActorValues
Browse files Browse the repository at this point in the history
  • Loading branch information
otsffs authored Jan 3, 2025
1 parent 299f208 commit 7dddbba
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Code/client/Games/Skyrim/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,14 @@ void Actor::SetActorValue(uint32_t aId, float aValue) noexcept

void Actor::ForceActorValue(ActorValueOwner::ForceMode aMode, uint32_t aId, float aValue) noexcept
{
const float current = GetActorValue(aId);
actorValueOwner.ForceCurrent(aMode, aId, aValue - current);
float initialValue = aMode == ActorValueOwner::ForceMode::PERMANENT
? GetActorPermanentValue(aId)
: GetActorValue(aId);

if (aValue == initialValue)
return;

actorValueOwner.ForceCurrent(aMode, aId, aValue - initialValue);
}

Inventory Actor::GetActorInventory() const noexcept
Expand Down Expand Up @@ -716,16 +722,10 @@ void Actor::SetMagicEquipment(const MagicEquipment& acEquipment) noexcept
void Actor::SetActorValues(const ActorValues& acActorValues) noexcept
{
for (auto& value : acActorValues.ActorMaxValuesList)
{
float current = actorValueOwner.GetValue(value.first);
actorValueOwner.ForceCurrent(ActorValueOwner::ForceMode::PERMANENT, value.first, value.second - current);
}
ForceActorValue(ActorValueOwner::ForceMode::PERMANENT, value.first, value.second);

for (auto& value : acActorValues.ActorValuesList)
{
float current = actorValueOwner.GetValue(value.first);
actorValueOwner.ForceCurrent(ActorValueOwner::ForceMode::DAMAGE, value.first, value.second - current);
}
ForceActorValue(ActorValueOwner::ForceMode::DAMAGE, value.first, value.second);
}

void Actor::SetFactions(const Factions& acFactions) noexcept
Expand Down

0 comments on commit 7dddbba

Please sign in to comment.