mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Effect power now affects more than just poise
This commit is contained in:
parent
1a58b7a8d4
commit
610d47f787
@ -90,7 +90,7 @@ common-rand_name = Random name
|
||||
common-stats-combat_rating = CR
|
||||
common-stats-power = Power
|
||||
common-stats-speed = Speed
|
||||
common-stats-poise = Poise
|
||||
common-stats-effect-power = Effect Power
|
||||
common-stats-range = Range
|
||||
common-stats-energy_efficiency = Energy Efficiency
|
||||
common-stats-buff_strength = Buff/Debuff Strength
|
||||
|
@ -4,7 +4,11 @@ use crate::{
|
||||
comp::{
|
||||
ability::Capability,
|
||||
inventory::{
|
||||
item::{armor::Protection, tool::ToolKind, ItemDesc, ItemKind, MaterialStatManifest},
|
||||
item::{
|
||||
armor::Protection,
|
||||
tool::{self, ToolKind},
|
||||
ItemDesc, ItemKind, MaterialStatManifest,
|
||||
},
|
||||
slot::EquipSlot,
|
||||
},
|
||||
skillset::SkillGroupKind,
|
||||
@ -28,7 +32,7 @@ use crate::{comp::Group, resources::Time};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use specs::{saveload::MarkerAllocator, Entity as EcsEntity, ReadStorage};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use std::ops::MulAssign;
|
||||
use std::ops::{Mul, MulAssign};
|
||||
#[cfg(not(target_arch = "wasm32"))] use vek::*;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@ -832,6 +836,46 @@ pub enum CombatEffect {
|
||||
StunnedVulnerable(f32),
|
||||
}
|
||||
|
||||
impl CombatEffect {
|
||||
pub fn adjusted_by_stats(self, stats: tool::Stats) -> Self {
|
||||
match self {
|
||||
CombatEffect::Heal(h) => CombatEffect::Heal(h * stats.effect_power),
|
||||
CombatEffect::Buff(CombatBuff {
|
||||
kind,
|
||||
dur_secs,
|
||||
strength,
|
||||
chance,
|
||||
}) => CombatEffect::Buff(CombatBuff {
|
||||
kind,
|
||||
dur_secs,
|
||||
strength: strength * stats.buff_strength,
|
||||
chance,
|
||||
}),
|
||||
CombatEffect::Knockback(Knockback {
|
||||
direction,
|
||||
strength,
|
||||
}) => CombatEffect::Knockback(Knockback {
|
||||
direction,
|
||||
strength: strength * stats.buff_strength,
|
||||
}),
|
||||
CombatEffect::EnergyReward(e) => CombatEffect::EnergyReward(e),
|
||||
CombatEffect::Lifesteal(l) => CombatEffect::Lifesteal(l * stats.effect_power),
|
||||
CombatEffect::Poise(p) => CombatEffect::Poise(p * stats.effect_power),
|
||||
CombatEffect::Combo(c) => CombatEffect::Combo(c),
|
||||
CombatEffect::StageVulnerable(v, s) => {
|
||||
CombatEffect::StageVulnerable(v * stats.effect_power, s)
|
||||
},
|
||||
CombatEffect::RefreshBuff(c, b) => CombatEffect::RefreshBuff(c, b),
|
||||
CombatEffect::BuffsVulnerable(v, b) => {
|
||||
CombatEffect::BuffsVulnerable(v * stats.effect_power, b)
|
||||
},
|
||||
CombatEffect::StunnedVulnerable(v) => {
|
||||
CombatEffect::StunnedVulnerable(v * stats.effect_power)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum CombatRequirement {
|
||||
@ -1106,11 +1150,16 @@ impl CombatBuffStrength {
|
||||
}
|
||||
|
||||
impl MulAssign<f32> for CombatBuffStrength {
|
||||
fn mul_assign(&mut self, mul: f32) {
|
||||
fn mul_assign(&mut self, mul: f32) { *self = *self * mul; }
|
||||
}
|
||||
|
||||
impl Mul<f32> for CombatBuffStrength {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, mult: f32) -> Self {
|
||||
match self {
|
||||
Self::DamageFraction(ref mut val) | Self::Value(ref mut val) => {
|
||||
*val *= mul;
|
||||
},
|
||||
Self::DamageFraction(val) => Self::DamageFraction(val * mult),
|
||||
Self::Value(val) => Self::Value(val * mult),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1305,15 +1305,7 @@ impl CharacterAbility {
|
||||
*poise_damage *= stats.effect_power;
|
||||
*shockwave_duration *= stats.range;
|
||||
*energy_cost /= stats.energy_efficiency;
|
||||
if let Some(CombatEffect::Buff(combat::CombatBuff {
|
||||
kind: _,
|
||||
dur_secs: _,
|
||||
strength,
|
||||
chance: _,
|
||||
})) = damage_effect
|
||||
{
|
||||
*strength *= stats.buff_strength;
|
||||
}
|
||||
*damage_effect = damage_effect.map(|de| de.adjusted_by_stats(stats));
|
||||
},
|
||||
BasicBeam {
|
||||
ref mut buildup_duration,
|
||||
@ -1338,15 +1330,7 @@ impl CharacterAbility {
|
||||
// Duration modified to keep velocity constant
|
||||
*beam_duration *= stats.range;
|
||||
*energy_drain /= stats.energy_efficiency;
|
||||
if let Some(CombatEffect::Buff(combat::CombatBuff {
|
||||
kind: _,
|
||||
dur_secs: _,
|
||||
strength,
|
||||
chance: _,
|
||||
})) = damage_effect
|
||||
{
|
||||
*strength *= stats.buff_strength;
|
||||
}
|
||||
*damage_effect = damage_effect.map(|de| de.adjusted_by_stats(stats));
|
||||
},
|
||||
BasicAura {
|
||||
ref mut buildup_duration,
|
||||
|
@ -913,6 +913,11 @@ impl CharacterState {
|
||||
} else {
|
||||
AttackSource::AirShockwave
|
||||
}),
|
||||
CharacterState::LeapShockwave(data) => Some(if data.static_data.requires_ground {
|
||||
AttackSource::GroundShockwave
|
||||
} else {
|
||||
AttackSource::AirShockwave
|
||||
}),
|
||||
CharacterState::BasicBeam(_) => Some(AttackSource::Beam),
|
||||
CharacterState::BasicAura(_) => None,
|
||||
CharacterState::Blink(_) => None,
|
||||
@ -926,11 +931,6 @@ impl CharacterState {
|
||||
CharacterState::DiveMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::RiposteMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::RapidMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::LeapShockwave(data) => Some(if data.static_data.requires_ground {
|
||||
AttackSource::GroundShockwave
|
||||
} else {
|
||||
AttackSource::AirShockwave
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ pub struct MeleeConstructor {
|
||||
}
|
||||
|
||||
impl MeleeConstructor {
|
||||
pub fn create_melee(self, (crit_chance, crit_mult): (f32, f32), buff_strength: f32) -> Melee {
|
||||
pub fn create_melee(self, (crit_chance, crit_mult): (f32, f32), tool_stats: Stats) -> Melee {
|
||||
use MeleeConstructorKind::*;
|
||||
if self.scaled.is_some() {
|
||||
dev_panic!(
|
||||
@ -83,9 +83,10 @@ impl MeleeConstructor {
|
||||
let buff = CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Bleeding,
|
||||
dur_secs: 10.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.1),
|
||||
chance: 0.1,
|
||||
});
|
||||
})
|
||||
.adjusted_by_stats(tool_stats);
|
||||
let mut damage = AttackDamage::new(
|
||||
Damage {
|
||||
source: DamageSource::Melee,
|
||||
@ -109,7 +110,8 @@ impl MeleeConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
|
||||
@ -132,9 +134,10 @@ impl MeleeConstructor {
|
||||
let buff = CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Bleeding,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.05 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.05),
|
||||
chance: 0.1,
|
||||
});
|
||||
})
|
||||
.adjusted_by_stats(tool_stats);
|
||||
let mut damage = AttackDamage::new(
|
||||
Damage {
|
||||
source: DamageSource::Melee,
|
||||
@ -158,7 +161,8 @@ impl MeleeConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
|
||||
@ -200,7 +204,8 @@ impl MeleeConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
|
||||
@ -239,7 +244,8 @@ impl MeleeConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: pull,
|
||||
direction: KnockbackDir::Towards,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
|
||||
@ -276,7 +282,8 @@ impl MeleeConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
|
||||
@ -419,9 +426,7 @@ impl MeleeConstructor {
|
||||
if let Some(ref mut scaled) = &mut self.scaled {
|
||||
*scaled = scaled.adjusted_by_stats(stats);
|
||||
}
|
||||
if let Some(CombatEffect::Buff(CombatBuff { strength, .. })) = &mut self.damage_effect {
|
||||
*strength *= stats.buff_strength;
|
||||
}
|
||||
self.damage_effect = self.damage_effect.map(|de| de.adjusted_by_stats(stats));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ use crate::{
|
||||
Attack, AttackDamage, AttackEffect, CombatBuff, CombatBuffStrength, CombatEffect,
|
||||
CombatRequirement, Damage, DamageKind, DamageSource, GroupTarget, Knockback, KnockbackDir,
|
||||
},
|
||||
comp::{buff::BuffKind, item::Reagent},
|
||||
comp::{
|
||||
buff::BuffKind,
|
||||
item::{tool, Reagent},
|
||||
},
|
||||
uid::Uid,
|
||||
Explosion, RadiusEffect,
|
||||
};
|
||||
@ -119,7 +122,7 @@ impl ProjectileConstructor {
|
||||
owner: Option<Uid>,
|
||||
crit_chance: f32,
|
||||
crit_mult: f32,
|
||||
buff_strength: f32,
|
||||
tool_stats: tool::Stats,
|
||||
damage_effect: Option<CombatEffect>,
|
||||
) -> Projectile {
|
||||
let instance = rand::random();
|
||||
@ -135,7 +138,8 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen))
|
||||
@ -143,9 +147,10 @@ impl ProjectileConstructor {
|
||||
let buff = CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Bleeding,
|
||||
dur_secs: 10.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.1),
|
||||
chance: 0.1,
|
||||
});
|
||||
})
|
||||
.adjusted_by_stats(tool_stats);
|
||||
let mut damage = AttackDamage::new(
|
||||
Damage {
|
||||
source: DamageSource::Projectile,
|
||||
@ -187,9 +192,10 @@ impl ProjectileConstructor {
|
||||
let buff = CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Burning,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.1),
|
||||
chance: 0.1,
|
||||
});
|
||||
})
|
||||
.adjusted_by_stats(tool_stats);
|
||||
let damage = AttackDamage::new(
|
||||
Damage {
|
||||
source: DamageSource::Explosion,
|
||||
@ -268,9 +274,10 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Poisoned,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.8 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.8),
|
||||
chance: 1.0,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let damage = AttackDamage::new(
|
||||
@ -359,7 +366,8 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let damage = AttackDamage::new(
|
||||
@ -506,7 +514,8 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let buff = AttackEffect::new(
|
||||
@ -514,9 +523,10 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Burning,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.2 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.2),
|
||||
chance: 1.0,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let damage = AttackDamage::new(
|
||||
@ -563,7 +573,8 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Knockback(Knockback {
|
||||
strength: knockback,
|
||||
direction: KnockbackDir::Away,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let buff = AttackEffect::new(
|
||||
@ -571,9 +582,10 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Burning,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.2 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.2),
|
||||
chance: 1.0,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let damage = AttackDamage::new(
|
||||
@ -628,9 +640,10 @@ impl ProjectileConstructor {
|
||||
CombatEffect::Buff(CombatBuff {
|
||||
kind: BuffKind::Frozen,
|
||||
dur_secs: 5.0,
|
||||
strength: CombatBuffStrength::DamageFraction(0.05 * buff_strength),
|
||||
strength: CombatBuffStrength::DamageFraction(0.05),
|
||||
chance: 1.0,
|
||||
}),
|
||||
})
|
||||
.adjusted_by_stats(tool_stats),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let damage = AttackDamage::new(
|
||||
|
@ -75,13 +75,13 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength)
|
||||
.create_melee(crit_data, tool_stats)
|
||||
.with_block_breaking(
|
||||
data.inputs
|
||||
.break_block_pos
|
||||
|
@ -80,12 +80,12 @@ impl CharacterBehavior for Data {
|
||||
// Fire
|
||||
let (crit_chance, crit_mult) =
|
||||
get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
let projectile = self.static_data.projectile.create_projectile(
|
||||
Some(*data.uid),
|
||||
crit_chance,
|
||||
crit_mult,
|
||||
buff_strength,
|
||||
tool_stats,
|
||||
self.static_data.damage_effect,
|
||||
);
|
||||
// Shoots all projectiles simultaneously
|
||||
|
@ -71,9 +71,9 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
} else {
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
data.updater
|
||||
.insert(data.entity, strike.create_melee(crit_data, buff_strength));
|
||||
.insert(data.entity, strike.create_melee(crit_data, tool_stats));
|
||||
|
||||
if let CharacterState::ChargedMelee(c) = &mut update.character {
|
||||
c.stage_section = StageSection::Charge;
|
||||
@ -141,14 +141,14 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.handle_scaling(self.charge_amount)
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
|
||||
if let Some(FrontendSpecifier::GroundCleave) = self.static_data.specifier {
|
||||
|
@ -112,7 +112,7 @@ impl CharacterBehavior for Data {
|
||||
// Fire
|
||||
let (crit_chance, crit_mult) =
|
||||
get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
// Gets offsets
|
||||
let body_offsets = data.body.projectile_offsets(update.ori.look_vec());
|
||||
let pos = Pos(data.pos.0 + body_offsets);
|
||||
@ -120,7 +120,7 @@ impl CharacterBehavior for Data {
|
||||
Some(*data.uid),
|
||||
crit_chance,
|
||||
crit_mult,
|
||||
buff_strength,
|
||||
tool_stats,
|
||||
self.static_data.damage_effect,
|
||||
);
|
||||
output_events.emit_server(ServerEvent::Shoot {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||
combat::{Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement},
|
||||
comp::{
|
||||
character_state::OutputEvents,
|
||||
melee::MultiTarget,
|
||||
@ -72,16 +72,7 @@ impl Stage<f32> {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
||||
if let Some(CombatEffect::Buff(CombatBuff {
|
||||
kind: _,
|
||||
dur_secs: _,
|
||||
ref mut strength,
|
||||
chance: _,
|
||||
})) = self.damage_effect
|
||||
{
|
||||
*strength *= stats.buff_strength;
|
||||
}
|
||||
pub fn adjusted_by_stats(self, stats: Stats) -> Self {
|
||||
Self {
|
||||
stage: self.stage,
|
||||
base_damage: self.base_damage * stats.power,
|
||||
@ -97,7 +88,7 @@ impl Stage<f32> {
|
||||
base_recover_duration: self.base_recover_duration / stats.speed,
|
||||
forward_movement: self.forward_movement,
|
||||
damage_kind: self.damage_kind,
|
||||
damage_effect: self.damage_effect,
|
||||
damage_effect: self.damage_effect.map(|de| de.adjusted_by_stats(stats)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,13 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
strike_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
} else if self.timer < strike_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
character_state::OutputEvents, CharacterState, Melee, MeleeConstructor,
|
||||
character_state::OutputEvents, item::tool, CharacterState, Melee, MeleeConstructor,
|
||||
MeleeConstructorKind, StateUpdate,
|
||||
},
|
||||
states::{
|
||||
@ -62,11 +62,11 @@ impl CharacterBehavior for Data {
|
||||
|
||||
let create_melee = |charge_frac: f32| {
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.handle_scaling(charge_frac)
|
||||
.create_melee(crit_data, buff_strength)
|
||||
.create_melee(crit_data, tool_stats)
|
||||
};
|
||||
|
||||
match self.stage_section {
|
||||
@ -208,14 +208,14 @@ impl CharacterBehavior for Data {
|
||||
.min(1.0);
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.handle_scaling(charge_frac)
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
@ -277,5 +277,5 @@ fn create_test_melee(static_data: StaticData) -> Melee {
|
||||
multi_target: None,
|
||||
damage_effect: None,
|
||||
};
|
||||
melee.create_melee((0.0, 0.0), 0.0)
|
||||
melee.create_melee((0.0, 0.0), tool::Stats::one())
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ impl CharacterBehavior for Data {
|
||||
if !self.exhausted {
|
||||
// Attack
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
let scaling = self.max_vertical_speed / self.static_data.vertical_speed;
|
||||
let scaling = scaling.min(self.static_data.max_scaling);
|
||||
|
||||
@ -104,7 +104,7 @@ impl CharacterBehavior for Data {
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.handle_scaling(scaling)
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
|
||||
if let CharacterState::DiveMelee(c) = &mut update.character {
|
||||
|
@ -107,11 +107,11 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
melee_constructor.create_melee(crit_data, buff_strength),
|
||||
melee_constructor.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -120,13 +120,13 @@ impl CharacterBehavior for Data {
|
||||
StageSection::Recover => {
|
||||
if !self.exhausted {
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
|
||||
update.character = CharacterState::LeapMelee(Data {
|
||||
|
@ -85,13 +85,13 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -93,7 +93,7 @@ impl CharacterBehavior for Data {
|
||||
// Fire if input is pressed still
|
||||
let (crit_chance, crit_mult) =
|
||||
get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
// Gets offsets
|
||||
let body_offsets = data.body.projectile_offsets(update.ori.look_vec());
|
||||
let pos = Pos(data.pos.0 + body_offsets);
|
||||
@ -101,7 +101,7 @@ impl CharacterBehavior for Data {
|
||||
Some(*data.uid),
|
||||
crit_chance,
|
||||
crit_mult,
|
||||
buff_strength,
|
||||
tool_stats,
|
||||
self.static_data.damage_effect,
|
||||
);
|
||||
output_events.emit_server(ServerEvent::Shoot {
|
||||
|
@ -65,13 +65,13 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -93,13 +93,13 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
|
||||
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
|
||||
|
||||
data.updater.insert(
|
||||
data.entity,
|
||||
self.static_data
|
||||
.melee_constructor
|
||||
.create_melee(crit_data, buff_strength),
|
||||
.create_melee(crit_data, tool_stats),
|
||||
);
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
if matches!(
|
||||
|
@ -7,7 +7,11 @@ use crate::{
|
||||
character_state::OutputEvents,
|
||||
controller::InventoryManip,
|
||||
inventory::slot::{ArmorSlot, EquipSlot, Slot},
|
||||
item::{armor::Friction, tool::AbilityContext, Hands, ItemKind, ToolKind},
|
||||
item::{
|
||||
armor::Friction,
|
||||
tool::{self, AbilityContext},
|
||||
Hands, ItemKind, ToolKind,
|
||||
},
|
||||
quadruped_low, quadruped_medium, quadruped_small,
|
||||
skills::{Skill, SwimSkill, SKILL_MODIFIERS},
|
||||
theropod, Body, CharacterAbility, CharacterState, Density, InputAttr, InputKind,
|
||||
@ -1269,8 +1273,7 @@ pub fn get_crit_data(data: &JoinData<'_>, ai: AbilityInfo) -> (f32, f32) {
|
||||
(crit_chance, crit_mult)
|
||||
}
|
||||
|
||||
/// Returns buff strength from the weapon used in the ability
|
||||
pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 {
|
||||
pub fn get_tool_stats(data: &JoinData<'_>, ai: AbilityInfo) -> tool::Stats {
|
||||
ai.hand
|
||||
.map(|hand| match hand {
|
||||
HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand,
|
||||
@ -1279,12 +1282,12 @@ pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 {
|
||||
.and_then(|slot| data.inventory.and_then(|inv| inv.equipped(slot)))
|
||||
.and_then(|item| {
|
||||
if let ItemKind::Tool(tool) = &*item.kind() {
|
||||
Some(tool.base_buff_strength())
|
||||
Some(tool.stats)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or(1.0)
|
||||
.unwrap_or(tool::Stats::one())
|
||||
}
|
||||
|
||||
pub fn input_is_pressed(data: &JoinData<'_>, input: InputKind) -> bool {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use common::{
|
||||
comp::{object, Body, LightEmitter, PhysicsState, Pos, ProjectileConstructor},
|
||||
comp::{item::tool, object, Body, LightEmitter, PhysicsState, Pos, ProjectileConstructor},
|
||||
event::{Emitter, ServerEvent},
|
||||
terrain::{Block, TerrainChunkSize},
|
||||
util::Dir,
|
||||
@ -188,7 +188,13 @@ impl WiringAction {
|
||||
pos,
|
||||
dir: Dir::forward(),
|
||||
body: Body::Object(object::Body::Arrow),
|
||||
projectile: constr.create_projectile(None, 0.0, 1.0, 1.0, None),
|
||||
projectile: constr.create_projectile(
|
||||
None,
|
||||
0.0,
|
||||
1.0,
|
||||
tool::Stats::one(),
|
||||
None,
|
||||
),
|
||||
light: None,
|
||||
speed: 5.0,
|
||||
object: None,
|
||||
|
@ -620,12 +620,10 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
);
|
||||
|
||||
// Effect Power
|
||||
// TODO: Allow effect power to have different terminology based on what it is
|
||||
// affecting.
|
||||
stat_text(
|
||||
format!(
|
||||
"{} : {:+.0}%",
|
||||
i18n.get_msg("common-stats-poise"),
|
||||
i18n.get_msg("common-stats-effect-power"),
|
||||
(stats.effect_power - 1.0) * 100.0
|
||||
),
|
||||
2,
|
||||
@ -1053,13 +1051,13 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
let effect_power_text = if is_primary {
|
||||
format!(
|
||||
"{} : {:+.0}%",
|
||||
i18n.get_msg("common-stats-poise"),
|
||||
i18n.get_msg("common-stats-effect-power"),
|
||||
(stats.effect_power - 1.0) * 100.0
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"{} : x{:.2}",
|
||||
i18n.get_msg("common-stats-poise"),
|
||||
i18n.get_msg("common-stats-effect-power"),
|
||||
stats.effect_power
|
||||
)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user