From 022c1417b6f8718200a52830a94f89163f4c5232 Mon Sep 17 00:00:00 2001 From: Ben Wallis Date: Sat, 13 Nov 2021 20:46:45 +0000 Subject: [PATCH] EXP on kill is now shared between damage contributors. A "damage contributor" is either an individual entity, or a group - depending if the attacker is in a group. This means that not only does the "killing blow" no longer get 100% of EXP, but multiple groups and individuals all receive their fair share of EXP on death (assuming they are still within range of the entity when it dies). Damage from a given individual or group only counts towards a kill for 10 minutes since that individual or group's last damage to the entity - after this period their damage contribution is removed. This avoids the list of damage contributors growing excessively large for an entity that does a lot of combat but never dies. EXP sharing within groups is unchanged - the difference is simply that the input to this calculation may be less than 100% of the base EXP reward for the kill if other individuals or groups contributed damage. --- CHANGELOG.md | 1 + common/frontend/src/lib.rs | 5 + common/net/src/msg/ecs_packet.rs | 17 +- common/src/combat.rs | 69 +++++-- common/src/comp/group.rs | 2 +- common/src/comp/health.rs | 197 +++++++++++++++++-- common/src/lib.rs | 1 + common/src/resources.rs | 2 +- common/state/src/plugin/module.rs | 16 +- common/systems/src/beam.rs | 2 + common/systems/src/buff.rs | 32 ++- common/systems/src/melee.rs | 2 + common/systems/src/projectile.rs | 2 + common/systems/src/shockwave.rs | 2 + common/systems/src/stats.rs | 9 +- plugin/api/src/lib.rs | 8 +- server/src/cmd.rs | 2 + server/src/events/entity_manipulation.rs | 238 +++++++++++++++-------- server/src/state_ext.rs | 16 +- server/src/sys/agent.rs | 26 ++- voxygen/src/audio/music.rs | 7 +- voxygen/src/ecs/sys/floater.rs | 6 +- voxygen/src/scene/figure/mod.rs | 6 +- 23 files changed, 512 insertions(+), 156 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35ec7fd29b..20735e8a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Tweaked critical chance of legendary weapons - Agents using fireball projectiles aim at the feet instead of the eyes - Explosions can now have a nonzero minimum falloff +- EXP on kill is now shared based on damage contribution ### Removed diff --git a/common/frontend/src/lib.rs b/common/frontend/src/lib.rs index 1f5b389f48..7ebfa4585d 100644 --- a/common/frontend/src/lib.rs +++ b/common/frontend/src/lib.rs @@ -53,6 +53,11 @@ where .add_directive("veloren_common::trade=info".parse().unwrap()) .add_directive("veloren_world::sim=info".parse().unwrap()) .add_directive("veloren_world::civ=info".parse().unwrap()) + .add_directive( + "veloren_server::events::entity_manipulation=info" + .parse() + .unwrap(), + ) .add_directive("hyper=info".parse().unwrap()) .add_directive("prometheus_hyper=info".parse().unwrap()) .add_directive("mio::pool=info".parse().unwrap()) diff --git a/common/net/src/msg/ecs_packet.rs b/common/net/src/msg/ecs_packet.rs index cac265fce0..09dcf509c2 100644 --- a/common/net/src/msg/ecs_packet.rs +++ b/common/net/src/msg/ecs_packet.rs @@ -1,6 +1,7 @@ use crate::sync; -use common::comp; +use common::{comp, resources::Time}; use serde::{Deserialize, Serialize}; +use specs::WorldExt; use std::marker::PhantomData; use sum_type::sum_type; @@ -92,7 +93,12 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Auras(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Energy(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Combo(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::Health(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Health(mut comp) => { + // Time isn't synced between client and server so replace the Time from the + // server with the Client's local Time to enable accurate comparison. + comp.last_change.time = *world.read_resource::