mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make npcs attack again
This commit is contained in:
parent
1279f70184
commit
81591fcaf7
@ -29,6 +29,8 @@ pub enum ToolKind {
|
||||
Staff,
|
||||
Shield,
|
||||
Debug(DebugKind),
|
||||
/// This is an placeholder item, it is used by non-humanoid npcs to attack
|
||||
Empty,
|
||||
}
|
||||
|
||||
impl ToolData {
|
||||
@ -97,6 +99,7 @@ impl ToolData {
|
||||
],
|
||||
Possess => vec![],
|
||||
},
|
||||
Empty => vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,6 +185,17 @@ impl Asset for Item {
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
name: "Empty Item".to_owned(),
|
||||
description: "This item may grant abilities, but is invisible".to_owned(),
|
||||
kind: ItemKind::Tool(ToolData {
|
||||
kind: ToolKind::Empty,
|
||||
equip_time_millis: 0,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str { &self.name }
|
||||
|
||||
pub fn description(&self) -> &str { &self.description }
|
||||
|
@ -44,13 +44,11 @@ impl CharacterBehavior for Data {
|
||||
});
|
||||
} else if !self.exhausted {
|
||||
// Hit attempt
|
||||
if let Some(tool) = unwrap_tool_data(data) {
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_damage: self.base_damage,
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
});
|
||||
}
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_damage: self.base_damage,
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
});
|
||||
|
||||
update.character = CharacterState::BasicMelee(Data {
|
||||
buildup_duration: self.buildup_duration,
|
||||
|
@ -2,7 +2,7 @@ use super::SysTimer;
|
||||
use crate::{chunk_generator::ChunkGenerator, client::Client, Tick};
|
||||
use common::{
|
||||
assets,
|
||||
comp::{self, item, Player, Pos},
|
||||
comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos},
|
||||
event::{EventBus, ServerEvent},
|
||||
generation::EntityKind,
|
||||
msg::ServerMsg,
|
||||
@ -12,7 +12,7 @@ use common::{
|
||||
};
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
use specs::{Join, Read, ReadStorage, System, Write, WriteExpect, WriteStorage};
|
||||
use std::sync::Arc;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use vek::*;
|
||||
|
||||
/// This system will handle loading generated chunks and unloading
|
||||
@ -181,22 +181,50 @@ impl<'a> System<'a> for Sys {
|
||||
.expect("SPAWN_NPCS is nonempty")(
|
||||
);
|
||||
let mut stats = comp::Stats::new(name, body);
|
||||
let mut loadout = comp::Loadout {
|
||||
active_item: main.map(|item| comp::ItemConfig {
|
||||
item,
|
||||
primary_ability: None,
|
||||
secondary_ability: None,
|
||||
block_ability: None,
|
||||
dodge_ability: None,
|
||||
}),
|
||||
second_item: None,
|
||||
shoulder: None,
|
||||
chest: None,
|
||||
belt: None,
|
||||
hand: None,
|
||||
pants: None,
|
||||
foot: None,
|
||||
};
|
||||
|
||||
let mut loadout =
|
||||
if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) {
|
||||
let mut abilities = tool.get_abilities();
|
||||
let mut ability_drain = abilities.drain(..);
|
||||
|
||||
comp::Loadout {
|
||||
active_item: main.map(|item| comp::ItemConfig {
|
||||
item,
|
||||
primary_ability: ability_drain.next(),
|
||||
secondary_ability: ability_drain.next(),
|
||||
block_ability: Some(comp::CharacterAbility::BasicBlock),
|
||||
dodge_ability: Some(comp::CharacterAbility::Roll),
|
||||
}),
|
||||
second_item: None,
|
||||
shoulder: None,
|
||||
chest: None,
|
||||
belt: None,
|
||||
hand: None,
|
||||
pants: None,
|
||||
foot: None,
|
||||
}
|
||||
} else {
|
||||
comp::Loadout {
|
||||
active_item: Some(ItemConfig {
|
||||
item: Item::empty(),
|
||||
primary_ability: Some(CharacterAbility::BasicMelee {
|
||||
buildup_duration: Duration::from_millis(50),
|
||||
recover_duration: Duration::from_millis(50),
|
||||
base_damage: 10,
|
||||
}),
|
||||
secondary_ability: None,
|
||||
block_ability: None,
|
||||
dodge_ability: None,
|
||||
}),
|
||||
second_item: None,
|
||||
shoulder: None,
|
||||
chest: None,
|
||||
belt: None,
|
||||
hand: None,
|
||||
pants: None,
|
||||
foot: None,
|
||||
}
|
||||
};
|
||||
|
||||
let mut scale = 1.0;
|
||||
|
||||
@ -220,9 +248,11 @@ impl<'a> System<'a> for Sys {
|
||||
loadout = comp::Loadout {
|
||||
active_item: Some(comp::ItemConfig {
|
||||
item: assets::load_expect_cloned("common.items.weapons.hammer_1"),
|
||||
primary_ability: None, /* TODO: when implementing this, make sure
|
||||
* to adjust the base damage (see todo
|
||||
* below) */
|
||||
primary_ability: Some(CharacterAbility::BasicMelee {
|
||||
buildup_duration: Duration::from_millis(800),
|
||||
recover_duration: Duration::from_millis(200),
|
||||
base_damage: 130,
|
||||
}),
|
||||
secondary_ability: None,
|
||||
block_ability: None,
|
||||
dodge_ability: None,
|
||||
|
@ -236,6 +236,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
|
||||
ToolKind::Bow => 0.0,
|
||||
ToolKind::Dagger => 0.0,
|
||||
ToolKind::Debug(_) => 0.0,
|
||||
ToolKind::Empty => 0.0,
|
||||
},
|
||||
weapon_y: match ToolKind::Hammer {
|
||||
ToolKind::Sword(_) => -1.25,
|
||||
@ -246,6 +247,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
|
||||
ToolKind::Bow => -2.0,
|
||||
ToolKind::Dagger => -2.0,
|
||||
ToolKind::Debug(_) => 0.0,
|
||||
ToolKind::Empty => 0.0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
|
||||
ToolKind::Bow => 0.0,
|
||||
ToolKind::Dagger => 0.0,
|
||||
ToolKind::Debug(_) => 0.0,
|
||||
ToolKind::Empty => 0.0,
|
||||
},
|
||||
weapon_y: match ToolKind::Hammer {
|
||||
// TODO: Inventory
|
||||
@ -187,6 +188,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
|
||||
ToolKind::Bow => -2.0,
|
||||
ToolKind::Dagger => -2.0,
|
||||
ToolKind::Debug(_) => 0.0,
|
||||
ToolKind::Empty => 0.0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ pub enum ItemKey {
|
||||
Utility(Utility),
|
||||
Consumable(Consumable),
|
||||
Ingredient(Ingredient),
|
||||
Empty,
|
||||
}
|
||||
impl From<&Item> for ItemKey {
|
||||
fn from(item: &Item) -> Self {
|
||||
|
@ -636,6 +636,7 @@ pub fn mesh_main(item_kind: Option<&ItemKind>) -> Mesh<FigurePipeline> {
|
||||
ToolKind::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)),
|
||||
ToolKind::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)),
|
||||
ToolKind::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)),
|
||||
ToolKind::Empty => return Mesh::new(),
|
||||
},
|
||||
_ => return Mesh::new(),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user