more experience experimentation, new elapsed time calculating and formatting funcitons, attempt to fix node leak failed

This commit is contained in:
tonydero 2024-10-25 14:46:19 -06:00
parent 0cccf62b6c
commit ec6b012341
8 changed files with 98 additions and 38 deletions

View File

@ -2,22 +2,65 @@ extends SceneTree
func level_eqn(experience):
return log(0.2 * experience + 5) + 1
# return log(0.2 * experience + 5) + 1
return pow(experience / 50, 0.5) + 1
func experience_eqn(level):
# return 5 * exp(level - 1) - 5
return 100 * (level - 1)**3
return 50 * pow((level - 1), 1.7)
func avg_difficulty():
return (1 + (2.0 / 100) + (3.0 / 500) + (4.0 / 2500) + (5.0 / 25000)) / 5.0
func exp_kill_eqn(level):
var difficulty = avg_difficulty()
# var experience_per_kill = ((level / 10) + 1) ** avg_difficulty ** 3
var tier = (level - 1) / 10
return (tier + 1) * difficulty
func kill_eqn(level):
var avg_difficulty = 2
# var experience_per_kill = ((level / 10) + 1) ** avg_difficulty ** 3
var experience_per_kill = ((level - 1)/10) + 1 * avg_difficulty
return experience_eqn(level) / experience_per_kill
var experience_per_kill = exp_kill_eqn(level)
return (experience_eqn(level) - experience_eqn(level - 1)) / experience_per_kill
func time_per_level(level):
var seconds_per_kill = 2
var kills = kill_eqn(level)
return kills * seconds_per_kill
func elapsed_time(seconds: float) -> Array:
# returns array of time in format [seconds_remainder, minutes, hours, days]
var seconds_remainder = fmod(seconds, 60)
var seconds_int = floori(seconds)
var minutes = seconds_int / 60 % 60
var hours = seconds_int / 60 / 60 % 24
var days = seconds_int / 60 / 60 / 24
return [seconds_remainder, minutes, hours, days]
func elapsed_time_format(elapsed_time: Array, round_seconds: bool = true) -> String:
var seconds_format = "%02.3f"
var days_format = "%d days "
if elapsed_time[3] == 0:
days_format = ""
elapsed_time = elapsed_time.slice(0,3)
if round_seconds:
seconds_format = "%02d"
elapsed_time.reverse()
return (days_format + "%02d:%02d:" + seconds_format) % elapsed_time
func _init() -> void:
for level in range(1, 101):
print("%s: %s" % [level, kill_eqn(level)])
var total_time = 0
for level in range(2, 101):
total_time += time_per_level(level)
print("%s: %.1f @ %s per kill taking %s" % [level, kill_eqn(level), exp_kill_eqn(level), elapsed_time_format(elapsed_time(time_per_level(level)))])
print(elapsed_time_format(elapsed_time(total_time)))
# print(elapsed_time_format(elapsed_time(999*24*60*60)))
quit()

View File

@ -369,52 +369,52 @@ layout_mode = 2
size_flags_horizontal = 8
theme_override_styles/panel = SubResource("StyleBoxEmpty_co4b5")
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/UIRight"]
[node name="InfoPanel" type="VBoxContainer" parent="MarginContainer/UIRight"]
layout_mode = 2
[node name="SystemClock" type="Label" parent="MarginContainer/UIRight/VBoxContainer"]
[node name="SystemClock" type="Label" parent="MarginContainer/UIRight/InfoPanel"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "HH:MM:SS"
[node name="ClockTimer" type="Timer" parent="MarginContainer/UIRight/VBoxContainer/SystemClock"]
[node name="ClockTimer" type="Timer" parent="MarginContainer/UIRight/InfoPanel/SystemClock"]
autostart = true
[node name="ZoneTimer" type="HBoxContainer" parent="MarginContainer/UIRight/VBoxContainer"]
[node name="ZoneTimer" type="HBoxContainer" parent="MarginContainer/UIRight/InfoPanel"]
layout_mode = 2
size_flags_horizontal = 8
[node name="ZTLabel" type="Label" parent="MarginContainer/UIRight/VBoxContainer/ZoneTimer"]
[node name="ZTLabel" type="Label" parent="MarginContainer/UIRight/InfoPanel/ZoneTimer"]
layout_mode = 2
text = "Zone:"
[node name="ZTVal" type="Label" parent="MarginContainer/UIRight/VBoxContainer/ZoneTimer"]
[node name="ZTVal" type="Label" parent="MarginContainer/UIRight/InfoPanel/ZoneTimer"]
unique_name_in_owner = true
layout_mode = 2
text = "HH:MM:SS"
text = "DDD HH:MM:SS"
[node name="AreaTimer" type="HBoxContainer" parent="MarginContainer/UIRight/VBoxContainer"]
[node name="AreaTimer" type="HBoxContainer" parent="MarginContainer/UIRight/InfoPanel"]
layout_mode = 2
size_flags_horizontal = 8
[node name="ATLabel" type="Label" parent="MarginContainer/UIRight/VBoxContainer/AreaTimer"]
[node name="ATLabel" type="Label" parent="MarginContainer/UIRight/InfoPanel/AreaTimer"]
layout_mode = 2
text = "Area:"
[node name="ATVal" type="Label" parent="MarginContainer/UIRight/VBoxContainer/AreaTimer"]
[node name="ATVal" type="Label" parent="MarginContainer/UIRight/InfoPanel/AreaTimer"]
unique_name_in_owner = true
layout_mode = 2
text = "HH:MM:SS"
text = "DDD HH:MM:SS"
[node name="AreaCount" type="HBoxContainer" parent="MarginContainer/UIRight/VBoxContainer"]
[node name="AreaCount" type="HBoxContainer" parent="MarginContainer/UIRight/InfoPanel"]
layout_mode = 2
[node name="AreaCountLabel" type="Label" parent="MarginContainer/UIRight/VBoxContainer/AreaCount"]
[node name="AreaCountLabel" type="Label" parent="MarginContainer/UIRight/InfoPanel/AreaCount"]
layout_mode = 2
text = "Areas Completed:"
[node name="AreaCountVal" type="Label" parent="MarginContainer/UIRight/VBoxContainer/AreaCount"]
[node name="AreaCountVal" type="Label" parent="MarginContainer/UIRight/InfoPanel/AreaCount"]
unique_name_in_owner = true
layout_mode = 2
text = "0"
@ -422,4 +422,4 @@ text = "0"
[connection signal="pressed" from="MarginContainer/UITop/ContinueButton" to="." method="_on_continue_button_pressed"]
[connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"]
[connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"]
[connection signal="timeout" from="MarginContainer/UIRight/VBoxContainer/SystemClock/ClockTimer" to="." method="_on_clock_timer_timeout"]
[connection signal="timeout" from="MarginContainer/UIRight/InfoPanel/SystemClock/ClockTimer" to="." method="_on_clock_timer_timeout"]

View File

@ -6,6 +6,7 @@
[node name="NPCEnemy" type="CharacterBody2D"]
script = ExtResource("1_ec4cy")
attack_base = 0
npcDifficulty = 1
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]

View File

@ -4,7 +4,7 @@
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dv3o6"]
[node name="PanelContainer" type="PanelContainer"]
[node name="QuestDisplay" type="PanelContainer"]
offset_left = 175.0
offset_right = 175.0
offset_bottom = 40.0

View File

@ -77,6 +77,29 @@ func fade_node(node: Node, direction: String, duration: float) -> void:
node.hide()
_:
print("Unknown fade direction")
func elapsed_time(seconds: float) -> Array:
# returns array of time in format [seconds_remainder, minutes, hours, days]
var seconds_remainder = fmod(seconds, 60)
var seconds_int = floori(seconds)
var minutes = seconds_int / 60 % 60
var hours = seconds_int / 60 / 60 % 24
var days = seconds_int / 60 / 60 / 24
return [seconds_remainder, minutes, hours, days]
func elapsed_time_format(elapsed_time: Array, round_seconds: bool = true) -> String:
var seconds_format = "%02.3f"
var days_format = "%d days "
if elapsed_time[3] == 0:
days_format = ""
elapsed_time = elapsed_time.slice(0,3)
if round_seconds:
seconds_format = "%02d"
elapsed_time.reverse()
return (days_format + "%02d:%02d:" + seconds_format) % elapsed_time
func _input(event: InputEvent) -> void:

View File

@ -4,7 +4,7 @@ extends NPC
var target
var attack_base := 1
@export var attack_base := 1
var attack_damage := 0
var speed := 200
var prevCollisions := 0

View File

@ -10,7 +10,6 @@ extends PanelContainer
@export var goalTotal := 1
var goalCurrent := 0
var questComplete := false
func _ready() -> void:
SignalBus.enemy_died.connect(_on_enemy_died)
@ -19,17 +18,10 @@ func _ready() -> void:
_set_goal_val()
func _process(_delta: float) -> void:
if questComplete:
Globals.fade_node(%QuestProgress, "out", 0.1)
Globals.fade_node(%QuestComplete, "in", 0.1)
func _set_goal_text() -> void:
var goalStr = WorldArea.GoalType.keys()[self.goalType].capitalize()
var factionStr = Globals.World.Faction.keys()[self.faction].capitalize()
# TODO: use better string formatting methods
$QuestProgress/GoalTypeVal.text = goalStr + " " + factionStr + "s"
$QuestProgress/GoalTypeVal.text = "%s %ss" % [goalStr, factionStr]
func _set_goal_val() -> void:
@ -42,7 +34,8 @@ func _quest_goal_check(enemyKillType: Globals.World.Faction) -> void:
$QuestProgress/CompletedVal.text = str(self.goalCurrent)
if self.goalCurrent == self.goalTotal:
SignalBus.quest_completed.emit()
questComplete = true
Globals.fade_node(%QuestComplete, "in", 0.1)
Globals.fade_node(%QuestProgress, "out", 0.1)
func _generate_random_quest() -> void:

View File

@ -59,7 +59,7 @@ func _go_next_area() -> void:
# Globals.debug_print("gna signal emitted")
%QuestsContainer.remove_child(prevAreaQuest)
# Globals.debug_print("gna quest removed")
# HACK: rethink logic flow, or is it? node count not going up...
# HACK: rethink logic flow, memory leaking like a seive
# prevAreaQuest.queue_free()
totalAreas += 1
%AreaCountVal.text = str(totalAreas)
@ -92,6 +92,6 @@ func _on_clock_timer_timeout() -> void:
var current_time = Time.get_unix_time_from_system()
%SystemClock.text = Time.get_time_string_from_unix_time(current_time)
current_zone_duration = current_time - start_zone_time
%ZTVal.text = Time.get_time_string_from_unix_time(current_zone_duration)
%ZTVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_zone_duration))
current_area_duration = current_time - start_area_time
%ATVal.text = Time.get_time_string_from_unix_time(current_area_duration)
%ATVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_area_duration))