Tweaked shockwave values. Added shockwave damage type. Changed how knockback was handled in shockwaves to make negative knockback work better.

This commit is contained in:
Sam 2020-08-09 18:11:58 -05:00
parent 829d8a20d1
commit f5dad20899
4 changed files with 46 additions and 21 deletions

View File

@ -15,6 +15,7 @@ pub enum DamageSource {
Projectile,
Explosion,
Falling,
Shockwave,
}
impl Damage {
@ -74,6 +75,23 @@ impl Damage {
self.healthchange = -10.0;
}
},
DamageSource::Shockwave => {
// Critical hit
if rand::random() {
self.healthchange *= 1.2;
}
// Block
if block {
self.healthchange *= 1.0 - BLOCK_EFFICIENCY
}
// Armor
self.healthchange *= 1.0 - loadout.get_damage_reduction();
// Min damage
if self.healthchange > -10.0 {
self.healthchange = -10.0;
}
},
_ => {},
}
}

View File

@ -118,11 +118,11 @@ impl Tool {
Sword(_) => vec![
GroundShockwave {
energy_cost: 0,
buildup_duration: Duration::from_millis(1000),
recover_duration: Duration::from_millis(2000),
damage: 300,
buildup_duration: Duration::from_millis(500),
recover_duration: Duration::from_millis(1000),
damage: 500,
knockback: -30.0,
shockwave_angle: 15.0,
shockwave_angle: 90.0,
shockwave_speed: 10.0,
shockwave_duration: Duration::from_millis(3000),
},
@ -363,20 +363,20 @@ impl Tool {
vec![
BasicMelee {
energy_cost: 0,
buildup_duration: Duration::from_millis(0),
recover_duration: Duration::from_millis(300),
knockback: 20.0,
buildup_duration: Duration::from_millis(500),
recover_duration: Duration::from_millis(250),
knockback: 25.0,
base_healthchange: -200,
range: 10.0,
max_angle: 120.0,
},
GroundShockwave {
energy_cost: 0,
buildup_duration: Duration::from_millis(1000),
recover_duration: Duration::from_millis(2000),
damage: 300,
buildup_duration: Duration::from_millis(500),
recover_duration: Duration::from_millis(1000),
damage: 500,
knockback: -30.0,
shockwave_angle: 15.0,
shockwave_angle: 90.0,
shockwave_speed: 10.0,
shockwave_duration: Duration::from_millis(3000),
},

View File

@ -31,13 +31,12 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.7);
handle_jump(data, &mut update);
handle_move(data, &mut update, 0.05);
if self.buildup_duration != Duration::default() {
// Build up
update.character = CharacterState::GroundShockwave(Data {
exhausted: false,
exhausted: self.exhausted,
buildup_duration: self
.buildup_duration
.checked_sub(Duration::from_secs_f32(data.dt.0))
@ -79,7 +78,7 @@ impl CharacterBehavior for Data {
} else if self.recover_duration != Duration::default() {
// Recovery
update.character = CharacterState::GroundShockwave(Data {
exhausted: false,
exhausted: self.exhausted,
buildup_duration: self.buildup_duration,
recover_duration: self
.recover_duration

View File

@ -183,7 +183,7 @@ impl<'a> System<'a> for Sys {
}
// Weapon gives base damage
let source = DamageSource::Melee;
let source = DamageSource::Shockwave;
let mut damage = Damage {
healthchange: -(shockwave.damage as f32),
@ -210,11 +210,19 @@ impl<'a> System<'a> for Sys {
});
}
if shockwave.knockback != 0.0 {
local_emitter.emit(LocalEvent::ApplyForce {
entity: b,
force: shockwave.knockback
* *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5),
});
if shockwave.knockback < 0.0 {
local_emitter.emit(LocalEvent::ApplyForce {
entity: b,
force: shockwave.knockback
* *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, -1.0)), 0.5),
});
} else {
local_emitter.emit(LocalEvent::ApplyForce {
entity: b,
force: shockwave.knockback
* *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5),
});
}
}
}
}