Show weapon range, add Target component
This commit is contained in:
parent
76fed8a80f
commit
3ecf6ec97e
@ -54,3 +54,6 @@ pub struct Confusion {}
|
||||
|
||||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AlwaysTargetsSelf {}
|
||||
|
||||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Target {}
|
||||
|
37
src/gui.rs
37
src/gui.rs
@ -13,7 +13,7 @@ use tooltip::draw_tooltips;
|
||||
use crate::components::{
|
||||
Attribute, Attributes, Consumable, CursedItem, Duration, Equipped, HungerClock, HungerState,
|
||||
InBackpack, KnownSpells, MagicItem, MagicItemClass, Name, ObfuscatedName, Pools, StatusEffect,
|
||||
Viewshed,
|
||||
Viewshed, Weapon,
|
||||
};
|
||||
use crate::game_log::GameLog;
|
||||
use crate::{camera, colors, Map, MasterDungeonMap, State};
|
||||
@ -211,16 +211,37 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||
let mut y = 13;
|
||||
let entities = ecs.entities();
|
||||
let equipped = ecs.read_storage::<Equipped>();
|
||||
let weapon = ecs.read_storage::<Weapon>();
|
||||
for (entity, equipped_by) in (&entities, &equipped).join() {
|
||||
if equipped_by.owner == *player_entity {
|
||||
ctx.print_color(
|
||||
50,
|
||||
y,
|
||||
get_item_color(ecs, entity),
|
||||
colors::BLACK,
|
||||
&get_item_display_name(ecs, entity),
|
||||
);
|
||||
let name = get_item_display_name(ecs, entity);
|
||||
ctx.print_color(50, y, get_item_color(ecs, entity), colors::BLACK, &name);
|
||||
y += 1;
|
||||
|
||||
if let Some(weapon) = weapon.get(entity) {
|
||||
let mut weapon_info = if weapon.damage_bonus < 0 {
|
||||
format!(
|
||||
"┤ {} ({}d{}{})",
|
||||
&name, weapon.damage_n_dice, weapon.damage_die_type, weapon.damage_bonus
|
||||
)
|
||||
} else if weapon.damage_bonus == 0 {
|
||||
format!(
|
||||
"┤ {} ({}d{})",
|
||||
&name, weapon.damage_n_dice, weapon.damage_die_type
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"┤ {} ({}d{}+{})",
|
||||
&name, weapon.damage_n_dice, weapon.damage_die_type, weapon.damage_bonus
|
||||
)
|
||||
};
|
||||
|
||||
if let Some(range) = weapon.range {
|
||||
weapon_info += &format!(" (range: {}, F to fire)", range);
|
||||
}
|
||||
weapon_info += " ├";
|
||||
ctx.print_color(3, 45, colors::YELLOW, colors::BLACK, &weapon_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,14 +94,14 @@ fn init_state() -> State {
|
||||
Consumable,
|
||||
CursedItem,
|
||||
DamageOverTime,
|
||||
Door,
|
||||
DMSerializationHelper,
|
||||
Door,
|
||||
Duration,
|
||||
EntityMoved,
|
||||
EntryTrigger,
|
||||
EquipmentChanged,
|
||||
Equippable,
|
||||
Equipped,
|
||||
EquipmentChanged,
|
||||
Faction,
|
||||
Hidden,
|
||||
HungerClock,
|
||||
@ -115,7 +115,6 @@ fn init_state() -> State {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
@ -145,6 +144,7 @@ fn init_state() -> State {
|
||||
SpecialAbilities,
|
||||
SpellTemplate,
|
||||
StatusEffect,
|
||||
Target,
|
||||
TeachesSpell,
|
||||
TeleportTo,
|
||||
TileSize,
|
||||
@ -159,6 +159,7 @@ fn init_state() -> State {
|
||||
WantsToPickupItem,
|
||||
WantsToRemoveItem,
|
||||
WantsToUseItem,
|
||||
Weapon,
|
||||
Wearable,
|
||||
);
|
||||
|
||||
|
@ -535,7 +535,11 @@ pub fn spawn_named_item(
|
||||
});
|
||||
let (n_dice, die_type, bonus) = parse_dice_string(&weapon.base_damage);
|
||||
let mut wpn = Weapon {
|
||||
range: None,
|
||||
range: if weapon.range == "melee" {
|
||||
None
|
||||
} else {
|
||||
Some(weapon.range.parse::<i32>().expect("Not a number"))
|
||||
},
|
||||
attribute: WeaponAttribute::Might,
|
||||
damage_n_dice: n_dice,
|
||||
damage_die_type: die_type,
|
||||
|
@ -73,14 +73,14 @@ pub fn save_game(ecs: &mut World) {
|
||||
Consumable,
|
||||
CursedItem,
|
||||
DamageOverTime,
|
||||
Door,
|
||||
DMSerializationHelper,
|
||||
Door,
|
||||
Duration,
|
||||
EntityMoved,
|
||||
EntryTrigger,
|
||||
EquipmentChanged,
|
||||
Equippable,
|
||||
Equipped,
|
||||
EquipmentChanged,
|
||||
Faction,
|
||||
Hidden,
|
||||
HungerClock,
|
||||
@ -94,7 +94,6 @@ pub fn save_game(ecs: &mut World) {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
@ -123,6 +122,7 @@ pub fn save_game(ecs: &mut World) {
|
||||
SpecialAbilities,
|
||||
SpellTemplate,
|
||||
StatusEffect,
|
||||
Target,
|
||||
TeachesSpell,
|
||||
TeleportTo,
|
||||
TileSize,
|
||||
@ -137,6 +137,7 @@ pub fn save_game(ecs: &mut World) {
|
||||
WantsToPickupItem,
|
||||
WantsToRemoveItem,
|
||||
WantsToUseItem,
|
||||
Weapon,
|
||||
Wearable,
|
||||
);
|
||||
}
|
||||
@ -207,14 +208,14 @@ pub fn load_game(ecs: &mut World) {
|
||||
Consumable,
|
||||
CursedItem,
|
||||
DamageOverTime,
|
||||
Door,
|
||||
DMSerializationHelper,
|
||||
Door,
|
||||
Duration,
|
||||
EntityMoved,
|
||||
EntryTrigger,
|
||||
EquipmentChanged,
|
||||
Equippable,
|
||||
Equipped,
|
||||
EquipmentChanged,
|
||||
Faction,
|
||||
Hidden,
|
||||
HungerClock,
|
||||
@ -228,7 +229,6 @@ pub fn load_game(ecs: &mut World) {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
@ -250,13 +250,14 @@ pub fn load_game(ecs: &mut World) {
|
||||
Renderable,
|
||||
SerializationHelper,
|
||||
SingleActivation,
|
||||
Slow,
|
||||
Skills,
|
||||
Slow,
|
||||
SpawnParticleBurst,
|
||||
SpawnParticleLine,
|
||||
SpecialAbilities,
|
||||
SpellTemplate,
|
||||
StatusEffect,
|
||||
Target,
|
||||
TeachesSpell,
|
||||
TeleportTo,
|
||||
TileSize,
|
||||
@ -271,6 +272,7 @@ pub fn load_game(ecs: &mut World) {
|
||||
WantsToPickupItem,
|
||||
WantsToRemoveItem,
|
||||
WantsToUseItem,
|
||||
Weapon,
|
||||
Wearable,
|
||||
);
|
||||
}
|
||||
|
@ -39,15 +39,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
.build();
|
||||
|
||||
// Starting equipment
|
||||
let starting_equipment = vec![
|
||||
let starting_equipment_carried = ["Dried Sausage", "Beer", "Shortbow"];
|
||||
let starting_equipment_equipped = [
|
||||
"Rusty Longsword",
|
||||
"Dried Sausage",
|
||||
"Beer",
|
||||
"Stained Tunic",
|
||||
"Torn Trousers",
|
||||
"Old Boots",
|
||||
];
|
||||
for equipment in starting_equipment.iter() {
|
||||
for equipment in starting_equipment_carried.iter() {
|
||||
spawn_named_entity(
|
||||
&RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
@ -55,6 +54,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
SpawnType::Carried { by: player },
|
||||
);
|
||||
}
|
||||
for equipment in starting_equipment_equipped.iter() {
|
||||
spawn_named_entity(
|
||||
&RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
*equipment,
|
||||
SpawnType::Equipped { by: player },
|
||||
);
|
||||
}
|
||||
|
||||
// Starting hangover
|
||||
ecs.create_entity()
|
||||
|
Loading…
Reference in New Issue
Block a user