Fixed staff RMB, bug in ranged weapon code

This commit is contained in:
Joshua Barretto 2020-07-06 23:37:44 +01:00
parent 30619771af
commit f77d2f06c6
5 changed files with 21 additions and 15 deletions

View File

@ -44,9 +44,7 @@ impl Alignment {
// TODO: Remove this hack
pub fn is_friendly_to_players(&self) -> bool {
match self {
Alignment::Npc
| Alignment::Tame
| Alignment::Owned(_) => true,
Alignment::Npc | Alignment::Tame | Alignment::Owned(_) => true,
_ => false,
}
}

View File

@ -331,18 +331,18 @@ impl Tool {
},
BasicRanged {
energy_cost: 0,
holdable: true,
holdable: false,
prepare_duration: Duration::from_millis(250),
recover_duration: Duration::from_millis(200),
recover_duration: Duration::from_millis(600),
projectile: Projectile {
hit_solid: vec![projectile::Effect::Vanish],
hit_entity: vec![
projectile::Effect::Damage(HealthChange {
// TODO: This should not be fixed (?)
amount: -2,
amount: -3,
cause: HealthSource::Projectile { owner: None },
}),
projectile::Effect::RewardEnergy(100),
projectile::Effect::RewardEnergy(150),
projectile::Effect::Vanish,
],
time_left: Duration::from_secs(20),
@ -350,7 +350,7 @@ impl Tool {
},
projectile_body: Body::Object(object::Body::BoltFire),
projectile_light: Some(LightEmitter {
col: (1.0, 0.8, 0.11).into(),
col: (0.85, 0.5, 0.11).into(),
..Default::default()
}),
@ -375,7 +375,7 @@ impl Tool {
},
projectile_body: Body::Object(object::Body::BoltFireBig),
projectile_light: Some(LightEmitter {
col: (1.0, 0.8, 0.11).into(),
col: (1.0, 0.75, 0.11).into(),
..Default::default()
}),

View File

@ -31,9 +31,11 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
if self.prepare_timer < self.prepare_duration
|| self.holdable && !self.exhausted && data.inputs.holding_ability_key()
{
if !self.exhausted && if self.holdable {
data.inputs.holding_ability_key() || self.prepare_timer < self.prepare_duration
} else {
self.prepare_timer < self.prepare_duration
} {
// Prepare (draw the bow)
update.character = CharacterState::BasicRanged(Data {
prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0),

View File

@ -1,6 +1,7 @@
use crate::{
comp::{
Alignment, Attacking, Body, CharacterState, HealthChange, HealthSource, Ori, Pos, Scale, Stats,
Alignment, Attacking, Body, CharacterState, HealthChange, HealthSource, Ori, Pos, Scale,
Stats,
},
event::{EventBus, LocalEvent, ServerEvent},
sync::Uid,
@ -120,7 +121,11 @@ impl<'a> System<'a> for Sys {
// TODO: remove this when there is a better way to target healing
// Don't heal npc's hp
if alignment_b_maybe.map(|a| !a.is_friendly_to_players()).unwrap_or(true) && healthchange > 0.0 {
if alignment_b_maybe
.map(|a| !a.is_friendly_to_players())
.unwrap_or(true)
&& healthchange > 0.0
{
healthchange = 0.0;
}

View File

@ -256,7 +256,8 @@ impl PlayState for SessionState {
}
};
let can_build = self.client
let can_build = self
.client
.borrow()
.state()
.read_storage::<comp::CanBuild>()