1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-25 22:32:18 +02:00

more refactor

This commit is contained in:
Gerkiz
2021-11-14 21:01:01 +01:00
parent 2501240d53
commit b679e32dc5
16 changed files with 510 additions and 386 deletions

View File

@@ -393,7 +393,7 @@ function Public.update_health(player)
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if data.health and data.health.valid then
data.health.caption = (math.round(player.character.health * 10) / 10)
data.health.caption = (round(player.character.health * 10) / 10)
end
local shield_gui = player.character.get_inventory(defines.inventory.character_armor)
if not shield_gui.is_empty() then
@@ -497,8 +497,15 @@ function Public.get_melee_modifier(player)
return (rpg_t.strength - 10) * 0.10
end
function Public.get_final_damage_modifier(player)
local rpg_t = Public.get_value_from_player(player.index)
local rng = random(10, 35) * 0.01
return (rpg_t.strength - 10) * rng
end
function Public.get_final_damage(player, entity, original_damage_amount)
local damage = original_damage_amount + original_damage_amount * Public.get_melee_modifier(player)
local modifier = Public.get_final_damage_modifier(player)
local damage = original_damage_amount + original_damage_amount * modifier
if entity.prototype.resistances then
if entity.prototype.resistances.physical then
damage = damage - entity.prototype.resistances.physical.decrease
@@ -570,7 +577,7 @@ function Public.get_one_punch_chance(player)
if rpg_t.strength < 100 then
return 0
end
local chance = math.round(rpg_t.strength * 0.01, 1)
local chance = round(rpg_t.strength * 0.012, 1)
if chance > 100 then
chance = 100
end
@@ -580,7 +587,7 @@ end
function Public.get_extra_following_robots(player)
local rpg_t = Public.get_value_from_player(player.index)
local strength = rpg_t.strength
local count = math.round(strength / 2 * 0.03, 3)
local count = round(strength / 2 * 0.03, 3)
return count
end
@@ -750,7 +757,7 @@ function Public.gain_xp(player, amount, added_to_pool, text)
Public.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
local fee = amount - add_to_global_pool(amount, true)
Public.debug_log('RPG - ' .. player.name .. ' got fee: ' .. fee)
amount = math.round(amount, 3) - fee
amount = round(amount, 3) - fee
if rpg_extra.difficulty then
amount = amount + rpg_extra.difficulty
end
@@ -759,7 +766,7 @@ function Public.gain_xp(player, amount, added_to_pool, text)
Public.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
end
rpg_t.xp = math.round(rpg_t.xp + amount, 3)
rpg_t.xp = round(rpg_t.xp + amount, 3)
rpg_t.xp_since_last_floaty_text = rpg_t.xp_since_last_floaty_text + amount
if not experience_levels[rpg_t.level + 1] then