weapon fix, and inability to remove cursed items
This commit is contained in:
parent
d277384cc5
commit
e403a6d845
6 changed files with 79 additions and 23 deletions
|
|
@ -110,7 +110,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#808080", "bg": "#000000", "order": 2 },
|
||||
"weight": 1,
|
||||
"value": 2,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "FINESSE", "damage": "1d4", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "FINESSE", "damage": "1d4", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_shortsword",
|
||||
|
|
@ -118,7 +119,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
|
||||
"weight": 2,
|
||||
"value": 10,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "STRENGTH", "damage": "1d6", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "STRENGTH", "damage": "1d6", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_rapier",
|
||||
|
|
@ -126,7 +128,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
|
||||
"weight": 2,
|
||||
"value": 10,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "FINESSE", "damage": "1d8", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "FINESSE", "damage": "1d8", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_pitchfork",
|
||||
|
|
@ -134,7 +137,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
|
||||
"weight": 2,
|
||||
"value": 5,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "FINESSE", "damage": "1d6", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "FINESSE", "damage": "1d6", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_sickle",
|
||||
|
|
@ -142,7 +146,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
|
||||
"weight": 2,
|
||||
"value": 5,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "FINESSE", "damage": "1d6", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "FINESSE", "damage": "1d6", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_handaxe",
|
||||
|
|
@ -150,7 +155,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
|
||||
"weight": 2,
|
||||
"value": 5,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "STRENGTH", "damage": "1d6", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "STRENGTH", "damage": "1d6", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_longsword",
|
||||
|
|
@ -158,7 +164,8 @@
|
|||
"renderable": { "glyph": ")", "fg": "#FFF8DC", "bg": "#000000", "order": 2 },
|
||||
"weight": 3,
|
||||
"value": 15,
|
||||
"equip": { "slot": "EQUIP_MELEE", "flag": "STRENGTH", "damage": "1d8", "to_hit": 0 }
|
||||
"flags": ["EQUIP_MELEE"],
|
||||
"equip": { "flag": "STRENGTH", "damage": "1d8", "to_hit": 0 }
|
||||
},
|
||||
{
|
||||
"id": "equip_smallshield",
|
||||
|
|
|
|||
|
|
@ -48,12 +48,10 @@
|
|||
"id": "scrolls",
|
||||
"table": [
|
||||
{ "id": "scroll_confusion", "weight": 2, "difficulty": 1},
|
||||
{ "id": "scroll_magicmap_c", "weight": 2, "difficulty": 1},
|
||||
{ "id": "scroll_magicmap", "weight": 2, "difficulty": 1},
|
||||
{ "id": "scroll_embers", "weight": 2, "difficulty": 2},
|
||||
{ "id": "scroll_health", "weight": 2, "difficulty": 2},
|
||||
{ "id": "scroll_fireball", "weight": 2, "difficulty": 2},
|
||||
{ "id": "scroll_fireball_c", "weight": 2, "difficulty": 2},
|
||||
{ "id": "scroll_mass_health", "weight": 1, "difficulty": 2},
|
||||
{ "id": "scroll_mass_confusion", "weight": 1, "difficulty": 3}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::{
|
|||
gamelog,
|
||||
gui::{item_colour, obfuscate_name},
|
||||
Beatitude, EquipmentChanged, Equippable, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName,
|
||||
WantsToUseItem,
|
||||
WantsToUseItem, BUC,
|
||||
};
|
||||
use specs::prelude::*;
|
||||
|
||||
|
|
@ -47,14 +47,40 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
if let Some(can_equip) = equippable.get(wants_to_use_item.item) {
|
||||
let target_slot = can_equip.slot;
|
||||
let mut logger = gamelog::Logger::new();
|
||||
|
||||
// Remove any items target has in item's slot
|
||||
let mut can_equip = true;
|
||||
let mut to_unequip: Vec<Entity> = Vec::new();
|
||||
for (item_entity, already_equipped, _name) in (&entities, &equipped, &names).join() {
|
||||
if already_equipped.owner == target && already_equipped.slot == target_slot {
|
||||
if let Some(beatitude) = beatitudes.get(item_entity) {
|
||||
if beatitude.buc == BUC::Cursed {
|
||||
can_equip = false;
|
||||
logger = logger
|
||||
.append("You can't remove the")
|
||||
.colour(item_colour(item_entity, &beatitudes, &dm))
|
||||
.append_n(
|
||||
obfuscate_name(
|
||||
item_entity,
|
||||
&names,
|
||||
&magic_items,
|
||||
&obfuscated_names,
|
||||
&beatitudes,
|
||||
&dm,
|
||||
None,
|
||||
)
|
||||
.0,
|
||||
)
|
||||
.colour(rltk::WHITE)
|
||||
.append("!");
|
||||
}
|
||||
}
|
||||
to_unequip.push(item_entity);
|
||||
}
|
||||
}
|
||||
if !can_equip {
|
||||
logger.log();
|
||||
continue;
|
||||
}
|
||||
for item in to_unequip.iter() {
|
||||
equipped.remove(*item);
|
||||
backpack.insert(*item, InBackpack { owner: target }).expect("Unable to insert backpack");
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use crate::{
|
||||
gamelog,
|
||||
gui::{item_colour, obfuscate_name},
|
||||
Beatitude, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName, WantsToRemoveItem,
|
||||
Beatitude, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName, WantsToRemoveItem, BUC,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct ItemRemoveSystem {}
|
||||
|
|
@ -37,11 +38,14 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
) = data;
|
||||
|
||||
for (entity, to_remove) in (&entities, &wants_remove).join() {
|
||||
equipped.remove(to_remove.item);
|
||||
if let Some(_) = names.get(to_remove.item) {
|
||||
if entity == *player_entity {
|
||||
let mut can_remove = true;
|
||||
if let Some(beatitude) = beatitudes.get(to_remove.item) {
|
||||
// If cursed, can't remove!
|
||||
if beatitude.buc == BUC::Cursed {
|
||||
can_remove = false;
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.append("You can't remove the")
|
||||
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||
.append_n(
|
||||
obfuscate_name(
|
||||
to_remove.item,
|
||||
|
|
@ -54,7 +58,34 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
)
|
||||
.0,
|
||||
)
|
||||
.colour(WHITE)
|
||||
.append("!")
|
||||
.log();
|
||||
}
|
||||
}
|
||||
if !can_remove {
|
||||
continue;
|
||||
}
|
||||
// If not cursed, remove it
|
||||
equipped.remove(to_remove.item);
|
||||
if let Some(_) = names.get(to_remove.item) {
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||
.append_n(
|
||||
obfuscate_name(
|
||||
to_remove.item,
|
||||
&names,
|
||||
&magic_items,
|
||||
&obfuscated_names,
|
||||
&beatitudes,
|
||||
&dm,
|
||||
None,
|
||||
)
|
||||
.0,
|
||||
)
|
||||
.colour(WHITE)
|
||||
.period()
|
||||
.log();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ pub struct Name {
|
|||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Equippable {
|
||||
pub slot: String,
|
||||
pub flag: String,
|
||||
pub damage: String,
|
||||
pub to_hit: Option<i32>,
|
||||
|
|
|
|||
|
|
@ -659,6 +659,7 @@ fn find_slot_for_equippable_item(tag: &str, raws: &RawMaster) -> EquipmentSlot {
|
|||
if let Some(flags) = &item.flags {
|
||||
for flag in flags {
|
||||
match flag.as_str() {
|
||||
"EQUIP_MELEE" => return EquipmentSlot::Melee,
|
||||
"EQUIP_SHIELD" => return EquipmentSlot::Shield,
|
||||
"EQUIP_BODY" => return EquipmentSlot::Body,
|
||||
"EQUIP_HEAD" => return EquipmentSlot::Head,
|
||||
|
|
@ -670,12 +671,6 @@ fn find_slot_for_equippable_item(tag: &str, raws: &RawMaster) -> EquipmentSlot {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(equip) = &item.equip {
|
||||
match equip.slot.as_str() {
|
||||
"EQUIP_MELEE" => return EquipmentSlot::Melee,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
panic!("Trying to equip {}, but it has no slot tag.", tag);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue