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:
commit
0e7a922d78
@ -168,19 +168,18 @@ impl Stats {
|
||||
}
|
||||
|
||||
// TODO: Delete this once stat points will be a thing
|
||||
pub fn update_hp_bonus(&mut self, level: u32) {
|
||||
self.health
|
||||
.set_maximum(self.health.maximum() + (10 * level) / 2);
|
||||
pub fn update_max_hp(&mut self) {
|
||||
self.health.set_maximum(42 * self.level.amount);
|
||||
}
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
pub fn new(name: String, main: Option<comp::Item>) -> Self {
|
||||
Self {
|
||||
let mut stats = Self {
|
||||
name,
|
||||
health: Health {
|
||||
current: 100,
|
||||
maximum: 100,
|
||||
current: 0,
|
||||
maximum: 0,
|
||||
last_change: None,
|
||||
},
|
||||
level: Level { amount: 1 },
|
||||
@ -198,7 +197,14 @@ impl Stats {
|
||||
alt: None,
|
||||
},
|
||||
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 {
|
||||
|
@ -15,10 +15,6 @@ pub enum LocalEvent {
|
||||
entity: EcsEntity,
|
||||
vel: Vec3<f32>,
|
||||
},
|
||||
LandOnGround {
|
||||
entity: EcsEntity,
|
||||
vel: Vec3<f32>,
|
||||
},
|
||||
}
|
||||
|
||||
pub enum ServerEvent {
|
||||
@ -41,6 +37,10 @@ pub enum ServerEvent {
|
||||
dir: Vec3<f32>,
|
||||
projectile: comp::Projectile,
|
||||
},
|
||||
LandOnGround {
|
||||
entity: EcsEntity,
|
||||
vel: Vec3<f32>,
|
||||
},
|
||||
Mount(EcsEntity, EcsEntity),
|
||||
Unmount(EcsEntity),
|
||||
}
|
||||
|
@ -406,14 +406,6 @@ impl State {
|
||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||
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) => {
|
||||
if let Some(vel) = velocities.get_mut(entity) {
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
|
@ -177,13 +177,15 @@ impl<'a> System<'a> for Sys {
|
||||
// Block
|
||||
if controller.secondary
|
||||
&& (character.movement == Stand || character.movement == Run)
|
||||
&& (character.action == Idle || character.action.is_wield())
|
||||
&& character.action.is_wield()
|
||||
{
|
||||
character.action = Block {
|
||||
time_left: Duration::from_secs(5),
|
||||
};
|
||||
} else if !controller.secondary && character.action.is_block() {
|
||||
character.action = Idle;
|
||||
character.action = Wield {
|
||||
time_left: Duration::default(),
|
||||
};
|
||||
}
|
||||
}
|
||||
Some(Item::Debug(item::Debug::Boost)) => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use {
|
||||
crate::{
|
||||
comp::{Body, Mass, Mounting, Ori, PhysicsState, Pos, Scale, Sticky, Vel},
|
||||
event::{EventBus, LocalEvent},
|
||||
event::{EventBus, ServerEvent},
|
||||
state::DeltaTime,
|
||||
terrain::{Block, TerrainGrid},
|
||||
vol::ReadVol,
|
||||
@ -45,7 +45,7 @@ impl<'a> System<'a> for Sys {
|
||||
ReadStorage<'a, Uid>,
|
||||
ReadExpect<'a, TerrainGrid>,
|
||||
Read<'a, DeltaTime>,
|
||||
Read<'a, EventBus<LocalEvent>>,
|
||||
Read<'a, EventBus<ServerEvent>>,
|
||||
ReadStorage<'a, Scale>,
|
||||
ReadStorage<'a, Sticky>,
|
||||
ReadStorage<'a, Mass>,
|
||||
@ -245,7 +245,7 @@ impl<'a> System<'a> for Sys {
|
||||
on_ground = true;
|
||||
|
||||
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.level.change_by(1);
|
||||
}
|
||||
stat.update_hp_bonus(stat.level.level());
|
||||
stat.update_max_hp();
|
||||
stat.health
|
||||
.set_to(stat.health.maximum(), HealthSource::LevelUp)
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ impl Server {
|
||||
let mut state = State::default();
|
||||
state
|
||||
.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
|
||||
.ecs_mut()
|
||||
.add_resource(EventBus::<ServerEvent>::default());
|
||||
@ -357,11 +357,9 @@ impl Server {
|
||||
ecs.entity_from_uid(by.into()).map(|attacker| {
|
||||
if let Some(attacker_stats) = stats.get_mut(attacker) {
|
||||
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
||||
attacker_stats.exp.change_by(
|
||||
(entity_stats.health.maximum() as f64 / 10.0
|
||||
+ entity_stats.level.level() as f64 * 10.0)
|
||||
as i64,
|
||||
);
|
||||
attacker_stats
|
||||
.exp
|
||||
.change_by((entity_stats.level.level() * 10) as i64);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -401,6 +399,22 @@ impl Server {
|
||||
.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) => {
|
||||
if state
|
||||
.ecs()
|
||||
@ -565,10 +579,7 @@ impl Server {
|
||||
let mut scale = 1.0;
|
||||
|
||||
// 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));
|
||||
if stats.level.level() > 1 {
|
||||
stats.update_hp_bonus(stats.level.level());
|
||||
}
|
||||
stats.level.set_level(rand::thread_rng().gen_range(1, 3));
|
||||
|
||||
if npc.boss {
|
||||
if rand::random::<f32>() < 0.8 {
|
||||
@ -581,10 +592,11 @@ impl Server {
|
||||
);
|
||||
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>();
|
||||
}
|
||||
|
||||
stats.update_max_hp();
|
||||
self.create_npc(comp::Pos(npc.pos), stats, body)
|
||||
.with(comp::Agent::enemy())
|
||||
.with(comp::Scale(scale))
|
||||
|
Loading…
Reference in New Issue
Block a user