From 2651546ea8f46150372e0b1e7665917c859963b0 Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Fri, 22 Jan 2021 21:24:55 +0100 Subject: [PATCH 1/8] added basic definitions and some functions that don't do anything yet --- assets/effector_defs.yaml | 6 ++++++ assets/leader_defs.yaml | 6 ++++++ assets/skill_defs.yaml | 20 ++++++++++++++++++++ src/ids.rs | 4 ++++ src/main.rs | 1 + src/systems/caustic_scales.rs | 27 +++++++++++++++++++++++++++ src/systems/mod.rs | 2 ++ 7 files changed, 66 insertions(+) create mode 100644 src/systems/caustic_scales.rs diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 1963278..92c559d 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -66,3 +66,9 @@ defs: effects: - - Attack - Additive: 1.0 + DamageOverTime: + key: DamageOverTime + duration: 10.0 + effects: + - - Health + - Additive: -1.0 \ No newline at end of file diff --git a/assets/leader_defs.yaml b/assets/leader_defs.yaml index 5dbca8e..db51f37 100644 --- a/assets/leader_defs.yaml +++ b/assets/leader_defs.yaml @@ -54,3 +54,9 @@ defs: skills: - ReturnDamage - BattleCall + GreenSnakeLeader: + key: GreenSnakeLeader + name: "GreenSnakeLeader" + skills: + - CausticScales + - VenomBite diff --git a/assets/skill_defs.yaml b/assets/skill_defs.yaml index 547b07a..0387f28 100644 --- a/assets/skill_defs.yaml +++ b/assets/skill_defs.yaml @@ -210,3 +210,23 @@ defs: item_conditions: [] stat_effectors: - BattleHungry + CausticScales: + key: CausticScales + name: Caustic Scales + friendly_name: caustic_scales + description: Applies damage over time and armor reduction for any enemy that attacks/damages this leader. + cooldown: 0.0 + passive: true + conditions: [] + item_conditions: [] + stat_effectors: [] + VenomBite: + key: VenomBite + name: Venom Bite + friendly_name: venom_bite + description: Every attack applies damage over time and slow. Stacks up to 5 instances. + cooldown: 0.0 + passive: true + conditions: [] + item_conditions: [] + stat_effectors: [] diff --git a/src/ids.rs b/src/ids.rs index 9642a08..c8957a9 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -46,6 +46,8 @@ pub enum Skills { DarkPresence, ReturnDamage, BattleCall, + CausticScales, + VenomBite, } /// The different items ids. @@ -60,6 +62,7 @@ pub enum Items { #[allow(missing_docs)] #[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Copy, Clone, Debug)] pub enum Effectors { + DamageOverTime, DoubleDamage, DoubleAttackSpeed, Root, @@ -85,5 +88,6 @@ pub enum Leaders { AxePersonLeader, CentaurPersonLeader, Celsus, + GreenSnakeLeader, SoulsCollector, } diff --git a/src/main.rs b/src/main.rs index 34f59d5..9562c36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -235,6 +235,7 @@ fn main() -> BError { nature_summon_system, bear_spawner_system, savagery_system, + caustic_scales_system, battle_hunger_system, air_corrosion_system, dark_presence_system, diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs new file mode 100644 index 0000000..39a02fa --- /dev/null +++ b/src/systems/caustic_scales.rs @@ -0,0 +1,27 @@ +use crate::*; + +/// Returns half of the received damage. +pub fn caustic_scales_system( + skills: &Components>, + game_events: &mut Vec, +) -> SystemResult { + let mut apply_acid = None; + for ev in game_events.iter() { + if let GameEvent::DamageEntity(a, t, _dmg) = ev { + if let Some(skills) = skills.get(*t) { + if skills.skills.get(&Skills::CausticScales).is_some() { + // Here attacker entity should get status effect with DOT and lowered defence + // return_damage = Some(GameEvent::DamageEntity(*t, *a, dmg / 2.0)); + + } + } + } + } + + // this part necessary? + if let Some(event) = apply_acid { + game_events.push(event); + } + + Ok(()) +} diff --git a/src/systems/mod.rs b/src/systems/mod.rs index 9118a44..c153e28 100644 --- a/src/systems/mod.rs +++ b/src/systems/mod.rs @@ -3,6 +3,7 @@ mod air_corrosion; mod aoe_damage; mod battle_hunger; mod bear_spawner; +mod caustic_scales; mod creep_spawner; mod damage_entity; mod dark_presence; @@ -37,6 +38,7 @@ pub use self::aoe_damage::*; pub use self::battle_hunger::*; pub use self::bear_spawner::*; pub use self::creep_spawner::*; +pub use self::caustic_scales::*; pub use self::damage_entity::*; pub use self::dark_presence::*; pub use self::game_stats_updater::*; From 6753f6f9e4c30b2fa06cbf19d9b6952b04ebaaf7 Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Sat, 23 Jan 2021 23:24:53 +0100 Subject: [PATCH 2/8] update on caustic scale system --- assets/effector_defs.yaml | 8 ++++++- src/ids.rs | 1 + src/main.rs | 2 +- src/systems/caustic_scales.rs | 44 +++++++++++++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 92c559d..7bb75a6 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -71,4 +71,10 @@ defs: duration: 10.0 effects: - - Health - - Additive: -1.0 \ No newline at end of file + - Additive: -1.0 + AttackSpeedDecrease: + key: AttackSpeedIncrease + duration: 10.0 + effects: + - - AttackSpeed + - MultiplicativeMultiplier: 0.8 \ No newline at end of file diff --git a/src/ids.rs b/src/ids.rs index c8957a9..7ff162f 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -66,6 +66,7 @@ pub enum Effectors { DoubleDamage, DoubleAttackSpeed, Root, + AttackSpeedDecrease, AttackSpeedIncrease, HalfMovementSpeed, Savagery, diff --git a/src/main.rs b/src/main.rs index 9562c36..9a3b12a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -472,7 +472,7 @@ fn main() -> BError { vec![ Leaders::Generic1, Leaders::Generic2, - Leaders::Generic3, + Leaders::GreenSnakeLeader, Leaders::TreePersonLeader, Leaders::BearPersonLeader, ], diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs index 39a02fa..564aa4c 100644 --- a/src/systems/caustic_scales.rs +++ b/src/systems/caustic_scales.rs @@ -3,15 +3,55 @@ use crate::*; /// Returns half of the received damage. pub fn caustic_scales_system( skills: &Components>, + effector_defs: &EffectorDefinitions, + effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { let mut apply_acid = None; + + let dot_effector = effector_defs + .defs + .get(&Effectors::DamageOverTime) + .expect("Unknown effector key."); + + let asd_effector = effector_defs + .defs + .get(&Effectors::AttackSpeedDecrease) + .expect("Unknown effector key."); + + + for ev in game_events.iter() { if let GameEvent::DamageEntity(a, t, _dmg) = ev { if let Some(skills) = skills.get(*t) { if skills.skills.get(&Skills::CausticScales).is_some() { - // Here attacker entity should get status effect with DOT and lowered defence - // return_damage = Some(GameEvent::DamageEntity(*t, *a, dmg / 2.0)); + // Here attacker a should get the effectors of half attack speed and damage over time. + + if effectors.get(*a).is_none() { + effectors.insert(*a, EffectorSet::default()); + } + + // TODO: maybe better to have a single effector for bpoth effects? Depends on design philosophy IMO. + // TODO: if effectors already exist, renew duration instead. + effectors + .get_mut(*a) + .unwrap() + .effectors + .push(EffectorInstance::new( + Effectors::DamageOverTime, + dot_effector.duration, + )); + + // TODO: beautify code to not have repetitions like this + effectors + .get_mut(*a) + .unwrap() + .effectors + .push(EffectorInstance::new( + Effectors::AttackSpeedDecrease, + dot_effector.duration, + )); + } } From f80b5d0982dd3c9b654482a602411c3bb14b484e Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 20:37:33 +0100 Subject: [PATCH 3/8] viper acid skin should work now. Also now it is a single effector that damages AND reduces attack speed --- assets/effector_defs.yaml | 10 ++---- src/ids.rs | 3 +- src/systems/caustic_scales.rs | 59 +++++++++++++++-------------------- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 7bb75a6..311f6ec 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -66,15 +66,11 @@ defs: effects: - - Attack - Additive: 1.0 - DamageOverTime: - key: DamageOverTime + CausticScales: + key: CausticScales duration: 10.0 effects: - - Health - - Additive: -1.0 - AttackSpeedDecrease: - key: AttackSpeedIncrease - duration: 10.0 - effects: + - Additive: -3.0 - - AttackSpeed - MultiplicativeMultiplier: 0.8 \ No newline at end of file diff --git a/src/ids.rs b/src/ids.rs index 7ff162f..07ce423 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -62,11 +62,10 @@ pub enum Items { #[allow(missing_docs)] #[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Copy, Clone, Debug)] pub enum Effectors { - DamageOverTime, DoubleDamage, DoubleAttackSpeed, + CausticScales, Root, - AttackSpeedDecrease, AttackSpeedIncrease, HalfMovementSpeed, Savagery, diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs index 564aa4c..f0714a3 100644 --- a/src/systems/caustic_scales.rs +++ b/src/systems/caustic_scales.rs @@ -7,19 +7,12 @@ pub fn caustic_scales_system( effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { - let mut apply_acid = None; let dot_effector = effector_defs .defs - .get(&Effectors::DamageOverTime) + .get(&Effectors::CausticScales) .expect("Unknown effector key."); - - let asd_effector = effector_defs - .defs - .get(&Effectors::AttackSpeedDecrease) - .expect("Unknown effector key."); - - + for ev in game_events.iter() { if let GameEvent::DamageEntity(a, t, _dmg) = ev { @@ -31,37 +24,35 @@ pub fn caustic_scales_system( effectors.insert(*a, EffectorSet::default()); } - // TODO: maybe better to have a single effector for bpoth effects? Depends on design philosophy IMO. - // TODO: if effectors already exist, renew duration instead. - effectors - .get_mut(*a) - .unwrap() - .effectors - .push(EffectorInstance::new( - Effectors::DamageOverTime, - dot_effector.duration, - )); - - // TODO: beautify code to not have repetitions like this - effectors + let current_effectors = &mut effectors .get_mut(*a) .unwrap() - .effectors - .push(EffectorInstance::new( - Effectors::AttackSpeedDecrease, - dot_effector.duration, - )); - - + .effectors; + + // If CausticScales already applied, then just refresh the duration + if current_effectors.iter().any(|x| x.effector_key == Effectors::CausticScales ){ + for i in 0..current_effectors.len(){ + if current_effectors[i].effector_key == Effectors::CausticScales { + current_effectors[i].disable_in = dot_effector.duration; + } + } + } + // else add the effector: + else { + effectors + .get_mut(*a) + .unwrap() + .effectors + .push(EffectorInstance::new( + Effectors::CausticScales, + dot_effector.duration, + )); + } + } } } } - // this part necessary? - if let Some(event) = apply_acid { - game_events.push(event); - } - Ok(()) } From a463e8cbc8511586cba321ee16519cf3e8edf8db Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 20:57:59 +0100 Subject: [PATCH 4/8] viper done --- assets/effector_defs.yaml | 10 +++++++- assets/skill_defs.yaml | 2 +- src/ids.rs | 1 + src/main.rs | 1 + src/systems/caustic_scales.rs | 29 +++++++++++------------ src/systems/mod.rs | 4 +++- src/systems/venom_bite.rs | 44 +++++++++++++++++++++++++++++++++++ 7 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/systems/venom_bite.rs diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 311f6ec..6b3d8b4 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -71,6 +71,14 @@ defs: duration: 10.0 effects: - - Health - - Additive: -3.0 + - Additive: -6.0 - - AttackSpeed + - MultiplicativeMultiplier: 0.8 + HemotoxicVenom: + key: HemotoxicVenom + duration: 10.0 + effects: + - - Health + - Additive: -3.0 + - - ActionPointRefillRate - MultiplicativeMultiplier: 0.8 \ No newline at end of file diff --git a/assets/skill_defs.yaml b/assets/skill_defs.yaml index 0387f28..2996d7e 100644 --- a/assets/skill_defs.yaml +++ b/assets/skill_defs.yaml @@ -214,7 +214,7 @@ defs: key: CausticScales name: Caustic Scales friendly_name: caustic_scales - description: Applies damage over time and armor reduction for any enemy that attacks/damages this leader. + description: Applies damage over time and attack speed reduction for any enemy that attacks/damages this leader. cooldown: 0.0 passive: true conditions: [] diff --git a/src/ids.rs b/src/ids.rs index 07ce423..977cfa2 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -65,6 +65,7 @@ pub enum Effectors { DoubleDamage, DoubleAttackSpeed, CausticScales, + HemotoxicVenom, Root, AttackSpeedIncrease, HalfMovementSpeed, diff --git a/src/main.rs b/src/main.rs index 9a3b12a..a6d6383 100644 --- a/src/main.rs +++ b/src/main.rs @@ -236,6 +236,7 @@ fn main() -> BError { bear_spawner_system, savagery_system, caustic_scales_system, + venom_bite_system, battle_hunger_system, air_corrosion_system, dark_presence_system, diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs index f0714a3..07b0dfe 100644 --- a/src/systems/caustic_scales.rs +++ b/src/systems/caustic_scales.rs @@ -7,12 +7,10 @@ pub fn caustic_scales_system( effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { - let dot_effector = effector_defs .defs .get(&Effectors::CausticScales) .expect("Unknown effector key."); - for ev in game_events.iter() { if let GameEvent::DamageEntity(a, t, _dmg) = ev { @@ -24,14 +22,14 @@ pub fn caustic_scales_system( effectors.insert(*a, EffectorSet::default()); } - let current_effectors = &mut effectors - .get_mut(*a) - .unwrap() - .effectors; + let current_effectors = &mut effectors.get_mut(*a).unwrap().effectors; // If CausticScales already applied, then just refresh the duration - if current_effectors.iter().any(|x| x.effector_key == Effectors::CausticScales ){ - for i in 0..current_effectors.len(){ + if current_effectors + .iter() + .any(|x| x.effector_key == Effectors::CausticScales) + { + for i in 0..current_effectors.len() { if current_effectors[i].effector_key == Effectors::CausticScales { current_effectors[i].disable_in = dot_effector.duration; } @@ -40,15 +38,14 @@ pub fn caustic_scales_system( // else add the effector: else { effectors - .get_mut(*a) - .unwrap() - .effectors - .push(EffectorInstance::new( - Effectors::CausticScales, - dot_effector.duration, - )); + .get_mut(*a) + .unwrap() + .effectors + .push(EffectorInstance::new( + Effectors::CausticScales, + dot_effector.duration, + )); } - } } } diff --git a/src/systems/mod.rs b/src/systems/mod.rs index c153e28..86c39fe 100644 --- a/src/systems/mod.rs +++ b/src/systems/mod.rs @@ -32,13 +32,14 @@ mod transfer_gold; mod update_collision_resource; mod update_enemies_around_stat; mod update_win_condition; +mod venom_bite; pub use self::additional_attack::*; pub use self::air_corrosion::*; pub use self::aoe_damage::*; pub use self::battle_hunger::*; pub use self::bear_spawner::*; -pub use self::creep_spawner::*; pub use self::caustic_scales::*; +pub use self::creep_spawner::*; pub use self::damage_entity::*; pub use self::dark_presence::*; pub use self::game_stats_updater::*; @@ -67,3 +68,4 @@ pub use self::transfer_gold::*; pub use self::update_collision_resource::*; pub use self::update_enemies_around_stat::*; pub use self::update_win_condition::*; +pub use self::venom_bite::*; diff --git a/src/systems/venom_bite.rs b/src/systems/venom_bite.rs new file mode 100644 index 0000000..852edd7 --- /dev/null +++ b/src/systems/venom_bite.rs @@ -0,0 +1,44 @@ +use crate::*; + +/// Returns half of the received damage. +pub fn venom_bite_system( + skills: &Components>, + effector_defs: &EffectorDefinitions, + effectors: &mut Components>, + game_events: &mut Vec, +) -> SystemResult { + let venom_effector = effector_defs + .defs + .get(&Effectors::HemotoxicVenom) + .expect("Unknown effector key."); + + for ev in game_events.iter() { + if let GameEvent::DamageEntity(a, t, _dmg) = ev { + if let Some(skills) = skills.get(*a) { + if skills.skills.get(&Skills::VenomBite).is_some() { + if effectors.get(*t).is_none() { + effectors.insert(*t, EffectorSet::default()); + } + + let current_effectors = &mut effectors.get_mut(*t).unwrap().effectors; + + // Check how many stacks of HemotoxicVenom target has. + // If over 5 then do nothing. Otherwise apply 1 more + if current_effectors + .iter() + .filter(|x| x.effector_key == Effectors::HemotoxicVenom) + .count() + < 5 + { + current_effectors.push(EffectorInstance::new( + Effectors::HemotoxicVenom, + venom_effector.duration, + )); + } + } + } + } + } + + Ok(()) +} From 148da4f680527215428aacae396399cac4ee8d8b Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 21:24:13 +0100 Subject: [PATCH 5/8] renamed leader into "Adder", added one whitespace :P --- assets/effector_defs.yaml | 3 ++- assets/leader_defs.yaml | 6 +++--- src/ids.rs | 2 +- src/main.rs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 6b3d8b4..9f3c0e5 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -81,4 +81,5 @@ defs: - - Health - Additive: -3.0 - - ActionPointRefillRate - - MultiplicativeMultiplier: 0.8 \ No newline at end of file + - MultiplicativeMultiplier: 0.8 + \ No newline at end of file diff --git a/assets/leader_defs.yaml b/assets/leader_defs.yaml index db51f37..52b5f11 100644 --- a/assets/leader_defs.yaml +++ b/assets/leader_defs.yaml @@ -54,9 +54,9 @@ defs: skills: - ReturnDamage - BattleCall - GreenSnakeLeader: - key: GreenSnakeLeader - name: "GreenSnakeLeader" + Adder: + key: Adder + name: "Adder" skills: - CausticScales - VenomBite diff --git a/src/ids.rs b/src/ids.rs index 977cfa2..70fec80 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -89,6 +89,6 @@ pub enum Leaders { AxePersonLeader, CentaurPersonLeader, Celsus, - GreenSnakeLeader, SoulsCollector, + Adder, } diff --git a/src/main.rs b/src/main.rs index a6d6383..3305162 100644 --- a/src/main.rs +++ b/src/main.rs @@ -473,7 +473,7 @@ fn main() -> BError { vec![ Leaders::Generic1, Leaders::Generic2, - Leaders::GreenSnakeLeader, + Leaders::Adder, Leaders::TreePersonLeader, Leaders::BearPersonLeader, ], From a1aaf0467f7e2e144084606de38422ae3c5be805 Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 21:26:18 +0100 Subject: [PATCH 6/8] fixed newline in effector_defs.yaml --- assets/effector_defs.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 9f3c0e5..4a69f88 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -82,4 +82,3 @@ defs: - Additive: -3.0 - - ActionPointRefillRate - MultiplicativeMultiplier: 0.8 - \ No newline at end of file From 9d85595d0214a61f4724fa876e106414c735f711 Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 21:49:23 +0100 Subject: [PATCH 7/8] Divided effectors so each one affects a single stat --- assets/effector_defs.yaml | 18 ++++++++++++++---- src/ids.rs | 6 ++++-- src/systems/caustic_scales.rs | 34 +++++++++++++++++++++++++--------- src/systems/venom_bite.rs | 26 ++++++++++++++++++++------ 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index 4a69f88..eeef504 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -66,16 +66,26 @@ defs: effects: - - Attack - Additive: 1.0 - CausticScales: - key: CausticScales + CausticDamage: + key: CausticDamage duration: 10.0 effects: - - Health - Additive: -6.0 + CausticSlow: + key: CausticSlow + duration: 10.0 + effects: - - AttackSpeed - MultiplicativeMultiplier: 0.8 - HemotoxicVenom: - key: HemotoxicVenom + VenomSlow: + key: VenomSlow + duration: 10.0 + effects: + - - ActionPointRefillRate + - MultiplicativeMultiplier: 0.8 + VenomDamage: + key: VenomDamage duration: 10.0 effects: - - Health diff --git a/src/ids.rs b/src/ids.rs index 70fec80..2837c01 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -64,8 +64,10 @@ pub enum Items { pub enum Effectors { DoubleDamage, DoubleAttackSpeed, - CausticScales, - HemotoxicVenom, + CausticDamage, + CausticSlow, + VenomDamage, + VenomSlow, Root, AttackSpeedIncrease, HalfMovementSpeed, diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs index 07b0dfe..cca0a1a 100644 --- a/src/systems/caustic_scales.rs +++ b/src/systems/caustic_scales.rs @@ -1,22 +1,27 @@ use crate::*; -/// Returns half of the received damage. +/// Every unit that attacks this leader gets poisoned and has attack speed slowed. pub fn caustic_scales_system( skills: &Components>, effector_defs: &EffectorDefinitions, effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { + let dot_effector = effector_defs .defs - .get(&Effectors::CausticScales) + .get(&Effectors::CausticDamage) + .expect("Unknown effector key."); + + let slow_effector = effector_defs + .defs + .get(&Effectors::CausticSlow) .expect("Unknown effector key."); for ev in game_events.iter() { if let GameEvent::DamageEntity(a, t, _dmg) = ev { if let Some(skills) = skills.get(*t) { if skills.skills.get(&Skills::CausticScales).is_some() { - // Here attacker a should get the effectors of half attack speed and damage over time. if effectors.get(*a).is_none() { effectors.insert(*a, EffectorSet::default()); @@ -27,24 +32,35 @@ pub fn caustic_scales_system( // If CausticScales already applied, then just refresh the duration if current_effectors .iter() - .any(|x| x.effector_key == Effectors::CausticScales) + .any(|x| match x.effector_key { + Effectors::CausticDamage => true, + Effectors::CausticSlow => true, + _ => false, + }) { for i in 0..current_effectors.len() { - if current_effectors[i].effector_key == Effectors::CausticScales { + if current_effectors[i].effector_key == Effectors::CausticDamage { current_effectors[i].disable_in = dot_effector.duration; } + if current_effectors[i].effector_key == Effectors::CausticSlow { + current_effectors[i].disable_in = slow_effector.duration; + } } } - // else add the effector: else { effectors .get_mut(*a) .unwrap() .effectors - .push(EffectorInstance::new( - Effectors::CausticScales, + .append( + &mut vec![EffectorInstance::new( + Effectors::CausticDamage, dot_effector.duration, - )); + ), + EffectorInstance::new( + Effectors::CausticSlow, + slow_effector.duration, + )]); } } } diff --git a/src/systems/venom_bite.rs b/src/systems/venom_bite.rs index 852edd7..7cab382 100644 --- a/src/systems/venom_bite.rs +++ b/src/systems/venom_bite.rs @@ -1,15 +1,21 @@ use crate::*; -/// Returns half of the received damage. +/// Every attack applies stacking (up to 5) poison and slow debuff. pub fn venom_bite_system( skills: &Components>, effector_defs: &EffectorDefinitions, effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { - let venom_effector = effector_defs + + let dot_effector = effector_defs + .defs + .get(&Effectors::VenomDamage) + .expect("Unknown effector key."); + + let slow_effector = effector_defs .defs - .get(&Effectors::HemotoxicVenom) + .get(&Effectors::VenomSlow) .expect("Unknown effector key."); for ev in game_events.iter() { @@ -24,15 +30,23 @@ pub fn venom_bite_system( // Check how many stacks of HemotoxicVenom target has. // If over 5 then do nothing. Otherwise apply 1 more + // TODO: stack limit should be specified in data files, not hardcoded if current_effectors .iter() - .filter(|x| x.effector_key == Effectors::HemotoxicVenom) + .filter(|x| (x.effector_key == Effectors::VenomDamage) | + (x.effector_key == Effectors::VenomDamage)) .count() < 5 { + // Assume that VenomDamage and VenomSlow are always applied together + current_effectors.push(EffectorInstance::new( + Effectors::VenomDamage, + dot_effector.duration, + )); + current_effectors.push(EffectorInstance::new( - Effectors::HemotoxicVenom, - venom_effector.duration, + Effectors::VenomSlow, + slow_effector.duration, )); } } From ef839c92d517e44535b61e48081f4e16c72ce86c Mon Sep 17 00:00:00 2001 From: Vilius Peteraitis Date: Mon, 25 Jan 2021 21:51:45 +0100 Subject: [PATCH 8/8] cargo fmt and small data file fix --- assets/effector_defs.yaml | 2 -- src/systems/caustic_scales.rs | 35 ++++++++++------------------------- src/systems/venom_bite.rs | 7 ++++--- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/assets/effector_defs.yaml b/assets/effector_defs.yaml index eeef504..6b4f62a 100644 --- a/assets/effector_defs.yaml +++ b/assets/effector_defs.yaml @@ -90,5 +90,3 @@ defs: effects: - - Health - Additive: -3.0 - - - ActionPointRefillRate - - MultiplicativeMultiplier: 0.8 diff --git a/src/systems/caustic_scales.rs b/src/systems/caustic_scales.rs index cca0a1a..24f787c 100644 --- a/src/systems/caustic_scales.rs +++ b/src/systems/caustic_scales.rs @@ -7,7 +7,6 @@ pub fn caustic_scales_system( effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { - let dot_effector = effector_defs .defs .get(&Effectors::CausticDamage) @@ -22,7 +21,6 @@ pub fn caustic_scales_system( if let GameEvent::DamageEntity(a, t, _dmg) = ev { if let Some(skills) = skills.get(*t) { if skills.skills.get(&Skills::CausticScales).is_some() { - if effectors.get(*a).is_none() { effectors.insert(*a, EffectorSet::default()); } @@ -30,14 +28,11 @@ pub fn caustic_scales_system( let current_effectors = &mut effectors.get_mut(*a).unwrap().effectors; // If CausticScales already applied, then just refresh the duration - if current_effectors - .iter() - .any(|x| match x.effector_key { - Effectors::CausticDamage => true, - Effectors::CausticSlow => true, - _ => false, - }) - { + if current_effectors.iter().any(|x| match x.effector_key { + Effectors::CausticDamage => true, + Effectors::CausticSlow => true, + _ => false, + }) { for i in 0..current_effectors.len() { if current_effectors[i].effector_key == Effectors::CausticDamage { current_effectors[i].disable_in = dot_effector.duration; @@ -46,21 +41,11 @@ pub fn caustic_scales_system( current_effectors[i].disable_in = slow_effector.duration; } } - } - else { - effectors - .get_mut(*a) - .unwrap() - .effectors - .append( - &mut vec![EffectorInstance::new( - Effectors::CausticDamage, - dot_effector.duration, - ), - EffectorInstance::new( - Effectors::CausticSlow, - slow_effector.duration, - )]); + } else { + effectors.get_mut(*a).unwrap().effectors.append(&mut vec![ + EffectorInstance::new(Effectors::CausticDamage, dot_effector.duration), + EffectorInstance::new(Effectors::CausticSlow, slow_effector.duration), + ]); } } } diff --git a/src/systems/venom_bite.rs b/src/systems/venom_bite.rs index 7cab382..a8aa0bb 100644 --- a/src/systems/venom_bite.rs +++ b/src/systems/venom_bite.rs @@ -7,7 +7,6 @@ pub fn venom_bite_system( effectors: &mut Components>, game_events: &mut Vec, ) -> SystemResult { - let dot_effector = effector_defs .defs .get(&Effectors::VenomDamage) @@ -33,8 +32,10 @@ pub fn venom_bite_system( // TODO: stack limit should be specified in data files, not hardcoded if current_effectors .iter() - .filter(|x| (x.effector_key == Effectors::VenomDamage) | - (x.effector_key == Effectors::VenomDamage)) + .filter(|x| { + (x.effector_key == Effectors::VenomDamage) + | (x.effector_key == Effectors::VenomDamage) + }) .count() < 5 {