some variable renaming and messing with exp... still eluding me
This commit is contained in:
parent
f8e46af129
commit
b986b4cb7a
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
[node name="NPCEnemy" type="CharacterBody2D"]
|
[node name="NPCEnemy" type="CharacterBody2D"]
|
||||||
script = ExtResource("1_ec4cy")
|
script = ExtResource("1_ec4cy")
|
||||||
|
attack_base = 0
|
||||||
npcDifficulty = 1
|
npcDifficulty = 1
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
|
||||||
|
@ -43,20 +43,28 @@ text = "Load
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Exit"
|
text = "Exit"
|
||||||
|
|
||||||
[node name="TestButton" type="Button" parent="MenuButtons"]
|
[node name="DebugButtons" type="VBoxContainer" parent="MenuButtons"]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="TestButton" type="Button" parent="MenuButtons/DebugButtons"]
|
||||||
|
layout_mode = 2
|
||||||
text = "Test
|
text = "Test
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="AutostartToggle" type="CheckButton" parent="MenuButtons"]
|
[node name="AutostartToggle" type="CheckButton" parent="MenuButtons/DebugButtons"]
|
||||||
visible = false
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Auto Play"
|
text = "Auto Play"
|
||||||
|
|
||||||
|
[node name="EnemyDamageToggle" type="CheckButton" parent="MenuButtons/DebugButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="EnemyNumbersToggle" type="CheckButton" parent="MenuButtons/DebugButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
[connection signal="pressed" from="MenuButtons/PlayButton" to="." method="_on_play_button_pressed"]
|
[connection signal="pressed" from="MenuButtons/PlayButton" to="." method="_on_play_button_pressed"]
|
||||||
[connection signal="pressed" from="MenuButtons/SaveButton" to="." method="_on_save_button_pressed"]
|
[connection signal="pressed" from="MenuButtons/SaveButton" to="." method="_on_save_button_pressed"]
|
||||||
[connection signal="pressed" from="MenuButtons/LoadButton" to="." method="_on_load_button_pressed"]
|
[connection signal="pressed" from="MenuButtons/LoadButton" to="." method="_on_load_button_pressed"]
|
||||||
[connection signal="pressed" from="MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"]
|
[connection signal="pressed" from="MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"]
|
||||||
[connection signal="pressed" from="MenuButtons/TestButton" to="." method="_on_test_button_pressed"]
|
[connection signal="pressed" from="MenuButtons/DebugButtons/TestButton" to="." method="_on_test_button_pressed"]
|
||||||
[connection signal="toggled" from="MenuButtons/AutostartToggle" to="." method="_on_autostart_toggle_toggled"]
|
[connection signal="toggled" from="MenuButtons/DebugButtons/AutostartToggle" to="." method="_on_autostart_toggle_toggled"]
|
||||||
|
@ -12,6 +12,7 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_6qo1s")
|
theme_override_styles/panel = SubResource("StyleBoxEmpty_6qo1s")
|
||||||
script = ExtResource("1_83d5k")
|
script = ExtResource("1_83d5k")
|
||||||
|
spawn_enemy_count = 3
|
||||||
|
|
||||||
[node name="SpawnTimer" type="Timer" parent="."]
|
[node name="SpawnTimer" type="Timer" parent="."]
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ var playerPos
|
|||||||
enum TargetType {
|
enum TargetType {
|
||||||
SINGLE,
|
SINGLE,
|
||||||
CLEAVE,
|
CLEAVE,
|
||||||
|
CONE,
|
||||||
CHAIN,
|
CHAIN,
|
||||||
SWIPE,
|
SWIPE,
|
||||||
WAVE,
|
WAVE,
|
||||||
@ -18,8 +19,8 @@ enum TargetType {
|
|||||||
|
|
||||||
|
|
||||||
@export var target_type := TargetType.SINGLE
|
@export var target_type := TargetType.SINGLE
|
||||||
@export var target_angle := 2*PI
|
@export var target_angle := PI # mobs can't get behind
|
||||||
@export var base_cooldown := 0.0
|
@export var base_cooldown := 0.2
|
||||||
@export var attack_damage := 400
|
@export var attack_damage := 400
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -22,6 +22,9 @@ class World:
|
|||||||
CREATURE,
|
CREATURE,
|
||||||
MONSTER,
|
MONSTER,
|
||||||
}
|
}
|
||||||
|
enum Tier {
|
||||||
|
I, II, III, IV, V, VI, VII, VIII, IX, X
|
||||||
|
}
|
||||||
|
|
||||||
class Ability:
|
class Ability:
|
||||||
enum PDamageType {
|
enum PDamageType {
|
||||||
|
@ -4,15 +4,14 @@ extends CharacterBody2D
|
|||||||
|
|
||||||
|
|
||||||
enum NPCDifficulty {MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG}
|
enum NPCDifficulty {MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG}
|
||||||
enum NPCTier {I, II, III, IV, V, VI, VII, VIII, IX, X}
|
|
||||||
|
|
||||||
signal npc_died(npcTier: NPCTier)
|
signal npc_died(npcTier: Globals.World.Tier)
|
||||||
|
|
||||||
@export var charName := "Character"
|
@export var charName := "Character"
|
||||||
@export var maxHealth := 10
|
@export var maxHealth := 10
|
||||||
@export var damageTaken := 0
|
@export var damageTaken := 0
|
||||||
@export var npcDifficulty: NPCDifficulty
|
@export var npcDifficulty: NPCDifficulty
|
||||||
@export var npcTier: NPCTier
|
@export var npcTier: Globals.World.Tier
|
||||||
@export var faction: Globals.World.Faction
|
@export var faction: Globals.World.Faction
|
||||||
|
|
||||||
func _random_mod_health() -> void:
|
func _random_mod_health() -> void:
|
||||||
@ -40,7 +39,7 @@ func _random_mod_health() -> void:
|
|||||||
|
|
||||||
# func _init() -> void:
|
# func _init() -> void:
|
||||||
# self.npcDifficulty = NPCDifficulty.NORMAL
|
# self.npcDifficulty = NPCDifficulty.NORMAL
|
||||||
# self.npcTier = NPCTier.I
|
# self.npcTier = Globals.Tier.I
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
class_name Player
|
class_name Player
|
||||||
extends VBoxContainer
|
extends VBoxContainer
|
||||||
|
|
||||||
const EXP_COEFFICIENT := 10
|
|
||||||
const EXP_EXPONENT := 2.4
|
@export var health_regen := 1
|
||||||
|
@export var resource_regen := 1
|
||||||
|
|
||||||
var area_exp := 0.0
|
var area_exp := 0.0
|
||||||
var current_health: int
|
var current_health: int
|
||||||
@ -73,7 +74,7 @@ func _update_player_health(change: int) -> void:
|
|||||||
if current_health <= 0:
|
if current_health <= 0:
|
||||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(0)
|
$PlayerHealthBar/PlayerHealthCurrent.text = str(0)
|
||||||
$PlayerHealthBar.value = 0
|
$PlayerHealthBar.value = 0
|
||||||
print("You died.")
|
print("%s - You died." % Globals.elapsed_time_format(Globals.elapsed_time(PlayerState.zone_duration)))
|
||||||
# TODO: change to scene transition after slowing for a couple seconds
|
# TODO: change to scene transition after slowing for a couple seconds
|
||||||
# Engine.time_scale = 0.0001
|
# Engine.time_scale = 0.0001
|
||||||
# get_tree().paused = true
|
# get_tree().paused = true
|
||||||
@ -115,8 +116,10 @@ func _on_enemy_damaged_player(damage: int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _calculate_player_level() -> float:
|
func _calculate_player_level() -> float:
|
||||||
|
const EXP_COEFFICIENT := 0.04
|
||||||
var current_exp = PlayerState.experience
|
var current_exp = PlayerState.experience
|
||||||
return pow(current_exp / EXP_COEFFICIENT, 1 / EXP_EXPONENT) + 1
|
return EXP_COEFFICIENT * pow(current_exp, 0.5) + 1
|
||||||
|
# return pow(current_exp / EXP_COEFFICIENT, 1 / EXP_EXPONENT) + 1
|
||||||
# return log((0.2 * current_exp + 5) * 0.2) + 1
|
# return log((0.2 * current_exp + 5) * 0.2) + 1
|
||||||
|
|
||||||
|
|
||||||
@ -126,13 +129,16 @@ func _get_level_progress_percent() -> float:
|
|||||||
|
|
||||||
|
|
||||||
func _on_quest_completed() -> void:
|
func _on_quest_completed() -> void:
|
||||||
|
const QUEST_EXP_BASE := 10
|
||||||
var previous_whole_level = floor(PlayerState.level)
|
var previous_whole_level = floor(PlayerState.level)
|
||||||
|
var quest_exp = QUEST_EXP_BASE ** (PlayerState.world_tier + 1)
|
||||||
|
area_exp += quest_exp
|
||||||
PlayerState.experience += area_exp
|
PlayerState.experience += area_exp
|
||||||
PlayerState.level = _calculate_player_level()
|
PlayerState.level = _calculate_player_level()
|
||||||
var current_whole_level = floor(PlayerState.level)
|
var current_whole_level = floor(PlayerState.level)
|
||||||
if current_whole_level > previous_whole_level:
|
if current_whole_level > previous_whole_level:
|
||||||
SignalBus.player_leveled_up.emit()
|
SignalBus.player_leveled_up.emit()
|
||||||
print("You leveled up to %s!" % current_whole_level)
|
print("%s - You leveled up to %s!" % [Globals.elapsed_time_format(Globals.elapsed_time(PlayerState.zone_duration)), current_whole_level])
|
||||||
$PlayerExpBar.value = _get_level_progress_percent()
|
$PlayerExpBar.value = _get_level_progress_percent()
|
||||||
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.level))
|
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.level))
|
||||||
# if Globals.debug:
|
# if Globals.debug:
|
||||||
@ -144,5 +150,5 @@ func _on_quest_completed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_regen_timer_timeout() -> void:
|
func _on_regen_timer_timeout() -> void:
|
||||||
_update_player_health(1)
|
_update_player_health(health_regen)
|
||||||
_update_player_resource(1)
|
_update_player_resource(resource_regen)
|
||||||
|
@ -12,3 +12,4 @@ var base_health := 100
|
|||||||
var base_resource := 100
|
var base_resource := 100
|
||||||
var weapon_type: Globals.Weapon.WeaponType
|
var weapon_type: Globals.Weapon.WeaponType
|
||||||
var zone_duration := 0
|
var zone_duration := 0
|
||||||
|
var world_tier := Globals.World.Tier.I
|
||||||
|
@ -50,7 +50,7 @@ func _generate_random_quest() -> void:
|
|||||||
|
|
||||||
func _on_enemy_died(
|
func _on_enemy_died(
|
||||||
_enemyDifficulty: NPC.NPCDifficulty,
|
_enemyDifficulty: NPC.NPCDifficulty,
|
||||||
_enemyTier: NPC.NPCTier,
|
_enemyTier: Globals.World.Tier,
|
||||||
enemyFaction: Globals.World.Faction,
|
enemyFaction: Globals.World.Faction,
|
||||||
):
|
):
|
||||||
_quest_goal_check(enemyFaction)
|
_quest_goal_check(enemyFaction)
|
||||||
|
@ -4,10 +4,10 @@ extends Node
|
|||||||
|
|
||||||
signal enemy_died(
|
signal enemy_died(
|
||||||
npcDifficulty: NPC.NPCDifficulty,
|
npcDifficulty: NPC.NPCDifficulty,
|
||||||
npcTier: NPC.NPCTier,
|
npcTier: Globals.World.Tier,
|
||||||
faction: Globals.World.Faction,
|
faction: Globals.World.Faction,
|
||||||
)
|
)
|
||||||
signal enemy_damaged_player(damage : int)
|
signal enemy_damaged_player(damage: int)
|
||||||
signal player_leveled_up()
|
signal player_leveled_up()
|
||||||
signal quest_generated(quest: Quest)
|
signal quest_generated(quest: Quest)
|
||||||
signal quest_completed
|
signal quest_completed
|
||||||
|
@ -7,6 +7,7 @@ enum GoalType {KILL, FIND}
|
|||||||
|
|
||||||
@export var area_type := Globals.World.AreaType.WILDS
|
@export var area_type := Globals.World.AreaType.WILDS
|
||||||
@export var spawnTimerValue = 10.0
|
@export var spawnTimerValue = 10.0
|
||||||
|
@export var spawn_enemy_count := 1
|
||||||
|
|
||||||
|
|
||||||
var middleX: float
|
var middleX: float
|
||||||
@ -22,7 +23,7 @@ func _ready() -> void:
|
|||||||
_generate_quest()
|
_generate_quest()
|
||||||
|
|
||||||
$SpawnTimer.start(spawnTimerValue)
|
$SpawnTimer.start(spawnTimerValue)
|
||||||
_spawn_enemies(randi_range(1, 5))
|
_spawn_enemies(spawn_enemy_count)
|
||||||
# _spawn_enemies(5)
|
# _spawn_enemies(5)
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ func _spawn_enemies(numEnemies: int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_spawn_timer_timeout() -> void:
|
func _on_spawn_timer_timeout() -> void:
|
||||||
_spawn_enemies(randi_range(1, 5))
|
_spawn_enemies(spawn_enemy_count)
|
||||||
|
|
||||||
|
|
||||||
func _on_area_continue_pressed() -> void:
|
func _on_area_continue_pressed() -> void:
|
||||||
|
@ -4,9 +4,8 @@ extends Control
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Engine.time_scale = 1.0
|
Engine.time_scale = 1.0
|
||||||
if OS.is_debug_build():
|
if OS.is_debug_build():
|
||||||
$MenuButtons/TestButton.show()
|
$MenuButtons/DebugButtons.show()
|
||||||
$MenuButtons/AutostartToggle.show()
|
$MenuButtons/DebugButtons/AutostartToggle.button_pressed = Globals.debugAutoPlayEnabled
|
||||||
$MenuButtons/AutostartToggle.button_pressed = Globals.debugAutoPlayEnabled
|
|
||||||
await get_tree().create_timer(5).timeout
|
await get_tree().create_timer(5).timeout
|
||||||
if Globals.debugAutoPlayEnabled:
|
if Globals.debugAutoPlayEnabled:
|
||||||
_enter_loaded_save()
|
_enter_loaded_save()
|
||||||
@ -17,6 +16,7 @@ func _on_play_button_pressed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _enter_loaded_save() -> void:
|
func _enter_loaded_save() -> void:
|
||||||
|
# TODO: make this load a "where do you want to go/what do you want to do?"
|
||||||
get_tree().change_scene_to_file("res://scenes/combatUIScene.tscn")
|
get_tree().change_scene_to_file("res://scenes/combatUIScene.tscn")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user