Skip to content

Commit

Permalink
Added ArenaPlayerUtils.
Browse files Browse the repository at this point in the history
  • Loading branch information
afritz1 committed Nov 21, 2024
1 parent 6bdfd57 commit 7a4a30a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OpenTESArena/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ SET(TES_MATH
"${SRC_ROOT}/Math/Vector4.h")

SET(TES_PLAYER
"${SRC_ROOT}/Player/ArenaPlayerUtils.cpp"
"${SRC_ROOT}/Player/ArenaPlayerUtils.h"
"${SRC_ROOT}/Player/CharacterClassGeneration.cpp"
"${SRC_ROOT}/Player/CharacterClassGeneration.h"
"${SRC_ROOT}/Player/CharacterCreationState.cpp"
Expand Down
28 changes: 28 additions & 0 deletions OpenTESArena/src/Player/ArenaPlayerUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <cmath>

#include "ArenaPlayerUtils.h"

int ArenaPlayerUtils::getBaseSpeed(int speedAttribute, int encumbranceMod)
{
return ((((speedAttribute * 20) / 256) * (256 - encumbranceMod)) / 256) + 20;
}

int ArenaPlayerUtils::getMoveSpeed(int baseSpeed)
{
return baseSpeed;
}

int ArenaPlayerUtils::getTurnSpeed(int baseSpeed)
{
return (baseSpeed / 2) + 13;
}

int ArenaPlayerUtils::getChasmFallSpeed(int frame)
{
return static_cast<int>(std::pow(2, 2 + (frame / 2)));
}

int ArenaPlayerUtils::getJumpUnitsPerFrame(int frame)
{
return 10 - (2 * frame);
}
34 changes: 34 additions & 0 deletions OpenTESArena/src/Player/ArenaPlayerUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef ARENA_PLAYER_UTILS_H
#define ARENA_PLAYER_UTILS_H

namespace ArenaPlayerUtils
{
int getBaseSpeed(int speedAttribute, int encumbranceMod);
int getMoveSpeed(int baseSpeed);
int getTurnSpeed(int baseSpeed);

constexpr int AccelerationRate = 32;
constexpr int AccelerationMax = 256;
constexpr int DecelerationRate = 64;

constexpr int ChasmHeightDeltaDryChasm = -80;
constexpr int ChasmHeightSwimmingInterior = -25;
constexpr int ChasmHeightSwimmingCity = -50;
constexpr int ChasmHeightSwimmingWild = -10;
constexpr int ChasmHeightRowBoatInterior = -10;
constexpr int ChasmHeightRowBoatWild = -1;

constexpr int ChasmMagnetUnitsPerFrame = 16;
int getChasmFallSpeed(int frame);

constexpr int ChasmClimbingUnitsPerFrame = 6;

constexpr int JumpFrameCount = 10;
constexpr int JumpFrameCountAcrobat = JumpFrameCount * 2;
constexpr int JumpDisallowedCameraHeightUnits = 60; // Or in voxel column with any chasm.
constexpr int StandingJumpForwardUnits = 30; // (dist*pc.attr[STRENGTH])/128
int getJumpUnitsPerFrame(int frame);

}

#endif

0 comments on commit 7a4a30a

Please sign in to comment.