Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Implement Adder Leader #42

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions assets/effector_defs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,27 @@ defs:
effects:
- - Attack
- Additive: 1.0
CausticDamage:
key: CausticDamage
duration: 10.0
effects:
- - Health
- Additive: -6.0
CausticSlow:
key: CausticSlow
duration: 10.0
effects:
- - AttackSpeed
- MultiplicativeMultiplier: 0.8
VenomSlow:
key: VenomSlow
duration: 10.0
effects:
- - ActionPointRefillRate
- MultiplicativeMultiplier: 0.8
VenomDamage:
key: VenomDamage
duration: 10.0
effects:
- - Health
- Additive: -3.0
6 changes: 6 additions & 0 deletions assets/leader_defs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ defs:
skills:
- ReturnDamage
- BattleCall
Adder:
key: Adder
name: "Adder"
skills:
- CausticScales
- VenomBite
20 changes: 20 additions & 0 deletions assets/skill_defs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 attack speed 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: []
7 changes: 7 additions & 0 deletions src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub enum Skills {
DarkPresence,
ReturnDamage,
BattleCall,
CausticScales,
VenomBite,
}

/// The different items ids.
Expand All @@ -62,6 +64,10 @@ pub enum Items {
pub enum Effectors {
DoubleDamage,
DoubleAttackSpeed,
CausticDamage,
CausticSlow,
VenomDamage,
VenomSlow,
Root,
AttackSpeedIncrease,
HalfMovementSpeed,
Expand All @@ -86,4 +92,5 @@ pub enum Leaders {
CentaurPersonLeader,
Celsus,
SoulsCollector,
Adder,
}
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ fn main() -> BError {
nature_summon_system,
bear_spawner_system,
savagery_system,
caustic_scales_system,
venom_bite_system,
battle_hunger_system,
air_corrosion_system,
dark_presence_system,
Expand Down Expand Up @@ -471,7 +473,7 @@ fn main() -> BError {
vec![
Leaders::Generic1,
Leaders::Generic2,
Leaders::Generic3,
Leaders::Adder,
Leaders::TreePersonLeader,
Leaders::BearPersonLeader,
],
Expand Down
56 changes: 56 additions & 0 deletions src/systems/caustic_scales.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use crate::*;

/// Every unit that attacks this leader gets poisoned and has attack speed slowed.
pub fn caustic_scales_system(
skills: &Components<SkillSet<Skills>>,
effector_defs: &EffectorDefinitions<Stats, Effectors>,
effectors: &mut Components<EffectorSet<Effectors>>,
game_events: &mut Vec<GameEvent>,
) -> SystemResult {
let dot_effector = effector_defs
.defs
.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() {
if effectors.get(*a).is_none() {
effectors.insert(*a, EffectorSet::default());
}

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,
}) {
for i in 0..current_effectors.len() {
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 {
effectors.get_mut(*a).unwrap().effectors.append(&mut vec![
EffectorInstance::new(Effectors::CausticDamage, dot_effector.duration),
EffectorInstance::new(Effectors::CausticSlow, slow_effector.duration),
]);
}
}
}
}
}

Ok(())
}
4 changes: 4 additions & 0 deletions src/systems/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,11 +32,13 @@ 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::caustic_scales::*;
pub use self::creep_spawner::*;
pub use self::damage_entity::*;
pub use self::dark_presence::*;
Expand Down Expand Up @@ -65,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::*;
59 changes: 59 additions & 0 deletions src/systems/venom_bite.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use crate::*;

/// Every attack applies stacking (up to 5) poison and slow debuff.
pub fn venom_bite_system(
skills: &Components<SkillSet<Skills>>,
effector_defs: &EffectorDefinitions<Stats, Effectors>,
effectors: &mut Components<EffectorSet<Effectors>>,
game_events: &mut Vec<GameEvent>,
) -> SystemResult {
let dot_effector = effector_defs
.defs
.get(&Effectors::VenomDamage)
.expect("Unknown effector key.");

let slow_effector = effector_defs
.defs
.get(&Effectors::VenomSlow)
.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
// 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)
})
.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::VenomSlow,
slow_effector.duration,
));
}
}
}
}
}

Ok(())
}