mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add firework item
This commit is contained in:
parent
eea64f78ff
commit
9aab296264
7
assets/common/items/utility/firework.ron
Normal file
7
assets/common/items/utility/firework.ron
Normal file
@ -0,0 +1,7 @@
|
||||
Item(
|
||||
name: "Firework",
|
||||
description: "Label: Outdoor use only!\n\n<Right-Click to use>",
|
||||
kind: Throwable(
|
||||
kind: Firework,
|
||||
),
|
||||
)
|
@ -9,6 +9,7 @@
|
||||
(0.4, "common.items.ore.velorite"),
|
||||
(0.6, "common.items.ore.veloritefrag"),
|
||||
(0.1, "common.items.consumable.potion_minor"),
|
||||
(1.0, "common.items.utility.firework"),
|
||||
(0.01, "common.items.utility.collar"),
|
||||
(0.01, "common.items.utility.bomb_pile"),
|
||||
(0.1, "common.items.utility.bomb"),
|
||||
|
@ -6,6 +6,7 @@
|
||||
"potion_m": (("common.items.consumable.potion_med", 1), [("common.items.consumable.potion_minor", 2), ("common.items.ore.veloritefrag", 4)]),
|
||||
"collar_basic": (("common.items.utility.collar", 1), [("common.items.crafting_ing.leather_scraps", 5), ("common.items.crafting_ing.shiny_gem", 1)]),
|
||||
"bomb_coconut": (("common.items.utility.bomb", 1), [("common.items.crafting_ing.stones", 10), ("common.items.food.coconut", 2), ("common.items.ore.veloritefrag", 2), ("common.items.crafting_tools.mortar_pestle", 0)]),
|
||||
"firework": (("common.items.utility.firework", 1), [("common.items.crafting_ing.twigs", 1), ("common.items.crafting_ing.stones", 1), ("common.items.food.coconut", 2), ("common.items.ore.veloritefrag", 10), ("common.items.crafting_tools.mortar_pestle", 0)]),
|
||||
"apple_shroom_curry": (("common.items.food.apple_mushroom_curry", 1), [("common.items.food.mushroom", 10), ("common.items.food.coconut", 1), ("common.items.food.apple", 5), ("common.items.crafting_tools.mortar_pestle", 0)]),
|
||||
"apples_stick": (("common.items.food.apple_stick", 1),[("common.items.crafting_ing.twigs", 1), ("common.items.food.apple", 3)]),
|
||||
"mushroom_stick": (("common.items.food.mushroom_stick", 1),[("common.items.crafting_ing.twigs", 1), ("common.items.food.mushroom", 5)]),
|
||||
|
@ -1110,6 +1110,10 @@
|
||||
"voxel.object.bomb",
|
||||
(0.0, 0.5, 0.0), (-50.0, 40.0, 20.0), 0.8,
|
||||
),
|
||||
Throwable(Firework): VoxTrans(
|
||||
"voxel.object.firework",
|
||||
(0.0, 0.5, 0.0), (-50.0, 40.0, 20.0), 0.8,
|
||||
),
|
||||
Throwable(TrainingDummy): VoxTrans(
|
||||
"voxel.object.training_dummy",
|
||||
(0.0, -1.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
|
||||
|
@ -58,6 +58,7 @@ pub enum Body {
|
||||
CampfireLit = 51,
|
||||
BoltFireBig = 52,
|
||||
TrainingDummy = 53,
|
||||
Firework = 54,
|
||||
}
|
||||
|
||||
impl Body {
|
||||
@ -67,7 +68,7 @@ impl Body {
|
||||
}
|
||||
}
|
||||
|
||||
pub const ALL_OBJECTS: [Body; 54] = [
|
||||
pub const ALL_OBJECTS: [Body; 55] = [
|
||||
Body::Arrow,
|
||||
Body::Bomb,
|
||||
Body::Scarecrow,
|
||||
@ -122,6 +123,7 @@ pub const ALL_OBJECTS: [Body; 54] = [
|
||||
Body::BoltFireBig,
|
||||
Body::ArrowSnake,
|
||||
Body::TrainingDummy,
|
||||
Body::Firework,
|
||||
];
|
||||
|
||||
impl From<Body> for super::Body {
|
||||
@ -185,6 +187,7 @@ impl Body {
|
||||
Body::BoltFireBig => "bolt_fire_big",
|
||||
Body::ArrowSnake => "arrow_snake",
|
||||
Body::TrainingDummy => "training_dummy",
|
||||
Body::Firework => "firework",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use vek::Rgb;
|
||||
pub enum Throwable {
|
||||
Bomb,
|
||||
TrainingDummy,
|
||||
Firework,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
|
@ -6,6 +6,7 @@ use specs_idvs::IdvStorage;
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Object {
|
||||
Bomb { owner: Option<Uid> },
|
||||
Firework { owner: Option<Uid> },
|
||||
}
|
||||
|
||||
impl Component for Object {
|
||||
|
@ -402,16 +402,22 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
|
||||
// Throw items
|
||||
for (pos, vel, ori, kind) in thrown_items {
|
||||
let vel = vel.0
|
||||
+ *ori.0 * 20.0
|
||||
+ Vec3::unit_z() * 15.0
|
||||
+ Vec3::<f32>::zero().map(|_| rand::thread_rng().gen::<f32>() - 0.5) * 4.0;
|
||||
let vel = match kind {
|
||||
item::Throwable::Firework => Vec3::unit_z() * 200.0,
|
||||
_ => {
|
||||
vel.0
|
||||
+ *ori.0 * 20.0
|
||||
+ Vec3::unit_z() * 15.0
|
||||
+ Vec3::<f32>::zero().map(|_| rand::thread_rng().gen::<f32>() - 0.5) * 4.0
|
||||
},
|
||||
};
|
||||
|
||||
let uid = state.read_component_copied::<Uid>(entity);
|
||||
|
||||
let mut new_entity = state
|
||||
.create_object(Default::default(), match kind {
|
||||
item::Throwable::Bomb => comp::object::Body::Bomb,
|
||||
item::Throwable::Firework => comp::object::Body::Bomb,
|
||||
item::Throwable::TrainingDummy => comp::object::Body::TrainingDummy,
|
||||
})
|
||||
.with(comp::Pos(pos.0 + Vec3::unit_z() * 0.25))
|
||||
@ -421,6 +427,9 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
item::Throwable::Bomb => {
|
||||
new_entity = new_entity.with(comp::Object::Bomb { owner: uid });
|
||||
},
|
||||
item::Throwable::Firework => {
|
||||
new_entity = new_entity.with(comp::Object::Firework { owner: uid });
|
||||
},
|
||||
item::Throwable::TrainingDummy => {
|
||||
new_entity = new_entity.with(comp::Stats::new(
|
||||
"Training Dummy".to_string(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
use common::{
|
||||
comp::{HealthSource, Object, PhysicsState, Pos},
|
||||
comp::{HealthSource, Object, PhysicsState, Pos, Vel},
|
||||
event::{EventBus, ServerEvent},
|
||||
state::DeltaTime,
|
||||
};
|
||||
@ -14,19 +14,20 @@ impl<'a> System<'a> for Sys {
|
||||
Read<'a, DeltaTime>,
|
||||
Read<'a, EventBus<ServerEvent>>,
|
||||
ReadStorage<'a, Pos>,
|
||||
ReadStorage<'a, Vel>,
|
||||
ReadStorage<'a, PhysicsState>,
|
||||
WriteStorage<'a, Object>,
|
||||
);
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
(entities, _dt, server_bus, positions, physics_states, mut objects): Self::SystemData,
|
||||
(entities, _dt, server_bus, positions, velocities, physics_states, mut objects): Self::SystemData,
|
||||
) {
|
||||
let mut server_emitter = server_bus.emitter();
|
||||
|
||||
// Objects
|
||||
for (entity, pos, physics, object) in
|
||||
(&entities, &positions, &physics_states, &mut objects).join()
|
||||
for (entity, pos, vel, physics, object) in
|
||||
(&entities, &positions, &velocities, &physics_states, &mut objects).join()
|
||||
{
|
||||
match object {
|
||||
Object::Bomb { owner } => {
|
||||
@ -43,6 +44,20 @@ impl<'a> System<'a> for Sys {
|
||||
});
|
||||
}
|
||||
},
|
||||
Object::Firework { owner } => {
|
||||
if physics.on_surface().is_some() || vel.0.z < 0.0 {
|
||||
server_emitter.emit(ServerEvent::Destroy {
|
||||
entity,
|
||||
cause: HealthSource::Suicide,
|
||||
});
|
||||
server_emitter.emit(ServerEvent::Explosion {
|
||||
pos: pos.0,
|
||||
power: 4.0,
|
||||
owner: *owner,
|
||||
friendly_damage: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3418,6 +3418,7 @@ pub fn mesh_object(
|
||||
Vec3::new(-0.5, -6.0, -1.5),
|
||||
),
|
||||
Body::Bomb => ("object.bomb", Vec3::new(-5.5, -5.5, 0.0)),
|
||||
Body::Firework => ("object.firework", Vec3::new(-5.5, -5.5, 0.0)),
|
||||
Body::Scarecrow => ("object.scarecrow", Vec3::new(-9.5, -4.0, 0.0)),
|
||||
Body::Cauldron => ("object.cauldron", Vec3::new(-10.0, -10.0, 0.0)),
|
||||
Body::ChestVines => ("object.chest_vines", Vec3::new(-7.5, -6.0, 0.0)),
|
||||
|
Loading…
Reference in New Issue
Block a user