diff --git a/raws/items.json b/raws/items.json index 0e5a017..c98bfe7 100644 --- a/raws/items.json +++ b/raws/items.json @@ -75,7 +75,7 @@ "id": "equip_dagger", "name": { "name": "dagger", "plural": "daggers" }, "renderable": { "glyph": ")", "fg": "#808080", "bg": "#000000", "order": 2 }, - "weight": 130, + "weight": 1, "value": 2, "flags": ["EQUIP_MELEE", "FINESSE"], "effects": { "base_damage": "1d4" } diff --git a/src/ai/encumbrance_system.rs b/src/ai/encumbrance_system.rs index 5350614..ea2d77a 100644 --- a/src/ai/encumbrance_system.rs +++ b/src/ai/encumbrance_system.rs @@ -3,6 +3,8 @@ use rltk::prelude::*; use specs::prelude::*; use std::collections::HashMap; +pub const CARRY_CAPACITY_PER_STRENGTH: i32 = 8; + pub struct 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) { pool.weight = *weight; 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 { // Overloaded burdened diff --git a/src/ai/mod.rs b/src/ai/mod.rs index b33f335..88553eb 100644 --- a/src/ai/mod.rs +++ b/src/ai/mod.rs @@ -7,4 +7,4 @@ pub use quip_system::QuipSystem; mod regen_system; pub use regen_system::RegenSystem; mod encumbrance_system; -pub use encumbrance_system::EncumbranceSystem; +pub use encumbrance_system::{EncumbranceSystem, CARRY_CAPACITY_PER_STRENGTH}; diff --git a/src/components.rs b/src/components.rs index 749d6e8..84aa672 100644 --- a/src/components.rs +++ b/src/components.rs @@ -144,6 +144,7 @@ pub struct Pools { pub bac: i32, pub level: i32, pub weight: f32, + pub god: bool, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/src/damage_system.rs b/src/damage_system.rs index 90e33ae..d44e379 100644 --- a/src/damage_system.rs +++ b/src/damage_system.rs @@ -42,7 +42,9 @@ impl<'a> System<'a> for DamageSystem { for (entity, mut stats, damage) in (&entities, &mut stats, &damage).join() { for dmg in damage.amount.iter() { - stats.hit_points.current -= dmg.0; + if !stats.god { + stats.hit_points.current -= dmg.0; + } let pos = positions.get(entity); if let Some(pos) = pos { let idx = map.xy_idx(pos.x, pos.y); diff --git a/src/gui/cheat_menu.rs b/src/gui/cheat_menu.rs index 1d4e50b..7068206 100644 --- a/src/gui/cheat_menu.rs +++ b/src/gui/cheat_menu.rs @@ -7,6 +7,9 @@ pub enum CheatMenuResult { Cancel, Ascend, Descend, + Heal, + MagicMap, + GodMode, } 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 mut y = 3 + y_offset; - let count = 2; - let width = 18; + let count = 5; + let width = 19; ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(rltk::RED), RGB::named(rltk::BLACK)); y += 1; @@ -32,12 +35,28 @@ pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult { // Desc 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"); + 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 ctx.key { None => CheatMenuResult::NoResponse, Some(key) => match key { VirtualKeyCode::A => CheatMenuResult::Ascend, VirtualKeyCode::D => CheatMenuResult::Descend, + VirtualKeyCode::H => CheatMenuResult::Heal, + VirtualKeyCode::M => CheatMenuResult::MagicMap, + VirtualKeyCode::G => CheatMenuResult::GodMode, VirtualKeyCode::Escape => CheatMenuResult::Cancel, _ => CheatMenuResult::NoResponse, }, diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 0eb7215..226172c 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -1,7 +1,7 @@ use super::{ - camera, gamelog, gamesystem, rex_assets::RexAssets, ArmourClassBonus, Attributes, Burden, Equipped, Hidden, - HungerClock, HungerState, InBackpack, Map, Name, Player, Point, Pools, Position, Prop, Renderable, RunState, Skill, - Skills, State, Viewshed, + ai::CARRY_CAPACITY_PER_STRENGTH, camera, gamelog, gamesystem, rex_assets::RexAssets, ArmourClassBonus, Attributes, + Burden, Equipped, Hidden, HungerClock, HungerState, InBackpack, Map, Name, Player, Point, Pools, Position, Prop, + Renderable, RunState, Skill, Skills, State, Viewshed, }; use rltk::{Rltk, VirtualKeyCode, RGB}; 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 let names = ecs.read_storage::(); let mut equipment: Vec = Vec::new(); @@ -163,7 +166,11 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) { y, RGB::named(rltk::WHITE), 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; let (player_inventory, _inventory_ids) = get_player_inventory(&ecs); diff --git a/src/main.rs b/src/main.rs index a22baf4..30322c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -260,6 +260,28 @@ impl GameState for State { self.mapgen_next_state = Some(RunState::PreRun); new_runstate = RunState::MapGeneration; } + gui::CheatMenuResult::Heal => { + let player = self.ecs.fetch::(); + let mut pools = self.ecs.write_storage::(); + 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::(); + for v in map.revealed_tiles.iter_mut() { + *v = true; + } + new_runstate = RunState::AwaitingInput; + } + gui::CheatMenuResult::GodMode => { + let player = self.ecs.fetch::(); + let mut pools = self.ecs.write_storage::(); + 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 => { diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index 8c2394d..b440449 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -313,6 +313,7 @@ pub fn spawn_named_mob( hit_points: Pool { current: mob_hp, max: mob_hp }, mana: Pool { current: mob_mana, max: mob_mana }, weight: 0.0, + god: false, }; eb = eb.with(pools); eb = eb.with(EquipmentChanged {}); diff --git a/src/spawner.rs b/src/spawner.rs index 3d80607..fe8bf79 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -54,6 +54,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { level: 1, bac: 10, weight: 0.0, + god: false, }) .with(EquipmentChanged {}) .with(skills)