From 06d03773b5ed3bd1e10ea0575c693137dba8c200 Mon Sep 17 00:00:00 2001 From: tonydero Date: Fri, 18 Oct 2024 13:24:11 -0600 Subject: [PATCH] fix target check, rename some variables --- scenes/quest.tscn | 6 +++++- scenes/testScrollScene.tscn | 3 +-- scripts/AbilityPlayer.gd | 8 +++++--- scripts/NPC.gd | 24 ++++++++++++------------ scripts/NPCEnemy.gd | 7 ++++--- scripts/Quest.gd | 19 ++++++++++--------- scripts/SignalBus.gd | 3 ++- scripts/Styling.gd | 14 +++++++------- scripts/WorldArea.gd | 4 ++-- scripts/test_instance_scene.gd | 2 +- scripts/test_scene.gd | 8 ++++---- 11 files changed, 53 insertions(+), 45 deletions(-) diff --git a/scenes/quest.tscn b/scenes/quest.tscn index e812bd3..17028de 100644 --- a/scenes/quest.tscn +++ b/scenes/quest.tscn @@ -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" diff --git a/scenes/testScrollScene.tscn b/scenes/testScrollScene.tscn index 20b3a2e..e575f39 100644 --- a/scenes/testScrollScene.tscn +++ b/scenes/testScrollScene.tscn @@ -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")] diff --git a/scripts/AbilityPlayer.gd b/scripts/AbilityPlayer.gd index c1397c9..8d4cd6d 100644 --- a/scripts/AbilityPlayer.gd +++ b/scripts/AbilityPlayer.gd @@ -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 diff --git a/scripts/NPC.gd b/scripts/NPC.gd index 3cc9d3c..b2c58b4 100644 --- a/scripts/NPC.gd +++ b/scripts/NPC.gd @@ -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: diff --git a/scripts/NPCEnemy.gd b/scripts/NPCEnemy.gd index 04eff2c..cbbd003 100644 --- a/scripts/NPCEnemy.gd +++ b/scripts/NPCEnemy.gd @@ -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: diff --git a/scripts/Quest.gd b/scripts/Quest.gd index cc34791..d9a60fa 100644 --- a/scripts/Quest.gd +++ b/scripts/Quest.gd @@ -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) diff --git a/scripts/SignalBus.gd b/scripts/SignalBus.gd index 27b2c10..f4706d9 100644 --- a/scripts/SignalBus.gd +++ b/scripts/SignalBus.gd @@ -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 \ No newline at end of file diff --git a/scripts/Styling.gd b/scripts/Styling.gd index 993b72d..c7922ef 100644 --- a/scripts/Styling.gd +++ b/scripts/Styling.gd @@ -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 diff --git a/scripts/WorldArea.gd b/scripts/WorldArea.gd index 19d0a92..e09e3a0 100644 --- a/scripts/WorldArea.gd +++ b/scripts/WorldArea.gd @@ -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 diff --git a/scripts/test_instance_scene.gd b/scripts/test_instance_scene.gd index 4ac5b6d..54d028f 100644 --- a/scripts/test_instance_scene.gd +++ b/scripts/test_instance_scene.gd @@ -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) diff --git a/scripts/test_scene.gd b/scripts/test_scene.gd index 3b1ef3b..b4547a3 100644 --- a/scripts/test_scene.gd +++ b/scripts/test_scene.gd @@ -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)