mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'timo-tweeks' into 'master'
Timo tweeks See merge request veloren/veloren!569
This commit is contained in:
@ -168,19 +168,18 @@ impl Stats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Delete this once stat points will be a thing
|
// TODO: Delete this once stat points will be a thing
|
||||||
pub fn update_hp_bonus(&mut self, level: u32) {
|
pub fn update_max_hp(&mut self) {
|
||||||
self.health
|
self.health.set_maximum(42 * self.level.amount);
|
||||||
.set_maximum(self.health.maximum() + (10 * level) / 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stats {
|
impl Stats {
|
||||||
pub fn new(name: String, main: Option<comp::Item>) -> Self {
|
pub fn new(name: String, main: Option<comp::Item>) -> Self {
|
||||||
Self {
|
let mut stats = Self {
|
||||||
name,
|
name,
|
||||||
health: Health {
|
health: Health {
|
||||||
current: 100,
|
current: 0,
|
||||||
maximum: 100,
|
maximum: 0,
|
||||||
last_change: None,
|
last_change: None,
|
||||||
},
|
},
|
||||||
level: Level { amount: 1 },
|
level: Level { amount: 1 },
|
||||||
@ -198,7 +197,14 @@ impl Stats {
|
|||||||
alt: None,
|
alt: None,
|
||||||
},
|
},
|
||||||
is_dead: false,
|
is_dead: false,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
stats.update_max_hp();
|
||||||
|
stats
|
||||||
|
.health
|
||||||
|
.set_to(stats.health.maximum(), HealthSource::Revive);
|
||||||
|
|
||||||
|
stats
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_max_health(mut self, amount: u32) -> Self {
|
pub fn with_max_health(mut self, amount: u32) -> Self {
|
||||||
|
@ -15,10 +15,6 @@ pub enum LocalEvent {
|
|||||||
entity: EcsEntity,
|
entity: EcsEntity,
|
||||||
vel: Vec3<f32>,
|
vel: Vec3<f32>,
|
||||||
},
|
},
|
||||||
LandOnGround {
|
|
||||||
entity: EcsEntity,
|
|
||||||
vel: Vec3<f32>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ServerEvent {
|
pub enum ServerEvent {
|
||||||
@ -41,6 +37,10 @@ pub enum ServerEvent {
|
|||||||
dir: Vec3<f32>,
|
dir: Vec3<f32>,
|
||||||
projectile: comp::Projectile,
|
projectile: comp::Projectile,
|
||||||
},
|
},
|
||||||
|
LandOnGround {
|
||||||
|
entity: EcsEntity,
|
||||||
|
vel: Vec3<f32>,
|
||||||
|
},
|
||||||
Mount(EcsEntity, EcsEntity),
|
Mount(EcsEntity, EcsEntity),
|
||||||
Unmount(EcsEntity),
|
Unmount(EcsEntity),
|
||||||
}
|
}
|
||||||
|
@ -406,14 +406,6 @@ impl State {
|
|||||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||||
match event {
|
match event {
|
||||||
LocalEvent::LandOnGround { entity, vel } => {
|
|
||||||
if let Some(stats) = self.ecs.write_storage::<comp::Stats>().get_mut(entity) {
|
|
||||||
let falldmg = (vel.z / 1.5 + 10.0) as i32;
|
|
||||||
if falldmg < 0 {
|
|
||||||
stats.health.change_by(falldmg, comp::HealthSource::World);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LocalEvent::Jump(entity) => {
|
LocalEvent::Jump(entity) => {
|
||||||
if let Some(vel) = velocities.get_mut(entity) {
|
if let Some(vel) = velocities.get_mut(entity) {
|
||||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||||
|
@ -177,13 +177,15 @@ impl<'a> System<'a> for Sys {
|
|||||||
// Block
|
// Block
|
||||||
if controller.secondary
|
if controller.secondary
|
||||||
&& (character.movement == Stand || character.movement == Run)
|
&& (character.movement == Stand || character.movement == Run)
|
||||||
&& (character.action == Idle || character.action.is_wield())
|
&& character.action.is_wield()
|
||||||
{
|
{
|
||||||
character.action = Block {
|
character.action = Block {
|
||||||
time_left: Duration::from_secs(5),
|
time_left: Duration::from_secs(5),
|
||||||
};
|
};
|
||||||
} else if !controller.secondary && character.action.is_block() {
|
} else if !controller.secondary && character.action.is_block() {
|
||||||
character.action = Idle;
|
character.action = Wield {
|
||||||
|
time_left: Duration::default(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Item::Debug(item::Debug::Boost)) => {
|
Some(Item::Debug(item::Debug::Boost)) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
comp::{Body, Mass, Mounting, Ori, PhysicsState, Pos, Scale, Sticky, Vel},
|
comp::{Body, Mass, Mounting, Ori, PhysicsState, Pos, Scale, Sticky, Vel},
|
||||||
event::{EventBus, LocalEvent},
|
event::{EventBus, ServerEvent},
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
terrain::{Block, TerrainGrid},
|
terrain::{Block, TerrainGrid},
|
||||||
vol::ReadVol,
|
vol::ReadVol,
|
||||||
@ -45,7 +45,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
ReadStorage<'a, Uid>,
|
ReadStorage<'a, Uid>,
|
||||||
ReadExpect<'a, TerrainGrid>,
|
ReadExpect<'a, TerrainGrid>,
|
||||||
Read<'a, DeltaTime>,
|
Read<'a, DeltaTime>,
|
||||||
Read<'a, EventBus<LocalEvent>>,
|
Read<'a, EventBus<ServerEvent>>,
|
||||||
ReadStorage<'a, Scale>,
|
ReadStorage<'a, Scale>,
|
||||||
ReadStorage<'a, Sticky>,
|
ReadStorage<'a, Sticky>,
|
||||||
ReadStorage<'a, Mass>,
|
ReadStorage<'a, Mass>,
|
||||||
@ -245,7 +245,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
on_ground = true;
|
on_ground = true;
|
||||||
|
|
||||||
if !was_on_ground {
|
if !was_on_ground {
|
||||||
event_emitter.emit(LocalEvent::LandOnGround { entity, vel: vel.0 });
|
event_emitter.emit(ServerEvent::LandOnGround { entity, vel: vel.0 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
stat.exp.change_maximum_by(25);
|
stat.exp.change_maximum_by(25);
|
||||||
stat.level.change_by(1);
|
stat.level.change_by(1);
|
||||||
}
|
}
|
||||||
stat.update_hp_bonus(stat.level.level());
|
stat.update_max_hp();
|
||||||
stat.health
|
stat.health
|
||||||
.set_to(stat.health.maximum(), HealthSource::LevelUp)
|
.set_to(stat.health.maximum(), HealthSource::LevelUp)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ impl Server {
|
|||||||
let mut state = State::default();
|
let mut state = State::default();
|
||||||
state
|
state
|
||||||
.ecs_mut()
|
.ecs_mut()
|
||||||
.add_resource(SpawnPoint(Vec3::new(16_384.0, 16_384.0, 512.0)));
|
.add_resource(SpawnPoint(Vec3::new(16_384.0, 16_384.0, 190.0)));
|
||||||
state
|
state
|
||||||
.ecs_mut()
|
.ecs_mut()
|
||||||
.add_resource(EventBus::<ServerEvent>::default());
|
.add_resource(EventBus::<ServerEvent>::default());
|
||||||
@ -357,11 +357,9 @@ impl Server {
|
|||||||
ecs.entity_from_uid(by.into()).map(|attacker| {
|
ecs.entity_from_uid(by.into()).map(|attacker| {
|
||||||
if let Some(attacker_stats) = stats.get_mut(attacker) {
|
if let Some(attacker_stats) = stats.get_mut(attacker) {
|
||||||
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
||||||
attacker_stats.exp.change_by(
|
attacker_stats
|
||||||
(entity_stats.health.maximum() as f64 / 10.0
|
.exp
|
||||||
+ entity_stats.level.level() as f64 * 10.0)
|
.change_by((entity_stats.level.level() * 10) as i64);
|
||||||
as i64,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -401,6 +399,22 @@ impl Server {
|
|||||||
.insert(entity, comp::ForceUpdate);
|
.insert(entity, comp::ForceUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerEvent::LandOnGround { entity, vel } => {
|
||||||
|
if vel.z <= -25.0 {
|
||||||
|
if let Some(stats) = state
|
||||||
|
.ecs_mut()
|
||||||
|
.write_storage::<comp::Stats>()
|
||||||
|
.get_mut(entity)
|
||||||
|
{
|
||||||
|
let falldmg = (vel.z / 5.0) as i32;
|
||||||
|
if falldmg < 0 {
|
||||||
|
stats.health.change_by(falldmg, comp::HealthSource::World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServerEvent::Mount(mounter, mountee) => {
|
ServerEvent::Mount(mounter, mountee) => {
|
||||||
if state
|
if state
|
||||||
.ecs()
|
.ecs()
|
||||||
@ -565,10 +579,7 @@ impl Server {
|
|||||||
let mut scale = 1.0;
|
let mut scale = 1.0;
|
||||||
|
|
||||||
// TODO: Remove this and implement scaling or level depending on stuff like species instead
|
// TODO: Remove this and implement scaling or level depending on stuff like species instead
|
||||||
stats.level.set_level(rand::thread_rng().gen_range(1, 20));
|
stats.level.set_level(rand::thread_rng().gen_range(1, 3));
|
||||||
if stats.level.level() > 1 {
|
|
||||||
stats.update_hp_bonus(stats.level.level());
|
|
||||||
}
|
|
||||||
|
|
||||||
if npc.boss {
|
if npc.boss {
|
||||||
if rand::random::<f32>() < 0.8 {
|
if rand::random::<f32>() < 0.8 {
|
||||||
@ -581,10 +592,11 @@ impl Server {
|
|||||||
);
|
);
|
||||||
body = comp::Body::Humanoid(comp::humanoid::Body::random());
|
body = comp::Body::Humanoid(comp::humanoid::Body::random());
|
||||||
}
|
}
|
||||||
stats = stats.with_max_health(500 + rand::random::<u32>() % 400);
|
stats.level.set_level(rand::thread_rng().gen_range(10, 50));
|
||||||
scale = 2.5 + rand::random::<f32>();
|
scale = 2.5 + rand::random::<f32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats.update_max_hp();
|
||||||
self.create_npc(comp::Pos(npc.pos), stats, body)
|
self.create_npc(comp::Pos(npc.pos), stats, body)
|
||||||
.with(comp::Agent::enemy())
|
.with(comp::Agent::enemy())
|
||||||
.with(comp::Scale(scale))
|
.with(comp::Scale(scale))
|
||||||
|
Reference in New Issue
Block a user