mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better staff M1, random +1 damage, better attackrange,angle impl
This commit is contained in:
parent
387ab4a57e
commit
0456d3cbed
@ -13,6 +13,8 @@ pub enum CharacterAbility {
|
||||
buildup_duration: Duration,
|
||||
recover_duration: Duration,
|
||||
base_damage: u32,
|
||||
range: f32,
|
||||
max_angle: f32,
|
||||
},
|
||||
BasicRanged {
|
||||
recover_duration: Duration,
|
||||
@ -95,11 +97,15 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
buildup_duration,
|
||||
recover_duration,
|
||||
base_damage,
|
||||
range,
|
||||
max_angle,
|
||||
} => CharacterState::BasicMelee(basic_melee::Data {
|
||||
exhausted: false,
|
||||
buildup_duration: *buildup_duration,
|
||||
recover_duration: *recover_duration,
|
||||
base_damage: *base_damage,
|
||||
range: *range,
|
||||
max_angle: *max_angle,
|
||||
}),
|
||||
CharacterAbility::BasicRanged {
|
||||
recover_duration,
|
||||
@ -129,7 +135,7 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
}),
|
||||
CharacterAbility::BasicBlock => CharacterState::BasicBlock,
|
||||
CharacterAbility::Roll => CharacterState::Roll(roll::Data {
|
||||
remaining_duration: Duration::from_millis(600),
|
||||
remaining_duration: Duration::from_millis(300),
|
||||
}),
|
||||
CharacterAbility::TimedCombo {
|
||||
buildup_duration,
|
||||
|
@ -68,28 +68,24 @@ impl ToolData {
|
||||
use ToolKind::*;
|
||||
|
||||
match self.kind {
|
||||
Sword(_) => vec![
|
||||
// BasicMelee {
|
||||
// buildup_duration: Duration::from_millis(100),
|
||||
// recover_duration: Duration::from_millis(500),
|
||||
// base_damage: 6,
|
||||
// },
|
||||
TripleStrike { base_damage: 7 },
|
||||
DashMelee {
|
||||
buildup_duration: Duration::from_millis(500),
|
||||
recover_duration: Duration::from_millis(500),
|
||||
base_damage: 20,
|
||||
},
|
||||
],
|
||||
Sword(_) => vec![TripleStrike { base_damage: 7 }, DashMelee {
|
||||
buildup_duration: Duration::from_millis(500),
|
||||
recover_duration: Duration::from_millis(500),
|
||||
base_damage: 20,
|
||||
}],
|
||||
Axe(_) => vec![BasicMelee {
|
||||
buildup_duration: Duration::from_millis(700),
|
||||
recover_duration: Duration::from_millis(100),
|
||||
base_damage: 8,
|
||||
range: 3.5,
|
||||
max_angle: 30.0,
|
||||
}],
|
||||
Hammer(_) => vec![BasicMelee {
|
||||
buildup_duration: Duration::from_millis(700),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
base_damage: 10,
|
||||
range: 3.5,
|
||||
max_angle: 60.0,
|
||||
}],
|
||||
Bow(_) => vec![BasicRanged {
|
||||
projectile: Projectile {
|
||||
@ -113,12 +109,16 @@ impl ToolData {
|
||||
buildup_duration: Duration::from_millis(100),
|
||||
recover_duration: Duration::from_millis(400),
|
||||
base_damage: 5,
|
||||
range: 3.5,
|
||||
max_angle: 60.0,
|
||||
}],
|
||||
Staff(_) => vec![
|
||||
BasicMelee {
|
||||
buildup_duration: Duration::from_millis(400),
|
||||
buildup_duration: Duration::from_millis(0),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
base_damage: 7,
|
||||
base_damage: 3,
|
||||
range: 10.0,
|
||||
max_angle: 45.0,
|
||||
},
|
||||
BasicRanged {
|
||||
projectile: Projectile {
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// How long until state should deal damage
|
||||
pub buildup_duration: Duration,
|
||||
@ -13,6 +13,10 @@ pub struct Data {
|
||||
pub recover_duration: Duration,
|
||||
/// Base damage
|
||||
pub base_damage: u32,
|
||||
/// Max range
|
||||
pub range: f32,
|
||||
/// Max angle (45.0 will give you a 90.0 angle window)
|
||||
pub max_angle: f32,
|
||||
/// Whether the attack can deal more damage
|
||||
pub exhausted: bool,
|
||||
}
|
||||
@ -32,13 +36,15 @@ impl CharacterBehavior for Data {
|
||||
.unwrap_or_default(),
|
||||
recover_duration: self.recover_duration,
|
||||
base_damage: self.base_damage,
|
||||
range: self.range,
|
||||
max_angle: self.max_angle,
|
||||
exhausted: false,
|
||||
});
|
||||
} else if !self.exhausted {
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_damage: self.base_damage,
|
||||
max_angle: 75_f32.to_radians(),
|
||||
max_angle: self.max_angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
});
|
||||
@ -47,6 +53,8 @@ impl CharacterBehavior for Data {
|
||||
buildup_duration: self.buildup_duration,
|
||||
recover_duration: self.recover_duration,
|
||||
base_damage: self.base_damage,
|
||||
range: self.range,
|
||||
max_angle: self.max_angle,
|
||||
exhausted: true,
|
||||
});
|
||||
} else if self.recover_duration != Duration::default() {
|
||||
@ -58,6 +66,8 @@ impl CharacterBehavior for Data {
|
||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
base_damage: self.base_damage,
|
||||
range: self.range,
|
||||
max_angle: self.max_angle,
|
||||
exhausted: true,
|
||||
});
|
||||
} else {
|
||||
|
@ -22,7 +22,7 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) {
|
||||
if let Err(_) = update.energy.try_change_by(-8, EnergySource::Climb) {
|
||||
update.character = CharacterState::Idle {};
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ impl CharacterBehavior for Data {
|
||||
|
||||
if self.initialize {
|
||||
update.vel.0 = data.inputs.look_dir * 20.0;
|
||||
update.ori.0 = data.vel.0.normalized();
|
||||
}
|
||||
|
||||
if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, Scale,
|
||||
Stats,
|
||||
Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos,
|
||||
Scale, Stats,
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
sync::Uid,
|
||||
@ -25,6 +25,7 @@ impl<'a> System<'a> for Sys {
|
||||
ReadStorage<'a, Pos>,
|
||||
ReadStorage<'a, Ori>,
|
||||
ReadStorage<'a, Scale>,
|
||||
ReadStorage<'a, Agent>,
|
||||
ReadStorage<'a, Controller>,
|
||||
ReadStorage<'a, Body>,
|
||||
ReadStorage<'a, Stats>,
|
||||
@ -41,6 +42,7 @@ impl<'a> System<'a> for Sys {
|
||||
positions,
|
||||
orientations,
|
||||
scales,
|
||||
agents,
|
||||
controllers,
|
||||
bodies,
|
||||
stats,
|
||||
@ -50,12 +52,13 @@ impl<'a> System<'a> for Sys {
|
||||
) {
|
||||
let mut server_emitter = server_bus.emitter();
|
||||
// Attacks
|
||||
for (entity, uid, pos, ori, scale_maybe, _, _attacker_stats, attack) in (
|
||||
for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in (
|
||||
&entities,
|
||||
&uids,
|
||||
&positions,
|
||||
&orientations,
|
||||
scales.maybe(),
|
||||
agents.maybe(),
|
||||
&controllers,
|
||||
&stats,
|
||||
&mut attacking_storage,
|
||||
@ -100,6 +103,15 @@ impl<'a> System<'a> for Sys {
|
||||
// Weapon gives base damage
|
||||
let mut dmg = attack.base_damage;
|
||||
|
||||
// NPCs do less damage:
|
||||
if agent_maybe.is_some() {
|
||||
dmg = (dmg / 2).max(1);
|
||||
}
|
||||
|
||||
if rand::random() {
|
||||
dmg += 1;
|
||||
}
|
||||
|
||||
// Block
|
||||
if character_b.is_block()
|
||||
&& ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0
|
||||
|
@ -198,16 +198,19 @@ impl<'a> System<'a> for Sys {
|
||||
item,
|
||||
primary_ability: ability_drain.next(),
|
||||
secondary_ability: ability_drain.next(),
|
||||
block_ability: Some(comp::CharacterAbility::BasicBlock),
|
||||
block_ability: None,
|
||||
dodge_ability: Some(comp::CharacterAbility::Roll),
|
||||
})
|
||||
} else {
|
||||
Some(ItemConfig {
|
||||
// We need the empty item so npcs can attack
|
||||
item: Item::empty(),
|
||||
primary_ability: Some(CharacterAbility::BasicMelee {
|
||||
buildup_duration: Duration::from_millis(50),
|
||||
recover_duration: Duration::from_millis(50),
|
||||
base_damage: 1,
|
||||
buildup_duration: Duration::from_millis(0),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
base_damage: 2,
|
||||
range: 3.5,
|
||||
max_angle: 60.0,
|
||||
}),
|
||||
secondary_ability: None,
|
||||
block_ability: None,
|
||||
@ -301,6 +304,8 @@ impl<'a> System<'a> for Sys {
|
||||
buildup_duration: Duration::from_millis(800),
|
||||
recover_duration: Duration::from_millis(200),
|
||||
base_damage: 13,
|
||||
range: 3.5,
|
||||
max_angle: 60.0,
|
||||
}),
|
||||
secondary_ability: None,
|
||||
block_ability: None,
|
||||
|
Loading…
Reference in New Issue
Block a user