Ground death, need implementation for players

This commit is contained in:
ToasterPanic 2025-12-06 21:32:05 -05:00
parent e4893a5cc6
commit b13cf3d96b
8 changed files with 93 additions and 20 deletions

View file

@ -230,23 +230,6 @@ expand_mode = 2
script = ExtResource("16_hby33") script = ExtResource("16_hby33")
action_name = "dialogue_continue" action_name = "dialogue_continue"
[node name="BoostText" type="Label" parent="UI/Control"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 24.0
text = "BOOST: 100"
[node name="Distance" type="Label" parent="UI/Control"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -12.0
offset_right = 136.0
offset_bottom = 12.0
grow_vertical = 2
text = "DIST: 2048"
[node name="Interact" type="HFlowContainer" parent="UI/Control"] [node name="Interact" type="HFlowContainer" parent="UI/Control"]
layout_mode = 1 layout_mode = 1
anchors_preset = 14 anchors_preset = 14

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=57 format=4 uid="uid://dfjnikjjynj0e"] [gd_scene load_steps=59 format=4 uid="uid://dfjnikjjynj0e"]
[ext_resource type="AudioStream" uid="uid://dgv01wy8r7ej2" path="res://sounds/uglyburger.mp3" id="1_kpeax"] [ext_resource type="AudioStream" uid="uid://dgv01wy8r7ej2" path="res://sounds/uglyburger.mp3" id="1_kpeax"]
[ext_resource type="Texture2D" uid="uid://btcap3oh2dqt8" path="res://textures/wall_tile.png" id="2_4uppp"] [ext_resource type="Texture2D" uid="uid://btcap3oh2dqt8" path="res://textures/wall_tile.png" id="2_4uppp"]
@ -22,6 +22,8 @@
[ext_resource type="Script" uid="uid://cva4b60iqolqy" path="res://scripts/story_handler_1.gd" id="19_akl5n"] [ext_resource type="Script" uid="uid://cva4b60iqolqy" path="res://scripts/story_handler_1.gd" id="19_akl5n"]
[ext_resource type="Script" uid="uid://bv7ymrwe6ciax" path="res://scripts/enemy_ground.gd" id="21_tvsp8"] [ext_resource type="Script" uid="uid://bv7ymrwe6ciax" path="res://scripts/enemy_ground.gd" id="21_tvsp8"]
[ext_resource type="Texture2D" uid="uid://csrlh1sbdroud" path="res://textures/pistol.png" id="22_6l1ru"] [ext_resource type="Texture2D" uid="uid://csrlh1sbdroud" path="res://textures/pistol.png" id="22_6l1ru"]
[ext_resource type="AudioStream" uid="uid://boiv2kfau8gop" path="res://sounds/detecting.mp3" id="22_janyw"]
[ext_resource type="AudioStream" uid="uid://dpkn65kpftlmr" path="res://sounds/alerted.mp3" id="22_vmpfq"]
[ext_resource type="AudioStream" uid="uid://5x8fl2mk082h" path="res://sounds/gunshot_1.mp3" id="23_janyw"] [ext_resource type="AudioStream" uid="uid://5x8fl2mk082h" path="res://sounds/gunshot_1.mp3" id="23_janyw"]
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_vmimc"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_vmimc"]
@ -445,6 +447,16 @@ shape = SubResource("RectangleShape2D_83fjc")
position = Vector2(-162, -537) position = Vector2(-162, -537)
script = ExtResource("21_tvsp8") script = ExtResource("21_tvsp8")
[node name="Alerted" type="AudioStreamPlayer2D" parent="EnemyTest"]
stream = ExtResource("22_vmpfq")
volume_db = 8.0
bus = &"Sound Effects"
[node name="Detecting" type="AudioStreamPlayer2D" parent="EnemyTest"]
stream = ExtResource("22_janyw")
bus = &"Sound Effects"
parameters/looping = true
[node name="Sprite" type="AnimatedSprite2D" parent="EnemyTest"] [node name="Sprite" type="AnimatedSprite2D" parent="EnemyTest"]
scale = Vector2(2, 2) scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_vmpfq") sprite_frames = SubResource("SpriteFrames_vmpfq")
@ -471,6 +483,7 @@ texture = ExtResource("22_6l1ru")
[node name="Gunshot" type="AudioStreamPlayer2D" parent="EnemyTest/HeldItem"] [node name="Gunshot" type="AudioStreamPlayer2D" parent="EnemyTest/HeldItem"]
stream = ExtResource("23_janyw") stream = ExtResource("23_janyw")
bus = &"Sound Effects"
[node name="Hitbox" type="Area2D" parent="EnemyTest"] [node name="Hitbox" type="Area2D" parent="EnemyTest"]
collision_layer = 2 collision_layer = 2

View file

@ -4,6 +4,7 @@ var horizontial_movement = 0
var vertical_movement = 0 var vertical_movement = 0
var speed = 256 var speed = 256
var health = 100 var health = 100
var dead = false
var fire_delay = 0 var fire_delay = 0
@ -11,6 +12,7 @@ var fire_delay = 0
var busy = false var busy = false
var firing = false var firing = false
var sprinting = false
var equipped_ground_gun = "pistol" var equipped_ground_gun = "pistol"
var ammo_in_mag = 12 var ammo_in_mag = 12
@ -28,9 +30,33 @@ func _ready() -> void:
$HeldItem/Cast.add_exception(self) $HeldItem/Cast.add_exception(self)
func _process(delta: float) -> void: func _process(delta: float) -> void:
if dead:
velocity /= 1.3
$Sprite.rotation_degrees = -90
$Sprite.position.y = 64
$Sprite.animation = "idle"
$HeldItem.visible = false
return
if !$Sprite.is_playing(): if !$Sprite.is_playing():
$Sprite.play() $Sprite.play()
$Sprite.modulate.g = health / 100.0
$Sprite.modulate.b = health / 100.0
if health <= 0:
dead = true
$CollisionShape.queue_free()
$Hitbox.queue_free()
if randi_range(0, 1) == 0:
$Sprite.rotation_degrees = -90
else:
$Sprite.rotation_degrees = 90
if busy: if busy:
velocity = Vector2() velocity = Vector2()
else: else:
@ -54,8 +80,9 @@ func _process(delta: float) -> void:
var hit_target = $HeldItem/Cast.get_collider() var hit_target = $HeldItem/Cast.get_collider()
if "health" in hit_target: if hit_target:
hit_target.health -= 10 if "health" in hit_target.get_parent():
hit_target.get_parent().health -= 10
var bullet_impact = preload("res://scenes/particles/bullet_impact.tscn").instantiate() var bullet_impact = preload("res://scenes/particles/bullet_impact.tscn").instantiate()
bullet_impact.global_position = $HeldItem/Cast.get_collision_point() bullet_impact.global_position = $HeldItem/Cast.get_collision_point()

View file

@ -43,6 +43,10 @@ func _ready() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
super(delta) super(delta)
if dead:
$Detecting.stop()
return
if !player: if !player:
if game: if game:
player = game.get_node("PlayerGround") player = game.get_node("PlayerGround")
@ -55,17 +59,25 @@ func _process(delta: float) -> void:
var divider = clamp((player.global_position - global_position).length() / reaction_halve_distance, 1, 8) * 1.5 var divider = clamp((player.global_position - global_position).length() / reaction_halve_distance, 1, 8) * 1.5
reaction_timer += delta / divider reaction_timer += delta / divider
$Detecting.playing = true
$Detecting.pitch_scale = (reaction_timer / reaction_time) * 12
if reaction_time < reaction_timer: if reaction_time < reaction_timer:
ai_mode = AI_MODE_ATTACK ai_mode = AI_MODE_ATTACK
reaction_timer = 0 reaction_timer = 0
$Alerted.play()
else: else:
reaction_timer -= delta reaction_timer -= delta
$Detecting.playing = false
if reaction_timer < 0: if reaction_timer < 0:
reaction_timer = 0 reaction_timer = 0
elif ai_mode == AI_MODE_ATTACK: elif ai_mode == AI_MODE_ATTACK:
$Detecting.playing = false
$LineOfSight.look_at(player.global_position) $LineOfSight.look_at(player.global_position)
if player.is_ancestor_of($LineOfSight.get_collider()): if player.is_ancestor_of($LineOfSight.get_collider()):
if !$Navagent.target_position or ($Navagent.target_position != player.global_position): if !$Navagent.target_position or ($Navagent.target_position != player.global_position):

BIN
sounds/alerted.mp3 Normal file

Binary file not shown.

19
sounds/alerted.mp3.import Normal file
View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://dpkn65kpftlmr"
path="res://.godot/imported/alerted.mp3-3c4520eabb20b0fc7b092ab722b349ce.mp3str"
[deps]
source_file="res://sounds/alerted.mp3"
dest_files=["res://.godot/imported/alerted.mp3-3c4520eabb20b0fc7b092ab722b349ce.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

BIN
sounds/detecting.mp3 Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://boiv2kfau8gop"
path="res://.godot/imported/detecting.mp3-50635f71bfbfed860615114ed5e610e5.mp3str"
[deps]
source_file="res://sounds/detecting.mp3"
dest_files=["res://.godot/imported/detecting.mp3-50635f71bfbfed860615114ed5e610e5.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4