mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-13 23:44:49 +00:00
✨ Implement Teams and disallow team damage in Rabbit
This commit is contained in:
parent
1a19e5edfa
commit
ac8bd2d07c
10 changed files with 46 additions and 23 deletions
|
|
@ -27,6 +27,6 @@ func _physics_process(_delta : float) -> void:
|
|||
|
||||
for area in get_overlapping_areas():
|
||||
if area is HealthComponent and is_multiplayer_authority():
|
||||
area.damage.rpc(damage, damage_dealer.player_id)
|
||||
(area as HealthComponent).damage.rpc(damage, damage_dealer.player_id, damage_dealer.team_id)
|
||||
|
||||
set_physics_process(false)
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ func _grab(flag : Flag) -> void:
|
|||
_carried_flag = flag
|
||||
show()
|
||||
|
||||
func _release(inherited_velocity : Vector3, throw_speed : float) -> void:
|
||||
func _release(inherited_velocity : Vector3, throw_speed : float, dropper : Player) -> void:
|
||||
if _is_carrying():
|
||||
_carried_flag.drop()
|
||||
_carried_flag.drop(dropper)
|
||||
_carried_flag.rotation_degrees.x = 0.0
|
||||
_carried_flag.linear_velocity = inherited_velocity + (global_basis.z * throw_speed)
|
||||
# Throw the flag from some distance in front of the player to avoid regrabbing mid-air
|
||||
|
|
@ -55,8 +55,8 @@ func _sensor_on_body_entered(collider : Flag) -> void:
|
|||
if collider is Flag:
|
||||
_grab(collider)
|
||||
|
||||
func drop() -> void:
|
||||
_release(Vector3.ZERO, 0.0)
|
||||
func drop(dropper : Player) -> void:
|
||||
_release(Vector3.ZERO, 0.0, dropper)
|
||||
|
||||
func throw(inherited_velocity : Vector3) -> void:
|
||||
_release(inherited_velocity, max_throw_speed)
|
||||
func throw(inherited_velocity : Vector3, dropper : Player) -> void:
|
||||
_release(inherited_velocity, max_throw_speed, dropper)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class_name HealthComponent extends Area3D
|
|||
set(value):
|
||||
health = value
|
||||
health_changed.emit(value)
|
||||
@export var _player : Player
|
||||
|
||||
signal health_zeroed(killer_id : int)
|
||||
signal health_changed(value : float)
|
||||
|
|
@ -26,13 +27,16 @@ signal health_changed(value : float)
|
|||
func _ready() -> void:
|
||||
heal_full()
|
||||
|
||||
@rpc("call_local")
|
||||
func damage(amount : float, damage_dealer_id : int) -> void:
|
||||
@rpc("call_local", "reliable")
|
||||
func damage(amount : float, damage_dealer_id : int, damage_dealer_team_id : int) -> void:
|
||||
if damage_dealer_team_id == _player.team_id:
|
||||
return
|
||||
|
||||
health = clampf(health - amount, 0.0, max_health)
|
||||
if health == 0.0:
|
||||
health_zeroed.emit(damage_dealer_id)
|
||||
|
||||
@rpc("call_local")
|
||||
@rpc("call_local", "reliable")
|
||||
func _heal(amount : float) -> void:
|
||||
health = clampf(health + amount, 0.0, max_health)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue