mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed comments.
This commit is contained in:
parent
7971034fde
commit
52c93f613e
@ -8,14 +8,22 @@ use vek::*;
|
||||
|
||||
pub const BLOCK_EFFICIENCY: f32 = 0.9;
|
||||
|
||||
/// Each section of this struct determines what damage is applied to a
|
||||
/// particular target, using some identifier
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Damages {
|
||||
/// Targets enemies, and all other creatures not in your group
|
||||
pub enemy: Option<Damage>,
|
||||
/// Targets people in the same group as you, and any pets you have
|
||||
pub group: Option<Damage>,
|
||||
}
|
||||
|
||||
impl Damages {
|
||||
pub fn new(enemy: Option<Damage>, group: Option<Damage>) -> Self { Damages { enemy, group } }
|
||||
|
||||
pub fn get_damage(self, same_group: bool) -> Option<Damage> {
|
||||
if same_group { self.group } else { self.enemy }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -49,11 +57,7 @@ impl Damage {
|
||||
damage *= 1.0 - BLOCK_EFFICIENCY
|
||||
}
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
damage *= 1.0 - damage_reduction;
|
||||
|
||||
// Critical damage applies after armor for melee
|
||||
@ -77,11 +81,7 @@ impl Damage {
|
||||
damage *= 1.0 - BLOCK_EFFICIENCY
|
||||
}
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
damage *= 1.0 - damage_reduction;
|
||||
|
||||
HealthChange {
|
||||
@ -96,11 +96,7 @@ impl Damage {
|
||||
damage *= 1.0 - BLOCK_EFFICIENCY
|
||||
}
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
damage *= 1.0 - damage_reduction;
|
||||
|
||||
HealthChange {
|
||||
@ -111,11 +107,7 @@ impl Damage {
|
||||
Damage::Shockwave(damage) => {
|
||||
let mut damage = damage;
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
damage *= 1.0 - damage_reduction;
|
||||
|
||||
HealthChange {
|
||||
@ -126,11 +118,7 @@ impl Damage {
|
||||
Damage::Energy(damage) => {
|
||||
let mut damage = damage;
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
damage *= 1.0 - damage_reduction;
|
||||
|
||||
HealthChange {
|
||||
@ -145,11 +133,7 @@ impl Damage {
|
||||
Damage::Falling(damage) => {
|
||||
let mut damage = damage;
|
||||
// Armor
|
||||
let damage_reduction = if let Some(loadout) = loadout {
|
||||
loadout.get_damage_reduction()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let damage_reduction = loadout.map_or(0.0, |l| l.get_damage_reduction());
|
||||
if (damage_reduction - 1.0).abs() < f32::EPSILON {
|
||||
damage = 0.0;
|
||||
}
|
||||
@ -171,7 +155,7 @@ pub enum Knockback {
|
||||
}
|
||||
|
||||
impl Knockback {
|
||||
pub fn get_knockback(self, dir: Dir) -> Vec3<f32> {
|
||||
pub fn calculate_impulse(self, dir: Dir) -> Vec3<f32> {
|
||||
match self {
|
||||
Knockback::Away(strength) => strength * *Dir::slerp(dir, Dir::new(Vec3::unit_z()), 0.5),
|
||||
Knockback::Towards(strength) => {
|
||||
|
@ -74,14 +74,12 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::BasicBeam(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
particle_ori: Some(*data.inputs.look_dir),
|
||||
offset: self.offset,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Creates beam
|
||||
@ -97,11 +95,11 @@ impl CharacterBehavior for Data {
|
||||
};
|
||||
// Build up
|
||||
update.character = CharacterState::BasicBeam(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Cast,
|
||||
particle_ori: Some(*data.inputs.look_dir),
|
||||
offset: eye_height * 0.55,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -139,14 +137,12 @@ impl CharacterBehavior for Data {
|
||||
ori: Ori(data.inputs.look_dir),
|
||||
});
|
||||
update.character = CharacterState::BasicBeam(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
particle_ori: Some(*data.inputs.look_dir),
|
||||
offset: self.offset,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Consumes energy if there's enough left and ability key is held down
|
||||
@ -156,25 +152,22 @@ impl CharacterBehavior for Data {
|
||||
);
|
||||
} else {
|
||||
update.character = CharacterState::BasicBeam(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
particle_ori: Some(*data.inputs.look_dir),
|
||||
offset: self.offset,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Recover => {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
update.character = CharacterState::BasicBeam(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
particle_ori: Some(*data.inputs.look_dir),
|
||||
offset: self.offset,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -51,31 +51,27 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Swing,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Swing => {
|
||||
if !self.exhausted {
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Hit attempt
|
||||
@ -93,21 +89,18 @@ impl CharacterBehavior for Data {
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -115,13 +108,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recovery
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -54,8 +54,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
@ -63,7 +62,7 @@ impl CharacterBehavior for Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -84,9 +83,8 @@ impl CharacterBehavior for Data {
|
||||
|
||||
update.character = CharacterState::BasicRanged(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: self.timer,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
..*self
|
||||
});
|
||||
} else if self.timer < self.static_data.recover_duration {
|
||||
// Recovers
|
||||
@ -96,8 +94,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -36,11 +36,11 @@ impl CharacterBehavior for Data {
|
||||
update.vel.0 += *data.inputs.look_dir * 500.0 * data.dt.0;
|
||||
}
|
||||
update.character = CharacterState::Boost(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -68,14 +68,12 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Charge the attack
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: self.stage_section,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: charge,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
@ -88,14 +86,11 @@ impl CharacterBehavior for Data {
|
||||
{
|
||||
// Maintains charge
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: self.stage_section,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
@ -106,11 +101,9 @@ impl CharacterBehavior for Data {
|
||||
} else {
|
||||
// Transitions to swing
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: StageSection::Swing,
|
||||
timer: Duration::default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -135,35 +128,28 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Starts swinging
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: self.stage_section,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
exhausted: true,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: self.stage_section,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: StageSection::Recover,
|
||||
timer: Duration::default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -171,14 +157,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recovers
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
static_data: self.static_data,
|
||||
stage_section: self.stage_section,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
exhausted: self.exhausted,
|
||||
charge_amount: self.charge_amount,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -63,21 +63,18 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Charge,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -124,23 +121,21 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: true,
|
||||
..*self
|
||||
});
|
||||
} else if self.timer < self.static_data.charge_duration
|
||||
&& data.inputs.secondary.is_pressed()
|
||||
{
|
||||
// Charges
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
@ -151,13 +146,11 @@ impl CharacterBehavior for Data {
|
||||
} else if data.inputs.secondary.is_pressed() {
|
||||
// Holds charge
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
@ -171,13 +164,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recovers
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -100,8 +100,6 @@ impl CharacterBehavior for Data {
|
||||
// Build up
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
@ -111,18 +109,15 @@ impl CharacterBehavior for Data {
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: self.next_stage,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Swing,
|
||||
next_stage: self.next_stage,
|
||||
..*self
|
||||
});
|
||||
|
||||
// Hit attempt
|
||||
@ -158,8 +153,6 @@ impl CharacterBehavior for Data {
|
||||
// Swings
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
@ -169,18 +162,15 @@ impl CharacterBehavior for Data {
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: self.next_stage,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
next_stage: self.next_stage,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -191,8 +181,6 @@ impl CharacterBehavior for Data {
|
||||
// Checks if state will transition to next stage after recover
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
@ -205,14 +193,12 @@ impl CharacterBehavior for Data {
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: true,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
@ -225,8 +211,7 @@ impl CharacterBehavior for Data {
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: self.next_stage,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
} else if self.next_stage {
|
||||
@ -234,10 +219,10 @@ impl CharacterBehavior for Data {
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: (self.stage % self.static_data.num_stages) + 1,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
next_stage: false,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -81,25 +81,19 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to charge section of stage
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: !data.inputs.secondary.is_pressed(),
|
||||
timer: Duration::default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: StageSection::Charge,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -146,20 +140,15 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
}
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
..*self
|
||||
})
|
||||
} else if self.refresh_timer < Duration::from_millis(50) {
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
@ -168,20 +157,17 @@ impl CharacterBehavior for Data {
|
||||
.refresh_timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
})
|
||||
} else {
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
refresh_timer: Duration::default(),
|
||||
stage_section: self.stage_section,
|
||||
exhausted: false,
|
||||
..*self
|
||||
})
|
||||
}
|
||||
|
||||
@ -193,12 +179,9 @@ impl CharacterBehavior for Data {
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: Duration::default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: StageSection::Swing,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -206,25 +189,18 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: Duration::default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -232,15 +208,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recover
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
auto_charge: self.auto_charge,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
refresh_timer: self.refresh_timer,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -32,11 +32,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Draw weapon
|
||||
update.character = CharacterState::Equipping(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -76,8 +76,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transition to buildup
|
||||
@ -85,7 +84,7 @@ impl CharacterBehavior for Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -107,8 +106,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transition to shoot
|
||||
@ -116,7 +114,7 @@ impl CharacterBehavior for Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Shoot,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -162,8 +160,8 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
reps_remaining: self.reps_remaining - 1,
|
||||
..*self
|
||||
});
|
||||
} else if self.timer < self.static_data.shoot_duration {
|
||||
// Finish shooting
|
||||
@ -173,8 +171,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transition to recover
|
||||
@ -182,7 +179,7 @@ impl CharacterBehavior for Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -198,8 +195,7 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
reps_remaining: self.reps_remaining,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -54,21 +54,18 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::Roll(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
was_wielded: self.was_wielded,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to movement section of stage
|
||||
update.character = CharacterState::Roll(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Movement,
|
||||
was_wielded: self.was_wielded,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -76,21 +73,18 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.movement_duration {
|
||||
// Movement
|
||||
update.character = CharacterState::Roll(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
was_wielded: self.was_wielded,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::Roll(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
was_wielded: self.was_wielded,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -98,13 +92,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::Roll(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
was_wielded: self.was_wielded,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -57,12 +57,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::Shockwave(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Attack
|
||||
@ -87,9 +86,9 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Transitions to swing
|
||||
update.character = CharacterState::Shockwave(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Swing,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -97,19 +96,18 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
update.character = CharacterState::Shockwave(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover
|
||||
update.character = CharacterState::Shockwave(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -117,12 +115,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.swing_duration {
|
||||
// Recovers
|
||||
update.character = CharacterState::Shockwave(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -80,34 +80,27 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: StageSection::Swing,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Swing => {
|
||||
if !self.exhausted {
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
..*self
|
||||
});
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
@ -136,14 +129,11 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Swings
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else if update.energy.current() >= self.static_data.energy_cost
|
||||
&& (self.spins_remaining != 0
|
||||
@ -155,11 +145,10 @@ impl CharacterBehavior for Data {
|
||||
self.spins_remaining - 1
|
||||
};
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: new_spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: false,
|
||||
..*self
|
||||
});
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
update.energy.change_by(
|
||||
@ -169,11 +158,9 @@ impl CharacterBehavior for Data {
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -181,14 +168,11 @@ impl CharacterBehavior for Data {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recover
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
|
@ -168,10 +168,8 @@ impl<'a> System<'a> for Sys {
|
||||
continue;
|
||||
}
|
||||
|
||||
let damage = if !same_group && beam_segment.damages.enemy.is_some() {
|
||||
beam_segment.damages.enemy.unwrap()
|
||||
} else if same_group && beam_segment.damages.group.is_some() {
|
||||
beam_segment.damages.group.unwrap()
|
||||
let damage = if let Some(damage) = beam_segment.damages.get_damage(same_group) {
|
||||
damage
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
@ -182,7 +180,7 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
let change = damage.modify_damage(block, loadouts.get(b), beam_segment.owner);
|
||||
|
||||
if let Damage::Energy(_) = damage {
|
||||
if matches!(damage, Damage::Healing(_)) {
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: *uid_b,
|
||||
change,
|
||||
@ -205,21 +203,18 @@ impl<'a> System<'a> for Sys {
|
||||
EnergySource::HitEnemy,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Damage::Healing(_) = damage {
|
||||
if let Some(energy_mut) = beam_owner.and_then(|o| energies.get_mut(o)) {
|
||||
if energy_mut
|
||||
.try_change_by(
|
||||
-(beam_segment.energy_cost as i32), // Stamina use
|
||||
EnergySource::Ability,
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: *uid_b,
|
||||
change,
|
||||
});
|
||||
}
|
||||
} else if let Some(energy_mut) = beam_owner.and_then(|o| energies.get_mut(o)) {
|
||||
if energy_mut
|
||||
.try_change_by(
|
||||
-(beam_segment.energy_cost as i32), // Stamina use
|
||||
EnergySource::Ability,
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: *uid_b,
|
||||
change,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Adds entities that were hit to the hit_entities list on the beam, sees if it
|
||||
|
@ -11,7 +11,6 @@ use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}
|
||||
use std::time::Duration;
|
||||
use vek::*;
|
||||
|
||||
pub const BLOCK_EFFICIENCY: f32 = 0.9;
|
||||
pub const BLOCK_ANGLE: f32 = 180.0;
|
||||
|
||||
/// This system is responsible for handling accepted inputs like moving or
|
||||
@ -111,10 +110,8 @@ impl<'a> System<'a> for Sys {
|
||||
.map(|group_a| Some(group_a) == groups.get(b))
|
||||
.unwrap_or(false);
|
||||
|
||||
let damage = if !same_group && attack.damages.enemy.is_some() {
|
||||
attack.damages.enemy.unwrap()
|
||||
} else if same_group && attack.damages.group.is_some() {
|
||||
attack.damages.group.unwrap()
|
||||
let damage = if let Some(damage) = attack.damages.get_damage(same_group) {
|
||||
damage
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
@ -152,10 +149,10 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if change.amount != 0 {
|
||||
let kb_dir = Dir::new((pos_b.0 - pos.0).try_normalized().unwrap_or(*ori.0));
|
||||
server_emitter.emit(ServerEvent::Knockback {
|
||||
entity: b,
|
||||
impulse: attack.knockback.get_knockback(kb_dir),
|
||||
});
|
||||
let impulse = attack.knockback.calculate_impulse(kb_dir);
|
||||
if !impulse.is_approx_zero() {
|
||||
server_emitter.emit(ServerEvent::Knockback { entity: b, impulse });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,10 +100,8 @@ impl<'a> System<'a> for Sys {
|
||||
if Some(other) == projectile.owner {
|
||||
continue;
|
||||
}
|
||||
let damage = if !same_group && damages.enemy.is_some() {
|
||||
damages.enemy.unwrap()
|
||||
} else if same_group && damages.group.is_some() {
|
||||
damages.group.unwrap()
|
||||
let damage = if let Some(damage) = damages.get_damage(same_group) {
|
||||
damage
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
@ -121,10 +119,11 @@ impl<'a> System<'a> for Sys {
|
||||
if let Some(entity) =
|
||||
uid_allocator.retrieve_entity_internal(other.into())
|
||||
{
|
||||
local_emitter.emit(LocalEvent::ApplyImpulse {
|
||||
entity,
|
||||
impulse: knockback.get_knockback(ori.0),
|
||||
});
|
||||
let impulse = knockback.calculate_impulse(ori.0);
|
||||
if !impulse.is_approx_zero() {
|
||||
local_emitter
|
||||
.emit(LocalEvent::ApplyImpulse { entity, impulse });
|
||||
}
|
||||
}
|
||||
},
|
||||
projectile::Effect::RewardEnergy(energy) => {
|
||||
|
@ -192,10 +192,8 @@ impl<'a> System<'a> for Sys {
|
||||
&& (!shockwave.requires_ground || physics_state_b.on_ground);
|
||||
|
||||
if hit {
|
||||
let damage = if !same_group && shockwave.damages.enemy.is_some() {
|
||||
shockwave.damages.enemy.unwrap()
|
||||
} else if same_group && shockwave.damages.group.is_some() {
|
||||
shockwave.damages.group.unwrap()
|
||||
let damage = if let Some(damage) = shockwave.damages.get_damage(same_group) {
|
||||
damage
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
@ -213,10 +211,10 @@ impl<'a> System<'a> for Sys {
|
||||
});
|
||||
shockwave_hit_list.hit_entities.push(*uid_b);
|
||||
let kb_dir = Dir::new((pos_b.0 - pos.0).try_normalized().unwrap_or(*ori.0));
|
||||
server_emitter.emit(ServerEvent::Knockback {
|
||||
entity: b,
|
||||
impulse: shockwave.knockback.get_knockback(kb_dir),
|
||||
});
|
||||
let impulse = shockwave.knockback.calculate_impulse(kb_dir);
|
||||
if !impulse.is_approx_zero() {
|
||||
server_emitter.emit(ServerEvent::Knockback { entity: b, impulse });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user