forked from unfa/liblast
Reimplemented bullet hit effects in the new damage system.
parent
35253ee7e1
commit
29bf99d59e
|
@ -1,5 +1,7 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
|
var impact_player = preload("res://Assets/Effects/ImpactBlood.tscn")
|
||||||
|
|
||||||
var max_health = 100
|
var max_health = 100
|
||||||
var health = max_health:
|
var health = max_health:
|
||||||
set(value):
|
set(value):
|
||||||
|
@ -351,7 +353,13 @@ func _process(delta):
|
||||||
|
|
||||||
if not dead:
|
if not dead:
|
||||||
rpc(&'moan') # all puppets must scream!
|
rpc(&'moan') # all puppets must scream!
|
||||||
|
|
||||||
|
# spawn the bullet hit effect
|
||||||
|
var impact_vfx = impact_player.instantiate()
|
||||||
|
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(hit_normal)
|
||||||
|
impact_vfx.global_transform.origin = hit_position
|
||||||
|
get_tree().root.add_child(impact_vfx)
|
||||||
|
|
||||||
@rpc(any_peer, call_local, reliable) func spawn(spawn_transform: Transform3D):
|
@rpc(any_peer, call_local, reliable) func spawn(spawn_transform: Transform3D):
|
||||||
dead = false
|
dead = false
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ var casing = preload("res://Assets/Weapons/Handgun/Casing.tscn")
|
||||||
var flash = preload("res://Assets/Effects/MuzzleFlash.tscn")
|
var flash = preload("res://Assets/Effects/MuzzleFlash.tscn")
|
||||||
var tracer = preload("res://Assets/Effects/BulletTracer.tscn")
|
var tracer = preload("res://Assets/Effects/BulletTracer.tscn")
|
||||||
var impact_wall = preload("res://Assets/Effects/ImpactSparks.tscn")
|
var impact_wall = preload("res://Assets/Effects/ImpactSparks.tscn")
|
||||||
var impact_player = preload("res://Assets/Effects/ImpactBlood.tscn")
|
|
||||||
|
|
||||||
# accuracy
|
# accuracy
|
||||||
var spread_min = 1
|
var spread_min = 1
|
||||||
|
@ -66,6 +66,8 @@ var spread = spread_min
|
||||||
|
|
||||||
return # skip the rest - it's deprecated code
|
return # skip the rest - it's deprecated code
|
||||||
|
|
||||||
|
####################### DEPRACATED ↓↓↓↓↓↓↓↓
|
||||||
|
|
||||||
var impact_vfx
|
var impact_vfx
|
||||||
|
|
||||||
if ray: # did we hit anything?
|
if ray: # did we hit anything?
|
||||||
|
@ -107,22 +109,29 @@ var spread = spread_min
|
||||||
main.rpc(&'player_list_update', main.player_list.get(ray['collider'].get_multiplayer_authority()).serialize(), ray['collider'].get_multiplayer_authority())
|
main.rpc(&'player_list_update', main.player_list.get(ray['collider'].get_multiplayer_authority()).serialize(), ray['collider'].get_multiplayer_authority())
|
||||||
main.update_hud()
|
main.update_hud()
|
||||||
|
|
||||||
impact_vfx = impact_player.instantiate()
|
# impact_vfx = impact_player.instantiate()
|
||||||
else:
|
else:
|
||||||
impact_vfx = impact_wall.instantiate()
|
# impact_vfx = impact_wall.instantiate()
|
||||||
|
pass
|
||||||
|
|
||||||
if impact_vfx != null:
|
# if impact_vfx != null:
|
||||||
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(ray['normal'])
|
# impact_vfx.global_transform = impact_vfx.global_transform.looking_at(ray['normal'])
|
||||||
impact_vfx.global_transform.origin = ray['position']
|
# impact_vfx.global_transform.origin = ray['position']
|
||||||
get_tree().root.add_child(impact_vfx)
|
# get_tree().root.add_child(impact_vfx)
|
||||||
|
#
|
||||||
#print(ray)
|
#print(ray)
|
||||||
|
|
||||||
|
####################### DEPRACATED ↑↑↑↑↑↑↑↑
|
||||||
|
|
||||||
func give_damage(target: Node, hit_position: Vector3, hit_normal: Vector3, damage: int, source_position: Vector3, type: Globals.DamageType, push: float):
|
func give_damage(target: Node, hit_position: Vector3, hit_normal: Vector3, damage: int, source_position: Vector3, type: Globals.DamageType, push: float):
|
||||||
if target.has_method(&'take_damage'): # we've hit a player or something else - the ywill handle everything like effects etc.
|
if target.has_method(&'take_damage'): # we've hit a player or something else - the ywill handle everything like effects etc.
|
||||||
target.rpc(&'take_damage', get_multiplayer_authority(), hit_position, hit_normal, damage, source_position, type, push)
|
target.rpc(&'take_damage', get_multiplayer_authority(), hit_position, hit_normal, damage, source_position, type, push)
|
||||||
else:
|
else:
|
||||||
pass # TODO take data from the material of the target and spawn an appropriate hit effect
|
# TODO take data from the material of the target and spawn an appropriate hit effect
|
||||||
|
var impact_vfx = impact_wall.instantiate()
|
||||||
|
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(hit_normal)
|
||||||
|
impact_vfx.global_transform.origin = hit_position
|
||||||
|
get_tree().root.add_child(impact_vfx)
|
||||||
|
|
||||||
func trigger(index: int, active: bool) -> void:
|
func trigger(index: int, active: bool) -> void:
|
||||||
#print("Weapon " + str(name) + ", Trigger " + str(index) + ", active: " + str(active))
|
#print("Weapon " + str(name) + ", Trigger " + str(index) + ", active: " + str(active))
|
||||||
|
@ -141,5 +150,7 @@ func trigger(index: int, active: bool) -> void:
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
|
|
||||||
# align the sound source with the head to produce balanced stereo
|
# align the sound source with the head to produce balanced stereo
|
||||||
pass #$SFX/Shoot.global_transform = camera.global_transform
|
pass #$SFX/Shoot.global_transform = camera.global_transform
|
||||||
|
|
Loading…
Reference in New Issue