fix target check, rename some variables

This commit is contained in:
tonydero 2024-10-18 13:24:11 -06:00
parent 9ab9d2da7d
commit 06d03773b5
11 changed files with 53 additions and 45 deletions

View File

@ -14,7 +14,11 @@ script = ExtResource("1_o0k38")
[node name="QuestProgress" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="GoalTextVal" type="Label" parent="QuestProgress"]
[node name="GoalTypeVal" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "Quest Objective"
[node name="KillTypeVal" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "Quest Objective"

View File

@ -22,7 +22,6 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_gc1kb")
debug = true
spawnTimerValue = 0.75
[node name="SpawnTimer" type="Timer" parent="."]
@ -125,7 +124,7 @@ layout_mode = 2
size_flags_horizontal = 6
attack_range = 200
target_type = 3
attack_damage = 500
attack_damage = 50
auto_speed = 5.0
[node name="AbilityA3" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")]

View File

@ -65,11 +65,13 @@ func _deal_idle_damage(enemiesList) -> void:
match target_type:
TargTypes.SINGLE:
var target = _get_target(enemiesList)
target.damageTaken += attack_damage
if target:
target.damageTaken += attack_damage
_:
var targets = _get_targets(enemiesList)
for target in targets:
target.damageTaken += attack_damage
if targets:
for target in targets:
target.damageTaken += attack_damage

View File

@ -3,16 +3,16 @@ class_name NPC
extends CharacterBody2D
enum NPCDifficulties {MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG}
enum NPCTiers {I, II, III, IV, V, VI, VII, VIII, IX, X}
enum NPCDifficulty {MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG}
enum NPCTier {I, II, III, IV, V, VI, VII, VIII, IX, X}
signal npc_died(npcTier: NPCTiers)
signal npc_died(npcTier: NPCTier)
@export var charName := "Character"
@export var maxHealth := 10
@export var damageTaken := 0
@export var npcDifficulty: NPCDifficulties
@export var npcTier: NPCTiers
@export var npcDifficulty: NPCDifficulty
@export var npcTier: NPCTier
func _random_mod_health() -> void:
randomize()
@ -21,15 +21,15 @@ func _random_mod_health() -> void:
self.maxHealth *= noise_factor
# difficulty factor
match self.npcDifficulty:
NPCDifficulties.MINION:
NPCDifficulty.MINION:
self.maxHealth /= 2
NPCDifficulties.ELITE:
NPCDifficulty.ELITE:
self.maxHealth *= 2
NPCDifficulties.BOSS:
NPCDifficulty.BOSS:
self.maxHealth *= 4
NPCDifficulties.ELITEBOSS:
NPCDifficulty.ELITEBOSS:
self.maxHealth *= 8
NPCDifficulties.BBEG:
NPCDifficulty.BBEG:
self.maxHealth *= 16
# npcTier factor
self.maxHealth *= exp(self.npcTier)
@ -38,8 +38,8 @@ func _random_mod_health() -> void:
func _init() -> void:
self.npcDifficulty = NPCDifficulties.NORMAL
self.npcTier = NPCTiers.I
self.npcDifficulty = NPCDifficulty.NORMAL
self.npcTier = NPCTier.I
func _ready() -> void:

View File

@ -3,7 +3,7 @@ class_name NPCEnemy
extends NPC
@export var killType: WorldArea.KillTypes = WorldArea.KillTypes.NATURAL
@export var killType: WorldArea.Faction = WorldArea.Faction.CREATURE
var target
var speed := 200
@ -11,8 +11,9 @@ var prevCollisions := 0
func _init() -> void:
self.npcDifficulty = NPCDifficulties.NORMAL
self.npcTier = NPCTiers.I
# TODO: randomize within area restrictions? or put this in area?
self.npcDifficulty = NPCDifficulty.NORMAL
self.npcTier = NPCTier.I
func _ready() -> void:

View File

@ -2,8 +2,8 @@ class_name Quest
extends PanelContainer
@export var goalType := WorldArea.GoalTypes.KILLMANY
@export var killType := WorldArea.KillTypes.NATURAL
@export var goalType := WorldArea.GoalType.KILL
@export var faction := WorldArea.Faction.CREATURE
@export var goalTotal := 1
@export var goalCurrent := 0
@ -24,17 +24,18 @@ func _process(_delta: float) -> void:
func _set_goal_text() -> void:
var factionStr = WorldArea.Faction.keys()[self.faction].capitalize()
match self.goalType:
WorldArea.GoalTypes.KILLMANY:
$QuestProgress/GoalTextVal.text = "Kill Many"
WorldArea.GoalType.KILL:
$QuestProgress/GoalTypeVal.text = "Kill " + factionStr + "s"
func _set_goal_val() -> void:
$QuestProgress/GoalVal.text = str(self.goalTotal)
func _quest_goal_check(enemyKillType: WorldArea.KillTypes) -> void:
if enemyKillType == self.killType:
func _quest_goal_check(enemyKillType: WorldArea.Faction) -> void:
if enemyKillType == self.faction:
self.goalCurrent += 1
$QuestProgress/CompletedVal.text = str(self.goalCurrent)
if self.goalCurrent == self.goalTotal:
@ -57,8 +58,8 @@ func _generate_random_quest() -> void:
# self.goalType = GoalTypes.
# match self.goalType:
# GoalTypes.KILLMANY:
# self.killType = KillTypes.NATURAL
# self.faction = KillTypes.NATURAL
func _on_enemy_died(_enemyDifficulty: NPC.NPCDifficulties, enemyKillType: WorldArea.KillTypes):
_quest_goal_check(enemyKillType)
func _on_enemy_died(_enemyDifficulty: NPC.NPCDifficulty, enemyFaction: WorldArea.Faction):
_quest_goal_check(enemyFaction)

View File

@ -1,5 +1,6 @@
# signal bus to relay signals
extends Node
signal enemy_died(npcDifficulty: NPC.NPCDifficulties, killType: WorldArea.KillTypes)
signal enemy_died(npcDifficulty: NPC.NPCDifficulty, faction: WorldArea.Faction)
signal quest_completed

View File

@ -1,25 +1,25 @@
extends Node
func format_label_difficulty(label: Node, difficulty: NPC.NPCDifficulties) -> void:
func format_label_difficulty(label: Node, difficulty: NPC.NPCDifficulty) -> void:
label.label_settings.outline_size = 4
match difficulty:
NPC.NPCDifficulties.MINION:
NPC.NPCDifficulty.MINION:
label.label_settings.outline_color = Color.BLACK
label.label_settings.font_color = Color.LIGHT_GRAY
NPC.NPCDifficulties.NORMAL:
NPC.NPCDifficulty.NORMAL:
label.label_settings.outline_color = Color.DARK_GREEN
label.label_settings.font_color = Color.LIME_GREEN
NPC.NPCDifficulties.ELITE:
NPC.NPCDifficulty.ELITE:
label.label_settings.outline_color = Color.DARK_BLUE
label.label_settings.font_color = Color.DARK_CYAN
NPC.NPCDifficulties.BOSS:
NPC.NPCDifficulty.BOSS:
label.label_settings.outline_color = Color.PURPLE
label.label_settings.font_color = Color.MAGENTA
NPC.NPCDifficulties.ELITEBOSS:
NPC.NPCDifficulty.ELITEBOSS:
label.label_settings.outline_color = Color.ORANGE_RED
label.label_settings.font_color = Color.ORANGE
NPC.NPCDifficulties.BBEG:
NPC.NPCDifficulty.BBEG:
label.label_settings.font_color = Color.GOLD
label.label_settings.outline_size = 8
label.label_settings.outline_color = Color.DARK_RED

View File

@ -3,8 +3,8 @@ class_name WorldArea
extends PanelContainer
enum GoalTypes { KILLMANY, KILLFEW, KILLONE, GETMANY, GETFEW, GETONE }
enum KillTypes { NATURAL, VOID }
enum GoalType {KILL, FIND}
enum Faction {CREATURE, MONSTER}
@export var area_type := Globals.World.AreaTypes.WILDS

View File

@ -21,7 +21,7 @@ func _on_button_instantiate_pressed() -> void:
enemies[i].position = Vector2(posX, middleY)
enemies[0].get_node("%NPCNameLabel").text = "Test"
var bossEnemy = load("res://scenes/npc.tscn").instantiate()
bossEnemy.npcDifficulty = NPC.NPCDifficulties.BOSS
bossEnemy.npcDifficulty = NPC.NPCDifficulty.BOSS
add_child(bossEnemy)
bossEnemy.position = Vector2(middleX, upperY)
#print(bossEnemy.npcDifficulty)

View File

@ -9,13 +9,13 @@ func _on_exit_button_pressed() -> void:
func _on_test_button_pressed() -> void:
var rand_difficulty = NPC.NPCDifficulties.values().pick_random()
var rand_tier = NPC.NPCTiers.values().pick_random()
var rand_difficulty = NPC.NPCDifficulty.values().pick_random()
var rand_tier = NPC.NPCTier.values().pick_random()
var anNPC = NPC.new()
%TestNMEMaxHealthVal.text = str(anNPC.maxHealth)
#TestEMaxHealthVal.label_settings = LabelSettings.new()
%TestNMEName.text = str(NPC.NPCDifficulties.find_key(anNPC.npcDifficulty))
%TestNMETierVal.text = str(NPC.NPCTiers.find_key(anNPC.npcTier))
%TestNMEName.text = str(NPC.NPCDifficulty.find_key(anNPC.npcDifficulty))
%TestNMETierVal.text = str(NPC.NPCTier.find_key(anNPC.npcTier))
# style the name label based on the difficulty
styling.format_label_difficulty(%TestNMEName, anNPC.npcDifficulty)
#anNPC.position = Vector2(64, 64)