mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Small fixes
This commit is contained in:
parent
7bd4686187
commit
3f0f1c423c
@ -1,4 +1,4 @@
|
||||
use crate::{combat::DamageContributor, comp, uid::Uid};
|
||||
use crate::{combat::DamageContributor, comp, uid::Uid, DamageSource};
|
||||
use comp::{beam, item::Reagent, poise::PoiseState, skillset::SkillGroupKind, UtteranceKind};
|
||||
use hashbrown::HashSet;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -10,6 +10,7 @@ pub struct HealthChangeInfo {
|
||||
pub crit: bool,
|
||||
pub target: Uid,
|
||||
pub by: Option<DamageContributor>,
|
||||
pub cause: Option<DamageSource>,
|
||||
pub instance: u64,
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ pub fn handle_health_change(server: &Server, entity: EcsEntity, change: HealthCh
|
||||
amount: change.amount,
|
||||
by: change.by,
|
||||
target: *uid,
|
||||
cause: change.cause,
|
||||
crit: change.crit,
|
||||
instance: change.instance,
|
||||
},
|
||||
@ -571,48 +572,47 @@ pub fn handle_land_on_ground(server: &Server, entity: EcsEntity, vel: Vec3<f32>)
|
||||
let stats = ecs.read_storage::<Stats>();
|
||||
let time = ecs.read_resource::<Time>();
|
||||
let msm = ecs.read_resource::<MaterialStatManifest>();
|
||||
let server_eventbus = ecs.read_resource::<EventBus<ServerEvent>>();
|
||||
|
||||
// Handle health change
|
||||
if let Some(mut health) = ecs.write_storage::<comp::Health>().get_mut(entity) {
|
||||
let damage = Damage {
|
||||
source: DamageSource::Falling,
|
||||
kind: DamageKind::Crushing,
|
||||
value: falldmg,
|
||||
};
|
||||
let damage_reduction = Damage::compute_damage_reduction(
|
||||
Some(damage),
|
||||
inventories.get(entity),
|
||||
stats.get(entity),
|
||||
&msm,
|
||||
);
|
||||
let change = damage.calculate_health_change(
|
||||
damage_reduction,
|
||||
None,
|
||||
false,
|
||||
0.0,
|
||||
1.0,
|
||||
*time,
|
||||
rand::random(),
|
||||
);
|
||||
health.change_by(change);
|
||||
let server_eventbus = ecs.read_resource::<EventBus<ServerEvent>>();
|
||||
server_eventbus.emit_now(ServerEvent::HealthChange { entity, change });
|
||||
}
|
||||
// Emit health change
|
||||
let damage = Damage {
|
||||
source: DamageSource::Falling,
|
||||
kind: DamageKind::Crushing,
|
||||
value: falldmg,
|
||||
};
|
||||
let damage_reduction = Damage::compute_damage_reduction(
|
||||
Some(damage),
|
||||
inventories.get(entity),
|
||||
stats.get(entity),
|
||||
&msm,
|
||||
);
|
||||
let change = damage.calculate_health_change(
|
||||
damage_reduction,
|
||||
None,
|
||||
false,
|
||||
0.0,
|
||||
1.0,
|
||||
*time,
|
||||
rand::random(),
|
||||
);
|
||||
|
||||
// Handle poise change
|
||||
if let Some(mut poise) = ecs.write_storage::<comp::Poise>().get_mut(entity) {
|
||||
let poise_damage = -(mass.0 * vel.magnitude_squared() / 1500.0);
|
||||
let poise_change =
|
||||
Poise::apply_poise_reduction(poise_damage, inventories.get(entity), &msm);
|
||||
let poise_change = comp::PoiseChange {
|
||||
amount: poise_change,
|
||||
impulse: Vec3::unit_z(),
|
||||
by: None,
|
||||
cause: None,
|
||||
time: *time,
|
||||
};
|
||||
poise.change(poise_change);
|
||||
}
|
||||
server_eventbus.emit_now(ServerEvent::HealthChange { entity, change });
|
||||
|
||||
// Emit poise change
|
||||
let poise_damage = -(mass.0 * vel.magnitude_squared() / 1500.0);
|
||||
let poise_change =
|
||||
Poise::apply_poise_reduction(poise_damage, inventories.get(entity), &msm);
|
||||
let poise_change = comp::PoiseChange {
|
||||
amount: poise_change,
|
||||
impulse: Vec3::unit_z(),
|
||||
by: None,
|
||||
cause: None,
|
||||
time: *time,
|
||||
};
|
||||
server_eventbus.emit_now(ServerEvent::PoiseChange {
|
||||
entity,
|
||||
change: poise_change,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ use common::{
|
||||
outcome::Outcome,
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
uid::Uid,
|
||||
DamageSource,
|
||||
};
|
||||
use common_state::State;
|
||||
use event_mapper::SfxEventMapper;
|
||||
@ -527,8 +528,10 @@ impl SfxMgr {
|
||||
);
|
||||
},
|
||||
Outcome::HealthChange { pos, info, .. } => {
|
||||
// Don't emit sound effects from positive damage (healing)
|
||||
if info.amount < Health::HEALTH_EPSILON {
|
||||
// Ignore positive damage (healing) and buffs for now
|
||||
if info.amount < Health::HEALTH_EPSILON
|
||||
&& !matches!(info.cause, Some(DamageSource::Buff(_)))
|
||||
{
|
||||
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Damage);
|
||||
audio.emit_sfx(sfx_trigger_item, *pos, Some(1.5), underwater);
|
||||
}
|
||||
|
@ -2192,7 +2192,8 @@ impl Hud {
|
||||
let font_col = font_col(font_size, crit);
|
||||
// Timer sets the widget offset
|
||||
let y = if crit {
|
||||
ui_widgets.win_h * (floater.rand as f64 % 0.1) + ui_widgets.win_h * 0.05
|
||||
ui_widgets.win_h * (floater.rand as f64 % 0.075)
|
||||
+ ui_widgets.win_h * 0.05
|
||||
} else {
|
||||
(floater.timer as f64 / crate::ecs::sys::floater::HP_SHOWTIME as f64
|
||||
* number_speed)
|
||||
|
Loading…
Reference in New Issue
Block a user