Skip to content

Commit e5c64ae

Browse files
Dmytro Lysaipingw33n
authored andcommitted
[game] Add Perk definitions
1 parent 0d93b8f commit e5c64ae

File tree

3 files changed

+1064
-0
lines changed

3 files changed

+1064
-0
lines changed

src/game/script.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use crate::game::object;
1818
use crate::vm::{self, *};
1919
use crate::vm::value::Value;
2020

21+
pub const GVAR_PLAYER_REPUTATION: i32 = 0;
22+
2123
#[derive(Clone, Copy, Debug, Enum, Eq, PartialEq, Ord, PartialOrd, Primitive)]
2224
pub enum ScriptKind {
2325
System = 0x0,

src/game/stats.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const SKILL_NAME_MSG_BASE: MessageId = 100;
2525
const SKILL_DESCR_MSG_BASE: MessageId = 200;
2626
const SKILL_FORMULA_MSG_BASE: MessageId = 300;
2727
const LEVEL_UP_MSG: MessageId = 600;
28+
const PERK_NAME_MSG_BASE: MessageId = 101;
29+
const PERK_DESCR_MSG_BASE: MessageId = 1101;
2830

2931
struct Tagged {
3032
tagged: bool,
@@ -43,8 +45,10 @@ impl Default for Tagged {
4345
pub struct Stats {
4446
stat_msgs: Messages,
4547
skill_msgs: Messages,
48+
perk_msgs: Messages,
4649
stat_defs: EnumMap<Stat, StatDef>,
4750
skill_defs: EnumMap<Skill, SkillDef>,
51+
perk_defs: EnumMap<Perk, PerkDef>,
4852
traits: EnumMap<Trait, bool>,
4953
perks: HashMap<ProtoId, EnumMap<Perk, bool>>,
5054
tagged: EnumMap<Skill, Tagged>,
@@ -58,13 +62,18 @@ impl Stats {
5862
let skill_msgs = Messages::read_file(fs, language, "game/skill.msg")?;
5963
let skill_defs = SkillDef::defaults();
6064

65+
let perk_msgs = Messages::read_file(fs, language, "game/perk.msg")?;
66+
let perk_defs = PerkDef::defaults();
67+
6168
let mut perks = HashMap::new();
6269
perks.insert(ProtoId::DUDE, Default::default());
6370
Ok(Self {
6471
stat_msgs,
6572
skill_msgs,
73+
perk_msgs,
6674
stat_defs,
6775
skill_defs,
76+
perk_defs,
6877
traits: Default::default(),
6978
perks,
7079
tagged: Default::default(),
@@ -83,6 +92,14 @@ impl Stats {
8392
&self.skill_msgs.get(SKILL_FORMULA_MSG_BASE + skill as MessageId).unwrap().text
8493
}
8594

95+
pub fn perk_name(&self, perk: Perk) -> &bstr {
96+
&self.perk_msgs.get(PERK_NAME_MSG_BASE + perk as MessageId).unwrap().text
97+
}
98+
99+
pub fn perk_description(&self, perk: Perk) -> &bstr {
100+
&self.perk_msgs.get(PERK_DESCR_MSG_BASE + perk as MessageId).unwrap().text
101+
}
102+
86103
pub fn has_perk(&self, perk: Perk, pid: ProtoId) -> bool {
87104
self.perks.get(&pid).map(|m| m[perk]).unwrap_or(false)
88105
}

0 commit comments

Comments
 (0)