ranged targeting fixes (set_bg doesn't work with fancy console)
currently not using fancy features for anything, so just went back to the simple console
This commit is contained in:
parent
6e6d364aa5
commit
1e25d062db
6 changed files with 39 additions and 18 deletions
|
|
@ -32,7 +32,7 @@ pub fn mana_per_level(rng: &mut rltk::RandomNumberGenerator, intelligence: i32)
|
|||
}
|
||||
|
||||
pub fn mana_at_level(rng: &mut rltk::RandomNumberGenerator, intelligence: i32, level: i32) -> i32 {
|
||||
let mut total = 12;
|
||||
let mut total = 0;
|
||||
for _i in 0..level {
|
||||
total += mana_per_level(rng, intelligence);
|
||||
}
|
||||
|
|
|
|||
11
src/gui.rs
11
src/gui.rs
|
|
@ -492,7 +492,8 @@ pub fn ranged_target(gs: &mut State, ctx: &mut Rltk, range: i32, aoe: i32) -> (I
|
|||
if distance <= range as f32 {
|
||||
let screen_x = idx.x - min_x;
|
||||
let screen_y = idx.y - min_y;
|
||||
if screen_x > 0 && screen_x < (max_x - min_x) && screen_y > 0 && screen_y < (max_y - min_y) {
|
||||
if screen_x > 1 && screen_x < (max_x - min_x) - 1 && screen_y > 1 && screen_y < (max_y - min_y) - 1 {
|
||||
rltk::console::log("yo");
|
||||
ctx.set_bg(screen_x + x_offset, screen_y + y_offset, RGB::named(rltk::BLUE));
|
||||
available_cells.push(idx);
|
||||
}
|
||||
|
|
@ -505,8 +506,8 @@ pub fn ranged_target(gs: &mut State, ctx: &mut Rltk, range: i32, aoe: i32) -> (I
|
|||
// Draw mouse cursor
|
||||
let mouse_pos = ctx.mouse_pos();
|
||||
let mut mouse_pos_adjusted = mouse_pos;
|
||||
mouse_pos_adjusted.0 += min_x;
|
||||
mouse_pos_adjusted.1 += min_y;
|
||||
mouse_pos_adjusted.0 += min_x - x_offset;
|
||||
mouse_pos_adjusted.1 += min_y - y_offset;
|
||||
let map = gs.ecs.fetch::<Map>();
|
||||
let mut valid_target = false;
|
||||
for idx in available_cells.iter() {
|
||||
|
|
@ -525,12 +526,12 @@ pub fn ranged_target(gs: &mut State, ctx: &mut Rltk, range: i32, aoe: i32) -> (I
|
|||
ctx.set_bg(tile.x - min_x + x_offset, tile.y - min_y + y_offset, RGB::named(rltk::DARKCYAN));
|
||||
}
|
||||
}
|
||||
ctx.set_bg(mouse_pos.0 + x_offset, mouse_pos.1 + y_offset, RGB::named(rltk::CYAN));
|
||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(rltk::CYAN));
|
||||
if ctx.left_click {
|
||||
return (ItemMenuResult::Selected, Some(Point::new(mouse_pos_adjusted.0, mouse_pos_adjusted.1)));
|
||||
}
|
||||
} else {
|
||||
ctx.set_bg(mouse_pos.0 + x_offset, mouse_pos.1 + y_offset, RGB::named(rltk::RED));
|
||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(rltk::RED));
|
||||
if ctx.left_click {
|
||||
return (ItemMenuResult::Cancel, None);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ impl State {
|
|||
gamelog::Logger::new()
|
||||
.append("Taking a short rest, you manage to")
|
||||
.colour((0, 255, 0))
|
||||
.append("recover some of your strength")
|
||||
.append_n("recover some of your strength")
|
||||
.period()
|
||||
.log();
|
||||
let mut pools = self.ecs.write_storage::<Pools>();
|
||||
|
|
@ -499,7 +499,7 @@ fn main() -> rltk::BError {
|
|||
.with_fps_cap(60.0)
|
||||
.with_font("curses14x16.png", 14, 16)
|
||||
.with_tile_dimensions(14, 16)
|
||||
.with_fancy_console(DISPLAYWIDTH, DISPLAYHEIGHT, "curses14x16.png")
|
||||
.with_simple_console(DISPLAYWIDTH, DISPLAYHEIGHT, "curses14x16.png")
|
||||
//.with_simple_console_no_bg(DISPLAYWIDTH, DISPLAYHEIGHT, "terminal8x8.jpg")
|
||||
.build()?;
|
||||
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||
|
||||
if COMBAT_LOGGING {
|
||||
rltk::console::log(format!(
|
||||
"ATTACKLOG: {} *ATTACKED* {}: rolled ({}) 1d20 vs. {} (10 + {}AC + {}to-hit)",
|
||||
&name.name, &target_name.name, d20, target_number, armour_class, attacker_bonuses
|
||||
"ATTACKLOG: {} *{}* {}: rolled ({}) 1d20 vs. {} (10 + {}AC + {}to-hit)",
|
||||
&name.name, attack_verb, &target_name.name, d20, target_number, armour_class, attacker_bonuses
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -166,10 +166,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||
|
||||
if COMBAT_LOGGING {
|
||||
rltk::console::log(format!(
|
||||
"ATTACKLOG: {} *{}* {} for {} ({}[{}d{}]+{}[skill]+{}[attr])",
|
||||
"ATTACKLOG: {} HIT for {} ({}[{}d{}]+{}[skill]+{}[attr])",
|
||||
&name.name,
|
||||
attack_verb,
|
||||
&target_name.name,
|
||||
damage,
|
||||
base_damage,
|
||||
weapon_info.damage_n_dice,
|
||||
|
|
@ -220,7 +218,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||
}
|
||||
} else {
|
||||
if COMBAT_LOGGING {
|
||||
rltk::console::log(format!("ATTACKLOG: {} *MISSED* {}", &name.name, &target_name.name,));
|
||||
rltk::console::log(format!("ATTACKLOG: {} *MISSED*", &name.name));
|
||||
}
|
||||
|
||||
let pos = positions.get(wants_melee.target);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ use specs::prelude::*;
|
|||
use specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
const SPAWN_LOGGING: bool = true;
|
||||
|
||||
pub enum SpawnType {
|
||||
AtPosition { x: i32, y: i32 },
|
||||
Equipped { by: Entity },
|
||||
|
|
@ -243,11 +245,10 @@ pub fn spawn_named_mob(
|
|||
|
||||
let base_mob_level = if mob_template.level.is_some() { mob_template.level.unwrap() } else { 0 };
|
||||
let mut mob_level = base_mob_level;
|
||||
let difficulty = 0;
|
||||
if base_mob_level > difficulty {
|
||||
if base_mob_level > map_difficulty {
|
||||
mob_level -= 1;
|
||||
} else if base_mob_level < difficulty {
|
||||
mob_level += (difficulty - base_mob_level) / 5;
|
||||
} else if base_mob_level < map_difficulty {
|
||||
mob_level += (map_difficulty - base_mob_level) / 5;
|
||||
|
||||
if mob_level as f32 > 1.5 * base_mob_level as f32 {
|
||||
let mob_levelf32 = (1.5 * base_mob_level as f32).trunc();
|
||||
|
|
@ -262,6 +263,13 @@ pub fn spawn_named_mob(
|
|||
let mob_mana = mana_at_level(&mut rng, mob_int, mob_level);
|
||||
let mob_bac = if mob_template.bac.is_some() { mob_template.bac.unwrap() } else { 10 };
|
||||
|
||||
if SPAWN_LOGGING {
|
||||
rltk::console::log(format!(
|
||||
"SPAWNLOG: {} ({}HP, {}MANA, {}BAC) spawned at level {} (base level: {}, map difficulty: {})",
|
||||
&mob_template.name, mob_hp, mob_mana, mob_bac, mob_level, base_mob_level, map_difficulty
|
||||
));
|
||||
}
|
||||
|
||||
let pools = Pools {
|
||||
level: mob_level,
|
||||
xp: 0,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,20 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
|||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
raws::spawn_named_entity(
|
||||
&raws::RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
"scroll_magicmissile",
|
||||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
raws::spawn_named_entity(
|
||||
&raws::RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
"scroll_fireball",
|
||||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue