Skip to content

Commit

Permalink
KOTOR: Load creature movement rate based on appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed Jul 15, 2018
1 parent ca3bae9 commit ac52abf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/engines/kotor/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ namespace Engines {

namespace KotOR {

Creature::Creature(const Aurora::GFF3Struct &creature) : Object(kObjectTypeCreature) {
Creature::Creature(const Aurora::GFF3Struct &creature)
: Object(kObjectTypeCreature),
_walkRate(0.0f),
_runRate(0.0f) {
init();
load(creature);
}
Expand Down Expand Up @@ -147,6 +150,14 @@ SubRace Creature::getSubRace() const {
return _subRace;
}

float Creature::getWalkRate() const {
return _walkRate;
}

float Creature::getRunRate() const {
return _runRate;
}

void Creature::setPosition(float x, float y, float z) {
Object::setPosition(x, y, z);
Object::getPosition(x, y, z);
Expand Down Expand Up @@ -321,6 +332,8 @@ void Creature::getPartModels(PartModels &parts, uint32 state) {
else if (headBackupID >= 0)
parts.head = heads.getRow(headBackupID).getString("head");
}

loadMovementRate(appearance.getString("moverate"));
}

void Creature::getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation) {
Expand Down Expand Up @@ -412,6 +425,8 @@ void Creature::getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVar
parts.head += Common::composeString(_face + 1);

parts.bodyTexture += Common::UString::format("%02u", textureVariation);

loadMovementRate("PLAYER");
}

void Creature::loadBody(PartModels &parts) {
Expand Down Expand Up @@ -445,6 +460,13 @@ void Creature::loadHead(PartModels &parts) {
_model->attachModel("headhook", _headModel);
}

void Creature::loadMovementRate(const Common::UString &name) {
const Aurora::TwoDARow &speed = TwoDAReg.get2DA("creaturespeed").getRow("2daname", name);

_walkRate = speed.getFloat("walkrate");
_runRate = speed.getFloat("runrate");
}

void Creature::changeBody() {
uint32 state = 'a';
uint8 textureVariation = 1;
Expand Down
8 changes: 8 additions & 0 deletions src/engines/kotor/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Creature : public Object {
int getLevelByPosition(int position) const; ///< Get the level by its position in the level vector.
Class getClassByPosition(int position) const; ///< Get the class by its position in the level vector.

float getWalkRate() const;
float getRunRate() const;

// Positioning

/** Set the creature's position. */
Expand Down Expand Up @@ -173,6 +176,9 @@ class Creature : public Object {

std::vector<Action> _actionQueue;

float _walkRate;
float _runRate;


void init();

Expand All @@ -187,6 +193,8 @@ class Creature : public Object {
void getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation);
void loadBody(PartModels &parts);
void loadHead(PartModels &parts);
void loadMovementRate(const Common::UString &name);

void changeBody();
void changeWeapon(EquipmentSlot slot);

Expand Down

0 comments on commit ac52abf

Please sign in to comment.