fix dash attack angles, arrow damage and readd possession stick impl

This commit is contained in:
timokoesters 2020-03-17 14:15:39 +01:00
parent 7ded921ecc
commit f32eb1db75
9 changed files with 39 additions and 45 deletions

View File

@ -100,9 +100,10 @@ impl Component for CharacterState {
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Attacking {
pub base_damage: u32,
pub max_angle: f32,
pub applied: bool,
pub hit_count: u32,
}

View File

@ -71,7 +71,7 @@ impl ToolData {
hit_entity: vec![
projectile::Effect::Damage(HealthChange {
// TODO: This should not be fixed (?)
amount: -30,
amount: -3,
cause: HealthSource::Item,
}),
projectile::Effect::Vanish,
@ -104,7 +104,17 @@ impl ToolData {
only_up: true,
},
],
Possess => vec![],
Possess => vec![BasicRanged {
projectile: Projectile {
hit_ground: vec![projectile::Effect::Stick],
hit_wall: vec![projectile::Effect::Stick],
hit_entity: vec![projectile::Effect::Stick, projectile::Effect::Possess],
time_left: Duration::from_secs(10),
owner: None,
},
projectile_body: Body::Object(object::Body::ArrowSnake),
recover_duration: Duration::from_millis(300),
}],
},
Empty => vec![],
}

View File

@ -134,7 +134,7 @@ impl Stats {
}
// TODO: Delete this once stat points will be a thing
pub fn update_max_hp(&mut self) { self.health.set_maximum(21 + 3 * self.level.amount); }
pub fn update_max_hp(&mut self) { self.health.set_maximum(33 + 7 * self.level.amount); }
}
impl Stats {

View File

@ -46,6 +46,7 @@ impl CharacterBehavior for Data {
// Hit attempt
data.updater.insert(data.entity, Attacking {
base_damage: self.base_damage,
max_angle: 75_f32.to_radians(),
applied: false,
hit_count: 0,
});

View File

@ -48,12 +48,14 @@ impl CharacterBehavior for Data {
});
} else if !self.exhausted {
// Fire
let mut projectile = self.projectile.clone();
projectile.owner = Some(*data.uid);
update.server_events.push_front(ServerEvent::Shoot {
entity: data.entity,
dir: data.inputs.look_dir,
body: self.projectile_body,
light: None,
projectile: self.projectile.clone(),
projectile,
gravity: Some(Gravity(0.1)),
});

View File

@ -54,6 +54,7 @@ impl CharacterBehavior for Data {
// Hit attempt
data.updater.insert(data.entity, Attacking {
base_damage: self.base_damage,
max_angle: 180_f32.to_radians(),
applied: false,
hit_count: 0,
});

View File

@ -61,6 +61,7 @@ impl CharacterBehavior for Data {
// Swing hits
data.updater.insert(data.entity, Attacking {
base_damage: self.base_damage * (self.stage as u32 + 1),
max_angle: 75_f32.to_radians(),
applied: false,
hit_count: 0,
});

View File

@ -101,7 +101,7 @@ impl<'a> System<'a> for Sys {
&& !stats_b.is_dead
// Spherical wedge shaped attack field
&& pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2)
&& ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan()
&& ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan()
{
// Weapon gives base damage
let mut dmg = attack.base_damage;

View File

@ -77,46 +77,24 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) {
e
)
});
// Create inventory if it doesn't exist
{
let mut inventories = ecs.write_storage::<comp::Inventory>();
if let Some(inventory) = inventories.get_mut(possesse) {
inventory.push(assets::load_expect_cloned("common.items.debug.possess"));
} else {
inventories
.insert(possesse, comp::Inventory {
slots: vec![
Some(assets::load_expect_cloned("common.items.debug.possess")),
None,
None,
None,
None,
None,
None,
None,
],
})
.err()
.map(|e| {
error!(
"Error inserting inventory component during possession: {:?}",
e
)
});
}
}
ecs.write_storage::<comp::InventoryUpdate>()
.insert(
possesse,
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Possession),
)
.err()
.map(|e| {
error!(
"Error inserting inventory update component during possession: {:?}",
e
)
// Put possess item into loadout
let mut loadouts = ecs.write_storage::<comp::Loadout>();
let loadout = loadouts
.entry(possesse)
.expect("Could not read loadouts component while possessing")
.or_insert(comp::Loadout::default());
let item = assets::load_expect_cloned::<comp::Item>("common.items.debug.possess");
if let comp::ItemKind::Tool(tool) = item.kind {
loadout.active_item = Some(comp::ItemConfig {
item,
primary_ability: tool.get_abilities().get(0).cloned(),
secondary_ability: None,
block_ability: None,
dodge_ability: None,
});
}
// Move player component
{
let mut players = ecs.write_storage::<comp::Player>();