From 2785eb10f1fb722d64c4b6b4dab921f0517c1621 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 4 Jan 2022 11:16:36 -0500 Subject: [PATCH] Add components for handling natural attacks --- src/components.rs | 15 +++++++++++++++ src/main.rs | 1 + src/raws/mob_structs.rs | 14 ++++++++++++++ src/saveload_system.rs | 2 ++ 4 files changed, 32 insertions(+) diff --git a/src/components.rs b/src/components.rs index 527cc3e..6f79078 100644 --- a/src/components.rs +++ b/src/components.rs @@ -322,6 +322,21 @@ pub struct Pools { pub level: i32, } +#[derive(Serialize, Deserialize, Clone)] +pub struct NaturalAttack { + pub name: String, + pub damage_n_dice: i32, + pub damage_die_type: i32, + pub damage_bonus: i32, + pub hit_bonus: i32, +} + +#[derive(Component, Serialize, Deserialize, Clone)] +pub struct NaturalAttackDefense { + pub armor_class: Option, + pub attacks: Vec, +} + // Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an // Entity. diff --git a/src/main.rs b/src/main.rs index 005b3f3..d517161 100644 --- a/src/main.rs +++ b/src/main.rs @@ -537,6 +537,7 @@ fn main() -> ::rltk::BError { Attributes, Skills, Pools, + NaturalAttackDefense, ); gs.ecs.insert(SimpleMarkerAllocator::::new()); diff --git a/src/raws/mob_structs.rs b/src/raws/mob_structs.rs index 8e7895f..c2e53c5 100644 --- a/src/raws/mob_structs.rs +++ b/src/raws/mob_structs.rs @@ -18,6 +18,7 @@ pub struct Mob { pub hp: Option, pub mana: Option, pub equipped: Option>, + pub natural: Option, } #[derive(Deserialize, Debug)] @@ -27,3 +28,16 @@ pub struct MobAttributes { pub quickness: Option, pub intelligence: Option, } + +#[derive(Deserialize, Debug)] +pub struct MobNatural { + pub armor_class: Option, + pub attacks: Option>, +} + +#[derive(Deserialize, Debug)] +pub struct NaturalAttack { + pub name: String, + pub hit_bonus: i32, + pub damage: String, +} diff --git a/src/saveload_system.rs b/src/saveload_system.rs index c9bcb36..f2ce065 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -94,6 +94,7 @@ pub fn save_game(ecs: &mut World) { Attributes, Skills, Pools, + NaturalAttackDefense, ); } @@ -190,6 +191,7 @@ pub fn load_game(ecs: &mut World) { Attributes, Skills, Pools, + NaturalAttackDefense, ); }