fixed up some damage number bugs
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bjo2q6vca5qlv"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://bjo2q6vca5qlv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ejqql2660u6h" path="res://Worlds/GreenPlanet/Enemies/enemy_controller.gd" id="1_m83kr"]
|
||||
[ext_resource type="PackedScene" uid="uid://canrxnpxcugc2" path="res://Scenes/corpse.tscn" id="2_aed6c"]
|
||||
[ext_resource type="Script" uid="uid://bamhci3kawuyt" path="res://Scripts/health.gd" id="3_wiose"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqtew0t8sttpm" path="res://Scenes/damage_particle.tscn" id="4_mhq3m"]
|
||||
[ext_resource type="PackedScene" uid="uid://hjq3nrnumklp" path="res://Scenes/health_bar.tscn" id="9_4xla1"]
|
||||
[ext_resource type="Script" uid="uid://cojjgevmbhwal" path="res://Scripts/status_effector.gd" id="9_7hati"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1fn60m6xfcsq" path="res://Assets/Textures/minimap_enemy.png" id="9_7yfyh"]
|
||||
@@ -12,21 +10,16 @@
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_ss5ir"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[node name="Dog" type="CharacterBody3D" node_paths=PackedStringArray("status_manager", "movement_controller", "health", "d_n") groups=["Enemies"]]
|
||||
[node name="Dog" type="CharacterBody3D" node_paths=PackedStringArray("status_manager", "movement_controller", "d_n") groups=["Enemies"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_m83kr")
|
||||
status_manager = NodePath("StatusEffector")
|
||||
movement_controller = NodePath("BeeliningController")
|
||||
health = NodePath("Health")
|
||||
d_n = NodePath("Node3D")
|
||||
corpse_scene = ExtResource("2_aed6c")
|
||||
|
||||
[node name="Health" type="Node" parent="."]
|
||||
script = ExtResource("3_wiose")
|
||||
damage_particle_scene = ExtResource("4_mhq3m")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0.637873, 0)
|
||||
sorting_offset = 1.0
|
||||
@@ -68,6 +61,3 @@ sprite_container = NodePath("../SubViewport/HBoxContainer")
|
||||
metadata/_custom_type_script = "uid://cojjgevmbhwal"
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="."]
|
||||
|
||||
[connection signal="health_changed" from="Health" to="SubViewport/HealthBar" method="on_health_changed"]
|
||||
[connection signal="health_depleted" from="Health" to="." method="die"]
|
||||
|
||||
@@ -2,15 +2,18 @@ class_name EnemyController extends CharacterBody3D
|
||||
|
||||
signal reached_goal(enemy: Enemy, penalty: int)
|
||||
signal died(enemy: Enemy)
|
||||
signal health_changed(health: int)
|
||||
|
||||
@export var stats: Enemy
|
||||
@export var status_manager: StatusEffector
|
||||
@export var movement_controller: EnemyMovement
|
||||
@export var health: Health
|
||||
@export var max_health: int = 10
|
||||
@export var d_n: Node3D
|
||||
#@export var sprite: Sprite3D
|
||||
@export var corpse_scene: PackedScene
|
||||
|
||||
var damage_particle_scene: PackedScene = preload("res://Scenes/damage_particle.tscn")
|
||||
var current_health: int
|
||||
var corpse_root: Node
|
||||
var movement_speed: float
|
||||
var movement_speed_penalty: float = 1.0
|
||||
@@ -18,16 +21,61 @@ var alive: bool = true
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
health.max_health = stats.health
|
||||
health.current_health = stats.health
|
||||
max_health = stats.health
|
||||
current_health = stats.health
|
||||
health_changed.connect($SubViewport/HealthBar.on_health_changed)
|
||||
$SubViewport/HealthBar.setup(stats.health)
|
||||
#sprite.texture = stats.sprite.duplicate()
|
||||
movement_speed = stats.movement_speed
|
||||
status_manager.enemy = self
|
||||
|
||||
|
||||
func spawn_damage_indicator(damage: int, pos: Vector3, damage_type: Data.DamageIndicationType) -> void:
|
||||
var color: Color = Color.WHITE
|
||||
if damage_type == Data.DamageIndicationType.PLAYER:
|
||||
if !Data.preferences.display_self_damage_indicators:
|
||||
return
|
||||
else:
|
||||
color = Color.FIREBRICK
|
||||
if damage_type == Data.DamageIndicationType.TOWER:
|
||||
if !Data.preferences.display_tower_damage_indicators:
|
||||
return
|
||||
else:
|
||||
color = Color.WHITE_SMOKE
|
||||
if damage_type == Data.DamageIndicationType.OTHER_PLAYER:
|
||||
if !Data.preferences.display_party_damage_indicators:
|
||||
return
|
||||
else:
|
||||
color = Color.AQUAMARINE
|
||||
if damage_type == Data.DamageIndicationType.STATUS:
|
||||
if !Data.preferences.display_status_effect_damage_indicators:
|
||||
return
|
||||
else:
|
||||
color = Color.INDIAN_RED
|
||||
var marker: DamageParticle = damage_particle_scene.instantiate()
|
||||
get_tree().root.add_child(marker)
|
||||
marker.set_number(damage)
|
||||
marker.set_color(color)
|
||||
marker.position = pos
|
||||
|
||||
|
||||
func take_damage(damage: int, damage_type: Data.DamageIndicationType = Data.DamageIndicationType.TOWER, damage_point: Vector3 = global_position) -> void:
|
||||
current_health -= damage
|
||||
health_changed.emit(current_health)
|
||||
if damage > 0:
|
||||
spawn_damage_indicator(damage, damage_point, damage_type)
|
||||
if current_health <= 0:
|
||||
die()
|
||||
|
||||
|
||||
func heal_damage(healing: int) -> void:
|
||||
current_health += healing
|
||||
if current_health > max_health:
|
||||
current_health = max_health
|
||||
health_changed.emit(current_health)
|
||||
|
||||
|
||||
func apply_effect(effect: Effect) -> void:
|
||||
health.take_damage(effect.damage)
|
||||
take_damage(effect.damage)
|
||||
for status: StatusEffect in effect.status_effects:
|
||||
status_manager.add_effect(status)
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://b0nady5xm88bo"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://b0nady5xm88bo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ejqql2660u6h" path="res://Worlds/GreenPlanet/Enemies/enemy_controller.gd" id="1_fwsjt"]
|
||||
[ext_resource type="PackedScene" uid="uid://ri8r03wqy80t" path="res://Scenes/8_direction_sprite.tscn" id="2_o7jmg"]
|
||||
[ext_resource type="Script" uid="uid://bamhci3kawuyt" path="res://Scripts/health.gd" id="2_swu53"]
|
||||
[ext_resource type="PackedScene" uid="uid://canrxnpxcugc2" path="res://Scenes/corpse.tscn" id="2_y7h25"]
|
||||
[ext_resource type="Texture2D" uid="uid://dj13g1w14mekw" path="res://Assets/Textures/eye_dog.png" id="3_naknq"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqtew0t8sttpm" path="res://Scenes/damage_particle.tscn" id="4_tn1tu"]
|
||||
[ext_resource type="Script" uid="uid://cummt2be3r1gq" path="res://Scripts/hitbox.gd" id="7_5eo4w"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1fn60m6xfcsq" path="res://Assets/Textures/minimap_enemy.png" id="9_f8btv"]
|
||||
[ext_resource type="Script" uid="uid://b62xnsbki8axa" path="res://Scripts/EnemyAI/pathing_controller.gd" id="10_gljle"]
|
||||
@@ -23,20 +21,15 @@ region = Rect2(0, 0, 32, 32)
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_4tj6k"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[node name="WalkingEnemy" type="CharacterBody3D" node_paths=PackedStringArray("status_manager", "movement_controller", "health", "d_n") groups=["Enemies"]]
|
||||
[node name="WalkingEnemy" type="CharacterBody3D" node_paths=PackedStringArray("status_manager", "movement_controller", "d_n") groups=["Enemies"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_fwsjt")
|
||||
status_manager = NodePath("StatusEffector")
|
||||
movement_controller = NodePath("PathingController")
|
||||
health = NodePath("Health")
|
||||
d_n = NodePath("Node3D")
|
||||
corpse_scene = ExtResource("2_y7h25")
|
||||
|
||||
[node name="Health" type="Node" parent="."]
|
||||
script = ExtResource("2_swu53")
|
||||
damage_particle_scene = ExtResource("4_tn1tu")
|
||||
|
||||
[node name="DirectionSprite" parent="." instance=ExtResource("2_o7jmg")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.585, 0)
|
||||
pixel_size = 0.04
|
||||
@@ -95,7 +88,3 @@ metadata/_custom_type_script = "uid://cojjgevmbhwal"
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.429125, 0)
|
||||
|
||||
[connection signal="health_changed" from="Health" to="SubViewport/HealthBar" method="on_health_changed"]
|
||||
[connection signal="health_depleted" from="Health" to="." method="die"]
|
||||
[connection signal="took_damage" from="Hitbox" to="Health" method="take_damage"]
|
||||
|
||||
Reference in New Issue
Block a user