mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Give xp depending on max hp and lvl of entity killed
This commit is contained in:
@ -878,34 +878,18 @@ impl Server {
|
||||
}
|
||||
|
||||
// Give EXP to the client
|
||||
if let Some(_enemy) = ecs.read_storage::<comp::Body>().get(entity) {
|
||||
if let comp::HealthSource::Attack { by } = dying.cause {
|
||||
ecs.entity_from_uid(by.into()).and_then(|attacker| {
|
||||
let mut stats = ecs.write_storage::<comp::Stats>();
|
||||
let attacker_stats = stats.get_mut(attacker).unwrap();
|
||||
if let comp::HealthSource::Attack { by } = dying.cause {
|
||||
ecs.entity_from_uid(by.into()).map(|attacker| {
|
||||
let mut stats = ecs.write_storage::<comp::Stats>();
|
||||
let entity_stats = stats.get(entity).unwrap().clone();
|
||||
let attacker_stats = stats.get_mut(attacker).unwrap();
|
||||
|
||||
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
||||
// TODO: Don't make this a single value and make it depend on
|
||||
// slayed entity's level
|
||||
attacker_stats.exp.change_current_by(1.0);
|
||||
|
||||
if attacker_stats.exp.get_current() >= attacker_stats.exp.get_maximum()
|
||||
{
|
||||
attacker_stats.exp.change_maximum_by(25.0);
|
||||
attacker_stats.exp.set_current(0.0);
|
||||
attacker_stats.level.change_by(1);
|
||||
attacker_stats
|
||||
.health
|
||||
.set_maximum(attacker_stats.health.maximum() + 10);
|
||||
attacker_stats.health.set_to(
|
||||
attacker_stats.health.maximum(),
|
||||
comp::HealthSource::LevelUp,
|
||||
)
|
||||
}
|
||||
|
||||
ecs.read_storage::<comp::Player>().get(attacker).cloned()
|
||||
});
|
||||
}
|
||||
// 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,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
entity
|
||||
|
Reference in New Issue
Block a user