mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Warn about complex buffs when using /buff
This commit is contained in:
parent
18742bc7fb
commit
5aa30b0175
@ -64,6 +64,7 @@ command-battlemode-available-modes = Available modes: pvp, pve
|
|||||||
command-battlemode-same = Attempted to set the same battlemode
|
command-battlemode-same = Attempted to set the same battlemode
|
||||||
command-battlemode-updated = New battlemode: { $battlemode }
|
command-battlemode-updated = New battlemode: { $battlemode }
|
||||||
command-buff-unknown = Unknown buff: { $buff }
|
command-buff-unknown = Unknown buff: { $buff }
|
||||||
|
command-buff-complex = /buff doesn't work with this buff, use /buff_complex
|
||||||
command-skillpreset-load-error = Error while loading presets
|
command-skillpreset-load-error = Error while loading presets
|
||||||
command-skillpreset-broken = Skill preset is broken
|
command-skillpreset-broken = Skill preset is broken
|
||||||
command-skillpreset-missing = Preset does not exist: { $preset }
|
command-skillpreset-missing = Preset does not exist: { $preset }
|
||||||
|
@ -245,6 +245,13 @@ impl BuffKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_simple(self) -> bool {
|
||||||
|
match self.differentiate() {
|
||||||
|
BuffDescriptor::SimplePositive | BuffDescriptor::SimpleNegative => true,
|
||||||
|
BuffDescriptor::Complex => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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) }
|
||||||
|
|
||||||
|
@ -4145,10 +4145,30 @@ fn handle_buff(
|
|||||||
let duration = duration.unwrap_or(1.0);
|
let duration = duration.unwrap_or(1.0);
|
||||||
let buffdata = BuffData::new(strength, Some(Secs(duration)));
|
let buffdata = BuffData::new(strength, Some(Secs(duration)));
|
||||||
if buff != "all" {
|
if buff != "all" {
|
||||||
cast_buff(&buff, buffdata, server, target)
|
let buffkind = parse_buffkind(&buff).ok_or_else(|| {
|
||||||
|
Content::localized_with_args("command-buff-unknown", [("buff", buff.clone())])
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if buffkind.is_simple() {
|
||||||
|
cast_buff(buffkind, buffdata, server, target)
|
||||||
} else {
|
} else {
|
||||||
for kind in BUFF_PACK.iter() {
|
return Err(Content::localized_with_args("command-buff-complex", [(
|
||||||
cast_buff(kind, buffdata, server, target)?;
|
"buff", buff,
|
||||||
|
)]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for kind_key in BUFF_PACK.iter() {
|
||||||
|
let buffkind = parse_buffkind(kind_key).ok_or_else(|| {
|
||||||
|
Content::localized_with_args("command-buff-unknown", [(
|
||||||
|
"buff",
|
||||||
|
kind_key.to_owned(),
|
||||||
|
)])
|
||||||
|
})?;
|
||||||
|
|
||||||
|
// Execute only simple buffs, ignore complex
|
||||||
|
if buffkind.is_simple() {
|
||||||
|
cast_buff(buffkind, buffdata, server, target)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -4157,8 +4177,12 @@ fn handle_buff(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cast_buff(kind: &str, data: BuffData, server: &mut Server, target: EcsEntity) -> CmdResult<()> {
|
fn cast_buff(
|
||||||
if let Some(buffkind) = parse_buffkind(kind) {
|
buffkind: BuffKind,
|
||||||
|
data: BuffData,
|
||||||
|
server: &mut Server,
|
||||||
|
target: EcsEntity,
|
||||||
|
) -> CmdResult<()> {
|
||||||
let ecs = &server.state.ecs();
|
let ecs = &server.state.ecs();
|
||||||
let mut buffs_all = ecs.write_storage::<comp::Buffs>();
|
let mut buffs_all = ecs.write_storage::<comp::Buffs>();
|
||||||
let stats = ecs.read_storage::<comp::Stats>();
|
let stats = ecs.read_storage::<comp::Stats>();
|
||||||
@ -4178,12 +4202,8 @@ fn cast_buff(kind: &str, data: BuffData, server: &mut Server, target: EcsEntity)
|
|||||||
*time,
|
*time,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
|
||||||
Err(Content::localized_with_args("command-buff-unknown", [(
|
|
||||||
"buff", kind,
|
|
||||||
)]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_buffkind(buff: &str) -> Option<BuffKind> { BUFF_PARSER.get(buff).copied() }
|
fn parse_buffkind(buff: &str) -> Option<BuffKind> { BUFF_PARSER.get(buff).copied() }
|
||||||
|
Loading…
Reference in New Issue
Block a user