mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update triple_strike:
* add knockback * prevent infinite repeat * more dashes
This commit is contained in:
parent
3889ec7292
commit
857652ee23
@ -132,6 +132,7 @@ pub struct Attacking {
|
||||
pub max_angle: f32,
|
||||
pub applied: bool,
|
||||
pub hit_count: u32,
|
||||
pub knockback: f32,
|
||||
}
|
||||
|
||||
impl Component for Attacking {
|
||||
|
@ -48,6 +48,7 @@ impl CharacterBehavior for Data {
|
||||
max_angle: self.max_angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: 0.0,
|
||||
});
|
||||
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
|
@ -58,6 +58,7 @@ impl CharacterBehavior for Data {
|
||||
max_angle: 180_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: 0.0,
|
||||
});
|
||||
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
|
@ -57,6 +57,7 @@ impl CharacterBehavior for Data {
|
||||
max_angle: 75_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: 0.0,
|
||||
});
|
||||
|
||||
update.character = CharacterState::TimedCombo(Data {
|
||||
|
@ -60,28 +60,26 @@ impl CharacterBehavior for Data {
|
||||
let initialized = true;
|
||||
|
||||
// Handling movement
|
||||
if let Stage::First = self.stage {
|
||||
if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) {
|
||||
let adjusted_accel = if data.physics.touch_entity.is_none() {
|
||||
INITIAL_ACCEL
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
// Move player forward while in first third of first stage
|
||||
if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) {
|
||||
update.vel.0 =
|
||||
update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel;
|
||||
let mag2 = update.vel.0.magnitude_squared();
|
||||
if mag2 > BASE_SPEED.powf(2.0) {
|
||||
update.vel.0 = update.vel.0.normalized() * BASE_SPEED;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
handle_orientation(data, &mut update, 10.0);
|
||||
}
|
||||
if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) {
|
||||
let adjusted_accel = match (self.stage, data.physics.touch_entity.is_none()) {
|
||||
(Stage::First, true) => INITIAL_ACCEL,
|
||||
(Stage::Second, true) => INITIAL_ACCEL * 0.75,
|
||||
(Stage::Third, true) => INITIAL_ACCEL * 0.75,
|
||||
(_, _) => 0.0,
|
||||
};
|
||||
|
||||
// Move player forward while in first third of first stage
|
||||
if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) {
|
||||
update.vel.0 =
|
||||
update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel;
|
||||
let mag2 = update.vel.0.magnitude_squared();
|
||||
if mag2 > BASE_SPEED.powf(2.0) {
|
||||
update.vel.0 = update.vel.0.normalized() * BASE_SPEED;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
handle_move(data, &mut update);
|
||||
handle_orientation(data, &mut update, 10.0);
|
||||
}
|
||||
|
||||
// Handling attacking
|
||||
@ -101,6 +99,7 @@ impl CharacterBehavior for Data {
|
||||
max_angle: 180_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: 7.0,
|
||||
});
|
||||
|
||||
CharacterState::TripleStrike(Data {
|
||||
@ -113,18 +112,25 @@ impl CharacterBehavior for Data {
|
||||
})
|
||||
} else if stage_time_active > Duration::from_millis(STAGE_DURATION) {
|
||||
if should_transition {
|
||||
CharacterState::TripleStrike(Data {
|
||||
base_damage: self.base_damage,
|
||||
stage: match self.stage {
|
||||
Stage::First => Stage::Second,
|
||||
Stage::Second => Stage::Third,
|
||||
Stage::Third => Stage::First,
|
||||
},
|
||||
stage_time_active: Duration::default(),
|
||||
stage_exhausted: false,
|
||||
should_transition,
|
||||
initialized,
|
||||
})
|
||||
if let Stage::Third = self.stage {
|
||||
// Make sure attack component is removed
|
||||
data.updater.remove::<Attacking>(data.entity);
|
||||
// Done
|
||||
CharacterState::Wielding
|
||||
} else {
|
||||
CharacterState::TripleStrike(Data {
|
||||
base_damage: self.base_damage,
|
||||
stage: match self.stage {
|
||||
Stage::First => Stage::Second,
|
||||
Stage::Second => Stage::Third,
|
||||
Stage::Third => Stage::First,
|
||||
},
|
||||
stage_time_active: Duration::default(),
|
||||
stage_exhausted: false,
|
||||
should_transition,
|
||||
initialized,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// Make sure attack component is removed
|
||||
data.updater.remove::<Attacking>(data.entity);
|
||||
|
@ -159,7 +159,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
|
||||
|
||||
/// Will attempt to go into `loadout.active_item.ability1`
|
||||
pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.primary.is_pressed() {
|
||||
if data.inputs.primary.is_just_pressed() {
|
||||
if let Some(ability) = data
|
||||
.loadout
|
||||
.active_item
|
||||
@ -174,7 +174,7 @@ pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
|
||||
/// Will attempt to go into `loadout.active_item.ability2`
|
||||
pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.secondary.is_pressed() {
|
||||
if data.inputs.secondary.is_just_pressed() {
|
||||
if let Some(ability) = data
|
||||
.loadout
|
||||
.active_item
|
||||
@ -189,7 +189,7 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
|
||||
/// Will attempt to go into `loadout.active_item.ability3`
|
||||
pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.ability3.is_pressed() {
|
||||
if data.inputs.ability3.is_just_pressed() {
|
||||
if let Some(ability) = data
|
||||
.loadout
|
||||
.active_item
|
||||
@ -205,7 +205,7 @@ pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
/// Checks that player can perform a dodge, then
|
||||
/// attempts to go into `loadout.active_item.dodge_ability`
|
||||
pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.roll.is_pressed() {
|
||||
if data.inputs.roll.is_just_pressed() {
|
||||
if let Some(ability) = data
|
||||
.loadout
|
||||
.active_item
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos,
|
||||
Scale, Stats,
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
sync::Uid,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||
@ -19,6 +19,7 @@ impl<'a> System<'a> for Sys {
|
||||
type SystemData = (
|
||||
Entities<'a>,
|
||||
Read<'a, EventBus<ServerEvent>>,
|
||||
Read<'a, EventBus<LocalEvent>>,
|
||||
ReadStorage<'a, Uid>,
|
||||
ReadStorage<'a, Pos>,
|
||||
ReadStorage<'a, Ori>,
|
||||
@ -36,6 +37,7 @@ impl<'a> System<'a> for Sys {
|
||||
(
|
||||
entities,
|
||||
server_bus,
|
||||
local_bus,
|
||||
uids,
|
||||
positions,
|
||||
orientations,
|
||||
@ -49,6 +51,7 @@ impl<'a> System<'a> for Sys {
|
||||
): Self::SystemData,
|
||||
) {
|
||||
let mut server_emitter = server_bus.emitter();
|
||||
let mut local_emitter = local_bus.emitter();
|
||||
// Attacks
|
||||
for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in (
|
||||
&entities,
|
||||
@ -128,6 +131,13 @@ impl<'a> System<'a> for Sys {
|
||||
cause: HealthSource::Attack { by: *uid },
|
||||
},
|
||||
});
|
||||
if attack.knockback != 0.0 {
|
||||
local_emitter.emit(LocalEvent::KnockUp {
|
||||
entity: b,
|
||||
dir: ori.0,
|
||||
force: attack.knockback,
|
||||
});
|
||||
}
|
||||
attack.hit_count += 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user