depleted ammo destruction
This commit is contained in:
parent
7c7f68b6f5
commit
900502ec8a
12 changed files with 68 additions and 2068 deletions
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@
|
||||||
[ext_resource type="Script" uid="uid://3dphlay25fih" path="res://scripts/player/player.gd" id="1_g2els"]
|
[ext_resource type="Script" uid="uid://3dphlay25fih" path="res://scripts/player/player.gd" id="1_g2els"]
|
||||||
[ext_resource type="Script" uid="uid://dalwlndejfdhm" path="res://scripts/player/crosshair.gd" id="3_dqkch"]
|
[ext_resource type="Script" uid="uid://dalwlndejfdhm" path="res://scripts/player/crosshair.gd" id="3_dqkch"]
|
||||||
[ext_resource type="Script" uid="uid://bjhbdh6xsjgnn" path="res://scripts/player/player_camera.gd" id="3_qhqgy"]
|
[ext_resource type="Script" uid="uid://bjhbdh6xsjgnn" path="res://scripts/player/player_camera.gd" id="3_qhqgy"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c3hg4ux4j76j2" path="res://models/characters/viewmodels/molikman_hands.glb" id="4_dqkch"]
|
[ext_resource type="PackedScene" uid="uid://bc21f85o0ovc1" path="res://models/characters/viewmodels/molikman_hands.glb" id="4_dqkch"]
|
||||||
[ext_resource type="Script" uid="uid://6c14qse4vnra" path="res://scripts/player/player_raycast.gd" id="4_fjrip"]
|
[ext_resource type="Script" uid="uid://6c14qse4vnra" path="res://scripts/player/player_raycast.gd" id="4_fjrip"]
|
||||||
[ext_resource type="Script" uid="uid://bmecgup3kcua7" path="res://scripts/weapon_system/weapon_system.gd" id="4_qlg0r"]
|
[ext_resource type="Script" uid="uid://bmecgup3kcua7" path="res://scripts/weapon_system/weapon_system.gd" id="4_qlg0r"]
|
||||||
[ext_resource type="Script" uid="uid://dd5mp72dq43v6" path="res://scripts/multiplayer/own_visibility_toggle.gd" id="4_smehm"]
|
[ext_resource type="Script" uid="uid://dd5mp72dq43v6" path="res://scripts/multiplayer/own_visibility_toggle.gd" id="4_smehm"]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bxdatd1ilfgmc"]
|
[gd_scene load_steps=5 format=3 uid="uid://bxdatd1ilfgmc"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://scripts/weapon_system/weapon_substate_machine.gd" id="1_krsgt"]
|
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://scripts/weapon_system/weapon_substate_machine.gd" id="1_krsgt"]
|
||||||
[ext_resource type="Script" uid="uid://rx78vdadldm7" path="res://scripts/weapon_system/bomb/bomb_state.gd" id="2_870cc"]
|
[ext_resource type="Script" uid="uid://rx78vdadldm7" path="res://scripts/weapon_system/bomb/bomb_main_state.gd" id="2_870cc"]
|
||||||
|
[ext_resource type="Script" uid="uid://cx7j3kr1laq3s" path="res://scripts/weapon_system/bomb/bomb_idle_state.gd" id="3_1x0so"]
|
||||||
|
[ext_resource type="Script" uid="uid://dmyir46aricwi" path="res://scripts/weapon_system/bomb/bomb_intro_state.gd" id="4_fv3ha"]
|
||||||
|
|
||||||
[node name="Bomb" type="Node" node_paths=PackedStringArray("enter_state")]
|
[node name="Bomb" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||||
script = ExtResource("1_krsgt")
|
script = ExtResource("1_krsgt")
|
||||||
|
|
@ -9,12 +11,18 @@ animation_prefix = &"baked_bomb_"
|
||||||
droppable = &"uid://cxdgk74ln5xpn"
|
droppable = &"uid://cxdgk74ln5xpn"
|
||||||
visibility_target = &"bomb"
|
visibility_target = &"bomb"
|
||||||
max_ammo = 1
|
max_ammo = 1
|
||||||
|
ammo_mags = 0
|
||||||
can_be_previous = false
|
can_be_previous = false
|
||||||
destroy_when_empty = true
|
destroy_when_empty = true
|
||||||
enter_state = NodePath("Main")
|
slot = &"bomb"
|
||||||
|
enter_state = NodePath("Intro")
|
||||||
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
||||||
|
|
||||||
[node name="Main" type="Node" parent="."]
|
[node name="Plant" type="Node" parent="."]
|
||||||
script = ExtResource("2_870cc")
|
script = ExtResource("2_870cc")
|
||||||
|
|
||||||
[node name="Idle" type="Node" parent="."]
|
[node name="Idle" type="Node" parent="."]
|
||||||
|
script = ExtResource("3_1x0so")
|
||||||
|
|
||||||
|
[node name="Intro" type="Node" parent="."]
|
||||||
|
script = ExtResource("4_fv3ha")
|
||||||
|
|
|
||||||
12
scripts/weapon_system/bomb/bomb_idle_state.gd
Normal file
12
scripts/weapon_system/bomb/bomb_idle_state.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends WeaponState
|
||||||
|
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
machine.animation_player.play(machine.animation_prefix+"idle")
|
||||||
|
|
||||||
|
func exit() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func state_input(event: InputEvent) -> void:
|
||||||
|
if event.is_action("plr_bomb"):
|
||||||
|
transition.emit("Plant")
|
||||||
1
scripts/weapon_system/bomb/bomb_idle_state.gd.uid
Normal file
1
scripts/weapon_system/bomb/bomb_idle_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cx7j3kr1laq3s
|
||||||
12
scripts/weapon_system/bomb/bomb_intro_state.gd
Normal file
12
scripts/weapon_system/bomb/bomb_intro_state.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends WeaponState
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
machine.animation_player.play(machine.animation_prefix+"intro")
|
||||||
|
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||||
|
|
||||||
|
func exit() -> void:
|
||||||
|
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||||
|
|
||||||
|
func on_animation_finished(animation: StringName):
|
||||||
|
if animation == machine.animation_prefix + "intro":
|
||||||
|
transition.emit("Idle")
|
||||||
1
scripts/weapon_system/bomb/bomb_intro_state.gd.uid
Normal file
1
scripts/weapon_system/bomb/bomb_intro_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dmyir46aricwi
|
||||||
|
|
@ -21,5 +21,4 @@ func on_animation_finished(animation: StringName):
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func state_input(event: InputEvent) -> void:
|
||||||
if event.is_action_released("plr_bomb"):
|
if event.is_action_released("plr_bomb"):
|
||||||
|
transition.emit("Idle")
|
||||||
return_to_previous.emit()
|
|
||||||
|
|
@ -7,17 +7,32 @@ class_name WeaponSubStateMachine
|
||||||
@export var visibility_target: StringName
|
@export var visibility_target: StringName
|
||||||
|
|
||||||
@export var max_ammo: int
|
@export var max_ammo: int
|
||||||
@onready var ammo: int = max_ammo
|
@onready var ammo: int = max_ammo:
|
||||||
@onready var remaining_ammo: int = max_ammo * 3
|
set(value):
|
||||||
|
if value < 0:
|
||||||
|
ammo = 0
|
||||||
|
else:
|
||||||
|
ammo = value
|
||||||
|
if ammo <= 0 and remaining_ammo <= 0:
|
||||||
|
ammo_depleted.emit()
|
||||||
|
get:
|
||||||
|
return ammo
|
||||||
|
@export var ammo_mags: int = 3
|
||||||
|
@onready var remaining_ammo: int = max_ammo * ammo_mags:
|
||||||
|
set(value):
|
||||||
|
if value < 0:
|
||||||
|
remaining_ammo = 0
|
||||||
|
else:
|
||||||
|
remaining_ammo = value
|
||||||
|
|
||||||
@export var speed_modifier: float = 1.0
|
@export var speed_modifier: float = 1.0
|
||||||
|
|
||||||
@export var can_be_previous: bool = true
|
@export var can_be_previous: bool = true
|
||||||
@export var destroy_when_empty: bool = false
|
@export var destroy_when_empty: bool = false
|
||||||
|
|
||||||
@export var slot: StringName
|
@export var slot: StringName
|
||||||
|
|
||||||
signal request_return
|
signal request_return
|
||||||
|
signal ammo_depleted
|
||||||
|
|
||||||
var system: WeaponSystem
|
var system: WeaponSystem
|
||||||
var animation_player: AnimationPlayer
|
var animation_player: AnimationPlayer
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
|
||||||
state.player_camera = camera
|
state.player_camera = camera
|
||||||
state.player = player
|
state.player = player
|
||||||
state.request_return.connect(return_to_previous)
|
state.request_return.connect(return_to_previous)
|
||||||
|
state.ammo_depleted.connect(check_for_empty)
|
||||||
|
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
current_state = state
|
current_state = state
|
||||||
|
|
@ -133,6 +134,13 @@ func pick_up_weapon(data: Variant) -> Node:
|
||||||
|
|
||||||
return scene
|
return scene
|
||||||
|
|
||||||
|
func check_for_empty() -> void:
|
||||||
|
if is_multiplayer_authority() == false:
|
||||||
|
return
|
||||||
|
for child in get_children():
|
||||||
|
if child is WeaponSubStateMachine and child.ammo == 0 and child.remaining_ammo == 0 and child.destroy_when_empty:
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue