Fixed offsets for laser and rocket attacks of clay golem.

This commit is contained in:
Sam 2021-05-10 18:52:47 -05:00
parent 770d07ac90
commit 7f6c6c5603
4 changed files with 20 additions and 13 deletions

View File

@ -9,5 +9,5 @@ BasicRanged(
),
projectile_body: Object(ClayRocket),
projectile_light: None,
projectile_speed: 20.0,
projectile_speed: 30.0,
)

View File

@ -140,24 +140,26 @@ impl CharacterBehavior for Data {
owner: Some(*data.uid),
specifier: self.static_data.specifier,
};
// Gets offsets
let body_offsets_r = data.body.radius() + 1.0;
let body_offsets_z = match data.body {
Body::BirdLarge(_) | Body::Golem(_) => data.body.height() * 0.8,
Body::BirdLarge(_) => data.body.height() * 0.8,
Body::Golem(_) => data.body.height() * 0.9 + data.inputs.look_dir.z * 3.0,
_ => data.body.height() * 0.5,
};
// Gets offsets
let (body_offsets, ori) = match self.static_data.orientation_behavior {
OrientationBehavior::Normal | OrientationBehavior::Turret => (
Vec3::new(
(data.body.radius() + 1.0) * data.inputs.look_dir.x,
(data.body.radius() + 1.0) * data.inputs.look_dir.y,
body_offsets_r * data.inputs.look_dir.x,
body_offsets_r * data.inputs.look_dir.y,
body_offsets_z,
),
Ori::from(data.inputs.look_dir),
),
OrientationBehavior::FromOri => (
Vec3::new(
(data.body.radius() + 1.0) * update.ori.look_vec().x,
(data.body.radius() + 1.0) * update.ori.look_vec().y,
body_offsets_r * update.ori.look_vec().x,
body_offsets_r * update.ori.look_vec().y,
body_offsets_z,
),
Ori::from(Vec3::new(

View File

@ -187,11 +187,15 @@ pub fn handle_shoot(
.write_resource::<Vec<Outcome>>()
.push(Outcome::ProjectileShot { pos, body, vel });
let eye_height = state
.ecs()
.read_storage::<comp::Body>()
.get(entity)
.map_or(0.0, |b| b.eye_height());
let eye_height =
state
.ecs()
.read_storage::<comp::Body>()
.get(entity)
.map_or(0.0, |b| match b {
comp::Body::Golem(_) => b.height() * 0.45,
_ => b.eye_height(),
});
pos.z += eye_height;

View File

@ -1649,7 +1649,7 @@ impl<'a> AgentData<'a> {
)
}
Tactic::ClayGolem if matches!(self.char_state, CharacterState::BasicRanged(_)) => {
const ROCKET_SPEED: f32 = 20.0;
const ROCKET_SPEED: f32 = 30.0;
aim_projectile(
ROCKET_SPEED,
Vec3::new(self.pos.0.x, self.pos.0.y, self.pos.0.z + eye_offset),
@ -3508,6 +3508,7 @@ impl<'a> AgentData<'a> {
tgt_data.pos,
attack_data.dist_sqrd,
)
&& attack_data.angle < 45.0
{
// If target in range threshold and haven't been lasering for more than 10
// seconds already or if target is moving slow-ish, laser them