diff --git a/src/components.rs b/src/components.rs index ae3a6bf..746024d 100644 --- a/src/components.rs +++ b/src/components.rs @@ -291,6 +291,11 @@ pub struct LightSource { pub range: i32, } +#[derive(Component, Debug, Serialize, Deserialize, Clone)] +pub struct Initiative { + pub current: i32, +} + // 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 d5117ce..8cb25a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -467,6 +467,7 @@ fn main() -> ::rltk::BError { HungerClock, InBackpack, InflictsDamage, + Initiative, Item, LightSource, LootTable, diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index 0ba884d..6d390da 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -293,6 +293,9 @@ pub fn spawn_named_mob( // Spawn in the specified location eb = spawn_position(pos, eb, key, raws); + // Initiative of 2 + eb = eb.with(Initiative { current: 2 }); + // Renderable if let Some(renderable) = &mob_template.renderable { eb = eb.with(get_renderable_component(renderable)); diff --git a/src/saveload_system.rs b/src/saveload_system.rs index 2258dfc..cad6110 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -79,6 +79,7 @@ pub fn save_game(ecs: &mut World) { HungerClock, InBackpack, InflictsDamage, + Initiative, Item, LightSource, LootTable, @@ -184,6 +185,7 @@ pub fn load_game(ecs: &mut World) { HungerClock, InBackpack, InflictsDamage, + Initiative, Item, LightSource, LootTable, diff --git a/src/spawner.rs b/src/spawner.rs index 2b7ad49..e6700f9 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -54,6 +54,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { color: RGB::from_f32(1.0, 1.0, 0.5), range: 8, }) + .with(Initiative { current: 0 }) .marked::>() .build();