Skip to content

Commit

Permalink
Move structs out of class
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli2 committed Mar 31, 2016
1 parent a678953 commit 0d59206
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 104 deletions.
38 changes: 19 additions & 19 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ void ARX_PLAYER_ComputePlayerFullStats() {
ARX_PLAYER_ComputePlayerStats();

// Reset modifier values
player.m_attributeMod = ARXCHARACTER::PlayerAttribute();
player.m_skillMod = ARXCHARACTER::PlayerSkill();
player.m_miscMod = ARXCHARACTER::PlayerMisc();
player.m_attributeMod = PlayerAttribute();
player.m_skillMod = PlayerSkill();
player.m_miscMod = PlayerMisc();

// TODO why do this now and not after skills/stats have been calculated?
ARX_EQUIPMENT_IdentifyAll();
Expand Down Expand Up @@ -539,14 +539,14 @@ void ARX_PLAYER_ComputePlayerFullStats() {

// Calculate for modifiers from cheats
if(cur_mr == 3) {
ARXCHARACTER::PlayerAttribute attributeMod;
PlayerAttribute attributeMod;
attributeMod.strength = 1;
attributeMod.mind = 10;
attributeMod.constitution = 1;
attributeMod.dexterity = 10;
player.m_attributeMod.add(attributeMod);

ARXCHARACTER::PlayerSkill skillMod;
PlayerSkill skillMod;
skillMod.stealth = 5;
skillMod.mecanism = 5;
skillMod.intuition = 100;
Expand All @@ -558,7 +558,7 @@ void ARX_PLAYER_ComputePlayerFullStats() {
skillMod.defense = 100;
player.m_skillMod.add(skillMod);

ARXCHARACTER::PlayerMisc miscMod;
PlayerMisc miscMod;
miscMod.resistMagic = 100;
miscMod.resistPoison = 100;
miscMod.criticalHit = 5;
Expand All @@ -569,14 +569,14 @@ void ARX_PLAYER_ComputePlayerFullStats() {
player.Full_AimTime = 100;
}
if(sp_max) {
ARXCHARACTER::PlayerAttribute attributeMod;
PlayerAttribute attributeMod;
attributeMod.strength = 5;
attributeMod.mind = 5;
attributeMod.constitution = 5;
attributeMod.dexterity = 5;
player.m_attributeMod.add(attributeMod);

ARXCHARACTER::PlayerSkill skillMod;
PlayerSkill skillMod;
skillMod.stealth = 50;
skillMod.mecanism = 50;
skillMod.intuition = 50;
Expand All @@ -588,7 +588,7 @@ void ARX_PLAYER_ComputePlayerFullStats() {
skillMod.defense = 50;
player.m_skillMod.add(skillMod);

ARXCHARACTER::PlayerMisc miscMod;
PlayerMisc miscMod;
miscMod.resistMagic = 10;
miscMod.resistPoison = 10;
miscMod.criticalHit = 50;
Expand All @@ -599,14 +599,14 @@ void ARX_PLAYER_ComputePlayerFullStats() {
player.Full_AimTime = 100;
}
if(SPECIAL_PNUX) {
ARXCHARACTER::PlayerAttribute attributeMod;
PlayerAttribute attributeMod;
attributeMod.strength = Random::get(0, 5);
attributeMod.mind = Random::get(0, 5);
attributeMod.constitution = Random::get(0, 5);
attributeMod.dexterity = Random::get(0, 5);
player.m_attributeMod.add(attributeMod);

ARXCHARACTER::PlayerSkill skillMod;
PlayerSkill skillMod;
skillMod.stealth = Random::get(0, 20);
skillMod.mecanism = Random::get(0, 20);
skillMod.intuition = Random::get(0, 20);
Expand All @@ -618,7 +618,7 @@ void ARX_PLAYER_ComputePlayerFullStats() {
skillMod.defense = Random::get(0, 30);
player.m_skillMod.add(skillMod);

ARXCHARACTER::PlayerMisc miscMod;
PlayerMisc miscMod;
miscMod.resistMagic = Random::get(0, 20);
miscMod.resistPoison = Random::get(0, 20);
miscMod.criticalHit = Random::get(0, 20);
Expand All @@ -627,17 +627,17 @@ void ARX_PLAYER_ComputePlayerFullStats() {
player.m_miscMod.add(miscMod);
}
if(cur_rf == 3) {
ARXCHARACTER::PlayerAttribute attributeMod;
PlayerAttribute attributeMod;
attributeMod.mind = 10;
player.m_attributeMod.add(attributeMod);

ARXCHARACTER::PlayerSkill skillMod;
PlayerSkill skillMod;
skillMod.casting = 100;
skillMod.etheralLink = 100;
skillMod.objectKnowledge = 100;
player.m_skillMod.add(skillMod);

ARXCHARACTER::PlayerMisc miscMod;
PlayerMisc miscMod;
miscMod.resistMagic = 20;
miscMod.resistPoison = 20;
miscMod.damages = 1;
Expand All @@ -650,7 +650,7 @@ void ARX_PLAYER_ComputePlayerFullStats() {
// Attributes

// Calculate base attributes
ARXCHARACTER::PlayerAttribute attributeBase;
PlayerAttribute attributeBase;
attributeBase.strength = player.m_attribute.strength;
attributeBase.dexterity = player.m_attribute.dexterity;
attributeBase.constitution = player.m_attribute.constitution;
Expand Down Expand Up @@ -681,7 +681,7 @@ void ARX_PLAYER_ComputePlayerFullStats() {
// Skills

// Calculate base skills
ARXCHARACTER::PlayerSkill skillBase;
PlayerSkill skillBase;
skillBase.stealth = player.m_skill.stealth
+ player.m_attributeFull.dexterity * 2.f;
skillBase.mecanism = player.m_skill.mecanism
Expand Down Expand Up @@ -807,7 +807,7 @@ void ARX_PLAYER_MakeFreshHero()
player.m_attribute.dexterity = 6;
player.m_attribute.constitution = 6;

ARXCHARACTER::PlayerSkill skill;
PlayerSkill skill;
skill.stealth = 0;
skill.mecanism = 0;
skill.intuition = 0;
Expand Down Expand Up @@ -850,7 +850,7 @@ void ARX_PLAYER_MakeSpHero()
player.m_attribute.dexterity = 12;
player.m_attribute.constitution = 12;

ARXCHARACTER::PlayerSkill skill;
PlayerSkill skill;
skill.stealth = 5;
skill.mecanism = 5;
skill.intuition = 5;
Expand Down
170 changes: 85 additions & 85 deletions src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,91 @@ enum JumpPhase {
JumpEnd = 5
};

struct PlayerAttribute {
float strength;
float dexterity;
float constitution;
float mind;

PlayerAttribute()
: strength(0)
, dexterity(0)
, constitution(0)
, mind(0)
{}

void add(const PlayerAttribute & other) {
strength += other.strength;
dexterity += other.dexterity;
constitution += other.constitution;
mind += other.mind;
}
};

struct PlayerSkill {
float stealth;
float mecanism;
float intuition;

float etheralLink;
float objectKnowledge;
float casting;

float projectile;
float closeCombat;
float defense;

PlayerSkill()
: stealth(0)
, mecanism(0)
, intuition(0)
, etheralLink(0)
, objectKnowledge(0)
, casting(0)
, projectile(0)
, closeCombat(0)
, defense(0)
{}

void add(const PlayerSkill & other) {
stealth += other.stealth;
mecanism += other.mecanism;
intuition += other.intuition;

etheralLink += other.etheralLink;
objectKnowledge += other.objectKnowledge;
casting += other.casting;

projectile += other.projectile;
closeCombat += other.closeCombat;
defense += other.defense;
}
};

struct PlayerMisc {
float armorClass;
float resistMagic;
float resistPoison;
float criticalHit;
float damages;

PlayerMisc()
: armorClass(0)
, resistMagic(0)
, resistPoison(0)
, criticalHit(0)
, damages(0)
{}

void add(const PlayerMisc & other) {
armorClass += other.armorClass;
resistMagic += other.resistMagic;
resistPoison += other.resistPoison;
criticalHit += other.criticalHit;
damages += other.damages;
}
};

struct ARXCHARACTER {

Vec3f pos;
Expand Down Expand Up @@ -182,91 +267,6 @@ struct ARXCHARACTER {

EntityHandle equiped[MAX_EQUIPED];

struct PlayerAttribute {
float strength;
float dexterity;
float constitution;
float mind;

PlayerAttribute()
: strength(0)
, dexterity(0)
, constitution(0)
, mind(0)
{}

void add(const PlayerAttribute & other) {
strength += other.strength;
dexterity += other.dexterity;
constitution += other.constitution;
mind += other.mind;
}
};

struct PlayerSkill {
float stealth;
float mecanism;
float intuition;

float etheralLink;
float objectKnowledge;
float casting;

float projectile;
float closeCombat;
float defense;

PlayerSkill()
: stealth(0)
, mecanism(0)
, intuition(0)
, etheralLink(0)
, objectKnowledge(0)
, casting(0)
, projectile(0)
, closeCombat(0)
, defense(0)
{}

void add(const PlayerSkill & other) {
stealth += other.stealth;
mecanism += other.mecanism;
intuition += other.intuition;

etheralLink += other.etheralLink;
objectKnowledge += other.objectKnowledge;
casting += other.casting;

projectile += other.projectile;
closeCombat += other.closeCombat;
defense += other.defense;
}
};

struct PlayerMisc {
float armorClass;
float resistMagic;
float resistPoison;
float criticalHit;
float damages;

PlayerMisc()
: armorClass(0)
, resistMagic(0)
, resistPoison(0)
, criticalHit(0)
, damages(0)
{}

void add(const PlayerMisc & other) {
armorClass += other.armorClass;
resistMagic += other.resistMagic;
resistPoison += other.resistPoison;
criticalHit += other.criticalHit;
damages += other.damages;
}
};

// Modifier Values (Items, curses, etc...)
PlayerAttribute m_attributeMod;
PlayerSkill m_skillMod;
Expand Down

0 comments on commit 0d59206

Please sign in to comment.