cops only shoot characters on the same screen as them (fixes issue #79)
This commit is contained in:
parent
3e51a5062f
commit
8ac962d855
1 changed files with 24 additions and 23 deletions
|
@ -44,29 +44,30 @@ func _physics_process(delta):
|
|||
# check for player in raycast
|
||||
var collider = shoot_cast.get_collider()
|
||||
if collider != null && (collider.is_in_group("player") or collider.is_in_group("msx")):
|
||||
# kill player and enter shooting state temporarily
|
||||
collider.get_parent().die()
|
||||
# play sound
|
||||
Audio.play_sound(Audio.a_die_robot, Audio.ac_boss)
|
||||
# muzzle flash
|
||||
muzzle_flash.emitting = true
|
||||
shooting = true
|
||||
get_tree().create_timer(0.05, false).connect("timeout", self, "_stop_shoot")
|
||||
sprite.play("shoot")
|
||||
# check other raycast to find collision passing through player
|
||||
graphics_cast.force_raycast_update()
|
||||
var hit_position = graphics_cast.to_global(Vector2(256.0, 0.0))
|
||||
if graphics_cast.is_colliding():
|
||||
hit_position = graphics_cast.get_collision_point()
|
||||
# set line point to point of collision
|
||||
var hit_x = shoot_line.to_local(hit_position).x
|
||||
shoot_line.points[1].x = hit_x
|
||||
# shoot_line.visible = true
|
||||
# get_tree().create_timer(0.05, false).connect("timeout", shoot_line, "set_visible", [false], CONNECT_DEFERRED)
|
||||
# move and play sparks
|
||||
sparks.global_position = hit_position
|
||||
sparks.emitting = true
|
||||
return
|
||||
if Game.get_sector(global_position) == Game.get_sector(collider.global_position):
|
||||
# kill player and enter shooting state temporarily
|
||||
collider.get_parent().die()
|
||||
# play sound
|
||||
Audio.play_sound(Audio.a_die_robot, Audio.ac_boss)
|
||||
# muzzle flash
|
||||
muzzle_flash.emitting = true
|
||||
shooting = true
|
||||
get_tree().create_timer(0.05, false).connect("timeout", self, "_stop_shoot")
|
||||
sprite.play("shoot")
|
||||
# check other raycast to find collision passing through player
|
||||
graphics_cast.force_raycast_update()
|
||||
var hit_position = graphics_cast.to_global(Vector2(256.0, 0.0))
|
||||
if graphics_cast.is_colliding():
|
||||
hit_position = graphics_cast.get_collision_point()
|
||||
# set line point to point of collision
|
||||
var hit_x = shoot_line.to_local(hit_position).x
|
||||
shoot_line.points[1].x = hit_x
|
||||
# shoot_line.visible = true
|
||||
# get_tree().create_timer(0.05, false).connect("timeout", shoot_line, "set_visible", [false], CONNECT_DEFERRED)
|
||||
# move and play sparks
|
||||
sparks.global_position = hit_position
|
||||
sparks.emitting = true
|
||||
return
|
||||
|
||||
# if there aren't turns, walk around
|
||||
if turns == 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue