Adrenaline rush

This commit is contained in:
Sam
2023-05-16 21:04:43 -04:00
parent 4a690840e4
commit 6f31067b1a
9 changed files with 91 additions and 48 deletions

View File

@ -1,22 +1,11 @@
ComboMelee2( SelfBuff(
strikes: [ buildup_duration: 0.2,
( cast_duration: 0.2,
melee_constructor: ( recover_duration: 0.2,
kind: Slash( buff_kind: EnergyRegen,
damage: 4, buff_strength: 0.1,
poise: 5, buff_duration: Some(10.0),
knockback: 0, combo_cost: 1,
energy_regen: 5, combo_scaling: Some(Linear),
), energy_cost: 0,
range: 3.0,
angle: 45.0,
),
buildup_duration: 0.15,
swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.1,
ori_modifier: 0.6,
),
],
energy_cost_per_strike: 0,
) )

View File

@ -6,7 +6,7 @@ ComboMelee2(
damage: 16, damage: 16,
poise: 5, poise: 5,
knockback: 0, knockback: 0,
energy_regen: 5, energy_regen: 0,
), ),
range: 3.0, range: 3.0,
angle: 45.0, angle: 45.0,

View File

@ -5,5 +5,5 @@ SelfBuff(
buff_kind: ImminentCritical, buff_kind: ImminentCritical,
buff_strength: 1.0, buff_strength: 1.0,
buff_duration: Some(30.0), buff_duration: Some(30.0),
energy_cost: /*15*/0, energy_cost: 15,
) )

View File

@ -23,7 +23,7 @@ use crate::{
resources::Secs, resources::Secs,
states::{ states::{
behavior::JoinData, behavior::JoinData,
utils::{AbilityInfo, StageSection}, utils::{AbilityInfo, ScalingKind, StageSection},
*, *,
}, },
terrain::SpriteKind, terrain::SpriteKind,
@ -813,6 +813,7 @@ pub enum CharacterAbility {
energy_cost: f32, energy_cost: f32,
#[serde(default)] #[serde(default)]
combo_cost: u32, combo_cost: u32,
combo_scaling: Option<ScalingKind>,
#[serde(default)] #[serde(default)]
meta: AbilityMeta, meta: AbilityMeta,
}, },
@ -1454,6 +1455,7 @@ impl CharacterAbility {
buff_duration: _, buff_duration: _,
ref mut energy_cost, ref mut energy_cost,
combo_cost: _, combo_cost: _,
combo_scaling: _,
meta: _, meta: _,
} => { } => {
*buff_strength *= stats.diminished_buff_strength(); *buff_strength *= stats.diminished_buff_strength();
@ -2672,6 +2674,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
buff_duration, buff_duration,
energy_cost: _, energy_cost: _,
combo_cost, combo_cost,
combo_scaling,
meta: _, meta: _,
} => CharacterState::SelfBuff(self_buff::Data { } => CharacterState::SelfBuff(self_buff::Data {
static_data: self_buff::StaticData { static_data: self_buff::StaticData {
@ -2682,6 +2685,8 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
buff_strength: *buff_strength, buff_strength: *buff_strength,
buff_duration: *buff_duration, buff_duration: *buff_duration,
combo_cost: *combo_cost, combo_cost: *combo_cost,
combo_scaling: *combo_scaling,
combo_on_use: data.combo.map_or(0, |c| c.counter()),
ability_info, ability_info,
}, },
timer: Duration::default(), timer: Duration::default(),

View File

@ -236,7 +236,7 @@ impl BuffKind {
BuffKind::EnergyRegen => vec![BuffEffect::EnergyChangeOverTime { BuffKind::EnergyRegen => vec![BuffEffect::EnergyChangeOverTime {
rate: data.strength, rate: data.strength,
kind: ModifierKind::Additive, kind: ModifierKind::Additive,
tick_dur: Secs(1.0), tick_dur: Secs(0.25),
}], }],
BuffKind::IncreaseMaxEnergy => vec![BuffEffect::MaxEnergyModifier { BuffKind::IncreaseMaxEnergy => vec![BuffEffect::MaxEnergyModifier {
value: data.strength, value: data.strength,

View File

@ -83,24 +83,20 @@ impl CharacterBehavior for Data {
let mut melee_constructor = self.static_data.melee_constructor; let mut melee_constructor = self.static_data.melee_constructor;
if let Some(scaling) = self.static_data.scaling { if let Some(scaling) = self.static_data.scaling {
let scaled_by = match scaling.kind { let scaling_factor = scaling.kind.factor(
ScalingKind::Linear => { self.static_data.combo_on_use as f32,
self.static_data.combo_on_use as f32 self.static_data.minimum_combo as f32,
/ self.static_data.minimum_combo as f32 );
},
ScalingKind::Sqrt => (self.static_data.combo_on_use as f32
/ self.static_data.minimum_combo as f32)
.sqrt(),
};
match scaling.target { match scaling.target {
ScalingTarget::Attack => { ScalingTarget::Attack => {
melee_constructor = melee_constructor.handle_scaling(scaled_by); melee_constructor =
melee_constructor.handle_scaling(scaling_factor);
}, },
ScalingTarget::Buff => { ScalingTarget::Buff => {
if let Some(CombatEffect::Buff(CombatBuff { strength, .. })) = if let Some(CombatEffect::Buff(CombatBuff { strength, .. })) =
&mut melee_constructor.damage_effect &mut melee_constructor.damage_effect
{ {
*strength *= scaled_by; *strength *= scaling_factor;
} }
}, },
} }
@ -153,15 +149,6 @@ pub enum ScalingTarget {
Buff, Buff,
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ScalingKind {
// Reaches a scaling of 1 when at minimum combo, and a scaling of 2 when at double minimum
// combo
Linear,
// Reaches a scaling of 1 when at minimum combo, and a scaling of 2 when at 4x minimum combo
Sqrt,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Scaling { pub struct Scaling {
pub target: ScalingTarget, pub target: ScalingTarget,

View File

@ -30,6 +30,8 @@ pub struct StaticData {
/// How long buff lasts /// How long buff lasts
pub buff_duration: Option<Secs>, pub buff_duration: Option<Secs>,
pub combo_cost: u32, pub combo_cost: u32,
pub combo_scaling: Option<ScalingKind>,
pub combo_on_use: u32,
/// What key is used to press ability /// What key is used to press ability
pub ability_info: AbilityInfo, pub ability_info: AbilityInfo,
} }
@ -62,15 +64,26 @@ impl CharacterBehavior for Data {
}); });
} else { } else {
// Consume combo // Consume combo
let combo_consumption = if self.static_data.combo_scaling.is_some() {
self.static_data.combo_on_use
} else {
self.static_data.combo_cost
};
output_events.emit_server(ServerEvent::ComboChange { output_events.emit_server(ServerEvent::ComboChange {
entity: data.entity, entity: data.entity,
change: -(self.static_data.combo_cost as i32), change: -(combo_consumption as i32),
});
let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| {
cs.factor(
self.static_data.combo_on_use as f32,
self.static_data.combo_cost as f32,
)
}); });
// Creates buff // Creates buff
let buff = Buff::new( let buff = Buff::new(
self.static_data.buff_kind, self.static_data.buff_kind,
BuffData { BuffData {
strength: self.static_data.buff_strength, strength: self.static_data.buff_strength * scaling_factor,
duration: self.static_data.buff_duration, duration: self.static_data.buff_duration,
delay: None, delay: None,
}, },

View File

@ -1593,3 +1593,21 @@ pub fn leave_stance(data: &JoinData<'_>, output_events: &mut OutputEvents) {
}); });
} }
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ScalingKind {
// Reaches a scaling of 1 when at minimum combo, and a scaling of 2 when at double minimum
// combo
Linear,
// Reaches a scaling of 1 when at minimum combo, and a scaling of 2 when at 4x minimum combo
Sqrt,
}
impl ScalingKind {
pub fn factor(&self, val: f32, norm: f32) -> f32 {
match self {
Self::Linear => val / norm,
Self::Sqrt => (val / norm).sqrt(),
}
}
}

View File

@ -227,6 +227,37 @@ impl Animation for SelfBuffAnimation {
next.foot_r.position += Vec3::new(0.0, move2 * 4.0, move2 * -4.0); next.foot_r.position += Vec3::new(0.0, move2 * 4.0, move2 * -4.0);
next.foot_r.orientation.rotate_x(move2 * -1.2); next.foot_r.orientation.rotate_x(move2 * -1.2);
}, },
Some("common.abilities.axe.adrenaline_rush") => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Movement) => (anim_time, 0.0, 0.0),
Some(StageSection::Action) => (1.0, anim_time, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0),
};
let pullback = 1.0 - move3;
let move1 = move1 * pullback;
let move2 = move2 * pullback;
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(s_a.ahr.5);
next.control.position = Vec3::new(s_a.ac.0, s_a.ac.1, s_a.ac.2);
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
* Quaternion::rotation_y(s_a.ac.4)
* Quaternion::rotation_z(s_a.ac.5);
next.control.orientation.rotate_z(move1 * -1.8);
next.control.orientation.rotate_y(move1 * 1.5);
next.control.position += Vec3::new(move1 * 11.0, 0.0, 0.0);
next.control.orientation.rotate_y(move2 * 0.7);
next.control.orientation.rotate_z(move2 * 1.6);
next.control.position += Vec3::new(move2 * -8.0, 0.0, move2 * -3.0);
},
_ => {}, _ => {},
} }