add difficulty settings, increase drops

This commit is contained in:
Jim 2025-09-02 17:51:16 -04:00
parent d35344f910
commit dccd6d319e
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
9 changed files with 57 additions and 17 deletions

View file

@ -24,7 +24,27 @@ impl Plugin for CombatPlugin {
tick_invulnerability.in_set(GameSystemSet::StatusEffects),
)
.register_type::<Team>()
.register_type::<Health>();
.register_type::<Health>()
.insert_resource(Difficulty::Chill);
}
}
#[derive(Resource)]
pub enum Difficulty {
Chill,
Casual,
Standard,
Intense,
}
impl Difficulty {
pub fn core_damage_taken_mult(&self) -> f32 {
match self {
Difficulty::Chill => 0.65,
Difficulty::Casual => 0.8,
Difficulty::Standard => 1.0,
Difficulty::Intense => 1.2,
}
}
}
@ -164,6 +184,7 @@ fn on_attack(
Without<Invulnerable>,
>,
names: Query<&Name>,
difficulty: Res<Difficulty>,
) {
let Ok((mut health, invulnerability, opt_defense, opt_team)) =
attacked_query.get_mut(trigger.target())
@ -177,7 +198,16 @@ fn on_attack(
return;
}
let defense = opt_defense.cloned().unwrap_or_default();
let damage_taken = defense.calc_damage(trigger.event().amount);
let damage_amount = if matches!(opt_team, Some(Team::Core)) {
info!(
"reduced damage by {:?}",
difficulty.core_damage_taken_mult()
);
trigger.event().amount * difficulty.core_damage_taken_mult()
} else {
trigger.event().amount
};
let damage_taken = defense.calc_damage(damage_amount);
let old_health = health.current;
health.current = (old_health - damage_taken).max(0.0);
info!(
@ -220,7 +250,7 @@ fn on_die(
mut commands: Commands,
) {
if let Ok(drop) = drops.get(trigger.target()) {
resources.souls += drop.souls;
resources.0 = resources.0 + drop.0;
}
if let Ok(mut ec) = commands.get_entity(trigger.target()) {
info!(