feat: added deadly and execute
This commit is contained in:
parent
1c66dbf499
commit
9550cd2bbb
5 changed files with 237 additions and 47 deletions
|
|
@ -192,7 +192,7 @@ pub fn use_damaging_weapon(
|
|||
Query<&ArmourBodyPart>,
|
||||
Query<(Entity, &DeferredDamage)>,
|
||||
Query<Option<&mut DamageMitigationBonus>>,
|
||||
Query<(&ArmourBypassBonus)>,
|
||||
Query<&ArmourBypassBonus>,
|
||||
),
|
||||
(damage_proc_q, part_bonus_q): (Query<&DamageProcEffect>, Query<&PartDamageBonus>),
|
||||
(mut ammo_q, mut temp_q): (
|
||||
|
|
@ -245,6 +245,7 @@ pub fn use_damaging_weapon(
|
|||
commands.entity(instance).despawn();
|
||||
|
||||
if p_health.0 == 0 {
|
||||
commands.entity(player).insert(Defeated);
|
||||
log!(logger, "fight_end", {
|
||||
actor: target,
|
||||
recipient: player,
|
||||
|
|
@ -466,7 +467,7 @@ pub fn use_damaging_weapon(
|
|||
|
||||
// TODO: special ammo
|
||||
|
||||
let dmg = dmg_intrinsic
|
||||
let mut dmg = dmg_intrinsic
|
||||
* w_dmg.0
|
||||
* (1.0 + dmg_bonus.value)
|
||||
* (1.0 - armour_mitigation)
|
||||
|
|
@ -474,12 +475,12 @@ pub fn use_damaging_weapon(
|
|||
* (1.0 - bonus_mitigation)
|
||||
* mult
|
||||
* dmg_spread;
|
||||
let dmg = dmg.round() as u32;
|
||||
let mut dmg_i = dmg.round() as u32;
|
||||
|
||||
metrics.record_histogram(Some(player), "dmg", dmg);
|
||||
metrics.record_histogram(Some(weapon), "dmg", dmg);
|
||||
metrics.record_histogram(Some(player), "dmg", dmg_i);
|
||||
metrics.record_histogram(Some(weapon), "dmg", dmg_i);
|
||||
|
||||
if dmg > 0 {
|
||||
if dmg_i > 0 {
|
||||
for effect in damage_proc_q.iter_many(children) {
|
||||
match *effect {
|
||||
DamageProcEffect::MultiTurn { value, bonus } => {
|
||||
|
|
@ -528,18 +529,54 @@ pub fn use_damaging_weapon(
|
|||
DamageOverTimeType::Bleed => {
|
||||
commands
|
||||
.entity(target)
|
||||
.insert(DamageOverTime::<Bleed>::new(dmg));
|
||||
.insert(DamageOverTime::<Bleed>::new(dmg_i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DamageProcEffect::Deadly { chance } => {
|
||||
if chance >= 1.0 || rng.random_bool(chance as f64) {
|
||||
dmg = dmg_intrinsic
|
||||
* w_dmg.0
|
||||
* (1.0 + dmg_bonus.value + 5.0)
|
||||
* (1.0 - armour_mitigation)
|
||||
* (1.0 - def_mitigation)
|
||||
* (1.0 - bonus_mitigation)
|
||||
* mult
|
||||
* dmg_spread;
|
||||
dmg_i = dmg.round() as u32;
|
||||
}
|
||||
}
|
||||
DamageProcEffect::Execute { cutoff } => {
|
||||
if health.0 as f32 / target_max_health.value as f32 <= cutoff {
|
||||
commands.entity(target).insert(Defeated);
|
||||
let health_before = health.0;
|
||||
health.0 = 0;
|
||||
log!(logger, "executed", {
|
||||
actor: player,
|
||||
recipient: target,
|
||||
health_before,
|
||||
});
|
||||
log!(logger, "fight_end", {
|
||||
actor: player,
|
||||
recipient: target,
|
||||
fight_end_type: %if attacker {
|
||||
FightEndType::Victory
|
||||
} else {
|
||||
FightEndType::Loss
|
||||
},
|
||||
});
|
||||
metrics.increment_counter(Some(player), "victory", 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let health_before = health.0;
|
||||
|
||||
health.0 = health.0.saturating_sub(dmg as u16);
|
||||
health.0 = health.0.saturating_sub(dmg_i as u16);
|
||||
|
||||
log!(logger, "hit_target", {
|
||||
actor: player,
|
||||
|
|
@ -551,7 +588,7 @@ pub fn use_damaging_weapon(
|
|||
rounds,
|
||||
health_before: health_before,
|
||||
health_after: health.0,
|
||||
dmg,
|
||||
dmg: dmg_i,
|
||||
dmg_spread,
|
||||
dmg_intrinsic,
|
||||
dmg_weapon: w_dmg.0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue