diff options
| author | troido <troido@protonmail.com> | 2020-03-03 16:47:11 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-03 16:47:11 +0100 |
| commit | 9954b5cbaab27aaffcafa8723dcd5d1c99fa811f (patch) | |
| tree | 0133821c4fd3dfb7c5500204efaaa02f9bcc57fe /src/systems/fight.rs | |
| parent | b98ea15acbebe8815f9316b5a8ef3393fdd1c3e6 (diff) | |
implemented autoretaliate
Diffstat (limited to 'src/systems/fight.rs')
| -rw-r--r-- | src/systems/fight.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/systems/fight.rs b/src/systems/fight.rs index 703ea4a..88305e2 100644 --- a/src/systems/fight.rs +++ b/src/systems/fight.rs @@ -54,9 +54,6 @@ impl <'a> System<'a> for Fight { } Control::AttackTarget(t) => { if *t == entity { // don't knock yourself out - if let Some(autofighter) = autofighters.get_mut(entity){ - autofighter.target = None; - } } else if let Some(target_position) = positions.get(*t){ if position.pos.distance_to(target_position.pos) <= fighter.range { target = Some(*t); @@ -66,7 +63,9 @@ impl <'a> System<'a> for Fight { _ => {} } if let Some(ent) = target { - AttackInbox::add_message(&mut attacked, ent, fighter.attack.clone()); + let mut attack = fighter.attack.clone(); + attack.attacker = Some(entity); + AttackInbox::add_message(&mut attacked, ent, attack); cooldowns.insert(entity, ControlCooldown{amount: fighter.cooldown}).unwrap(); if let Some(autofighter) = autofighters.get_mut(entity){ autofighter.target = Some(ent); |
