mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-17 14:25:27 +09:00
Merge pull request #486 from bbassie/feature/convert-configs
Convert the remaining scenario configs into features
This commit is contained in:
1 parent
b4ee485b13
commit
757a36fc03
44 files changed
+2137
-2033
No files matched your search
@@ -1,42 +1,70 @@
|
||||
--[[ Control - Bonus
|
||||
Various bonus related event handlers
|
||||
|
||||
TODO Refactor this fully, this is temp to get it out of the player bonus gui file
|
||||
]]
|
||||
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules/exp_legacy/config/bonus")
|
||||
|
||||
--- @param event EventData.on_force_created
|
||||
local function apply_force_bonus(event)
|
||||
local force = event.force
|
||||
for k, v in pairs(config.force_bonus) do
|
||||
force[k] = math.floor(v.max_value / 2)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param event EventData.on_surface_created
|
||||
local function apply_surface_bonus(event)
|
||||
local surface = assert(game.get_surface(event.surface_index))
|
||||
for k, v in pairs(config.surface_bonus) do
|
||||
surface[k] = math.floor(v.max_value / 2)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param event EventData.on_player_died
|
||||
local function fast_respawn(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
if Roles.player_has_permission(player, "exp_scenario.player.instant_respawn") then
|
||||
player.ticks_to_respawn = 120
|
||||
end
|
||||
end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
return {
|
||||
events = {
|
||||
[e.on_force_created] = apply_force_bonus,
|
||||
[e.on_surface_created] = apply_surface_bonus,
|
||||
[e.on_player_died] = fast_respawn,
|
||||
}
|
||||
}
|
||||
--[[ Control - Bonus
|
||||
Various bonus related event handlers
|
||||
|
||||
TODO Refactor this fully, this is temp to get it out of the player bonus gui file
|
||||
]]
|
||||
|
||||
local Roles = require("modules/exp_roles")
|
||||
|
||||
--- Force bonuses are started at half their max value
|
||||
local force_bonus = {
|
||||
["worker_robots_battery_modifier"] = {
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false,
|
||||
},
|
||||
["worker_robots_storage_bonus"] = {
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false,
|
||||
},
|
||||
["following_robots_lifetime_modifier"] = {
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
--- Surface bonuses are started at half their max value
|
||||
local surface_bonus = {}
|
||||
|
||||
--- @param event EventData.on_force_created
|
||||
local function apply_force_bonus(event)
|
||||
local force = event.force
|
||||
for k, v in pairs(force_bonus) do
|
||||
force[k] = math.floor(v.max_value / 2)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param event EventData.on_surface_created
|
||||
local function apply_surface_bonus(event)
|
||||
local surface = assert(game.get_surface(event.surface_index))
|
||||
for k, v in pairs(surface_bonus) do
|
||||
surface[k] = math.floor(v.max_value / 2)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param event EventData.on_player_died
|
||||
local function fast_respawn(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
if Roles.player_has_permission(player, "exp_scenario.player.instant_respawn") then
|
||||
player.ticks_to_respawn = 120
|
||||
end
|
||||
end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
return {
|
||||
events = {
|
||||
[e.on_force_created] = apply_force_bonus,
|
||||
[e.on_surface_created] = apply_surface_bonus,
|
||||
[e.on_player_died] = fast_respawn,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user