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