extends Node @warning_ignore("unused_signal") signal sig_debug_camera_zoom(value: bool) @warning_ignore("unused_signal") signal sig_debug_god_mode(value: bool) @warning_ignore("unused_signal") signal sig_debug_enemy_god_mode(value: bool) @warning_ignore("unused_signal") signal sig_debug_stats_set(key: String, value: String) @warning_ignore("unused_signal") signal sig_stop_spawning(value: bool) const GROUP_ENEMY = "enemy" const GROUP_DAMAGEABLE = "damagable" const GROUP_PLAYER = "player" const GROUP_XP_ORB = "xp_orb" enum ModRarity { LEGENDARY, EPIC, RARE, NORMAL } var placeholder_tex: Texture2D var MOD_CHOICES = [ { "internal_name": "flat_health_small", "name": "+10 Health", "rarity": ModRarity.NORMAL, "tex": placeholder_tex, "description": "Adds 10 flat health.", "weight": 100, "mod_name": "max_health", "mod_value": 10.0, "mod_type": PlayerStatsModifier.ModifierType.ADDITIVE }, { "internal_name": "flat_health_med", "name": "+25 Health", "rarity": ModRarity.RARE, "tex": placeholder_tex, "description": "Adds 25 flat health.", "weight": 50, "mod_name": "max_health", "mod_value": 25.0, "mod_type": PlayerStatsModifier.ModifierType.ADDITIVE }, { "internal_name": "flat_health_large", "name": "+50 Health", "rarity": ModRarity.EPIC, "tex": placeholder_tex, "description": "Adds 50 flat health.", "weight": 10, "mod_name": "max_health", "mod_value": 50.0, "mod_type": PlayerStatsModifier.ModifierType.ADDITIVE }, { "internal_name": "flat_crit_small", "name": "2.5% More Critical Chance", "rarity": ModRarity.RARE, "tex": placeholder_tex, "description": "Gives 2.5% more base critical hit chance", "weight": 50, "mod_name": "crit_chance", "mod_value": 0.025, "mod_type": PlayerStatsModifier.ModifierType.ADDITIVE }, { "internal_name": "flat_crit_large", "name": "5% More Critical Chance", "rarity": ModRarity.EPIC, "tex": placeholder_tex, "description": "Gives 5% more base critical hit chance", "weight": 10, "mod_name": "crit_chance", "mod_value": 0.05, "mod_type": PlayerStatsModifier.ModifierType.ADDITIVE }, ] func _ready() -> void: placeholder_tex = PlaceholderTexture2D.new() placeholder_tex.size = Vector2(64.0, 64.0) func _draw_random_choice(fortune: float = 1.0) -> Dictionary: var total_weight: int = 0 for choice in MOD_CHOICES: total_weight += calculate_weight(choice["weight"], fortune) var roll = randi() % total_weight var cumulative = 0 for u in MOD_CHOICES: cumulative += u["weight"] if roll < cumulative: return u return MOD_CHOICES.back() func draw_random_mod(fortune: float = 1.0) -> PlayerStatsModifier: var choice = _draw_random_choice(fortune) var mod: PlayerStatsModifier = PlayerStatsModifier.new() mod.stat_name = choice["mod_name"] mod.value = choice["mod_value"] mod.type = choice["mod_type"] mod.description = choice["description"] mod.internal_name = choice["internal_name"] mod.tex = choice["tex"] mod.title = choice["name"] return mod func calculate_weight(weight: float, fortune: float): return weight**(1 / 1 + fortune)