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

mountain fortress and rpg updates

This commit is contained in:
Gerkiz
2021-05-04 19:51:02 +02:00
parent 6a95cb2108
commit 2065118aca
6 changed files with 91 additions and 18 deletions

View File

@@ -4,6 +4,8 @@ local Gui = require 'utils.gui'
local Color = require 'utils.color_presets'
local Token = require 'utils.token'
local Alert = require 'utils.alert'
local Task = require 'utils.task'
local Token = require 'utils.token'
local Public = {}
@@ -734,6 +736,35 @@ function Public.global_pool(players, count)
return
end
local damage_player_over_time_token =
Token.register(
function(data)
local player = data.player
local damage = data.damage
if not player.character or not player.character.valid then
return
end
player.character.health = player.character.health - damage
player.character.surface.create_entity({name = 'water-splash', position = player.position})
end
)
--- Damages a player over time.
function Public.damage_player_over_time(player, amount, damage)
if not player or not player.valid then
return
end
amount = amount or 5
damage = damage or 10
local tick = 20
for _ = 1, amount, 1 do
Task.set_timeout_in_ticks(tick, damage_player_over_time_token, {player = player, damage = damage})
tick = tick + 15
damage = damage + 10
end
end
--- Distributes the global xp pool to every connected player.
function Public.distribute_pool()
local count = #game.connected_players