mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
exit basic_attack when no weapon is equipped
This commit is contained in:
parent
8efcda724e
commit
d902828e00
@ -21,26 +21,18 @@ pub fn behavior(data: &JoinData) -> StateUpdate {
|
|||||||
remaining_duration,
|
remaining_duration,
|
||||||
} = data.character
|
} = data.character
|
||||||
{
|
{
|
||||||
handle_move(data, &mut update);
|
|
||||||
|
|
||||||
let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind);
|
let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind);
|
||||||
let can_apply_damage = !*exhausted
|
if let Some(Tool(tool)) = tool_kind {
|
||||||
&& if let Some(Tool(tool)) = tool_kind {
|
handle_move(data, &mut update);
|
||||||
*remaining_duration < tool.attack_recover_duration()
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut new_exhausted = *exhausted;
|
let mut new_exhausted = *exhausted;
|
||||||
|
|
||||||
if can_apply_damage {
|
if !*exhausted && *remaining_duration < tool.attack_recover_duration() {
|
||||||
if let Some(Tool(tool)) = tool_kind {
|
|
||||||
data.updater.insert(data.entity, Attacking {
|
data.updater.insert(data.entity, Attacking {
|
||||||
weapon: Some(tool),
|
weapon: Some(tool),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
new_exhausted = true;
|
new_exhausted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,11 +55,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate {
|
|||||||
|
|
||||||
// Check if attack duration has expired
|
// Check if attack duration has expired
|
||||||
if new_remaining_duration == Duration::default() {
|
if new_remaining_duration == Duration::default() {
|
||||||
update.character = if let Some(Tool(tool)) = tool_kind {
|
update.character = CharacterState::Wielding { tool };
|
||||||
CharacterState::Wielding { tool }
|
|
||||||
} else {
|
|
||||||
CharacterState::Idle {}
|
|
||||||
};
|
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,4 +63,8 @@ pub fn behavior(data: &JoinData) -> StateUpdate {
|
|||||||
} else {
|
} else {
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
update.character = CharacterState::Idle {};
|
||||||
|
update
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user