@@ -14,7 +14,7 @@ use crate::core::{
1414 event:: { self , ActiveEvent , Event } ,
1515 movement:: Path ,
1616 state:: { self , BattleResult , State } ,
17- Id , Moves , Phase , PlayerId , Strength ,
17+ Id , Moves , Phase , PlayerId , PushStrength , Strength , Weight ,
1818 } ,
1919 map:: { self , Dir , PosHex } ,
2020 utils,
@@ -369,9 +369,16 @@ fn try_execute_passive_abilities_on_attack(
369369 PassiveAbility :: HeavyImpact => {
370370 let dir = Dir :: get_dir_from_to ( attacker_pos, target_pos) ;
371371 let from = target_pos;
372- let to = Dir :: get_neighbor_pos ( target_pos, dir) ;
373- if state. map ( ) . is_inboard ( to) && !state:: is_tile_blocked ( state, to) {
374- let effect = effect:: FlyOff { from, to } . into ( ) ;
372+ let strength = PushStrength ( Weight :: Normal ) ;
373+ let blocker_weight = state. parts ( ) . blocker . get ( target_id) . weight ;
374+ let to = if strength. can_push ( blocker_weight) {
375+ Dir :: get_neighbor_pos ( target_pos, dir)
376+ } else {
377+ from
378+ } ;
379+ let is_inboard = state. map ( ) . is_inboard ( to) ;
380+ if to == from || is_inboard && !state:: is_tile_blocked ( state, to) {
381+ let effect = effect:: FlyOff { from, to, strength } . into ( ) ;
375382 effects. instant . push ( effect) ;
376383 }
377384 }
@@ -673,15 +680,22 @@ impl ExecuteContext {
673680fn execute_use_ability_knockback (
674681 state : & mut State ,
675682 command : & command:: UseAbility ,
683+ ability : ability:: Knockback ,
676684) -> ExecuteContext {
677685 let mut context = ExecuteContext :: default ( ) ;
678686 let id = state:: blocker_id_at ( state, command. pos ) ;
679687 let from = command. pos ;
688+ let strength = ability. strength ;
680689 let actor_pos = state. parts ( ) . pos . get ( command. id ) . 0 ;
681690 let dir = Dir :: get_dir_from_to ( actor_pos, command. pos ) ;
682- let to = Dir :: get_neighbor_pos ( command. pos , dir) ;
683- if state. map ( ) . is_inboard ( to) && !state:: is_tile_blocked ( state, to) {
684- let effect = effect:: Knockback { from, to } . into ( ) ;
691+ let blocker_weight = state. parts ( ) . blocker . get ( id) . weight ;
692+ let to = if strength. can_push ( blocker_weight) {
693+ Dir :: get_neighbor_pos ( command. pos , dir)
694+ } else {
695+ from
696+ } ;
697+ if to == from || state. map ( ) . is_inboard ( to) && !state:: is_tile_blocked ( state, to) {
698+ let effect = effect:: Knockback { from, to, strength } . into ( ) ;
685699 context. instant_effects . push ( ( id, vec ! [ effect] ) ) ;
686700 context. moved_actor_ids . push ( id) ;
687701 }
@@ -936,11 +950,21 @@ fn execute_use_ability_explode_push(
936950 if distance. 0 > 1 || command. id == id {
937951 continue ;
938952 }
953+ let blocker_weight = state. parts ( ) . blocker . get ( id) . weight ;
939954 let dir = Dir :: get_dir_from_to ( from, pos) ;
940- let to = Dir :: get_neighbor_pos ( pos, dir) ;
955+ let to = if PushStrength ( Weight :: Normal ) . can_push ( blocker_weight) {
956+ Dir :: get_neighbor_pos ( pos, dir)
957+ } else {
958+ pos
959+ } ;
941960 let mut effects = Vec :: new ( ) ;
942- if state. map ( ) . is_inboard ( to) && !state:: is_tile_blocked ( state, to) {
943- effects. push ( effect:: Knockback { from : pos, to } . into ( ) ) ;
961+ if to == pos || ( state. map ( ) . is_inboard ( to) && !state:: is_tile_blocked ( state, to) ) {
962+ let effect = effect:: Knockback {
963+ from : pos,
964+ to,
965+ strength : PushStrength ( Weight :: Normal ) ,
966+ } ;
967+ effects. push ( effect. into ( ) ) ;
944968 context. moved_actor_ids . push ( id) ;
945969 }
946970 context. instant_effects . push ( ( id, effects) ) ;
@@ -1126,7 +1150,7 @@ fn execute_use_ability_bloodlust(
11261150
11271151fn execute_use_ability ( state : & mut State , cb : Cb , command : & command:: UseAbility ) {
11281152 let mut context = match command. ability {
1129- Ability :: Knockback => execute_use_ability_knockback ( state, command) ,
1153+ Ability :: Knockback ( a ) => execute_use_ability_knockback ( state, command, a ) ,
11301154 Ability :: Club => execute_use_ability_club ( state, command) ,
11311155 Ability :: Jump ( _) => execute_use_ability_jump ( state, command) ,
11321156 Ability :: Dash => execute_use_ability_dash ( state, command) ,
0 commit comments