Extending the Combat System
Learn how to make the combat system better.
The current combat system is very simple. An entity attacks another entity and always inflicts one point of damage. This type of combat system doesn’t provide much of a difficulty curve as the adventurer progresses through the dungeon.
Let’s fix this problem by allowing different entities to inflict varying amounts of damage. Specifically, we’ll adjust the game so that the adventurer can inflict more damage as they find better weapons, and some monsters will cause more damage to the player thanks to bigger claws.
Damage from weapons and claws
Add a base_damage
field to the Template
structure in the spawner/template.rs
:
#[derive(Clone, Deserialize, Debug)]pub struct Template {pub entity_type : EntityType,pub levels : HashSet<usize>,pub frequency : i32,pub name : String,pub glyph : char,pub provides : Option<Vec<(String, i32)>>,pub hp : Option<i32>,pub base_damage : Option<i32>}
We have successfully updated the data format. Next, we have to add damage statistics to the monsters in the resources/template.ron
. Add more monsters and adjust their level distribution so that more dangerous monsters only appear later in the game:
Template(entity_type: Enemy,name : "Goblin", glyph : 'g', levels : [ 0 ],hp : Some(1),frequency: 3,base_damage: Some(1)),Template(entity_type: Enemy,name : "Orc", glyph : 'o', levels : [ 0, 1, 2 ],hp : Some(2),frequency: 2,base_damage: Some(1)),Template(entity_type: Enemy,name : "Ogre", glyph : 'O', levels : [ 1, 2 ],hp : Some(5),frequency: 1,base_damage: Some(2)),Template(entity_type: Enemy,name : "Ettin", glyph : 'E', levels : [ 2 ],hp : Some(10),frequency: 1,base_damage: Some(3)),
We’ve now implemented a difficulty curve. Monsters become progressively more dangerous as the adventurer explores the dungeon’s ...