continuing with the overhaul, allowed entities to wear stuff

This commit is contained in:
Llywelwyn 2023-07-28 06:57:14 +01:00
parent c169a1eae6
commit c2759e9e8e
6 changed files with 148 additions and 13 deletions

View file

@ -97,6 +97,110 @@
"flags": ["EQUIP_SHIELD"],
"effects": { "ac": "4", "melee_power_bonus": "-2" }
},
{
"id": "equip_body_weakleather",
"name": { "name": "leather jacket", "plural": "leather jackets" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BODY"],
"effects": { "ac": "1" }
},
{
"id": "equip_body_leather",
"name": { "name": "leather chestpiece", "plural": "leather chestpiece" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BODY"],
"effects": { "ac": "2" }
},
{
"id": "equip_body_studdedleather",
"name": { "name": "studded leather chestpiece", "plural": "studded leather chestpieces" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BODY"],
"effects": { "ac": "3" }
},
{
"id": "equip_body_ringmail_o",
"name": { "name": "orcish ring mail", "plural": "orcish ring mail" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BODY"],
"effects": { "ac": "3" }
},
{
"id": "equip_body_ringmail",
"name": { "name": "ring mail", "plural": "ring mail" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BODY"],
"effects": { "ac": "4" }
},
{
"id": "equip_head_leather",
"name": { "name": "leather cap", "plural": "leather caps" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_HEAD"],
"effects": { "ac": "1" }
},
{
"id": "equip_head_elvish",
"name": { "name": "elvish leather helm", "plural": "elvish leather helms" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_HEAD"],
"effects": { "ac": "2" }
},
{
"id": "equip_head_o",
"name": { "name": "orcish helm", "plural": "orcish helm" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_HEAD"],
"effects": { "ac": "2" }
},
{
"id": "equip_head_iron",
"name": { "name": "iron helm", "plural": "iron helm" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_HEAD"],
"effects": { "ac": "3" }
},
{
"id": "equip_feet_leather",
"name": { "name": "leather shoes", "plural": "leather shoes" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_FEET"]
},
{
"id": "equip_feet_elvish",
"name": { "name": "elvish leather shoes", "plural": "elvish leather shoes" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_FEET"],
"effects": { "ac": "1" }
},
{
"id": "equip_feet_o",
"name": { "name": "orcish boots", "plural": "orcish boots" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_FEET"],
"effects": { "ac": "1" }
},
{
"id": "equip_feet_iron",
"name": { "name": "iron boots", "plural": "iron boots" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_FEET"],
"effects": { "ac": "2" }
},
{
"id": "equip_neck_protection",
"name": { "name": "amulet of protection", "plural": "amulets of protection" },
"renderable": { "glyph": "\"", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_NECK"],
"effects": { "ac": "1" }
},
{
"id": "equip_back_protection",
"name": { "name": "cloak of protection", "plural": "cloaks of protection" },
"renderable": { "glyph": "[", "fg": "#aa6000", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_BACK"],
"effects": { "ac": "1" }
},
{
"id": "wand_magicmissile",
"name": { "name": "wand of magic missile", "plural": "wands of magic missile" },

View file

@ -66,7 +66,8 @@
"quips": ["You wont catch me down the mine.", "I'm not paid enough for that."],
"attacks": [
{ "name": "hits", "hit_bonus": 0, "damage": "1d8"}
]
],
"equipped": ["equip_shortsword", "equip_body_leather"]
},
{
"id": "dog_little",

View file

@ -2,12 +2,27 @@
{
"id": "equipment",
"table": [
{ "id": "equip_dagger", "weight": 4, "difficulty": 1},
{ "id": "equip_shortsword", "weight": 2, "difficulty": 1},
{ "id": "equip_smallshield", "weight": 4, "difficulty": 1},
{ "id": "equip_mediumshield", "weight": 2, "difficulty": 1},
{ "id": "equip_longsword", "weight": 1, "difficulty": 3},
{ "id": "equip_largeshield", "weight": 1, "difficulty": 3}
{ "id": "equip_dagger", "weight": 3, "difficulty": 1},
{ "id": "equip_shortsword", "weight": 3, "difficulty": 1},
{ "id": "equip_smallshield", "weight": 3, "difficulty": 1},
{ "id": "equip_mediumshield", "weight": 2, "difficulty": 1},
{ "id": "equip_body_weakleather", "weight": 4, "difficulty": 1},
{ "id": "equip_head_leather", "weight": 4, "difficulty": 1},
{ "id": "equip_feet_leather", "weight": 4, "difficulty": 1},
{ "id": "equip_body_leather", "weight": 4, "difficulty": 1},
{ "id": "equip_neck_protection", "weight": 1, "difficulty": 1},
{ "id": "equip_back_protection", "weight": 1, "difficulty": 1},
{ "id": "equip_body_studdedleather","weight": 3, "difficulty": 2},
{ "id": "equip_head_o", "weight": 4, "difficulty": 2},
{ "id": "equip_longsword", "weight": 2, "difficulty": 3},
{ "id": "equip_head_elvish", "weight": 3, "difficulty": 3},
{ "id": "equip_feet_elvish", "weight": 3, "difficulty": 3},
{ "id": "equip_body_ringmail_o", "weight": 4, "difficulty": 3},
{ "id": "equip_feet_o", "weight": 4, "difficulty": 3},
{ "id": "equip_body_ringmail", "weight": 2, "difficulty": 3},
{ "id": "equip_largeshield", "weight": 2, "difficulty": 3},
{ "id": "equip_head_iron", "weight": 3, "difficulty": 4},
{ "id": "equip_feet_iron", "weight": 2, "difficulty": 4}
]
},
{

View file

@ -173,11 +173,11 @@ pub enum EquipmentSlot {
Melee,
Shield,
Head,
Neck,
Torso,
Body,
Hands,
Legs,
Feet,
Neck,
Back,
}
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]

View file

@ -15,6 +15,7 @@ pub struct Mob {
pub skills: Option<HashMap<String, i32>>,
pub vision_range: i32,
pub quips: Option<Vec<String>>,
pub equipped: Option<Vec<String>>,
}
#[derive(Deserialize, Debug)]

View file

@ -107,11 +107,11 @@ pub fn spawn_named_item(raws: &RawMaster, ecs: &mut World, key: &str, pos: Spawn
"EQUIP_MELEE" => eb = eb.with(Equippable { slot: EquipmentSlot::Melee }),
"EQUIP_SHIELD" => eb = eb.with(Equippable { slot: EquipmentSlot::Shield }),
"EQUIP_HEAD" => eb = eb.with(Equippable { slot: EquipmentSlot::Head }),
"EQUIP_TORSO" => eb = eb.with(Equippable { slot: EquipmentSlot::Torso }),
"EQUIP_LEGS" => eb = eb.with(Equippable { slot: EquipmentSlot::Legs }),
"EQUIP_BODY" => eb = eb.with(Equippable { slot: EquipmentSlot::Body }),
"EQUIP_FEET" => eb = eb.with(Equippable { slot: EquipmentSlot::Feet }),
"EQUIP_HANDS" => eb = eb.with(Equippable { slot: EquipmentSlot::Hands }),
"EQUIP_NECK" => eb = eb.with(Equippable { slot: EquipmentSlot::Neck }),
"EQUIP_BACK" => eb = eb.with(Equippable { slot: EquipmentSlot::Back }),
"WAND" => eb = eb.with(Wand { uses: 3, max_uses: 3 }),
"FOOD" => eb = eb.with(ProvidesNutrition {}),
"STRENGTH" => weapon_type = 0,
@ -285,7 +285,15 @@ pub fn spawn_named_mob(raws: &RawMaster, ecs: &mut World, key: &str, pos: SpawnT
eb = eb.with(natural);
}
return Some(eb.build());
let new_mob = eb.build();
// Build entity, then check for anything they're wearing
if let Some(wielding) = &mob_template.equipped {
for tag in wielding.iter() {
spawn_named_entity(raws, ecs, tag, SpawnType::Equipped { by: new_mob });
}
}
return Some(new_mob);
}
None
}
@ -414,6 +422,12 @@ fn find_slot_for_equippable_item(tag: &str, raws: &RawMaster) -> EquipmentSlot {
match flag.as_str() {
"EQUIP_MELEE" => return EquipmentSlot::Melee,
"EQUIP_SHIELD" => return EquipmentSlot::Shield,
"EQUIP_BODY" => return EquipmentSlot::Body,
"EQUIP_HEAD" => return EquipmentSlot::Head,
"EQUIP_FEET" => return EquipmentSlot::Feet,
"EQUIP_NECK" => return EquipmentSlot::Neck,
"EQUIP_BACK" => return EquipmentSlot::Back,
"EQUIP_HANDS" => return EquipmentSlot::Hands,
_ => {}
}
}