mirror of https://github.com/profan/ld-39-jam.git
add owner thing to bullets and guns as stopgap measure to stop players bullets from killin him
This commit is contained in:
parent
1d1d2b4439
commit
64ecbc311e
12
Bullet.gd
12
Bullet.gd
|
@ -6,13 +6,15 @@ var velocity = Vector2(1, 0)
|
||||||
var lifetime = 16 # seconds
|
var lifetime = 16 # seconds
|
||||||
|
|
||||||
var bullet_dmg = 25
|
var bullet_dmg = 25
|
||||||
|
var bullet_owner
|
||||||
|
|
||||||
onready var sprite = get_node("Sprite")
|
onready var sprite = get_node("Sprite")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
|
|
||||||
func fire(delta, vel, dir, speed):
|
func fire(o, delta, vel, dir, speed):
|
||||||
|
bullet_owner = o
|
||||||
velocity = (vel.length() * dir + (dir * speed * delta))
|
velocity = (vel.length() * dir + (dir * speed * delta))
|
||||||
sprite.set_rot(dir.angle())
|
sprite.set_rot(dir.angle())
|
||||||
|
|
||||||
|
@ -36,8 +38,12 @@ func on_impact(e):
|
||||||
|
|
||||||
# new_bi.rotate(deg2rad(180))
|
# new_bi.rotate(deg2rad(180))
|
||||||
|
|
||||||
# damage and free
|
if bullet_owner == "Player" and e.type() == "Player":
|
||||||
e.do_damage(bullet_dmg)
|
pass
|
||||||
|
else:
|
||||||
|
# damage and free
|
||||||
|
e.do_damage(bullet_dmg)
|
||||||
|
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
func _fixed_process(delta):
|
func _fixed_process(delta):
|
||||||
|
|
|
@ -28,6 +28,8 @@ func _ready():
|
||||||
var t = get_tree().get_root().get_node("Game/MinimapControl").register_entity(self)
|
var t = get_tree().get_root().get_node("Game/MinimapControl").register_entity(self)
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
gun.set_owner(type())
|
||||||
|
|
||||||
cur_kinematic = km.Kinematic.new(self, grunt_max_speed)
|
cur_kinematic = km.Kinematic.new(self, grunt_max_speed)
|
||||||
steering = km.Steering.new()
|
steering = km.Steering.new()
|
||||||
|
|
||||||
|
|
6
Gun.gd
6
Gun.gd
|
@ -6,6 +6,7 @@ var gun_cooldown = 0
|
||||||
var gun_delay = 0.1125
|
var gun_delay = 0.1125
|
||||||
var gun_spread_max = deg2rad(4) # degrees max
|
var gun_spread_max = deg2rad(4) # degrees max
|
||||||
var gun_bullet_speed = 384
|
var gun_bullet_speed = 384
|
||||||
|
var gun_owner
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
|
@ -13,6 +14,9 @@ func _ready():
|
||||||
func _fixed_process(delta):
|
func _fixed_process(delta):
|
||||||
gun_cooldown = clamp(gun_cooldown - delta, 0, 1)
|
gun_cooldown = clamp(gun_cooldown - delta, 0, 1)
|
||||||
|
|
||||||
|
func set_owner(o):
|
||||||
|
gun_owner = o
|
||||||
|
|
||||||
func fire(delta, vel, dir):
|
func fire(delta, vel, dir):
|
||||||
if gun_cooldown <= 0:
|
if gun_cooldown <= 0:
|
||||||
var new_bullet = Bullet.instance()
|
var new_bullet = Bullet.instance()
|
||||||
|
@ -20,5 +24,5 @@ func fire(delta, vel, dir):
|
||||||
new_bullet.set_pos(gun_pos + vel)
|
new_bullet.set_pos(gun_pos + vel)
|
||||||
get_tree().get_root().add_child(new_bullet)
|
get_tree().get_root().add_child(new_bullet)
|
||||||
var rot = rand_range(-gun_spread_max, gun_spread_max)
|
var rot = rand_range(-gun_spread_max, gun_spread_max)
|
||||||
new_bullet.fire(delta, vel, dir.rotated(rot), gun_bullet_speed)
|
new_bullet.fire(gun_owner, delta, vel, dir.rotated(rot), gun_bullet_speed)
|
||||||
gun_cooldown += gun_delay
|
gun_cooldown += gun_delay
|
||||||
|
|
|
@ -34,6 +34,8 @@ func _ready():
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
left_particles.set_emitting(false)
|
left_particles.set_emitting(false)
|
||||||
right_particles.set_emitting(false)
|
right_particles.set_emitting(false)
|
||||||
|
left_gun.set_owner(type())
|
||||||
|
right_gun.set_owner(type())
|
||||||
|
|
||||||
func type():
|
func type():
|
||||||
return "Player"
|
return "Player"
|
||||||
|
|
Loading…
Reference in New Issue