mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Various tweaks:
* Store result of large condition expression in a variable before using in if statement (improves readability of code). * Buff doc comment improvements. Adding periods is neccessary since these will be merged into one line in the generated docs. * Add note on AbilityContext that AbilityContext::None is intended to be used rather than AbilityContext::Stance(Stance::None) perhaps in the future we can add some serde shenanigans to make this work better, but it is probably best to wait to see how this type evolves first.
This commit is contained in:
parent
2cc2aa86f4
commit
3ef4af0195
@ -517,7 +517,7 @@ impl Attack {
|
|||||||
.filter(|e| e.target.map_or(true, |t| t == target_group))
|
.filter(|e| e.target.map_or(true, |t| t == target_group))
|
||||||
.filter(|e| !avoid_effect(e))
|
.filter(|e| !avoid_effect(e))
|
||||||
{
|
{
|
||||||
if effect.requirements.iter().all(|req| match req {
|
let requirements_met = effect.requirements.iter().all(|req| match req {
|
||||||
CombatRequirement::AnyDamage => accumulated_damage > 0.0 && target.health.is_some(),
|
CombatRequirement::AnyDamage => accumulated_damage > 0.0 && target.health.is_some(),
|
||||||
CombatRequirement::Energy(r) => {
|
CombatRequirement::Energy(r) => {
|
||||||
if let Some(AttackerInfo {
|
if let Some(AttackerInfo {
|
||||||
@ -559,7 +559,8 @@ impl Attack {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}) {
|
});
|
||||||
|
if requirements_met {
|
||||||
is_applied = true;
|
is_applied = true;
|
||||||
match effect.effect {
|
match effect.effect {
|
||||||
CombatEffect::Knockback(kb) => {
|
CombatEffect::Knockback(kb) => {
|
||||||
|
@ -22,67 +22,67 @@ use super::Body;
|
|||||||
)]
|
)]
|
||||||
pub enum BuffKind {
|
pub enum BuffKind {
|
||||||
// Buffs
|
// Buffs
|
||||||
/// Restores health/time for some period
|
/// Restores health/time for some period.
|
||||||
/// Strength should be the healing per second
|
/// Strength should be the healing per second.
|
||||||
Regeneration,
|
Regeneration,
|
||||||
/// Restores health/time for some period for consumables
|
/// Restores health/time for some period for consumables.
|
||||||
/// Strength should be the healing per second
|
/// Strength should be the healing per second.
|
||||||
Saturation,
|
Saturation,
|
||||||
/// Applied when drinking a potion
|
/// Applied when drinking a potion.
|
||||||
/// Strength should be the healing per second
|
/// Strength should be the healing per second.
|
||||||
Potion,
|
Potion,
|
||||||
/// Applied when sitting at a campfire
|
/// Applied when sitting at a campfire.
|
||||||
/// Strength is fraction of health restored per second
|
/// Strength is fraction of health restored per second.
|
||||||
CampfireHeal,
|
CampfireHeal,
|
||||||
/// Restores energy/time for some period
|
/// Restores energy/time for some period.
|
||||||
/// Strength should be the healing per second
|
/// Strength should be the healing per second.
|
||||||
EnergyRegen,
|
EnergyRegen,
|
||||||
/// Raises maximum energy
|
/// Raises maximum energy.
|
||||||
/// Strength should be 10x the effect to max energy
|
/// Strength should be 10x the effect to max energy.
|
||||||
IncreaseMaxEnergy,
|
IncreaseMaxEnergy,
|
||||||
/// Raises maximum health
|
/// Raises maximum health.
|
||||||
/// Strength should be the effect to max health
|
/// Strength should be the effect to max health.
|
||||||
IncreaseMaxHealth,
|
IncreaseMaxHealth,
|
||||||
/// Makes you immune to attacks
|
/// Makes you immune to attacks.
|
||||||
/// Strength does not affect this buff
|
/// Strength does not affect this buff.
|
||||||
Invulnerability,
|
Invulnerability,
|
||||||
/// Reduces incoming damage
|
/// Reduces incoming damage.
|
||||||
/// Strength scales the damage reduction non-linearly. 0.5 provides 50% DR,
|
/// Strength scales the damage reduction non-linearly. 0.5 provides 50% DR,
|
||||||
/// 1.0 provides 67% DR
|
/// 1.0 provides 67% DR.
|
||||||
ProtectingWard,
|
ProtectingWard,
|
||||||
/// Increases movement speed and gives health regeneration
|
/// Increases movement speed and gives health regeneration.
|
||||||
/// Strength scales the movement speed linearly. 0.5 is 150% speed, 1.0 is
|
/// Strength scales the movement speed linearly. 0.5 is 150% speed, 1.0 is
|
||||||
/// 200% speed. Provides regeneration at 10x the value of the strength
|
/// 200% speed. Provides regeneration at 10x the value of the strength.
|
||||||
Frenzied,
|
Frenzied,
|
||||||
/// Increases movement and attack speed, but removes chance to get critical
|
/// Increases movement and attack speed, but removes chance to get critical
|
||||||
/// hits. Strength scales strength of both effects linearly. 0.5 is a
|
/// hits. Strength scales strength of both effects linearly. 0.5 is a
|
||||||
/// 50% increase, 1.0 is a 100% increase.
|
/// 50% increase, 1.0 is a 100% increase.
|
||||||
Hastened,
|
Hastened,
|
||||||
/// Increases resistance to incoming poise, and poise damage dealt as health
|
/// Increases resistance to incoming poise, and poise damage dealt as health
|
||||||
/// is lost from the time the buff activated
|
/// is lost from the time the buff activated.
|
||||||
/// Strength scales the resistance non-linearly. 0.5 provides 50%, 1.0
|
/// Strength scales the resistance non-linearly. 0.5 provides 50%, 1.0
|
||||||
/// provides 67%
|
/// provides 67%.
|
||||||
/// Strength scales the poise damage increase linearly, a strength of 1.0
|
/// Strength scales the poise damage increase linearly, a strength of 1.0
|
||||||
/// and n health less from activation will cause poise damage to increase by
|
/// and n health less from activation will cause poise damage to increase by
|
||||||
/// n%
|
/// n%.
|
||||||
Fortitude,
|
Fortitude,
|
||||||
/// Increases both attack damage and vulnerability to damage
|
/// Increases both attack damage and vulnerability to damage.
|
||||||
/// Damage increases linearly with strength, 1.0 is a 100% increase
|
/// Damage increases linearly with strength, 1.0 is a 100% increase.
|
||||||
/// Damage reduction decreases linearly with strength, 1.0 is a 100%
|
/// Damage reduction decreases linearly with strength, 1.0 is a 100%
|
||||||
/// decrease
|
/// decrease.
|
||||||
Reckless,
|
Reckless,
|
||||||
// Debuffs
|
// Debuffs
|
||||||
/// Does damage to a creature over time
|
/// Does damage to a creature over time.
|
||||||
/// Strength should be the DPS of the debuff
|
/// Strength should be the DPS of the debuff.
|
||||||
Burning,
|
Burning,
|
||||||
/// Lowers health over time for some duration
|
/// Lowers health over time for some duration.
|
||||||
/// Strength should be the DPS of the debuff
|
/// Strength should be the DPS of the debuff.
|
||||||
Bleeding,
|
Bleeding,
|
||||||
/// Lower a creature's max health over time
|
/// Lower a creature's max health over time.
|
||||||
/// Strength only affects the target max health, 0.5 targets 50% of base
|
/// Strength only affects the target max health, 0.5 targets 50% of base
|
||||||
/// max, 1.0 targets 100% of base max
|
/// max, 1.0 targets 100% of base max.
|
||||||
Cursed,
|
Cursed,
|
||||||
/// Reduces movement speed and causes bleeding damage
|
/// Reduces movement speed and causes bleeding damage.
|
||||||
/// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
|
/// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
|
||||||
/// speed, 1.0 is 33% speed. Bleeding is at 4x the value of the strength.
|
/// speed, 1.0 is 33% speed. Bleeding is at 4x the value of the strength.
|
||||||
Crippled,
|
Crippled,
|
||||||
@ -99,8 +99,8 @@ pub enum BuffKind {
|
|||||||
/// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
|
/// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
|
||||||
/// speed, 1.0 is 33% speed.
|
/// speed, 1.0 is 33% speed.
|
||||||
Ensnared,
|
Ensnared,
|
||||||
/// Drain stamina to a creature over time
|
/// Drain stamina to a creature over time.
|
||||||
/// Strength should be the energy per second of the debuff
|
/// Strength should be the energy per second of the debuff.
|
||||||
Poisoned,
|
Poisoned,
|
||||||
/// Results from having an attack parried.
|
/// Results from having an attack parried.
|
||||||
/// Causes your attack speed to be slower to emulate the recover duration of
|
/// Causes your attack speed to be slower to emulate the recover duration of
|
||||||
@ -115,7 +115,7 @@ pub enum BuffKind {
|
|||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
impl BuffKind {
|
impl BuffKind {
|
||||||
/// Checks if buff is buff or debuff
|
/// Checks if buff is buff or debuff.
|
||||||
pub fn is_buff(self) -> bool {
|
pub fn is_buff(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
BuffKind::Regeneration
|
BuffKind::Regeneration
|
||||||
@ -145,7 +145,7 @@ impl BuffKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if buff should queue
|
/// Checks if buff should queue.
|
||||||
pub fn queues(self) -> bool { matches!(self, BuffKind::Saturation) }
|
pub fn queues(self) -> bool { matches!(self, BuffKind::Saturation) }
|
||||||
|
|
||||||
/// Checks if the buff can affect other buff effects applied in the same
|
/// Checks if the buff can affect other buff effects applied in the same
|
||||||
@ -417,7 +417,7 @@ pub enum BuffChange {
|
|||||||
any_required: Vec<BuffCategory>,
|
any_required: Vec<BuffCategory>,
|
||||||
none_required: Vec<BuffCategory>,
|
none_required: Vec<BuffCategory>,
|
||||||
},
|
},
|
||||||
// Refreshes durations of all buffs with this kind
|
/// Refreshes durations of all buffs with this kind.
|
||||||
Refresh(BuffKind),
|
Refresh(BuffKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +360,10 @@ impl<T> AbilityKind<T> {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Copy, Eq, PartialEq, Hash)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Copy, Eq, PartialEq, Hash)]
|
||||||
pub enum AbilityContext {
|
pub enum AbilityContext {
|
||||||
|
/// Note, in this context `Stance::None` isn't intended to be used. e.g.
|
||||||
|
/// `AbilityContext::None` should always be used instead of
|
||||||
|
/// `AbilityContext::Stance(Stance::None)` in the ability map config
|
||||||
|
/// files(s).
|
||||||
Stance(Stance),
|
Stance(Stance),
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user