M1 now only regens stamina when healing allies if they are not at full health.

This commit is contained in:
Sam 2020-08-31 17:08:25 -05:00
parent 8f7d45100d
commit 6bb680f372
3 changed files with 24 additions and 17 deletions

View File

@ -276,7 +276,7 @@ void main() {
} else if (inst_mode == HEALING_BEAM) {
attr = Attr(
spiral_motion(beam_pos2() - inst_pos, 0.3 * (floor(2 * hash(vec4(inst_time)) + 0.5) - 0.5), lifetime / 2),
(1.7 - 0.7 * abs(floor(2 * hash(vec4(inst_time)) - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4)),
vec3((1.7 - 0.7 * abs(floor(2 * hash(vec4(inst_time)) - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))),
vec4(vec3(0.3, 0.7 + 0.4 * sin(tick.x * 8 - lifetime * 3), 0.3 + 0.1 * sin (tick.x * 2)), 0.3),
spin_in_axis(vec3(inst_entropy, inst_misc, inst_lifespan), tick.z)
);
@ -286,7 +286,7 @@ void main() {
vec3(rand0 * 1, rand1 * 1, rand2 * 1),
vec3(rand3 * 2, rand4 * 2, rand5 * 2)
),
0.8,
vec3(0.8),
vec4(vec3(0, 1, 0), 1),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
);

View File

@ -129,8 +129,13 @@ impl CharacterBehavior for Data {
});
// Grant energy on successful hit
let energy = (self.energy_regen as f32 / self.tick_rate) as i32;
update.energy.change_by(energy, EnergySource::HitEnemy);
if let Some(attack) = data.attacking {
if attack.applied && attack.hit_count > 0 {
data.updater.remove::<Attacking>(data.entity);
let energy = (self.energy_regen as f32 / self.tick_rate) as i32;
update.energy.change_by(energy, EnergySource::HitEnemy);
}
}
} else if self.recover_duration != Duration::default() {
// Recovery
update.character = CharacterState::BasicBeam(Data {

View File

@ -150,22 +150,25 @@ impl<'a> System<'a> for Sys {
}
if damage.healthchange != 0.0 {
let cause = if is_heal { HealthSource::Healing { by: Some(*uid) } } else { HealthSource::Attack { by: *uid } };
server_emitter.emit(ServerEvent::Damage {
uid: *uid_b,
change: HealthChange {
amount: damage.healthchange as i32,
cause,
},
});
if attack.lifesteal_eff > 0.0 && is_damage {
if is_damage || stats_b.health.current() != stats_b.health.maximum() {
let cause = if is_heal { HealthSource::Healing { by: Some(*uid) } } else { HealthSource::Attack { by: *uid } };
server_emitter.emit(ServerEvent::Damage {
uid: *uid,
uid: *uid_b,
change: HealthChange {
amount: (-damage.healthchange * attack.lifesteal_eff) as i32,
cause: HealthSource::Attack { by: *uid },
amount: damage.healthchange as i32,
cause,
},
});
if attack.lifesteal_eff > 0.0 && is_damage {
server_emitter.emit(ServerEvent::Damage {
uid: *uid,
change: HealthChange {
amount: (-damage.healthchange * attack.lifesteal_eff) as i32,
cause: HealthSource::Healing { by: Some(*uid) },
},
});
}
attack.hit_count += 1;
}
}
if attack.knockback != 0.0 && damage.healthchange != 0.0 {
@ -176,7 +179,6 @@ impl<'a> System<'a> for Sys {
* *Dir::slerp(kb_dir, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5),
});
}
attack.hit_count += 1;
}
}
}