mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'worldboss_aggro_fix' into 'master'
worldboss_aggro_fix See merge request veloren/veloren!4490
This commit is contained in:
commit
69003aaebe
@ -274,6 +274,10 @@ pub struct Psyche {
|
|||||||
/// wandering behavior in the idle state, and scaling `aggro_dist` in
|
/// wandering behavior in the idle state, and scaling `aggro_dist` in
|
||||||
/// certain situations.
|
/// certain situations.
|
||||||
pub aggro_range_multiplier: f32,
|
pub aggro_range_multiplier: f32,
|
||||||
|
/// Whether this entity should *intelligently* decide to loose aggro based
|
||||||
|
/// on distance from agent home and health, this is not suitable for world
|
||||||
|
/// bosses and roaming entities
|
||||||
|
pub should_stop_pursuing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a Body> for Psyche {
|
impl<'a> From<&'a Body> for Psyche {
|
||||||
@ -425,6 +429,13 @@ impl<'a> From<&'a Body> for Psyche {
|
|||||||
},
|
},
|
||||||
idle_wander_factor: 1.0,
|
idle_wander_factor: 1.0,
|
||||||
aggro_range_multiplier: 1.0,
|
aggro_range_multiplier: 1.0,
|
||||||
|
should_stop_pursuing: match body {
|
||||||
|
Body::BirdLarge(_) => false,
|
||||||
|
Body::BipedLarge(biped_large) => {
|
||||||
|
!matches!(biped_large.species, biped_large::Species::Gigasfrost)
|
||||||
|
},
|
||||||
|
_ => true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -994,7 +994,7 @@ impl<'a> AgentData<'a> {
|
|||||||
controller.push_utterance(UtteranceKind::Surprised);
|
controller.push_utterance(UtteranceKind::Surprised);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if agent.psyche.should_stop_pursuing || target.is_some() {
|
||||||
agent.target = target.map(|(entity, attack_target)| Target {
|
agent.target = target.map(|(entity, attack_target)| Target {
|
||||||
target: entity,
|
target: entity,
|
||||||
hostile: attack_target,
|
hostile: attack_target,
|
||||||
@ -1003,6 +1003,7 @@ impl<'a> AgentData<'a> {
|
|||||||
last_known_pos: get_pos(entity).map(|pos| pos.0),
|
last_known_pos: get_pos(entity).map(|pos| pos.0),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn attack(
|
pub fn attack(
|
||||||
&self,
|
&self,
|
||||||
|
@ -80,7 +80,8 @@ pub fn stop_pursuing(
|
|||||||
dur_since_last_attacked: f64,
|
dur_since_last_attacked: f64,
|
||||||
psyche: &Psyche,
|
psyche: &Psyche,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
should_let_target_escape(
|
psyche.should_stop_pursuing
|
||||||
|
&& should_let_target_escape(
|
||||||
dist_to_home_sqrd,
|
dist_to_home_sqrd,
|
||||||
dur_since_last_attacked,
|
dur_since_last_attacked,
|
||||||
own_health_fraction,
|
own_health_fraction,
|
||||||
|
@ -855,7 +855,7 @@ fn do_combat(bdata: &mut BehaviorData) -> bool {
|
|||||||
let is_time_to_retarget =
|
let is_time_to_retarget =
|
||||||
read_data.time.0 - selected_at > RETARGETING_THRESHOLD_SECONDS;
|
read_data.time.0 - selected_at > RETARGETING_THRESHOLD_SECONDS;
|
||||||
|
|
||||||
if !in_aggro_range && is_time_to_retarget {
|
if (!agent.psyche.should_stop_pursuing || !in_aggro_range) && is_time_to_retarget {
|
||||||
agent_data.choose_target(
|
agent_data.choose_target(
|
||||||
agent,
|
agent,
|
||||||
controller,
|
controller,
|
||||||
@ -889,6 +889,10 @@ fn do_combat(bdata: &mut BehaviorData) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// make sure world bosses and roaming entities stay aware, to continue pursuit
|
||||||
|
if !agent.psyche.should_stop_pursuing {
|
||||||
|
bdata.agent.awareness.set_maximally_aware();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user