add difficulty settings, increase drops
This commit is contained in:
parent
d35344f910
commit
dccd6d319e
9 changed files with 57 additions and 17 deletions
|
|
@ -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!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue