Skip to content

Commit

Permalink
Merge #292
Browse files Browse the repository at this point in the history
292: Adjust Slinger ranged attack to remove Knockback r=odecay a=Zac8668

Closes #290 

Co-authored-by: Isaac <[email protected]>
Co-authored-by: otis <[email protected]>
  • Loading branch information
3 people authored Jan 12, 2023
2 parents b6ff6a9 + a40d7b9 commit c9f8b8f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
2 changes: 2 additions & 0 deletions assets/items/bottle/bottle.item.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ kind: !Throwable
gravity: 1200
throw_velocity: [200, 300]
lifetime: 0.64
pushback: 80
hitstun_duration: 0.5
2 changes: 2 additions & 0 deletions assets/items/box/box.item.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ kind: !BreakableBox
gravity: 1200
throw_velocity: [200, 300]
lifetime: 0.64
pushback: 80
hitstun_duration: 0.5

hurtbox:
size: [36, 52]
Expand Down
2 changes: 2 additions & 0 deletions assets/items/rock/rock.item.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ kind: !Throwable
gravity: 300
throw_velocity: [300, 100]
lifetime: 1
pushback: 0
hitstun_duration: 0.0
4 changes: 2 additions & 2 deletions src/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct Attack {
//maybe just replace all fields with AttackMeta
pub damage: i32,
/// The direction and speed that the attack is hitting something in.
pub velocity: Vec2,
pub pushback: Vec2,
pub hitstun_duration: f32,
/// add this for attacks that are not immediately active, used in activate_hitbox
pub hitbox_meta: Option<ColliderMeta>,
Expand Down Expand Up @@ -221,7 +221,7 @@ fn attack_damage_system(

event_writer.send(DamageEvent {
damageing_entity: attack_entity,
damage_velocity: attack.velocity,
damage_velocity: attack.pushback,
damage: attack.damage,
damaged_entity: hurtbox_parent_entity,
hitstun_duration: attack.hitstun_duration,
Expand Down
22 changes: 11 additions & 11 deletions src/fighter_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Holding {
#[component(storage = "SparseSet")]
pub struct HitStun {
//velocity > pushback?
pub velocity: Vec2,
pub pushback: Vec2,
pub timer: Timer,
}
impl HitStun {
Expand Down Expand Up @@ -490,7 +490,7 @@ fn collect_hitstuns(
transition_intents.push_back(StateTransition::new(
HitStun {
//Hit stun velocity feels strange right now
velocity: event.damage_velocity,
pushback: event.damage_velocity,
timer: Timer::from_seconds(event.hitstun_duration, TimerMode::Once),
},
HitStun::PRIORITY,
Expand Down Expand Up @@ -880,7 +880,7 @@ fn flopping(
))
.insert(Attack {
damage: attack.damage,
velocity: if facing.is_left() {
pushback: if facing.is_left() {
Vec2::NEG_X
} else {
Vec2::X
Expand Down Expand Up @@ -1028,7 +1028,7 @@ fn chaining(
))
.insert(Attack {
damage: attack.damage,
velocity: if facing.is_left() {
pushback: if facing.is_left() {
Vec2::NEG_X
} else {
Vec2::X
Expand Down Expand Up @@ -1133,7 +1133,7 @@ fn punching(
))
.insert(Attack {
damage: attack.damage,
velocity: if facing.is_left() {
pushback: if facing.is_left() {
Vec2::NEG_X
} else {
Vec2::X
Expand Down Expand Up @@ -1270,7 +1270,7 @@ fn ground_slam(
))
.insert(Attack {
damage: attack.damage,
velocity: if facing.is_left() {
pushback: if facing.is_left() {
Vec2::NEG_X
} else {
Vec2::X
Expand Down Expand Up @@ -1491,10 +1491,10 @@ fn hitstun(
// If this is the start of the hit stun
if hitstun.timer.elapsed_secs() == 0.0 {
// Calculate animation to use based on attack direction and fighter facing
let is_left = hitstun.velocity.x < 0.0;
let is_left = hitstun.pushback.x < 0.0;
//TODO: change knocked right and left to knocked front and back
let use_left_anim = if facing.is_left() { !is_left } else { is_left };
let animation_name = if hitstun.velocity == Vec2::ZERO {
let animation_name = if hitstun.pushback == Vec2::ZERO {
HitStun::HITSTUN
} else if use_left_anim {
HitStun::KNOCKED_LEFT
Expand All @@ -1510,7 +1510,7 @@ fn hitstun(
hitstun.timer.tick(time.delta());

// Set our figher velocity to the hit stun velocity
**velocity = hitstun.velocity;
**velocity = hitstun.pushback;
}
}

Expand Down Expand Up @@ -1979,7 +1979,7 @@ fn melee_attacking(
))
.insert(Attack {
damage: attack.damage,
velocity: if facing.is_left() {
pushback: if facing.is_left() {
Vec2::NEG_X
} else {
Vec2::X
Expand Down Expand Up @@ -2116,7 +2116,7 @@ fn shooting(
))
.insert(Attack {
damage: attack.damage,
velocity: attack.velocity.unwrap_or(Vec2::ZERO) * direction_mul,
pushback: attack.velocity.unwrap_or(Vec2::ZERO) * direction_mul,
hitstun_duration: attack.hitstun_duration,
hitbox_meta: None,
})
Expand Down
21 changes: 16 additions & 5 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,26 @@ impl Projectile {
gravity,
throw_velocity,
lifetime,
pushback,
hitstun_duration,
..
}
| crate::metadata::ItemKind::BreakableBox {
damage,
gravity,
throw_velocity,
lifetime,
pushback,
hitstun_duration,
..
} => Some((damage, gravity, throw_velocity, lifetime)),
} => Some((
damage,
gravity,
throw_velocity,
lifetime,
pushback,
hitstun_duration,
)),
_ => None,
}
.expect("Non throwable item");
Expand All @@ -158,8 +169,8 @@ impl Projectile {
},
attack: Attack {
damage: item_vars.0,
velocity: Vec2::new(consts::ITEM_ATTACK_VELOCITY, 0.0) * direction_mul,
hitstun_duration: consts::HITSTUN_DURATION,
pushback: Vec2::new(item_vars.4, 0.0) * direction_mul,
hitstun_duration: item_vars.5,
hitbox_meta: None,
},
velocity: LinearVelocity(item_vars.2 * direction_mul),
Expand Down Expand Up @@ -317,7 +328,7 @@ fn explodable_system(
CollisionGroups::new(BodyLayers::ENEMY_ATTACK, BodyLayers::PLAYER),
Attack {
damage: attack.damage,
velocity: attack.velocity.unwrap_or(Vec2::ZERO),
pushback: attack.velocity.unwrap_or(Vec2::ZERO),
hitstun_duration: attack.hitstun_duration,
hitbox_meta: Some(explodable.attack.hitbox),
},
Expand Down Expand Up @@ -363,7 +374,7 @@ impl AnimatedProjectile {
sprite_bundle: animated_sprite,
attack: Attack {
damage,
velocity: Vec2::new(consts::ITEM_ATTACK_VELOCITY, 0.0) * direction_mul,
pushback: Vec2::new(consts::ITEM_ATTACK_VELOCITY, 0.0) * direction_mul,
hitstun_duration: consts::HITSTUN_DURATION,
hitbox_meta: None,
},
Expand Down
4 changes: 4 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ pub enum ItemKind {
gravity: f32,
throw_velocity: Vec2,
lifetime: f32,
pushback: f32,
hitstun_duration: f32,
},
BreakableBox {
damage: i32,
gravity: f32,
throw_velocity: Vec2,
lifetime: f32,
pushback: f32,
hitstun_duration: f32,
hurtbox: ColliderMeta,
hits: i32,
item: String,
Expand Down

0 comments on commit c9f8b8f

Please sign in to comment.