точно есть дэшм

This commit is contained in:
2026-07-21 00:27:17 +07:00
parent 1df926f1d8
commit d74fa3bd80
601 changed files with 2375919 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
extends StaticBody3D
@export var heal_amount: float = 30.0 # Сколько здоровья восстанавливает аптечка
var detect_area: Area3D = null
func _ready() -> void:
detect_area = $DetectArea
if detect_area == null:
print("[АПТЕЧКА] ОШИБКА: Узел 'DetectArea' не найден!")
func _physics_process(_delta: float) -> void:
if detect_area == null:
return
# Этот код плавно вращает модель аптечки вокруг своей оси Y
rotate_y(deg_to_rad(90.0) * _delta) # 90 градусов в секунду
# Используем наш проверенный и неубиваемый метод опроса зоны
var overlapping_bodies = detect_area.get_overlapping_bodies()
for body in overlapping_bodies:
if body == self:
continue
# Опознаем игрока по наличию WeaponManager
var weapon_manager = body.find_child("WeaponManager", true, false)
if weapon_manager == null and body.get_parent():
weapon_manager = body.get_parent().find_child("WeaponManager", true, false)
if weapon_manager != null:
# Ищем HealthComponent игрока
var player_node = body if body.find_child("WeaponManager", true, false) else body.get_parent()
var player_health = player_node.find_child("HealthComponent", true, false)
if player_health:
# Проверяем, нужно ли игрока вообще лечить (если хп меньше максимального)
if player_health.current_health < player_health.max_health:
# Лечим игрока
player_health.current_health += heal_amount
# Защита от избыточного лечения (чтобы здоровье не стало 120 из 100)
if player_health.current_health > player_health.max_health:
player_health.current_health = player_health.max_health
print("[АПТЕЧКА] Игрок исцелен на ", heal_amount, ". Текущее здоровье: ", player_health.current_health)
# Удаляем аптечку с земли, так как игрок её использовал
queue_free()
return
+1
View File
@@ -0,0 +1 @@
uid://b5wsni4pd1852
+31
View File
@@ -0,0 +1,31 @@
extends Node
class_name HealthComponent
@export var max_health: float = 100.0
var current_health: float = 0.0
# Сигналы, чтобы другие скрипты знали, когда объект ранен или умер
signal health_changed(new_health: float)
signal died
func _ready() -> void:
current_health = max_health
func take_damage(amount: float) -> void:
if current_health <= 0:
return
current_health -= amount
health_changed.emit(current_health)
print("[Здоровье] ", get_parent().name, " получил урон: ", amount, ". Осталось: ", current_health)
if current_health <= 0:
current_health = 0
die()
func die() -> void:
died.emit()
print("[Здоровье] ", get_parent().name, " погиб!")
# Для врага удаляем его со сцены, для игрока тут можно вызвать экран смерти
if get_parent() and get_parent().name != "Player":
get_parent().queue_free()
+1
View File
@@ -0,0 +1 @@
uid://drhhet1lt3f5a
+56
View File
@@ -0,0 +1,56 @@
extends StaticBody3D
@export var heal_amount: float = 30.0 # Сколько здоровья восстанавливает аптечка
var detect_area: Area3D = null
func _ready() -> void:
# Ищем дочернюю зону, как в сцене твоего рабочего автомата
detect_area = $DetectArea
if detect_area == null:
print("[АПТЕЧКА] ОШИБКА: Дочерний узел 'DetectArea' не найден!")
func _physics_process(delta: float) -> void:
if detect_area == null:
return
# Красивое вращение аптечки на полу (90 градусов в секунду)
rotate_y(deg_to_rad(90.0) * delta)
# Используем проверенный метод опроса зоны, как у автомата и NPC
var overlapping_bodies = detect_area.get_overlapping_bodies()
for body in overlapping_bodies:
if body == self or body is StaticBody3D or "CSG" in body.name:
continue
# Проверяем, является ли вошедший объект игроком или его родителем
var main_player = null
if body.name == "PlayerCharacter":
main_player = body
elif body.get_parent() and body.get_parent().name == "PlayerCharacter":
main_player = body.get_parent()
# Если это точно PlayerCharacter
if main_player != null:
# Ищем HealthComponent строго у корня игрока
var player_health = main_player.get_node_or_null("HealthComponent")
if player_health == null:
player_health = main_player.find_child("HealthComponent", true, false)
if player_health:
# Проверяем, нужно ли вообще лечить игрока (если хп меньше максимального)
if player_health.current_health < player_health.max_health:
# Добавляем здоровье
player_health.current_health += heal_amount
# Защита: здоровье не должно превышать максимум (например, стать 110 из 100)
if player_health.current_health > player_health.max_health:
player_health.current_health = player_health.max_health
print("[АПТЕЧКА] Игрок исцелен! Текущее здоровье: ", player_health.current_health)
# Удаляем аптечку со сцены, так как игрок её подобрал
queue_free()
return # Выходим, чтобы не проверять другие тела в этом кадре
+1
View File
@@ -0,0 +1 @@
uid://bhrqn66efyjt2
+32
View File
@@ -0,0 +1,32 @@
[gd_scene format=3 uid="uid://dmol158qdw0lp"]
[ext_resource type="Script" uid="uid://bhrqn66efyjt2" path="res://addons/hp/medical_kit.gd" id="1_ddvnm"]
[ext_resource type="PackedScene" uid="uid://cyxdexqmowyvh" path="res://addons/Addon Assets/Weapon Models/AmmunitionBox/ammobox_low.glb" id="2_koyrl"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vfsrg"]
size = Vector3(0.974533, 0.752262, 1.42589)
[sub_resource type="BoxShape3D" id="BoxShape3D_diulm"]
size = Vector3(1.90394, 1.28174, 2.08409)
[node name="medkit" type="StaticBody3D" unique_id=1288342592]
collision_layer = 64
collision_mask = 121
script = ExtResource("1_ddvnm")
[node name="Hitbox" type="CollisionShape3D" parent="." unique_id=824024126]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0297165, -0.00481224, 0.00307465)
shape = SubResource("BoxShape3D_vfsrg")
[node name="DetectArea" type="Area3D" parent="." unique_id=6166126]
collision_layer = 64
collision_mask = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="DetectArea" unique_id=1058434302]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0385975, 0.274414, -0.0104526)
shape = SubResource("BoxShape3D_diulm")
[node name="Model" parent="." unique_id=1010714069 instance=ExtResource("2_koyrl")]
transform = Transform3D(-2.84124e-07, 0, 6.5, 0, 6.5, 0, -6.5, 0, -2.84124e-07, 0, -0.0915464, 0)
[connection signal="area_entered" from="DetectArea" to="." method="_on_detect_area_area_entered"]