From 4e466c8131f0399e8de5c38503a3d3941fc0e48f Mon Sep 17 00:00:00 2001 From: Jayefuu Date: Wed, 24 Feb 2021 15:46:00 +0000 Subject: [PATCH 1/2] Added evo flying text on turret destruction to improve new player experience --- map_gen/maps/crash_site/events.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/map_gen/maps/crash_site/events.lua b/map_gen/maps/crash_site/events.lua index 7e3715d5..ec2137a0 100644 --- a/map_gen/maps/crash_site/events.lua +++ b/map_gen/maps/crash_site/events.lua @@ -4,12 +4,14 @@ local Token = require 'utils.token' local Global = require 'utils.global' local math = require 'utils.math' local table = require 'utils.table' +local Color = require 'resources.color_presets' local random = math.random local set_timeout_in_ticks = Task.set_timeout_in_ticks local ceil = math.ceil local draw_arc = rendering.draw_arc local fast_remove = table.fast_remove +local round = math.round local tau = 2 * math.pi local start_angle = -tau / 4 @@ -271,12 +273,16 @@ local function do_pole(entity) ) end -local function do_evolution(entity_name, entity_force) +local function do_evolution(entity, entity_name, entity_force) local factor = turret_evolution_factor[entity_name] if factor then local old = entity_force.evolution_factor - local new = old + (1 - old) * factor - entity_force.evolution_factor = math.min(new, 1) + local extra = (1 - old) * factor + local new = old + extra + if new < 1 then + entity_force.evolution_factor = math.min(new, 1) + entity.surface.create_entity{name="flying-text", position = {entity.position.x - 1, entity.position.y}, text = "+" .. round(extra*100,2) .. "% evo", color = Color.plum} + end end end @@ -549,7 +555,7 @@ Event.add( if entity_force.name == 'enemy' then do_pole(entity) - do_evolution(entity_name, entity_force) + do_evolution(entity, entity_name, entity_force) do_coin_drop(entity_name, entity, cause) do_bot_spawn(entity_name, entity, event) end From b74908f64bb0c178b046539f54225baeceb09caf Mon Sep 17 00:00:00 2001 From: Jayefuu Date: Wed, 24 Feb 2021 19:04:03 +0000 Subject: [PATCH 2/2] Updated errors --- map_gen/maps/crash_site/events.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/map_gen/maps/crash_site/events.lua b/map_gen/maps/crash_site/events.lua index ec2137a0..94b246ad 100644 --- a/map_gen/maps/crash_site/events.lua +++ b/map_gen/maps/crash_site/events.lua @@ -280,8 +280,9 @@ local function do_evolution(entity, entity_name, entity_force) local extra = (1 - old) * factor local new = old + extra if new < 1 then - entity_force.evolution_factor = math.min(new, 1) - entity.surface.create_entity{name="flying-text", position = {entity.position.x - 1, entity.position.y}, text = "+" .. round(extra*100,2) .. "% evo", color = Color.plum} + entity_force.evolution_factor = new + local position = entity.position + entity.surface.create_entity{name="flying-text", position = {position.x - 1, position.y}, text = "+" .. round(extra*100,2) .. "% evo", color = Color.plum} end end end