feat: implemented extra status effect effectiveness and duration
This commit is contained in:
parent
9b720facf8
commit
39c6714317
3 changed files with 68 additions and 12 deletions
|
|
@ -6,7 +6,13 @@ use proxisim_models::bundle::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Stages, effect::Effects};
|
use crate::{
|
||||||
|
Stages,
|
||||||
|
effect::Effects,
|
||||||
|
player::status_effect::{
|
||||||
|
ExtraStatusEffectEffectiveness, Hardened, Hastened, Sharpened, Strengthened,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
fn spawn_permanent_effects(
|
fn spawn_permanent_effects(
|
||||||
merit_q: Query<(
|
merit_q: Query<(
|
||||||
|
|
@ -17,6 +23,7 @@ fn spawn_permanent_effects(
|
||||||
Option<&DrugCooldown>,
|
Option<&DrugCooldown>,
|
||||||
)>,
|
)>,
|
||||||
mut effects: Effects,
|
mut effects: Effects,
|
||||||
|
mut commands: Commands,
|
||||||
) {
|
) {
|
||||||
for (player, merits, edu, faction, drug_cd) in merit_q.iter() {
|
for (player, merits, edu, faction, drug_cd) in merit_q.iter() {
|
||||||
if merits.brawn > 0 {
|
if merits.brawn > 0 {
|
||||||
|
|
@ -211,6 +218,14 @@ fn spawn_permanent_effects(
|
||||||
if edu.def2760 {
|
if edu.def2760 {
|
||||||
effects.spawn(AdditiveBonus::<Speed>::new("DEF2760", 0.03), player);
|
effects.spawn(AdditiveBonus::<Speed>::new("DEF2760", 0.03), player);
|
||||||
}
|
}
|
||||||
|
if edu.spt2480 {
|
||||||
|
commands.entity(player).insert((
|
||||||
|
ExtraStatusEffectEffectiveness::<1, Strengthened>::new(1.1),
|
||||||
|
ExtraStatusEffectEffectiveness::<1, Sharpened>::new(1.1),
|
||||||
|
ExtraStatusEffectEffectiveness::<1, Hardened>::new(1.1),
|
||||||
|
ExtraStatusEffectEffectiveness::<1, Hastened>::new(1.1),
|
||||||
|
));
|
||||||
|
}
|
||||||
if edu.spt2490 {
|
if edu.spt2490 {
|
||||||
effects.spawn(AdditiveBonus::<Speed>::new("SPT2490", 0.02), player);
|
effects.spawn(AdditiveBonus::<Speed>::new("SPT2490", 0.02), player);
|
||||||
effects.spawn(AdditiveBonus::<Strength>::new("SPT2490", 0.02), player);
|
effects.spawn(AdditiveBonus::<Strength>::new("SPT2490", 0.02), player);
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,6 @@ fn use_damaging_weapon(
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
// TODO: special ammo
|
|
||||||
|
|
||||||
let mut dmg = dmg_intrinsic
|
let mut dmg = dmg_intrinsic
|
||||||
* w_dmg.0
|
* w_dmg.0
|
||||||
|
|
|
||||||
|
|
@ -162,16 +162,54 @@ where
|
||||||
M: AdditiveStatusEffectMarker<N>,
|
M: AdditiveStatusEffectMarker<N>,
|
||||||
{
|
{
|
||||||
marker: PhantomData<M>,
|
marker: PhantomData<M>,
|
||||||
extra_effectiveness: f32,
|
|
||||||
extra_duration: f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const N: usize, M: AdditiveStatusEffectMarker<N>> Default for AdditiveStatusEffect<N, M> {
|
impl<const N: usize, M: AdditiveStatusEffectMarker<N>> Default for AdditiveStatusEffect<N, M> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
extra_effectiveness: 0.0,
|
}
|
||||||
extra_duration: 0.0,
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct ExtraStatusEffectEffectiveness<const N: usize, M>
|
||||||
|
where
|
||||||
|
M: AdditiveStatusEffectMarker<N>,
|
||||||
|
{
|
||||||
|
marker: PhantomData<M>,
|
||||||
|
pub factor: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<const N: usize, M> ExtraStatusEffectEffectiveness<N, M>
|
||||||
|
where
|
||||||
|
M: AdditiveStatusEffectMarker<N>,
|
||||||
|
{
|
||||||
|
pub fn new(factor: f32) -> Self {
|
||||||
|
Self {
|
||||||
|
marker: PhantomData,
|
||||||
|
factor,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct ExtraStatusEffectDuration<const N: usize, M>
|
||||||
|
where
|
||||||
|
M: AdditiveStatusEffectMarker<N>,
|
||||||
|
{
|
||||||
|
marker: PhantomData<M>,
|
||||||
|
pub factor: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<const N: usize, M> ExtraStatusEffectDuration<N, M>
|
||||||
|
where
|
||||||
|
M: AdditiveStatusEffectMarker<N>,
|
||||||
|
{
|
||||||
|
pub fn new(factor: f32) -> Self {
|
||||||
|
Self {
|
||||||
|
marker: PhantomData,
|
||||||
|
factor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,30 +421,34 @@ impl DamageOverTimeMarker for Bleed {
|
||||||
|
|
||||||
fn apply_additive_status_effect<const N: usize, M: AdditiveStatusEffectMarker<N>>(
|
fn apply_additive_status_effect<const N: usize, M: AdditiveStatusEffectMarker<N>>(
|
||||||
In(entities): In<Vec<Entity>>,
|
In(entities): In<Vec<Entity>>,
|
||||||
effect_q: Query<(Entity, &ChildOf, &AdditiveStatusEffect<N, M>)>,
|
effect_q: Query<(Entity, &ChildOf)>,
|
||||||
mut parent_q: Query<Option<&mut StatusEffectStack<M>>>,
|
mut parent_q: Query<(
|
||||||
|
Option<&mut StatusEffectStack<M>>,
|
||||||
|
Option<&ExtraStatusEffectDuration<N, M>>,
|
||||||
|
Option<&ExtraStatusEffectEffectiveness<N, M>>,
|
||||||
|
)>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut effects: Effects,
|
mut effects: Effects,
|
||||||
mut logger: Logger,
|
mut logger: Logger,
|
||||||
) {
|
) {
|
||||||
for (entity, player, effect) in effect_q.iter_many(entities) {
|
for (entity, player) in effect_q.iter_many(entities) {
|
||||||
log!(logger, "apply_status_effect", {
|
log!(logger, "apply_status_effect", {
|
||||||
recipient: player.parent(),
|
recipient: player.parent(),
|
||||||
effect: std::any::type_name::<M>(),
|
effect: std::any::type_name::<M>(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let stack = parent_q.get_mut(player.parent()).unwrap();
|
let (stack, extra_duration, extra_effect) = parent_q.get_mut(player.parent()).unwrap();
|
||||||
|
|
||||||
let new_effects = <M::AffectedStats as Stats<N>>::spawn_additive_effects(
|
let new_effects = <M::AffectedStats as Stats<N>>::spawn_additive_effects(
|
||||||
&mut effects,
|
&mut effects,
|
||||||
player.parent(),
|
player.parent(),
|
||||||
M::factor() * (1.0 + effect.extra_effectiveness),
|
M::factor() * extra_effect.map_or(1.0, |e| e.factor),
|
||||||
std::any::type_name::<M>(),
|
std::any::type_name::<M>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
commands.entity(entity).insert((
|
commands.entity(entity).insert((
|
||||||
LinkedComponents(new_effects),
|
LinkedComponents(new_effects),
|
||||||
TimeLimitedEffect(M::duration() * (1.0 + effect.extra_duration)),
|
TimeLimitedEffect(M::duration() * extra_duration.map_or(1.0, |e| e.factor)),
|
||||||
));
|
));
|
||||||
|
|
||||||
if let Some(mut stack) = stack {
|
if let Some(mut stack) = stack {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue