mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 16:34:48 +00:00
Merge branch 'feat/friend-and-foe-iffs' into 'develop'
✨ Implement friend and foe IFF color change and fix bugs See merge request open-fpsz/open-fpsz!78
This commit is contained in:
commit
72f99eff07
5 changed files with 43 additions and 9 deletions
|
|
@ -5,7 +5,7 @@ enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }
|
||||||
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
|
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
|
||||||
|
|
||||||
signal grabbed(grabber : Player)
|
signal grabbed(grabber : Player)
|
||||||
signal regrabbed
|
signal regrabbed(grabber : Player)
|
||||||
signal dropped(dropper : Player)
|
signal dropped(dropper : Player)
|
||||||
|
|
||||||
var last_carrier : Player = null
|
var last_carrier : Player = null
|
||||||
|
|
@ -22,7 +22,7 @@ func grab(grabber : Player) -> void:
|
||||||
grabbed.emit(grabber)
|
grabbed.emit(grabber)
|
||||||
last_carrier = grabber
|
last_carrier = grabber
|
||||||
else:
|
else:
|
||||||
regrabbed.emit()
|
regrabbed.emit(grabber)
|
||||||
|
|
||||||
func drop(dropper : Player) -> void:
|
func drop(dropper : Player) -> void:
|
||||||
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
||||||
signal died(player : Player, killer_id : int)
|
signal died(player : Player, killer_id : int)
|
||||||
signal energy_changed(energy : float)
|
signal energy_changed(energy : float)
|
||||||
|
|
||||||
|
static var pawn_player : Player
|
||||||
var g : float = ProjectSettings.get_setting("physics/3d/default_gravity") # in m/s²
|
var g : float = ProjectSettings.get_setting("physics/3d/default_gravity") # in m/s²
|
||||||
var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||||
var _jumping : bool = false
|
var _jumping : bool = false
|
||||||
|
|
@ -85,6 +86,7 @@ func _ready() -> void:
|
||||||
if _is_pawn():
|
if _is_pawn():
|
||||||
camera.current = true
|
camera.current = true
|
||||||
camera.fov = _game_settings.fov
|
camera.fov = _game_settings.fov
|
||||||
|
pawn_player = self
|
||||||
# set the spring arm translation to be about head height level
|
# set the spring arm translation to be about head height level
|
||||||
$Smoothing/SpringArm3D.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
|
$Smoothing/SpringArm3D.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,19 @@ func _process(_delta : float) -> void:
|
||||||
|
|
||||||
# if the player is NOT infront of the camera or camera does NOT have LOS to player
|
# if the player is NOT infront of the camera or camera does NOT have LOS to player
|
||||||
if camera.is_position_behind(attach_point.global_position) or !is_within_los:
|
if camera.is_position_behind(attach_point.global_position) or !is_within_los:
|
||||||
_iff_container.hide() # hide the IFF and exit function
|
_iff_container.hide()
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
_iff_container.show() # display the IFF
|
_iff_container.show()
|
||||||
|
|
||||||
|
# Show the correct IFF based on whether the player we're looking at belongs is a friend or a foe
|
||||||
|
# in other words if their team_ids are the same as the "pawn" player
|
||||||
|
if player.pawn_player != null:
|
||||||
|
if player.pawn_player.team_id == player.team_id:
|
||||||
|
%FoeChevron.hide()
|
||||||
|
%FriendChevron.show()
|
||||||
|
else:
|
||||||
|
%FoeChevron.show()
|
||||||
|
%FriendChevron.hide()
|
||||||
|
|
||||||
func _physics_process(_delta : float) -> void:
|
func _physics_process(_delta : float) -> void:
|
||||||
# https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
|
# https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
|
||||||
|
|
@ -48,9 +57,12 @@ func _physics_process(_delta : float) -> void:
|
||||||
is_within_los = false # always initialise trace_success as false
|
is_within_los = false # always initialise trace_success as false
|
||||||
var space_state : PhysicsDirectSpaceState3D = camera.get_world_3d().direct_space_state
|
var space_state : PhysicsDirectSpaceState3D = camera.get_world_3d().direct_space_state
|
||||||
# do a trace check from camera to towards the player
|
# do a trace check from camera to towards the player
|
||||||
var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(camera.global_position, attach_point.global_position)
|
var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(camera.global_position, player.global_position)
|
||||||
|
# only collide with Layer 1 (objects) and Layer 32 (terrain/structures)
|
||||||
|
query.collision_mask = 0b10000000_00000000_00000000_00000001
|
||||||
# exclude the camera owner nodes from intersecting with the trace check
|
# exclude the camera owner nodes from intersecting with the trace check
|
||||||
query.exclude = [camera.owner]
|
if player.pawn_player:
|
||||||
|
query.exclude = [player.pawn_player]
|
||||||
# do trace check and store result
|
# do trace check and store result
|
||||||
var result : Dictionary = space_state.intersect_ray(query)
|
var result : Dictionary = space_state.intersect_ray(query)
|
||||||
# if a result was returned and the hit result is the player
|
# if a result was returned and the hit result is the player
|
||||||
|
|
@ -74,7 +86,6 @@ func _physics_process(_delta : float) -> void:
|
||||||
|
|
||||||
new_iff_position.y -= _iff_container.size.y # move the IFF up so the bottom of it is at the players head
|
new_iff_position.y -= _iff_container.size.y # move the IFF up so the bottom of it is at the players head
|
||||||
new_iff_position.x -= _iff_container.size.x / 2 # move the IFF left so it's centered horizontally above players head
|
new_iff_position.x -= _iff_container.size.x / 2 # move the IFF left so it's centered horizontally above players head
|
||||||
|
|
||||||
position = new_iff_position # set the position of the IFF
|
position = new_iff_position # set the position of the IFF
|
||||||
|
|
||||||
func _update_health_bar(health : float) -> void:
|
func _update_health_bar(health : float) -> void:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ theme_override_styles/fill = ExtResource("2_e3xla")
|
||||||
value = 60.0
|
value = 60.0
|
||||||
show_percentage = false
|
show_percentage = false
|
||||||
|
|
||||||
[node name="Chevron" type="Label" parent="IFFContainer"]
|
[node name="FoeChevron" type="Label" parent="IFFContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
layout_direction = 2
|
layout_direction = 2
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
|
|
@ -52,3 +54,18 @@ theme_override_font_sizes/font_size = 14
|
||||||
text = "▼"
|
text = "▼"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 2
|
vertical_alignment = 2
|
||||||
|
|
||||||
|
[node name="FriendChevron" type="Label" parent="IFFContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
layout_direction = 2
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 1
|
||||||
|
theme_override_colors/font_color = Color(0, 1, 0, 0.2)
|
||||||
|
theme_override_colors/font_outline_color = Color(0, 0, 0, 0.2)
|
||||||
|
theme_override_constants/outline_size = 3
|
||||||
|
theme_override_constants/line_spacing = -20
|
||||||
|
theme_override_font_sizes/font_size = 14
|
||||||
|
text = "▼"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 2
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ func _load_map(scene : PackedScene, nickname : String) -> void:
|
||||||
func _add_flag() -> void:
|
func _add_flag() -> void:
|
||||||
_flag = FLAG.instantiate()
|
_flag = FLAG.instantiate()
|
||||||
_flag.grabbed.connect(_on_flag_grabbed)
|
_flag.grabbed.connect(_on_flag_grabbed)
|
||||||
|
_flag.regrabbed.connect(_on_flag_regrabbed)
|
||||||
_flag.dropped.connect(_on_flag_dropped)
|
_flag.dropped.connect(_on_flag_dropped)
|
||||||
_flag.global_position = _map_manager.get_flagstand().global_position
|
_flag.global_position = _map_manager.get_flagstand().global_position
|
||||||
objectives.add_child(_flag)
|
objectives.add_child(_flag)
|
||||||
|
|
@ -134,6 +135,9 @@ func _on_flag_grabbed(grabber : Player) -> void:
|
||||||
scoreboard.add_score_to_player(grabber, 10)
|
scoreboard.add_score_to_player(grabber, 10)
|
||||||
_flag_carrier_scoring_timer.start()
|
_flag_carrier_scoring_timer.start()
|
||||||
|
|
||||||
|
func _on_flag_regrabbed(grabber : Player) -> void:
|
||||||
|
grabber.team_id = team_rabbit.team_id
|
||||||
|
|
||||||
func _on_flag_dropped(dropper : Player) -> void:
|
func _on_flag_dropped(dropper : Player) -> void:
|
||||||
dropper.team_id = team_chasers.team_id
|
dropper.team_id = team_chasers.team_id
|
||||||
_flag_carrier_scoring_timer.stop()
|
_flag_carrier_scoring_timer.stop()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue