mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made stunned state invulnerable to poise damage
Fixing silly error for comp creation
This commit is contained in:
parent
dd69b5f2bc
commit
0f244bf84b
@ -173,7 +173,6 @@ impl Poise {
|
||||
}
|
||||
|
||||
pub fn change_by(&mut self, change: PoiseChange, impulse: Vec3<f32>) {
|
||||
println!("Poise change: {:?}", change);
|
||||
self.current = ((self.current as i32 + change.amount).max(0) as u32).min(self.maximum);
|
||||
self.knockback = impulse;
|
||||
self.last_change = (0.0, PoiseChange {
|
||||
|
@ -51,7 +51,7 @@ pub struct JoinData<'a> {
|
||||
pub controller: &'a Controller,
|
||||
pub inputs: &'a ControllerInputs,
|
||||
pub health: &'a Health,
|
||||
pub poise: Option<&'a Poise>,
|
||||
pub poise: &'a Poise,
|
||||
pub energy: &'a Energy,
|
||||
pub inventory: &'a Inventory,
|
||||
pub body: &'a Body,
|
||||
@ -81,7 +81,7 @@ pub type JoinTuple<'a> = (
|
||||
RestrictedMut<'a, Inventory>,
|
||||
&'a mut Controller,
|
||||
&'a Health,
|
||||
Option<&'a Poise>,
|
||||
&'a Poise,
|
||||
&'a Body,
|
||||
&'a PhysicsState,
|
||||
Option<&'a Attacking>,
|
||||
|
@ -120,7 +120,7 @@ impl<'a> System<'a> for Sys {
|
||||
&mut inventories.restrict_mut(),
|
||||
&mut controllers,
|
||||
&healths,
|
||||
poises.maybe(),
|
||||
&poises,
|
||||
&bodies,
|
||||
&physics_states,
|
||||
attacking_storage.maybe(),
|
||||
|
@ -190,7 +190,6 @@ impl<'a> System<'a> for Sys {
|
||||
entity,
|
||||
impulse: 5.0 * poise.knockback(),
|
||||
});
|
||||
//handle_knockback(server, entity, 5.0 * knockback_dir);
|
||||
},
|
||||
PoiseState::Dazed => {
|
||||
poise.reset();
|
||||
@ -203,7 +202,10 @@ impl<'a> System<'a> for Sys {
|
||||
stage_section: common::states::utils::StageSection::Buildup,
|
||||
was_wielded,
|
||||
});
|
||||
//handle_knockback(server, entity, 10.0 * knockback_dir);
|
||||
server_event_emitter.emit(ServerEvent::Knockback {
|
||||
entity,
|
||||
impulse: 10.0 * poise.knockback(),
|
||||
});
|
||||
},
|
||||
PoiseState::KnockedDown => {
|
||||
poise.reset();
|
||||
@ -216,7 +218,10 @@ impl<'a> System<'a> for Sys {
|
||||
stage_section: common::states::utils::StageSection::Buildup,
|
||||
was_wielded,
|
||||
});
|
||||
//handle_knockback(server, entity, 10.0 * knockback_dir);
|
||||
server_event_emitter.emit(ServerEvent::Knockback {
|
||||
entity,
|
||||
impulse: 10.0 * poise.knockback(),
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use common::{
|
||||
combat,
|
||||
comp::{
|
||||
self, aura, buff,
|
||||
chat::{KillSource, KillType},
|
||||
chat::{KillSource, KillType}, CharacterState,
|
||||
object, Alignment, Body, Energy, EnergyChange, Group, Health, HealthChange, HealthSource,
|
||||
Inventory, Item, Player, Poise, PoiseChange, PoiseSource, Pos, Stats,
|
||||
},
|
||||
@ -41,8 +41,12 @@ pub fn handle_poise(
|
||||
knockback_dir: Vec3<f32>,
|
||||
) {
|
||||
let ecs = &server.state.ecs();
|
||||
if let Some(poise) = ecs.write_storage::<Poise>().get_mut(entity) {
|
||||
poise.change_by(change, knockback_dir);
|
||||
if let Some(character_state) = ecs.read_storage::<CharacterState>().get(entity) {
|
||||
if !character_state.is_stunned() {
|
||||
if let Some(poise) = ecs.write_storage::<Poise>().get_mut(entity) {
|
||||
poise.change_by(change, knockback_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,19 @@ impl StateExt for State {
|
||||
Effect::PoiseChange(poise_damage) => {
|
||||
let loadouts = self.ecs().read_storage::<comp::Loadout>();
|
||||
let change = poise_damage.modify_poise_damage(loadouts.get(entity));
|
||||
self.ecs()
|
||||
.write_storage::<comp::Poise>()
|
||||
.get_mut(entity)
|
||||
.map(|poise| poise.change_by(change, Vec3::zero()));
|
||||
// Check to make sure the entity is not already stunned
|
||||
if let Some(character_state) = self
|
||||
.ecs()
|
||||
.read_storage::<comp::CharacterState>()
|
||||
.get(entity)
|
||||
{
|
||||
if !character_state.is_stunned() {
|
||||
self.ecs()
|
||||
.write_storage::<comp::Poise>()
|
||||
.get_mut(entity)
|
||||
.map(|poise| poise.change_by(change, Vec3::zero()));
|
||||
}
|
||||
}
|
||||
},
|
||||
Effect::Buff(buff) => {
|
||||
self.ecs()
|
||||
|
@ -108,6 +108,10 @@ impl<'a> TrackedComps<'a> {
|
||||
.get(entity)
|
||||
.cloned()
|
||||
.map(|c| comps.push(c.into()));
|
||||
self.poise
|
||||
.get(entity)
|
||||
.cloned()
|
||||
.map(|c| comps.push(c.into()));
|
||||
self.can_build
|
||||
.get(entity)
|
||||
.cloned()
|
||||
@ -214,6 +218,7 @@ impl<'a> ReadTrackers<'a> {
|
||||
.with_component(&comps.uid, &*self.auras, &comps.auras, filter)
|
||||
.with_component(&comps.uid, &*self.energy, &comps.energy, filter)
|
||||
.with_component(&comps.uid, &*self.health, &comps.health, filter)
|
||||
.with_component(&comps.uid, &*self.poise, &comps.poise, filter)
|
||||
.with_component(&comps.uid, &*self.can_build, &comps.can_build, filter)
|
||||
.with_component(
|
||||
&comps.uid,
|
||||
@ -282,6 +287,7 @@ fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) {
|
||||
trackers.auras.record_changes(&comps.auras);
|
||||
trackers.energy.record_changes(&comps.energy);
|
||||
trackers.health.record_changes(&comps.health);
|
||||
trackers.poise.record_changes(&comps.poise);
|
||||
trackers.can_build.record_changes(&comps.can_build);
|
||||
trackers.light_emitter.record_changes(&comps.light_emitter);
|
||||
trackers.item.record_changes(&comps.item);
|
||||
|
Loading…
Reference in New Issue
Block a user