Sceptre M2 Revamp

This commit is contained in:
gGmMsS123 2021-04-23 22:16:36 +03:00
parent 6c2d73c357
commit 1c99542df9
21 changed files with 53 additions and 315 deletions

View File

@ -2,5 +2,6 @@ TargetedEffect(
buildup_duration: 0.5,
recover_duration: 0.5,
max_range: 25.0,
effect: heal: 100.0,
heal: 100.0,
energy_cost:150,
)

View File

@ -10,5 +10,5 @@ BasicBeam(
energy_regen: 25,
energy_drain: 0,
orientation_behavior: Normal,
specifier: HealingBeam,
specifier: LifestealBeam,
)

View File

@ -76,7 +76,7 @@
),
Sceptre: (
primary: "common.abilities.sceptre.lifestealbeam",
secondary: "common.abilities.sceptre.healingbeam",
secondary: "common.abilities.sceptre.targetedheal",
abilities: [
(Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
],

View File

@ -61,7 +61,7 @@
"hud.skill.sc_heal_cost_title": "Stamina Cost",
"hud.skill.sc_heal_cost": "Healing others requires 20% less stamina{SP}",
"hud.skill.sc_heal_range_title": "Range",
"hud.skill.sc_heal_range": "Your beam reachs 20% further{SP}",
"hud.skill.sc_heal_range": "The duration is decreased by 15%{SP}",
"hud.skill.sc_wardaura_unlock_title": "Warding Aura Unlock",
"hud.skill.sc_wardaura_unlock": "Allows you to ward your allies against enemy attacks{SP}",
"hud.skill.sc_wardaura_strength_title": "Strength",

View File

@ -138,7 +138,7 @@ impl Attack {
accumulated_damage += applied_damage;
emit_outcome(Outcome::Damage { pos: target.pos });
if change.amount != 0 {
emit(ServerEvent::Damage {
emit(ServerEvent::HealthChange {
entity: target.entity,
change,
});
@ -183,7 +183,7 @@ impl Attack {
},
};
if change.amount != 0 {
emit(ServerEvent::Damage {
emit(ServerEvent::HealthChange {
entity: attacker_entity,
change,
});
@ -208,7 +208,7 @@ impl Attack {
},
};
if change.amount != 0 {
emit(ServerEvent::Damage {
emit(ServerEvent::HealthChange {
entity: target.entity,
change,
});
@ -318,7 +318,7 @@ impl Attack {
},
};
if change.amount != 0 {
emit(ServerEvent::Damage {
emit(ServerEvent::HealthChange {
entity: attacker_entity,
change,
});
@ -343,7 +343,7 @@ impl Attack {
},
};
if change.amount != 0 {
emit(ServerEvent::Damage {
emit(ServerEvent::HealthChange {
entity: target.entity,
change,
});

View File

@ -30,6 +30,7 @@ pub enum CharacterAbilityType {
BasicBeam,
RepeaterRanged,
BasicAura,
}
impl From<&CharacterState> for CharacterAbilityType {
@ -241,17 +242,6 @@ pub enum CharacterAbility {
range: f32,
energy_cost: f32,
},
HealingBeam {
buildup_duration: f32,
recover_duration: f32,
beam_duration: f32,
heal: f32,
tick_rate: f32,
range: f32,
max_angle: f32,
energy_cost: f32,
specifier: beam::FrontendSpecifier,
},
Blink {
buildup_duration: f32,
recover_duration: f32,
@ -269,6 +259,7 @@ pub enum CharacterAbility {
recover_duration: f32,
max_range: f32,
heal: f32,
energy_cost: f32,
},
}
@ -334,7 +325,14 @@ impl CharacterAbility {
.try_change_by(-(*energy_cost as i32), EnergySource::Ability)
.is_ok()
},
CharacterAbility::HealingBeam { .. } => data.combo.counter() > 0,
CharacterAbility::TargetedEffect { energy_cost, .. } => {
data.combo.counter() > 0 &&
update
.energy
.try_change_by(-(*energy_cost as i32), EnergySource::Ability)
.is_ok()
}
_=> true,
}
}
@ -538,18 +536,6 @@ impl CharacterAbility {
*recover_duration /= speed;
aura.strength *= power;
},
HealingBeam {
ref mut buildup_duration,
ref mut recover_duration,
ref mut heal,
ref mut tick_rate,
..
} => {
*buildup_duration /= speed;
*recover_duration /= speed;
*heal *= power;
*tick_rate *= speed;
},
Blink {
ref mut buildup_duration,
ref mut recover_duration,
@ -594,7 +580,6 @@ impl CharacterAbility {
| ChargedMelee { energy_cost, .. }
| ChargedRanged { energy_cost, .. }
| Shockwave { energy_cost, .. }
| HealingBeam { energy_cost, .. }
| BasicAura { energy_cost, .. } => *energy_cost as u32,
BasicBeam { energy_drain, .. } => {
if *energy_drain > f32::EPSILON {
@ -1077,26 +1062,6 @@ impl CharacterAbility {
*lifesteal *= 1.15_f32.powi(level.into());
}
},
HealingBeam {
ref mut heal,
ref mut energy_cost,
ref mut range,
ref mut beam_duration,
..
} => {
if let Ok(Some(level)) = skillset.skill_level(Sceptre(HHeal)) {
*heal *= 1.2_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Sceptre(HRange)) {
let range_mod = 1.2_f32.powi(level.into());
*range *= range_mod;
// Duration modified to keep velocity constant
*beam_duration *= range_mod;
}
if let Ok(Some(level)) = skillset.skill_level(Sceptre(HCost)) {
*energy_cost *= 0.8_f32.powi(level.into());
}
},
BasicAura {
ref mut aura,
ref mut range,
@ -1581,32 +1546,6 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
timer: Duration::default(),
stage_section: StageSection::Buildup,
}),
CharacterAbility::HealingBeam {
buildup_duration,
recover_duration,
beam_duration,
heal,
tick_rate,
range,
max_angle,
energy_cost,
specifier,
} => CharacterState::HealingBeam(healing_beam::Data {
static_data: healing_beam::StaticData {
buildup_duration: Duration::from_secs_f32(*buildup_duration),
recover_duration: Duration::from_secs_f32(*recover_duration),
beam_duration: Duration::from_secs_f32(*beam_duration),
heal: *heal,
tick_rate: *tick_rate,
range: *range,
max_angle: *max_angle,
energy_cost: *energy_cost,
ability_info,
specifier: *specifier,
},
timer: Duration::default(),
stage_section: StageSection::Buildup,
}),
CharacterAbility::Blink {
buildup_duration,
recover_duration,
@ -1622,6 +1561,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
stage_section: StageSection::Buildup,
}),
CharacterAbility::TargetedEffect {
energy_cost,
buildup_duration,
recover_duration,
max_range, heal } => CharacterState::TargetedEffect(targeted_effect::Data {
@ -1630,7 +1570,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
recover_duration: Duration::from_secs_f32(*recover_duration),
max_range: *max_range,
ability_info,
heal,
heal: *heal,
},
timer: Duration::default(),
stage_section: StageSection::Buildup,

View File

@ -50,6 +50,5 @@ impl Component for Beam {
pub enum FrontendSpecifier {
Flamethrower,
LifestealBeam,
HealingBeam,
Cultist,
}

View File

@ -92,8 +92,6 @@ pub enum CharacterState {
/// beam as a large amount of functionality needed to be special cased
/// specifically for the healing beam. There was also functionality present
/// on basic beam which was unnecessary for the healing beam.
HealingBeam(healing_beam::Data),
/// A short teleport that targets either a position or entity
Blink(blink::Data),
/// Summons creatures that fight for the caster
BasicSummon(basic_summon::Data),
@ -119,7 +117,6 @@ impl CharacterState {
| CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_)
| CharacterState::BasicAura(_)
| CharacterState::HealingBeam(_)
)
}
@ -142,7 +139,6 @@ impl CharacterState {
| CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_)
| CharacterState::BasicAura(_)
| CharacterState::HealingBeam(_)
)
}
@ -163,7 +159,6 @@ impl CharacterState {
| CharacterState::Stunned(_)
| CharacterState::Wielding
| CharacterState::Talk
| CharacterState::HealingBeam(_)
)
}

View File

@ -35,16 +35,12 @@ pub enum LocalEvent {
#[allow(clippy::large_enum_variant)] // TODO: Pending review in #587
pub enum ServerEvent {
HealthChange {
entity: EcsEntity,
change: comp::HealthChange,
},
Explosion {
pos: Vec3<f32>,
explosion: Explosion,
owner: Option<Uid>,
},
Damage {
HealthChange {
entity: EcsEntity,
change: comp::HealthChange,
},

View File

@ -5,7 +5,7 @@ use crate::{
InventoryAction, Melee, Ori, PhysicsState, Pos, SkillSet, StateUpdate, Stats, Vel,
},
resources::DeltaTime,
uid::Uid,
uid::{Uid, UidAllocator},
};
use specs::{
hibitset,
@ -95,6 +95,7 @@ pub struct JoinData<'a> {
pub msm: &'a MaterialStatManifest,
pub combo: &'a Combo,
pub alignment: Option<&'a comp::Alignment>,
pub uid_allocator: &'a UidAllocator,
}
type RestrictedMut<'a, C> = PairedStorage<
@ -125,6 +126,7 @@ pub struct JoinStruct<'a> {
pub skill_set: &'a SkillSet,
pub combo: &'a Combo,
pub alignment: Option<&'a comp::Alignment>,
pub uid_allocator: &'a UidAllocator,
}
impl<'a> JoinData<'a> {
@ -156,6 +158,7 @@ impl<'a> JoinData<'a> {
msm,
combo: j.combo,
alignment: j.alignment,
uid_allocator: j.uid_allocator,
}
}
}

View File

@ -1,163 +0,0 @@
use crate::{
combat::{Attack, AttackEffect, CombatEffect, CombatRequirement, GroupTarget},
comp::{beam, CharacterState, Ori, Pos, StateUpdate},
event::ServerEvent,
states::{
behavior::{CharacterBehavior, JoinData},
utils::*,
},
uid::Uid,
};
use serde::{Deserialize, Serialize};
use std::time::Duration;
use vek::*;
/// Separated out to condense update portions of character state
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StaticData {
/// How long until state should deal damage or heal
pub buildup_duration: Duration,
/// How long the state has until exiting
pub recover_duration: Duration,
/// How long each beam segment persists for
pub beam_duration: Duration,
/// Base healing per tick
pub heal: f32,
/// Ticks of healing per second
pub tick_rate: f32,
/// Max range
pub range: f32,
/// Max angle (45.0 will give you a 90.0 angle window)
pub max_angle: f32,
/// Energy consumed per second for heal ticks
pub energy_cost: f32,
/// What key is used to press ability
pub ability_info: AbilityInfo,
/// Used to specify the beam to the frontend
pub specifier: beam::FrontendSpecifier,
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Data {
/// Struct containing data that does not change over the course of the
/// character state
pub static_data: StaticData,
/// Timer for each stage
pub timer: Duration,
/// What section the character stage is in
pub stage_section: StageSection,
}
impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {
if self.timer < self.static_data.buildup_duration {
// Build up
update.character = CharacterState::HealingBeam(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
..*self
});
} else {
// Creates beam
data.updater.insert(data.entity, beam::Beam {
hit_entities: Vec::<Uid>::new(),
tick_dur: Duration::from_secs_f32(1.0 / self.static_data.tick_rate),
timer: Duration::default(),
});
// Build up
update.character = CharacterState::HealingBeam(Data {
timer: Duration::default(),
stage_section: StageSection::Cast,
..*self
});
}
},
StageSection::Cast => {
if input_is_pressed(data, self.static_data.ability_info.input) {
let speed =
self.static_data.range / self.static_data.beam_duration.as_secs_f32();
let heal = AttackEffect::new(
Some(GroupTarget::InGroup),
CombatEffect::Heal(self.static_data.heal),
)
.with_requirement(CombatRequirement::Energy(self.static_data.energy_cost))
.with_requirement(CombatRequirement::Combo(1));
let attack = Attack::default().with_effect(heal);
let properties = beam::Properties {
attack,
angle: self.static_data.max_angle.to_radians(),
speed,
duration: self.static_data.beam_duration,
owner: Some(*data.uid),
specifier: self.static_data.specifier,
};
// Gets offsets
let body_offsets = Vec3::new(
(data.body.radius() + 0.2) * data.inputs.look_dir.x,
(data.body.radius() + 0.2) * data.inputs.look_dir.y,
data.body.eye_height() * 0.6,
);
let pos = Pos(data.pos.0 + body_offsets);
// Create beam segment
update.server_events.push_front(ServerEvent::BeamSegment {
properties,
pos,
ori: Ori::from(data.inputs.look_dir),
});
update.character = CharacterState::HealingBeam(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
..*self
});
} else {
update.character = CharacterState::HealingBeam(Data {
timer: Duration::default(),
stage_section: StageSection::Recover,
..*self
});
}
},
StageSection::Recover => {
if self.timer < self.static_data.recover_duration {
update.character = CharacterState::HealingBeam(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
..*self
});
} else {
// Done
update.character = CharacterState::Wielding;
// Make sure attack component is removed
data.updater.remove::<beam::Beam>(data.entity);
}
},
_ => {
// If it somehow ends up in an incorrect stage section
update.character = CharacterState::Wielding;
// Make sure attack component is removed
data.updater.remove::<beam::Beam>(data.entity);
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -16,7 +16,6 @@ pub mod dash_melee;
pub mod equipping;
pub mod glide;
pub mod glide_wield;
pub mod healing_beam;
pub mod idle;
pub mod leap_melee;
pub mod repeater_ranged;

View File

@ -8,6 +8,7 @@ use crate::{
};
use serde::{Deserialize, Serialize};
use std::time::Duration;
use specs::saveload::MarkerAllocator;
/// Separated out to condense update portions of character state
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -16,12 +17,12 @@ pub struct StaticData {
pub buildup_duration: Duration,
/// How long the state recovers for
pub recover_duration: Duration,
/// What the max range of the teleport is
/// What the max range of the heal is
pub max_range: f32,
/// Miscellaneous information about the ability
pub ability_info: AbilityInfo,
/// Heal
pub heal: HealthChange,
pub heal: f32,
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -53,12 +54,18 @@ impl CharacterBehavior for Data {
// Heals a target
if let Some(input_attr) = self.static_data.ability_info.input_attr {
if let Some(target) = input_attr.target_entity {
if let Some(target) = data.uid_allocator.retrieve_entity_internal(target.into()) {
update.server_events.push_front(ServerEvent::HealthChange {
entity: target,
change: HealthChange {
amount: self.static_data.heal as i32,
cause: HealthSource::Heal { by: Some(*data.uid) },
}});
update.server_events.push_front(ServerEvent::ComboChange {
entity: data.entity,
change: -1,
})
}
}
}
// Transitions to recover section of stage

View File

@ -132,7 +132,7 @@ impl<'a> System<'a> for Sys {
(health.maximum() as f32 * *accumulated) as i32
},
};
server_emitter.emit(ServerEvent::Damage {
server_emitter.emit(ServerEvent::HealthChange {
entity,
change: HealthChange { amount, cause },
});

View File

@ -20,6 +20,7 @@ use common::{
behavior::{CharacterBehavior, JoinData, JoinStruct},
},
uid::Uid,
uid::UidAllocator,
};
use common_ecs::{Job, Origin, Phase, System};
use std::time::Duration;
@ -77,6 +78,7 @@ pub struct ReadData<'a> {
msm: Read<'a, MaterialStatManifest>,
combos: ReadStorage<'a, Combo>,
alignments: ReadStorage<'a, comp::Alignment>,
uid_allocator: Read<'a, UidAllocator>,
}
/// ## Character Behavior System
@ -265,6 +267,8 @@ impl<'a> System<'a> for Sys {
skill_set: &skill_set,
combo: &combo,
alignment: read_data.alignments.get(entity),
uid_allocator: &read_data.uid_allocator,
};
for action in actions {
@ -311,7 +315,6 @@ impl<'a> System<'a> for Sys {
CharacterState::Shockwave(data) => data.handle_event(&j, action),
CharacterState::BasicBeam(data) => data.handle_event(&j, action),
CharacterState::BasicAura(data) => data.handle_event(&j, action),
CharacterState::HealingBeam(data) => data.handle_event(&j, action),
CharacterState::Blink(data) => data.handle_event(&j, action),
CharacterState::BasicSummon(data) => data.handle_event(&j, action),
CharacterState::TargetedEffect(data) => data.handle_event(&j, action),
@ -366,7 +369,6 @@ impl<'a> System<'a> for Sys {
CharacterState::Shockwave(data) => data.behavior(&j),
CharacterState::BasicBeam(data) => data.behavior(&j),
CharacterState::BasicAura(data) => data.behavior(&j),
CharacterState::HealingBeam(data) => data.behavior(&j),
CharacterState::Blink(data) => data.behavior(&j),
CharacterState::BasicSummon(data) => data.behavior(&j),
CharacterState::TargetedEffect(data) => data.behavior(&j),

View File

@ -246,7 +246,6 @@ impl<'a> System<'a> for Sys {
| CharacterState::Shockwave { .. }
| CharacterState::BasicBeam { .. }
| CharacterState::BasicAura { .. }
| CharacterState::HealingBeam { .. }
| CharacterState::Blink { .. }
| CharacterState::TargetedEffect { .. }
| CharacterState::BasicSummon { .. } => {

View File

@ -92,7 +92,7 @@ impl Server {
ServerEvent::Knockback { entity, impulse } => {
handle_knockback(&self, entity, impulse)
},
ServerEvent::Damage { entity, change } => handle_damage(&self, entity, change),
ServerEvent::HealthChange { entity, change } => handle_damage(&self, entity, change),
ServerEvent::PoiseChange {
entity,
change,

View File

@ -390,7 +390,7 @@ impl SfxMgr {
audio.play_sfx(file_ref, *pos, None);
},
Outcome::Beam { pos, specifier } => match specifier {
beam::FrontendSpecifier::LifestealBeam | beam::FrontendSpecifier::HealingBeam => {
beam::FrontendSpecifier::LifestealBeam => {
let file_ref = "voxygen.audio.sfx.abilities.sceptre_channeling";
if thread_rng().gen_bool(0.5) {
audio.play_sfx(file_ref, *pos, None);

View File

@ -110,7 +110,6 @@ pub enum ParticleMode {
Firefly = 11,
Bee = 12,
GroundShockwave = 13,
HealingBeam = 14,
EnergyNature = 15,
FlameThrower = 16,
FireShockwave = 17,

View File

@ -1284,32 +1284,6 @@ impl FigureMgr {
skeleton_attr,
)
},
CharacterState::HealingBeam(s) => {
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f32()
},
StageSection::Cast => s.timer.as_secs_f32(),
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f32()
},
_ => 0.0,
};
anim::character::BeamAnimation::update_skeleton(
&target_base,
(
Some(s.static_data.ability_info),
hands,
time,
rel_vel.magnitude(),
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();

View File

@ -718,19 +718,6 @@ impl ParticleMgr {
},
);
},
beam::FrontendSpecifier::HealingBeam => {
// Emit a light when using healing
lights.push(Light::new(pos.0, Rgb::new(0.1, 1.0, 0.15), 1.0));
for i in 0..beam_tick_count {
self.particles.push(Particle::new_directed(
beam.properties.duration,
time + i as f64 / 1000.0,
ParticleMode::HealingBeam,
pos.0,
pos.0 + *ori.look_dir() * range,
));
}
},
beam::FrontendSpecifier::LifestealBeam => {
// Emit a light when using lifesteal beam
lights.push(Light::new(pos.0, Rgb::new(0.8, 1.0, 0.5), 1.0));