Snowball attack.

This commit is contained in:
Sam 2021-05-31 20:51:47 -05:00
parent a82984b925
commit 81f7e690fd
8 changed files with 100 additions and 13 deletions

View File

@ -2,12 +2,12 @@ BasicRanged(
energy_cost: 0,
buildup_duration: 0.5,
recover_duration: 0.4,
projectile: Frostball( // Snowball
damage: 80.0,
projectile: Snowball(
damage: 200.0,
radius: 5.0,
),
projectile_body: Object(BoltFire), // Snowball
projectile_speed: 30.0,
projectile_body: Object(Snowball),
projectile_speed: 60.0,
num_projectiles: 1,
projectile_spread: 0.0,
)

View File

@ -719,4 +719,14 @@
central: ("armor.empty"),
)
),
Snowball: (
bone0: (
offset: (-12.5, -12.5, 0.0),
central: ("weapon.projectile.snowball"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
})

BIN
assets/voxygen/voxel/weapon/projectile/snowball.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -84,6 +84,7 @@ make_case_elim!(
ClayRocket = 69,
HaniwaSentry = 70,
SeaLantern = 71,
Snowball = 72,
}
);
@ -94,7 +95,7 @@ impl Body {
}
}
pub const ALL_OBJECTS: [Body; 72] = [
pub const ALL_OBJECTS: [Body; 73] = [
Body::Arrow,
Body::Bomb,
Body::Scarecrow,
@ -167,6 +168,7 @@ pub const ALL_OBJECTS: [Body; 72] = [
Body::ClayRocket,
Body::HaniwaSentry,
Body::SeaLantern,
Body::Snowball,
];
impl From<Body> for super::Body {
@ -248,6 +250,7 @@ impl Body {
Body::ClayRocket => "clay_rocket",
Body::HaniwaSentry => "haniwa_sentry",
Body::SeaLantern => "sea_lantern",
Body::Snowball => "snowball",
}
}
@ -270,6 +273,7 @@ impl Body {
Body::Crate => 300.0, // let's say it's a lot of wood and maybe some contents
Body::Scarecrow => 900.0,
Body::TrainingDummy => 2000.0,
Body::Snowball => 0.9 * WATER_DENSITY,
// let them sink
_ => 1.1 * WATER_DENSITY,
};
@ -340,6 +344,7 @@ impl Body {
Body::ClayRocket => 50.0,
Body::HaniwaSentry => 300.0,
Body::SeaLantern => 1000.0,
Body::Snowball => 7360.0, // 2.5 m diamter
};
Mass(m)
@ -354,6 +359,7 @@ impl Body {
Body::Crossbow => Vec3::new(3.0, 3.0, 1.5),
Body::HaniwaSentry => Vec3::new(0.8, 0.8, 1.4),
Body::SeaLantern => Vec3::new(0.5, 0.5, 1.0),
Body::Snowball => Vec3::broadcast(2.5),
_ => Vec3::broadcast(0.5),
}
}

View File

@ -32,6 +32,10 @@ pub struct Projectile {
/// Whether projectile collides with entities in the same group as its
/// owner
pub ignore_group: bool,
/// Whether the projectile is sticky
pub is_sticky: bool,
/// Whether the projectile should use a point collider
pub is_point: bool,
}
impl Component for Projectile {
@ -64,6 +68,10 @@ pub enum ProjectileConstructor {
radius: f32,
knockback: f32,
},
Snowball {
damage: f32,
radius: f32,
},
}
impl ProjectileConstructor {
@ -113,6 +121,8 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(15),
owner,
ignore_group: true,
is_sticky: true,
is_point: true,
}
},
Fireball {
@ -149,6 +159,8 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(10),
owner,
ignore_group: true,
is_sticky: true,
is_point: true,
}
},
Frostball { damage, radius } => {
@ -167,7 +179,7 @@ impl ProjectileConstructor {
let explosion = Explosion {
effects: vec![RadiusEffect::Attack(attack)],
radius,
reagent: Some(Reagent::Blue),
reagent: Some(Reagent::White),
};
Projectile {
hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish],
@ -175,6 +187,8 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(10),
owner,
ignore_group: true,
is_sticky: true,
is_point: true,
}
},
NecroticSphere { damage, radius } => {
@ -201,6 +215,8 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(10),
owner,
ignore_group: true,
is_sticky: true,
is_point: true,
}
},
Possess => Projectile {
@ -209,6 +225,8 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(10),
owner,
ignore_group: false,
is_sticky: true,
is_point: true,
},
ClayRocket {
damage,
@ -249,6 +267,35 @@ impl ProjectileConstructor {
time_left: Duration::from_secs(10),
owner,
ignore_group: true,
is_sticky: true,
is_point: true,
}
},
Snowball { damage, radius } => {
let damage = AttackDamage::new(
Damage {
source: DamageSource::Explosion,
kind: DamageKind::Energy,
value: damage,
},
Some(GroupTarget::OutOfGroup),
);
let attack = Attack::default()
.with_damage(damage)
.with_crit(crit_chance, crit_mult);
let explosion = Explosion {
effects: vec![RadiusEffect::Attack(attack)],
radius,
reagent: Some(Reagent::White),
};
Projectile {
hit_solid: vec![],
hit_entity: vec![Effect::Explode(explosion), Effect::Vanish],
time_left: Duration::from_secs(120),
owner,
ignore_group: true,
is_sticky: false,
is_point: false,
}
},
}
@ -300,6 +347,13 @@ impl ProjectileConstructor {
*damage *= power;
*radius *= range;
},
Snowball {
ref mut damage,
ref mut radius,
} => {
*damage *= power;
*radius *= range;
},
}
self
}

View File

@ -285,17 +285,29 @@ impl StateExt for State {
body: comp::Body,
projectile: comp::Projectile,
) -> EcsEntityBuilder {
self.ecs_mut()
let mut projectile_base = self
.ecs_mut()
.create_entity_synced()
.with(pos)
.with(vel)
.with(comp::Ori::from_unnormalized_vec(vel.0).unwrap_or_default())
.with(body.mass())
.with(body.density())
.with(comp::Collider::Point)
.with(body)
.with(projectile)
.with(comp::Sticky)
.with(body.density());
if projectile.is_sticky {
projectile_base = projectile_base.with(comp::Sticky)
}
if projectile.is_point {
projectile_base = projectile_base.with(comp::Collider::Point)
} else {
projectile_base = projectile_base.with(comp::Collider::Box {
radius: body.radius(),
z_min: 0.0,
z_max: body.height(),
})
}
projectile_base.with(projectile).with(body)
}
fn create_shockwave(

View File

@ -132,6 +132,8 @@ impl<'a> System<'a> for Sys {
time_left: Duration::from_secs(60),
owner: *owner,
ignore_group: true,
is_sticky: true,
is_point: true,
},
speed,
object: Some(Object::Firework {

View File

@ -100,7 +100,7 @@ impl ParticleMgr {
},
);
},
Some(Reagent::Blue) => {
Some(Reagent::White) => {
self.particles.resize_with(
self.particles.len() + (75.0 * power.abs()) as usize,
|| {