mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix animals not attacking
This commit is contained in:
10
assets/common/items/weapons/empty.ron
Normal file
10
assets/common/items/weapons/empty.ron
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Item(
|
||||||
|
name: "Empty",
|
||||||
|
description: "",
|
||||||
|
kind: Tool (
|
||||||
|
(
|
||||||
|
kind: Empty,
|
||||||
|
equip_time_millis: 200,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
@ -283,7 +283,14 @@ impl Tool {
|
|||||||
projectile_gravity: None,
|
projectile_gravity: None,
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
Empty => vec![],
|
Empty => vec![BasicMelee {
|
||||||
|
energy_cost: 0,
|
||||||
|
buildup_duration: Duration::from_millis(0),
|
||||||
|
recover_duration: Duration::from_millis(1000),
|
||||||
|
base_healthchange: -2,
|
||||||
|
range: 3.5,
|
||||||
|
max_angle: 45.0,
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,10 +256,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
let dist_sqrd = pos.0.distance_squared(tgt_pos.0);
|
let dist_sqrd = pos.0.distance_squared(tgt_pos.0);
|
||||||
if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) {
|
if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) {
|
||||||
// Close-range attack
|
// Close-range attack
|
||||||
inputs.move_dir = Vec2::from(tgt_pos.0 - pos.0)
|
/*inputs.move_dir = Vec2::from(tgt_pos.0 - pos.0)
|
||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or(Vec2::unit_y())
|
.unwrap_or(Vec2::unit_y())
|
||||||
* 0.7;
|
* 0.7;*/
|
||||||
|
|
||||||
match tactic {
|
match tactic {
|
||||||
Tactic::Melee | Tactic::Staff => inputs.primary.set_state(true),
|
Tactic::Melee | Tactic::Staff => inputs.primary.set_state(true),
|
||||||
|
@ -2,7 +2,7 @@ use super::SysTimer;
|
|||||||
use crate::{chunk_generator::ChunkGenerator, client::Client, Tick};
|
use crate::{chunk_generator::ChunkGenerator, client::Client, Tick};
|
||||||
use common::{
|
use common::{
|
||||||
assets,
|
assets,
|
||||||
comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos},
|
comp::{self, item, CharacterAbility, ItemConfig, Player, Pos},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
generation::get_npc_name,
|
generation::get_npc_name,
|
||||||
msg::ServerMsg,
|
msg::ServerMsg,
|
||||||
@ -110,8 +110,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
let name = entity.name.unwrap_or("Unnamed".to_string());
|
let name = entity.name.unwrap_or("Unnamed".to_string());
|
||||||
let alignment = entity.alignment;
|
let alignment = entity.alignment;
|
||||||
let main_tool = entity.main_tool;
|
let main_tool = entity.main_tool;
|
||||||
|
|
||||||
let mut stats = comp::Stats::new(name, body);
|
let mut stats = comp::Stats::new(name, body);
|
||||||
|
// let damage = stats.level.level() as i32; TODO: Make NPC base damage
|
||||||
|
// non-linearly depend on their level
|
||||||
|
|
||||||
let active_item =
|
let active_item =
|
||||||
if let Some(item::ItemKind::Tool(tool)) = main_tool.as_ref().map(|i| &i.kind) {
|
if let Some(item::ItemKind::Tool(tool)) = main_tool.as_ref().map(|i| &i.kind) {
|
||||||
@ -129,12 +130,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
} else {
|
} else {
|
||||||
Some(ItemConfig {
|
Some(ItemConfig {
|
||||||
// We need the empty item so npcs can attack
|
// We need the empty item so npcs can attack
|
||||||
item: Item::empty(),
|
item: assets::load_expect_cloned("common.items.weapons.empty"),
|
||||||
ability1: Some(CharacterAbility::BasicMelee {
|
ability1: Some(CharacterAbility::BasicMelee {
|
||||||
energy_cost: 0,
|
energy_cost: 0,
|
||||||
buildup_duration: Duration::from_millis(0),
|
buildup_duration: Duration::from_millis(0),
|
||||||
recover_duration: Duration::from_millis(400),
|
recover_duration: Duration::from_millis(400),
|
||||||
base_healthchange: -4,
|
base_healthchange: -2,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
max_angle: 60.0,
|
max_angle: 60.0,
|
||||||
}),
|
}),
|
||||||
@ -213,7 +214,21 @@ impl<'a> System<'a> for Sys {
|
|||||||
tabard: None,
|
tabard: None,
|
||||||
},
|
},
|
||||||
_ => comp::Loadout {
|
_ => comp::Loadout {
|
||||||
active_item,
|
active_item: Some(comp::ItemConfig {
|
||||||
|
item: assets::load_expect_cloned("common.items.weapons.empty"),
|
||||||
|
ability1: Some(CharacterAbility::BasicMelee {
|
||||||
|
energy_cost: 10,
|
||||||
|
buildup_duration: Duration::from_millis(800),
|
||||||
|
recover_duration: Duration::from_millis(200),
|
||||||
|
base_healthchange: -2,
|
||||||
|
range: 3.5,
|
||||||
|
max_angle: 60.0,
|
||||||
|
}),
|
||||||
|
ability2: None,
|
||||||
|
ability3: None,
|
||||||
|
block_ability: None,
|
||||||
|
dodge_ability: None,
|
||||||
|
}),
|
||||||
second_item: None,
|
second_item: None,
|
||||||
shoulder: None,
|
shoulder: None,
|
||||||
chest: None,
|
chest: None,
|
||||||
@ -258,7 +273,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
energy_cost: 0,
|
energy_cost: 0,
|
||||||
buildup_duration: Duration::from_millis(800),
|
buildup_duration: Duration::from_millis(800),
|
||||||
recover_duration: Duration::from_millis(200),
|
recover_duration: Duration::from_millis(200),
|
||||||
base_healthchange: -13,
|
base_healthchange: -10,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
max_angle: 60.0,
|
max_angle: 60.0,
|
||||||
}),
|
}),
|
||||||
|
@ -813,15 +813,15 @@ impl Settlement {
|
|||||||
})
|
})
|
||||||
.do_if(rng.gen(), |entity| {
|
.do_if(rng.gen(), |entity| {
|
||||||
entity.with_main_tool(assets::load_expect_cloned(
|
entity.with_main_tool(assets::load_expect_cloned(
|
||||||
match rng.gen_range(0, 8) {
|
match rng.gen_range(0, 7) {
|
||||||
0 => "common.items.weapons.tool.broom",
|
0 => "common.items.weapons.tool.broom",
|
||||||
1 => "common.items.weapons.tool.hoe",
|
1 => "common.items.weapons.tool.hoe",
|
||||||
2 => "common.items.weapons.tool.pickaxe",
|
2 => "common.items.weapons.tool.pickaxe",
|
||||||
3 => "common.items.weapons.tool.pitchfork",
|
3 => "common.items.weapons.tool.pitchfork",
|
||||||
4 => "common.items.weapons.tool.rake",
|
4 => "common.items.weapons.tool.rake",
|
||||||
5 => "common.items.weapons.tool.shovel-0",
|
5 => "common.items.weapons.tool.shovel-0",
|
||||||
6 => "common.items.weapons.tool.shovel-1",
|
_ => "common.items.weapons.tool.shovel-1",
|
||||||
_ => "common.items.weapons.bow.starter_bow",
|
//_ => "common.items.weapons.bow.starter_bow", TODO: Re-Add this when we have a better way of distributing weapons here
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user