Made 3rd ability interruptible. Final balance tweaks.

This commit is contained in:
Sam 2020-09-20 12:23:33 -05:00
parent 8070a38a89
commit b4018e7d42
11 changed files with 82 additions and 51 deletions

View File

@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Figure meshing no longer blocks the main thread.
- Overhauled persistence layer including no longer storing serialized JSON items in the database
- Overhauled representation of blocks to permit fluid and sprite coexistence
- Overhauled sword
### Removed

View File

@ -115,6 +115,7 @@ pub enum CharacterAbility {
energy_cost: u32,
is_infinite: bool,
is_helicopter: bool,
is_interruptible: bool,
forward_speed: f32,
num_spins: u32,
},
@ -418,6 +419,7 @@ impl From<&CharacterAbility> for CharacterState {
energy_cost,
is_infinite,
is_helicopter,
is_interruptible,
forward_speed,
num_spins,
} => CharacterState::SpinMelee(spin_melee::Data {
@ -431,6 +433,7 @@ impl From<&CharacterAbility> for CharacterState {
energy_cost: *energy_cost,
is_infinite: *is_infinite,
is_helicopter: *is_helicopter,
is_interruptible: *is_interruptible,
forward_speed: *forward_speed,
num_spins: *num_spins,
},

View File

@ -184,15 +184,16 @@ impl Tool {
is_interruptible: true,
},
SpinMelee {
buildup_duration: Duration::from_millis(1000),
buildup_duration: Duration::from_millis(750),
swing_duration: Duration::from_millis(500),
recover_duration: Duration::from_millis(100),
base_damage: (100.0 * self.base_power()) as u32,
knockback: 0.0,
recover_duration: Duration::from_millis(500),
base_damage: (140.0 * self.base_power()) as u32,
knockback: 10.0,
range: 3.5,
energy_cost: 0,
energy_cost: 200,
is_infinite: false,
is_helicopter: false,
is_interruptible: true,
forward_speed: 1.0,
num_spins: 3,
},
@ -217,6 +218,7 @@ impl Tool {
energy_cost: 100,
is_infinite: true,
is_helicopter: true,
is_interruptible: false,
forward_speed: 0.0,
num_spins: 1,
},

View File

@ -66,7 +66,12 @@ impl LoadoutBuilder {
}
/// Builds loadout of creature when spawned
pub fn build_loadout(body: Body, alignment: Alignment, mut main_tool: Option<Item>, is_giant: bool) -> Self {
pub fn build_loadout(
body: Body,
alignment: Alignment,
mut main_tool: Option<Item>,
is_giant: bool,
) -> Self {
#![allow(clippy::single_match)] // For when this is done to more than just golems.
match body {
Body::Golem(golem) => match golem.species {
@ -76,10 +81,12 @@ impl LoadoutBuilder {
));
},
},
Body::Humanoid(_) => if is_giant {
main_tool = Some(Item::new_from_asset_expect(
"common.items.npc_weapons.sword.zweihander_sword_0",
));
Body::Humanoid(_) => {
if is_giant {
main_tool = Some(Item::new_from_asset_expect(
"common.items.npc_weapons.sword.zweihander_sword_0",
));
}
},
_ => {},
};
@ -219,7 +226,7 @@ impl LoadoutBuilder {
tabard: None,
},
_ => LoadoutBuilder::animal(body).build(),
}
},
},
Body::Golem(golem) => match golem.species {
golem::Species::StoneGolem => Loadout {

View File

@ -77,8 +77,7 @@ impl CharacterBehavior for Data {
// Allows for other states to interrupt this state
if self.is_interruptible && !data.inputs.primary.is_pressed() {
handle_dodge_input(data, &mut update);
handle_ability2_input(data, &mut update);
handle_interrupt(data, &mut update);
match update.character {
CharacterState::ComboMelee(_) => {},
_ => {

View File

@ -64,8 +64,7 @@ impl CharacterBehavior for Data {
// Allows for other states to interrupt this state
if self.static_data.is_interruptible && !data.inputs.secondary.is_pressed() {
handle_dodge_input(data, &mut update);
handle_ability1_input(data, &mut update);
handle_interrupt(data, &mut update);
match update.character {
CharacterState::DashMelee(_) => {},
_ => {

View File

@ -28,6 +28,8 @@ pub struct StaticData {
pub is_infinite: bool,
/// Used to maintain classic axe spin physics
pub is_helicopter: bool,
/// Whether the state can be interrupted by other abilities
pub is_interruptible: bool,
/// Used for forced forward movement
pub forward_speed: f32,
/// Number of spins
@ -55,8 +57,17 @@ impl CharacterBehavior for Data {
if self.static_data.is_helicopter {
update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0;
} else {
handle_orientation(data, &mut update, 1.0);
}
// Allows for other states to interrupt this state
if self.static_data.is_interruptible && !data.inputs.ability3.is_pressed() {
handle_interrupt(data, &mut update);
match update.character {
CharacterState::SpinMelee(_) => {},
_ => {
return update;
},
}
}
if self.stage_section == StageSection::Buildup
@ -71,7 +82,7 @@ impl CharacterBehavior for Data {
.unwrap_or_default(),
spins_remaining: self.spins_remaining,
stage_section: self.stage_section,
exhausted: self.exhausted
exhausted: self.exhausted,
});
} else if self.stage_section == StageSection::Buildup {
// Transitions to swing section of stage
@ -80,7 +91,7 @@ impl CharacterBehavior for Data {
timer: Duration::default(),
spins_remaining: self.spins_remaining,
stage_section: StageSection::Swing,
exhausted: self.exhausted
exhausted: self.exhausted,
});
} else if !self.exhausted {
update.character = CharacterState::SpinMelee(Data {
@ -102,7 +113,10 @@ impl CharacterBehavior for Data {
} else if self.stage_section == StageSection::Swing
&& self.timer < self.static_data.swing_duration
{
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
if !self.static_data.is_helicopter {
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
handle_orientation(data, &mut update, 1.0);
}
// Swings
update.character = CharacterState::SpinMelee(Data {
@ -113,37 +127,37 @@ impl CharacterBehavior for Data {
.unwrap_or_default(),
spins_remaining: self.spins_remaining,
stage_section: self.stage_section,
exhausted: self.exhausted
exhausted: self.exhausted,
});
} else if update.energy.current() >= self.static_data.energy_cost
&& (self.spins_remaining != 0
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
{
let new_spins_remaining = if self.static_data.is_infinite {
self.spins_remaining
} else {
self.spins_remaining - 1
};
update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data,
timer: Duration::default(),
spins_remaining: new_spins_remaining,
stage_section: self.stage_section,
exhausted: false,
});
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(
-(self.static_data.energy_cost as i32),
EnergySource::Ability,
);
} else if self.stage_section == StageSection::Swing {
&& (self.spins_remaining != 0
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
{
let new_spins_remaining = if self.static_data.is_infinite {
self.spins_remaining
} else {
self.spins_remaining - 1
};
update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data,
timer: Duration::default(),
spins_remaining: new_spins_remaining,
stage_section: self.stage_section,
exhausted: false,
});
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(
-(self.static_data.energy_cost as i32),
EnergySource::Ability,
);
} else if self.stage_section == StageSection::Swing {
// Transitions to recover section of stage
update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data,
timer: Duration::default(),
spins_remaining: self.spins_remaining,
stage_section: StageSection::Recover,
exhausted: self.exhausted
exhausted: self.exhausted,
})
} else if self.stage_section == StageSection::Recover
&& self.timer < self.static_data.recover_duration
@ -157,7 +171,7 @@ impl CharacterBehavior for Data {
.unwrap_or_default(),
spins_remaining: self.spins_remaining,
stage_section: self.stage_section,
exhausted: self.exhausted
exhausted: self.exhausted,
})
} else {
// Done

View File

@ -347,6 +347,13 @@ pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a Tool> {
}
}
pub fn handle_interrupt(data: &JoinData, update: &mut StateUpdate) {
handle_ability1_input(data, update);
handle_ability2_input(data, update);
handle_ability3_input(data, update);
handle_dodge_input(data, update);
}
/// Determines what portion a state is in. Used in all attacks (eventually). Is
/// used to control aspects of animation code, as well as logic within the
/// character states.

View File

@ -621,7 +621,8 @@ fn handle_spawn(
.create_npc(
pos,
comp::Stats::new(get_npc_name(id).into(), body),
LoadoutBuilder::build_loadout(body, alignment, None, false).build(),
LoadoutBuilder::build_loadout(body, alignment, None, false)
.build(),
body,
)
.with(comp::Vel(vel))

View File

@ -120,7 +120,9 @@ impl<'a> System<'a> for Sys {
// let damage = stats.level.level() as i32; TODO: Make NPC base damage
// non-linearly depend on their level
let loadout = LoadoutBuilder::build_loadout(body, alignment, main_tool, entity.is_giant).build();
let loadout =
LoadoutBuilder::build_loadout(body, alignment, main_tool, entity.is_giant)
.build();
let mut scale = entity.scale;

View File

@ -81,11 +81,7 @@ impl State {
kind != "Sceptre" && kind != "SceptreVelorite"
} else if let ToolKind::Debug(kind) = &kind.kind {
kind == "Boost"
} else if let ToolKind::Sword(_) = &kind.kind {
true
} else {
false
}
} else {matches!(&kind.kind, ToolKind::Sword(_))}
} else {
false
}