Made golem laser spawn based off of orientation rather than look_dir. Additional balance tweaks.

This commit is contained in:
Sam 2021-05-09 12:43:47 -05:00
parent fca56be4c0
commit 0d53e790fd
9 changed files with 58 additions and 26 deletions

View File

@ -2,13 +2,13 @@ BasicBeam(
buildup_duration: 0.20,
recover_duration: 0.20,
beam_duration: 0.25,
damage: 30,
tick_rate: 5.0,
damage: 100,
tick_rate: 2.0,
range: 40.0,
max_angle: 1.0,
damage_effect: None,
energy_regen: 50,
energy_drain: 0,
orientation_behavior: Normal,
orientation_behavior: FromOri,
specifier: ClayGolem,
)

View File

@ -6,10 +6,10 @@ Shockwave(
damage: 500,
poise_damage: 50,
knockback: (strength: 40.0, direction: TowardsUp),
shockwave_angle: 360.0,
shockwave_angle: 180.0,
shockwave_vertical_angle: 90.0,
shockwave_speed: 15.0,
shockwave_duration: 3.0,
shockwave_duration: 2.5,
requires_ground: true,
move_efficiency: 0.0,
damage_kind: Crushing,

View File

@ -6,8 +6,8 @@ BasicMelee(
base_damage: 200,
base_poise_damage: 50,
knockback: 10.0,
range: 5.0,
max_angle: 60.0,
range: 4.0,
max_angle: 45.0,
damage_effect: None,
damage_kind: Crushing,
)

View File

@ -243,7 +243,7 @@ pub enum CharacterAbility {
damage_effect: Option<CombatEffect>,
energy_regen: f32,
energy_drain: f32,
orientation_behavior: basic_beam::MovementBehavior,
orientation_behavior: basic_beam::OrientationBehavior,
specifier: beam::FrontendSpecifier,
},
BasicAura {

View File

@ -239,6 +239,16 @@ impl From<Dir> for Ori {
}
}
impl From<Vec3<f32>> for Ori {
fn from(dir: Vec3<f32>) -> Self {
let dir = Dir::from_unnormalized(dir).unwrap_or_default();
let from = Dir::default();
let q = Quaternion::<f32>::rotation_from_to_3d(*from, *dir).normalized();
Self(q).uprighted()
}
}
impl From<Quaternion<f32>> for Ori {
fn from(quat: Quaternion<f32>) -> Self { Self::new(quat) }
}

View File

@ -228,7 +228,6 @@ impl ProjectileConstructor {
source: DamageSource::Explosion,
kind: DamageKind::Energy,
value: damage,
kind: DamageKind::Energy,
},
Some(GroupTarget::OutOfGroup),
);

View File

@ -39,7 +39,7 @@ pub struct StaticData {
/// Energy drained per second
pub energy_drain: f32,
/// Used to dictate how orientation functions in this state
pub orientation_behavior: MovementBehavior,
pub orientation_behavior: OrientationBehavior,
/// What key is used to press ability
pub ability_info: AbilityInfo,
/// Used to specify the beam to the frontend
@ -61,14 +61,16 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
match self.static_data.orientation_behavior {
MovementBehavior::Normal => {},
MovementBehavior::Turret => {
let ori_rate = match self.static_data.orientation_behavior {
OrientationBehavior::Normal => 0.6,
OrientationBehavior::Turret => {
update.ori = Ori::from(data.inputs.look_dir);
0.6
},
}
OrientationBehavior::FromOri => 0.1,
};
handle_orientation(data, &mut update, 0.6);
handle_orientation(data, &mut update, ori_rate);
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update, 1.0);
@ -143,17 +145,34 @@ impl CharacterBehavior for Data {
_ => data.body.height() * 0.5,
};
// Gets offsets
let body_offsets = Vec3::new(
(data.body.radius() + 1.0) * data.inputs.look_dir.x,
(data.body.radius() + 1.0) * data.inputs.look_dir.y,
body_offsets_z,
);
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_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_z,
),
Ori::from(Vec3::new(
update.ori.look_vec().x,
update.ori.look_vec().y,
data.inputs.look_dir.z,
)),
),
};
let pos = Pos(data.pos.0 + body_offsets);
// Create beam segment
update.server_events.push_front(ServerEvent::BeamSegment {
properties,
pos,
ori: Ori::from(data.inputs.look_dir),
ori,
});
update.character = CharacterState::BasicBeam(Data {
timer: self
@ -210,7 +229,13 @@ impl CharacterBehavior for Data {
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum MovementBehavior {
pub enum OrientationBehavior {
/// Uses look_dir as direction of beam
Normal,
/// Uses look_dir as direction of beam, sets orientation to same direction
/// as look_dir
Turret,
/// Uses orientation x and y and look_dir z as direction of beam (z from
/// look_dir as orientation will only go through 2d rotations naturally)
FromOri,
}

View File

@ -3470,7 +3470,7 @@ impl<'a> AgentData<'a> {
tgt_data: &TargetData,
read_data: &ReadData,
) {
const GOLEM_MELEE_RANGE: f32 = 5.0;
const GOLEM_MELEE_RANGE: f32 = 4.0;
const GOLEM_LASER_RANGE: f32 = 30.0;
const GOLEM_LONG_RANGE: f32 = 50.0;
const GOLEM_TARGET_SPEED: f32 = 8.0;

View File

@ -402,9 +402,7 @@ impl SfxMgr {
audio.emit_sfx(sfx_trigger_item, *pos, None, false);
}
},
beam::FrontendSpecifier::ClayGolem => {
// TODO: Get sfx for this
},
beam::FrontendSpecifier::ClayGolem => {},
},
Outcome::BreakBlock { pos, .. } => {
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::BreakBlock);