mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'knightresspaladin/block-tweaks' into 'master'
Make parrying refund the block stamina cost and cancel the recover animation See merge request veloren/veloren!2792
This commit is contained in:
commit
ba2b26dfa3
@ -131,6 +131,7 @@ impl Attack {
|
|||||||
source: AttackSource,
|
source: AttackSource,
|
||||||
dir: Dir,
|
dir: Dir,
|
||||||
kind: DamageKind,
|
kind: DamageKind,
|
||||||
|
mut emit: impl FnMut(ServerEvent),
|
||||||
mut emit_outcome: impl FnMut(Outcome),
|
mut emit_outcome: impl FnMut(Outcome),
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
let damage_reduction =
|
let damage_reduction =
|
||||||
@ -148,6 +149,10 @@ impl Attack {
|
|||||||
pos: target.pos,
|
pos: target.pos,
|
||||||
uid: target.uid,
|
uid: target.uid,
|
||||||
});
|
});
|
||||||
|
emit(ServerEvent::Parry {
|
||||||
|
entity: target.entity,
|
||||||
|
energy_cost: data.static_data.energy_cost,
|
||||||
|
});
|
||||||
if parry {
|
if parry {
|
||||||
1.0
|
1.0
|
||||||
} else {
|
} else {
|
||||||
@ -213,6 +218,7 @@ impl Attack {
|
|||||||
attack_source,
|
attack_source,
|
||||||
dir,
|
dir,
|
||||||
damage.damage.kind,
|
damage.damage.kind,
|
||||||
|
|e| emit(e),
|
||||||
|o| emit_outcome(o),
|
|o| emit_outcome(o),
|
||||||
);
|
);
|
||||||
let change = damage.damage.calculate_health_change(
|
let change = damage.damage.calculate_health_change(
|
||||||
|
@ -1572,13 +1572,14 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
|
|||||||
recover_duration,
|
recover_duration,
|
||||||
max_angle,
|
max_angle,
|
||||||
block_strength,
|
block_strength,
|
||||||
energy_cost: _,
|
energy_cost,
|
||||||
} => CharacterState::BasicBlock(basic_block::Data {
|
} => CharacterState::BasicBlock(basic_block::Data {
|
||||||
static_data: basic_block::StaticData {
|
static_data: basic_block::StaticData {
|
||||||
buildup_duration: Duration::from_secs_f32(*buildup_duration),
|
buildup_duration: Duration::from_secs_f32(*buildup_duration),
|
||||||
recover_duration: Duration::from_secs_f32(*recover_duration),
|
recover_duration: Duration::from_secs_f32(*recover_duration),
|
||||||
max_angle: *max_angle,
|
max_angle: *max_angle,
|
||||||
block_strength: *block_strength,
|
block_strength: *block_strength,
|
||||||
|
energy_cost: *energy_cost as i32,
|
||||||
ability_info,
|
ability_info,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
|
@ -167,6 +167,10 @@ pub enum ServerEvent {
|
|||||||
entity: EcsEntity,
|
entity: EcsEntity,
|
||||||
change: i32,
|
change: i32,
|
||||||
},
|
},
|
||||||
|
Parry {
|
||||||
|
entity: EcsEntity,
|
||||||
|
energy_cost: i32,
|
||||||
|
},
|
||||||
RequestSiteInfo {
|
RequestSiteInfo {
|
||||||
entity: EcsEntity,
|
entity: EcsEntity,
|
||||||
id: SiteId,
|
id: SiteId,
|
||||||
|
@ -19,6 +19,8 @@ pub struct StaticData {
|
|||||||
pub block_strength: f32,
|
pub block_strength: f32,
|
||||||
/// What key is used to press ability
|
/// What key is used to press ability
|
||||||
pub ability_info: AbilityInfo,
|
pub ability_info: AbilityInfo,
|
||||||
|
/// Energy consumed to initiate the block
|
||||||
|
pub energy_cost: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -17,9 +17,9 @@ use common::{
|
|||||||
self, aura, buff,
|
self, aura, buff,
|
||||||
chat::{KillSource, KillType},
|
chat::{KillSource, KillType},
|
||||||
inventory::item::MaterialStatManifest,
|
inventory::item::MaterialStatManifest,
|
||||||
object, Alignment, Auras, Body, CharacterState, Energy, EnergyChange, Group, Health,
|
object, Alignment, Auras, Body, CharacterState, Energy, EnergyChange, EnergySource, Group,
|
||||||
HealthChange, HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos,
|
Health, HealthChange, HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource,
|
||||||
SkillSet, Stats,
|
Pos, SkillSet, Stats,
|
||||||
},
|
},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
lottery::{LootSpec, Lottery},
|
lottery::{LootSpec, Lottery},
|
||||||
@ -1206,6 +1206,19 @@ pub fn handle_combo_change(server: &Server, entity: EcsEntity, change: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_parry(server: &Server, entity: EcsEntity, energy_cost: i32) {
|
||||||
|
let ecs = &server.state.ecs();
|
||||||
|
if let Some(mut character) = ecs.write_storage::<comp::CharacterState>().get_mut(entity) {
|
||||||
|
*character = CharacterState::Wielding;
|
||||||
|
};
|
||||||
|
if let Some(mut energy) = ecs.write_storage::<Energy>().get_mut(entity) {
|
||||||
|
energy.change_by(EnergyChange {
|
||||||
|
amount: energy_cost,
|
||||||
|
source: EnergySource::Ability,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_teleport_to(server: &Server, entity: EcsEntity, target: Uid, max_range: Option<f32>) {
|
pub fn handle_teleport_to(server: &Server, entity: EcsEntity, target: Uid, max_range: Option<f32>) {
|
||||||
let ecs = &server.state.ecs();
|
let ecs = &server.state.ecs();
|
||||||
let mut positions = ecs.write_storage::<Pos>();
|
let mut positions = ecs.write_storage::<Pos>();
|
||||||
|
@ -8,7 +8,8 @@ use entity_creation::{
|
|||||||
use entity_manipulation::{
|
use entity_manipulation::{
|
||||||
handle_aura, handle_bonk, handle_buff, handle_combo_change, handle_damage, handle_delete,
|
handle_aura, handle_bonk, handle_buff, handle_combo_change, handle_damage, handle_delete,
|
||||||
handle_destroy, handle_energy_change, handle_entity_attacked_hook, handle_explosion,
|
handle_destroy, handle_energy_change, handle_entity_attacked_hook, handle_explosion,
|
||||||
handle_knockback, handle_land_on_ground, handle_poise, handle_respawn, handle_teleport_to,
|
handle_knockback, handle_land_on_ground, handle_parry, handle_poise, handle_respawn,
|
||||||
|
handle_teleport_to,
|
||||||
};
|
};
|
||||||
use group_manip::handle_group;
|
use group_manip::handle_group;
|
||||||
use information::handle_site_info;
|
use information::handle_site_info;
|
||||||
@ -209,6 +210,10 @@ impl Server {
|
|||||||
ServerEvent::ComboChange { entity, change } => {
|
ServerEvent::ComboChange { entity, change } => {
|
||||||
handle_combo_change(self, entity, change)
|
handle_combo_change(self, entity, change)
|
||||||
},
|
},
|
||||||
|
ServerEvent::Parry {
|
||||||
|
entity,
|
||||||
|
energy_cost,
|
||||||
|
} => handle_parry(self, entity, energy_cost),
|
||||||
ServerEvent::RequestSiteInfo { entity, id } => handle_site_info(self, entity, id),
|
ServerEvent::RequestSiteInfo { entity, id } => handle_site_info(self, entity, id),
|
||||||
ServerEvent::MineBlock { entity, pos, tool } => {
|
ServerEvent::MineBlock { entity, pos, tool } => {
|
||||||
handle_mine_block(self, entity, pos, tool)
|
handle_mine_block(self, entity, pos, tool)
|
||||||
|
Loading…
Reference in New Issue
Block a user