mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make entities protect owned bodies.
This commit is contained in:
parent
82273f0f36
commit
a00121bedf
@ -79,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Bumped tracing-subscriber to resolve [RUSTSEC-2022-0006](https://rustsec.org/advisories/RUSTSEC-2022-0006)
|
||||
- Made /home command a mod+ exclusive
|
||||
- Friendly creatures will now defend each other
|
||||
- Creatures will now defend their pets
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -1503,9 +1503,8 @@ impl<'a> AgentData<'a> {
|
||||
})
|
||||
};
|
||||
|
||||
let guard_other = |e_health: &Health,
|
||||
e_body: Option<&Body>,
|
||||
e_alignment: Option<&Alignment>| {
|
||||
let guard_other =
|
||||
|e_health: &Health, e_body: Option<&Body>, e_alignment: Option<&Alignment>| {
|
||||
let i_am_a_guard = read_data
|
||||
.stats
|
||||
.get(*self.entity)
|
||||
@ -1519,11 +1518,15 @@ impl<'a> AgentData<'a> {
|
||||
eb.is_same_species_as(mb) || (eb.is_humanoid() && mb.is_humanoid())
|
||||
})
|
||||
});
|
||||
let i_own_other =
|
||||
matches!(e_alignment, Some(Alignment::Owned(ouid)) if self.uid == ouid);
|
||||
let other_has_taken_damage = read_data.time.0 - e_health.last_change.time.0 < 5.0;
|
||||
let attacker_of = |health: &Health| health.last_change.damage_by();
|
||||
|
||||
let i_should_defend = other_has_taken_damage
|
||||
&& ((we_are_friendly && we_share_species) || (i_am_a_guard && other_is_a_villager));
|
||||
&& ((we_are_friendly && we_share_species)
|
||||
|| (i_am_a_guard && other_is_a_villager)
|
||||
|| i_own_other);
|
||||
|
||||
i_should_defend
|
||||
.then(|| {
|
||||
|
Loading…
Reference in New Issue
Block a user