Expands cheat menu
This commit is contained in:
parent
0344f87da8
commit
71f5c2ac9f
10 changed files with 66 additions and 10 deletions
|
|
@ -75,7 +75,7 @@
|
||||||
"id": "equip_dagger",
|
"id": "equip_dagger",
|
||||||
"name": { "name": "dagger", "plural": "daggers" },
|
"name": { "name": "dagger", "plural": "daggers" },
|
||||||
"renderable": { "glyph": ")", "fg": "#808080", "bg": "#000000", "order": 2 },
|
"renderable": { "glyph": ")", "fg": "#808080", "bg": "#000000", "order": 2 },
|
||||||
"weight": 130,
|
"weight": 1,
|
||||||
"value": 2,
|
"value": 2,
|
||||||
"flags": ["EQUIP_MELEE", "FINESSE"],
|
"flags": ["EQUIP_MELEE", "FINESSE"],
|
||||||
"effects": { "base_damage": "1d4" }
|
"effects": { "base_damage": "1d4" }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ use rltk::prelude::*;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub const CARRY_CAPACITY_PER_STRENGTH: i32 = 8;
|
||||||
|
|
||||||
pub struct EncumbranceSystem {}
|
pub struct EncumbranceSystem {}
|
||||||
|
|
||||||
impl<'a> System<'a> for EncumbranceSystem {
|
impl<'a> System<'a> for EncumbranceSystem {
|
||||||
|
|
@ -49,7 +51,8 @@ impl<'a> System<'a> for EncumbranceSystem {
|
||||||
if let Some(pool) = pools.get_mut(*entity) {
|
if let Some(pool) = pools.get_mut(*entity) {
|
||||||
pool.weight = *weight;
|
pool.weight = *weight;
|
||||||
if let Some(attr) = attributes.get(*entity) {
|
if let Some(attr) = attributes.get(*entity) {
|
||||||
let carry_capacity_lbs = (attr.strength.base + attr.strength.modifiers) * 10;
|
let carry_capacity_lbs =
|
||||||
|
(attr.strength.base + attr.strength.modifiers) * CARRY_CAPACITY_PER_STRENGTH;
|
||||||
if pool.weight as i32 > 3 * carry_capacity_lbs {
|
if pool.weight as i32 > 3 * carry_capacity_lbs {
|
||||||
// Overloaded
|
// Overloaded
|
||||||
burdened
|
burdened
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ pub use quip_system::QuipSystem;
|
||||||
mod regen_system;
|
mod regen_system;
|
||||||
pub use regen_system::RegenSystem;
|
pub use regen_system::RegenSystem;
|
||||||
mod encumbrance_system;
|
mod encumbrance_system;
|
||||||
pub use encumbrance_system::EncumbranceSystem;
|
pub use encumbrance_system::{EncumbranceSystem, CARRY_CAPACITY_PER_STRENGTH};
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ pub struct Pools {
|
||||||
pub bac: i32,
|
pub bac: i32,
|
||||||
pub level: i32,
|
pub level: i32,
|
||||||
pub weight: f32,
|
pub weight: f32,
|
||||||
|
pub god: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@ impl<'a> System<'a> for DamageSystem {
|
||||||
|
|
||||||
for (entity, mut stats, damage) in (&entities, &mut stats, &damage).join() {
|
for (entity, mut stats, damage) in (&entities, &mut stats, &damage).join() {
|
||||||
for dmg in damage.amount.iter() {
|
for dmg in damage.amount.iter() {
|
||||||
|
if !stats.god {
|
||||||
stats.hit_points.current -= dmg.0;
|
stats.hit_points.current -= dmg.0;
|
||||||
|
}
|
||||||
let pos = positions.get(entity);
|
let pos = positions.get(entity);
|
||||||
if let Some(pos) = pos {
|
if let Some(pos) = pos {
|
||||||
let idx = map.xy_idx(pos.x, pos.y);
|
let idx = map.xy_idx(pos.x, pos.y);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ pub enum CheatMenuResult {
|
||||||
Cancel,
|
Cancel,
|
||||||
Ascend,
|
Ascend,
|
||||||
Descend,
|
Descend,
|
||||||
|
Heal,
|
||||||
|
MagicMap,
|
||||||
|
GodMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
||||||
|
|
@ -20,8 +23,8 @@ pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
||||||
);
|
);
|
||||||
let x = 1 + x_offset;
|
let x = 1 + x_offset;
|
||||||
let mut y = 3 + y_offset;
|
let mut y = 3 + y_offset;
|
||||||
let count = 2;
|
let count = 5;
|
||||||
let width = 18;
|
let width = 19;
|
||||||
|
|
||||||
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(rltk::RED), RGB::named(rltk::BLACK));
|
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(rltk::RED), RGB::named(rltk::BLACK));
|
||||||
y += 1;
|
y += 1;
|
||||||
|
|
@ -32,12 +35,28 @@ pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
||||||
// Desc
|
// Desc
|
||||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('d'));
|
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('d'));
|
||||||
ctx.print(x_offset + 4, y, "DESCEND A FLOOR");
|
ctx.print(x_offset + 4, y, "DESCEND A FLOOR");
|
||||||
|
y += 1;
|
||||||
|
// Heal
|
||||||
|
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('h'));
|
||||||
|
ctx.print(x_offset + 4, y, "HEAL TO FULL");
|
||||||
|
y += 1;
|
||||||
|
// Reveal map
|
||||||
|
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('m'));
|
||||||
|
ctx.print(x_offset + 4, y, "MAGIC MAP REVEAL");
|
||||||
|
y += 1;
|
||||||
|
// Godmode
|
||||||
|
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('g'));
|
||||||
|
ctx.print(x_offset + 4, y, "GOD MODE");
|
||||||
|
y += 1;
|
||||||
// Match keys
|
// Match keys
|
||||||
match ctx.key {
|
match ctx.key {
|
||||||
None => CheatMenuResult::NoResponse,
|
None => CheatMenuResult::NoResponse,
|
||||||
Some(key) => match key {
|
Some(key) => match key {
|
||||||
VirtualKeyCode::A => CheatMenuResult::Ascend,
|
VirtualKeyCode::A => CheatMenuResult::Ascend,
|
||||||
VirtualKeyCode::D => CheatMenuResult::Descend,
|
VirtualKeyCode::D => CheatMenuResult::Descend,
|
||||||
|
VirtualKeyCode::H => CheatMenuResult::Heal,
|
||||||
|
VirtualKeyCode::M => CheatMenuResult::MagicMap,
|
||||||
|
VirtualKeyCode::G => CheatMenuResult::GodMode,
|
||||||
VirtualKeyCode::Escape => CheatMenuResult::Cancel,
|
VirtualKeyCode::Escape => CheatMenuResult::Cancel,
|
||||||
_ => CheatMenuResult::NoResponse,
|
_ => CheatMenuResult::NoResponse,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{
|
use super::{
|
||||||
camera, gamelog, gamesystem, rex_assets::RexAssets, ArmourClassBonus, Attributes, Burden, Equipped, Hidden,
|
ai::CARRY_CAPACITY_PER_STRENGTH, camera, gamelog, gamesystem, rex_assets::RexAssets, ArmourClassBonus, Attributes,
|
||||||
HungerClock, HungerState, InBackpack, Map, Name, Player, Point, Pools, Position, Prop, Renderable, RunState, Skill,
|
Burden, Equipped, Hidden, HungerClock, HungerState, InBackpack, Map, Name, Player, Point, Pools, Position, Prop,
|
||||||
Skills, State, Viewshed,
|
Renderable, RunState, Skill, Skills, State, Viewshed,
|
||||||
};
|
};
|
||||||
use rltk::{Rltk, VirtualKeyCode, RGB};
|
use rltk::{Rltk, VirtualKeyCode, RGB};
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
@ -139,6 +139,9 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if stats.god {
|
||||||
|
ctx.print_color(20, 20, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "--- GODMODE: ON ---");
|
||||||
|
}
|
||||||
// Draw equipment
|
// Draw equipment
|
||||||
let names = ecs.read_storage::<Name>();
|
let names = ecs.read_storage::<Name>();
|
||||||
let mut equipment: Vec<String> = Vec::new();
|
let mut equipment: Vec<String> = Vec::new();
|
||||||
|
|
@ -163,7 +166,11 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::WHITE),
|
RGB::named(rltk::WHITE),
|
||||||
RGB::named(rltk::BLACK),
|
RGB::named(rltk::BLACK),
|
||||||
&format!("[{:.1}/{} lbs]", stats.weight, (attributes.strength.base + attributes.strength.modifiers) * 10),
|
&format!(
|
||||||
|
"[{:.1}/{} lbs]",
|
||||||
|
stats.weight,
|
||||||
|
(attributes.strength.base + attributes.strength.modifiers) * CARRY_CAPACITY_PER_STRENGTH
|
||||||
|
),
|
||||||
);
|
);
|
||||||
y += 1;
|
y += 1;
|
||||||
let (player_inventory, _inventory_ids) = get_player_inventory(&ecs);
|
let (player_inventory, _inventory_ids) = get_player_inventory(&ecs);
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -260,6 +260,28 @@ impl GameState for State {
|
||||||
self.mapgen_next_state = Some(RunState::PreRun);
|
self.mapgen_next_state = Some(RunState::PreRun);
|
||||||
new_runstate = RunState::MapGeneration;
|
new_runstate = RunState::MapGeneration;
|
||||||
}
|
}
|
||||||
|
gui::CheatMenuResult::Heal => {
|
||||||
|
let player = self.ecs.fetch::<Entity>();
|
||||||
|
let mut pools = self.ecs.write_storage::<Pools>();
|
||||||
|
let mut player_pools = pools.get_mut(*player).unwrap();
|
||||||
|
player_pools.hit_points.current = player_pools.hit_points.max;
|
||||||
|
new_runstate = RunState::AwaitingInput;
|
||||||
|
}
|
||||||
|
gui::CheatMenuResult::MagicMap => {
|
||||||
|
let mut map = self.ecs.fetch_mut::<Map>();
|
||||||
|
for v in map.revealed_tiles.iter_mut() {
|
||||||
|
*v = true;
|
||||||
|
}
|
||||||
|
new_runstate = RunState::AwaitingInput;
|
||||||
|
}
|
||||||
|
gui::CheatMenuResult::GodMode => {
|
||||||
|
let player = self.ecs.fetch::<Entity>();
|
||||||
|
let mut pools = self.ecs.write_storage::<Pools>();
|
||||||
|
let mut player_pools = pools.get_mut(*player).unwrap();
|
||||||
|
gamelog::Logger::new().item_name("TOGGLED GOD MODE!").log();
|
||||||
|
player_pools.god = !player_pools.god;
|
||||||
|
new_runstate = RunState::AwaitingInput;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunState::ShowInventory => {
|
RunState::ShowInventory => {
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,7 @@ pub fn spawn_named_mob(
|
||||||
hit_points: Pool { current: mob_hp, max: mob_hp },
|
hit_points: Pool { current: mob_hp, max: mob_hp },
|
||||||
mana: Pool { current: mob_mana, max: mob_mana },
|
mana: Pool { current: mob_mana, max: mob_mana },
|
||||||
weight: 0.0,
|
weight: 0.0,
|
||||||
|
god: false,
|
||||||
};
|
};
|
||||||
eb = eb.with(pools);
|
eb = eb.with(pools);
|
||||||
eb = eb.with(EquipmentChanged {});
|
eb = eb.with(EquipmentChanged {});
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
level: 1,
|
level: 1,
|
||||||
bac: 10,
|
bac: 10,
|
||||||
weight: 0.0,
|
weight: 0.0,
|
||||||
|
god: false,
|
||||||
})
|
})
|
||||||
.with(EquipmentChanged {})
|
.with(EquipmentChanged {})
|
||||||
.with(skills)
|
.with(skills)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue