leveling stuff/experimentation
This commit is contained in:
parent
507b96868e
commit
d1f24f3dd1
@ -1,70 +0,0 @@
|
|||||||
extends SceneTree
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE: not likely final
|
|
||||||
var exp_coefficient := 50
|
|
||||||
var exp_exponent := 1.7
|
|
||||||
|
|
||||||
func level_eqn(experience):
|
|
||||||
# return log(0.2 * experience + 5) + 1
|
|
||||||
return pow(experience / exp_coefficient, 1/exp_exponent) + 1
|
|
||||||
|
|
||||||
|
|
||||||
func experience_eqn(level):
|
|
||||||
# return 5 * exp(level - 1) - 5
|
|
||||||
return exp_coefficient * pow((level - 1), exp_exponent)
|
|
||||||
|
|
||||||
|
|
||||||
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 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:
|
|
||||||
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()
|
|
@ -265,7 +265,7 @@ alignment = 1
|
|||||||
custom_minimum_size = Vector2(64, 64)
|
custom_minimum_size = Vector2(64, 64)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
attack_range = 9999
|
attack_range = 9999
|
||||||
auto_damage = 400
|
auto_damage = 450
|
||||||
|
|
||||||
[node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")]
|
[node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")]
|
||||||
visible = false
|
visible = false
|
||||||
|
@ -118,4 +118,4 @@ func _on_idle_cooldown_timeout() -> void:
|
|||||||
if not enemiesList.is_empty() and self.visible:
|
if not enemiesList.is_empty() and self.visible:
|
||||||
_deal_idle_damage(enemiesList)
|
_deal_idle_damage(enemiesList)
|
||||||
|
|
||||||
# TODO: implement active damage with signal to send resources spent to player cast/charge-time based instead of cooldowns for active abilities, but still uses "cooldown" value
|
# TODO: implement active damage with signal to send resources spent to player cast/charge-time based instead of cooldowns for active abilities, but still uses "cooldown" value
|
||||||
|
70
scripts/Analytics.gd
Normal file
70
scripts/Analytics.gd
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
extends SceneTree
|
||||||
|
|
||||||
|
|
||||||
|
class GameplaySim:
|
||||||
|
const EXP_COEFFICIENT := 10
|
||||||
|
const EXP_EXPONENT := 2.4
|
||||||
|
|
||||||
|
func level_eqn(experience):
|
||||||
|
# return log(0.2 * experience + 5) + 1
|
||||||
|
return pow(experience / EXP_COEFFICIENT, 1 / EXP_EXPONENT) + 1
|
||||||
|
|
||||||
|
|
||||||
|
func experience_eqn(level):
|
||||||
|
# return 5 * exp(level - 1) - 5
|
||||||
|
return EXP_COEFFICIENT * pow((level - 1), EXP_EXPONENT)
|
||||||
|
|
||||||
|
|
||||||
|
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 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:
|
||||||
|
var total_time = 0
|
||||||
|
for level in range(2, 92):
|
||||||
|
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()
|
@ -2,6 +2,8 @@
|
|||||||
class_name Player
|
class_name Player
|
||||||
extends VBoxContainer
|
extends VBoxContainer
|
||||||
|
|
||||||
|
const EXP_COEFFICIENT := 10
|
||||||
|
const EXP_EXPONENT := 2.4
|
||||||
|
|
||||||
var area_exp := 0.0
|
var area_exp := 0.0
|
||||||
var current_health: int
|
var current_health: int
|
||||||
@ -24,7 +26,8 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_enemy_died(enemyDifficulty, enemyTier, _enemyFaction) -> void:
|
func _on_enemy_died(enemyDifficulty, enemyTier, _enemyFaction) -> void:
|
||||||
var kill_exp = pow(pow(enemyTier + 1, enemyDifficulty), 3)
|
# var kill_exp = pow(pow(enemyTier + 1, enemyDifficulty), 3)
|
||||||
|
var kill_exp = (enemyTier + 1) * enemyDifficulty
|
||||||
area_exp += kill_exp
|
area_exp += kill_exp
|
||||||
# Globals.debug_print("T: " + str(enemyTier) + " D: " + str(enemyDifficulty))
|
# Globals.debug_print("T: " + str(enemyTier) + " D: " + str(enemyDifficulty))
|
||||||
# Globals.debug_print("K: " + str(kill_exp))
|
# Globals.debug_print("K: " + str(kill_exp))
|
||||||
@ -59,6 +62,7 @@ func _update_player_health(change: int) -> void:
|
|||||||
$PlayerHealthBar.value = 0
|
$PlayerHealthBar.value = 0
|
||||||
# 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
|
||||||
|
print("You died.")
|
||||||
get_tree().paused = true
|
get_tree().paused = true
|
||||||
elif current_health >= max_health:
|
elif current_health >= max_health:
|
||||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(max_health)
|
$PlayerHealthBar/PlayerHealthCurrent.text = str(max_health)
|
||||||
@ -98,7 +102,8 @@ func _on_enemy_damaged_player(damage: int) -> void:
|
|||||||
|
|
||||||
func _calculate_player_level() -> float:
|
func _calculate_player_level() -> float:
|
||||||
var current_exp = PlayerState.experience
|
var current_exp = PlayerState.experience
|
||||||
return log((0.2 * current_exp + 5) * 0.2) + 1
|
return pow(current_exp / EXP_COEFFICIENT, 1 / EXP_EXPONENT) + 1
|
||||||
|
# return log((0.2 * current_exp + 5) * 0.2) + 1
|
||||||
|
|
||||||
|
|
||||||
func _get_level_progress_percent() -> float:
|
func _get_level_progress_percent() -> float:
|
||||||
@ -107,8 +112,13 @@ func _get_level_progress_percent() -> float:
|
|||||||
|
|
||||||
|
|
||||||
func _on_quest_completed() -> void:
|
func _on_quest_completed() -> void:
|
||||||
|
var previous_whole_level = floor(PlayerState.level)
|
||||||
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)
|
||||||
|
if current_whole_level > previous_whole_level:
|
||||||
|
SignalBus.player_leveled_up.emit()
|
||||||
|
print("You leveled up to %s!" % 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:
|
||||||
|
@ -8,6 +8,7 @@ signal enemy_died(
|
|||||||
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 quest_generated(quest: Quest)
|
signal quest_generated(quest: Quest)
|
||||||
signal quest_completed
|
signal quest_completed
|
||||||
signal area_continue_pressed()
|
signal area_continue_pressed()
|
||||||
@ -17,6 +18,7 @@ func _dummy_func() -> void:
|
|||||||
# to get rid of the unused signal warnings
|
# to get rid of the unused signal warnings
|
||||||
enemy_died.emit()
|
enemy_died.emit()
|
||||||
enemy_damaged_player.emit()
|
enemy_damaged_player.emit()
|
||||||
|
player_leveled_up.emit()
|
||||||
quest_generated.emit()
|
quest_generated.emit()
|
||||||
quest_completed.emit()
|
quest_completed.emit()
|
||||||
area_continue_pressed.emit()
|
area_continue_pressed.emit()
|
||||||
|
Loading…
Reference in New Issue
Block a user