mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-07-26 18:36:23 +09:00
bonus changes (#429)
* Delete exp_legacy/module/modules/data/bonus.lua * Update _file_loader.lua * Update roles.lua * Update bonus.lua * Update player_bonus.lua * Update bonus.lua --------- Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,6 @@ return {
|
|||||||
"modules.data.quickbar",
|
"modules.data.quickbar",
|
||||||
"modules.data.alt-view",
|
"modules.data.alt-view",
|
||||||
"modules.data.tag",
|
"modules.data.tag",
|
||||||
-- 'modules.data.bonus',
|
|
||||||
"modules.data.language",
|
"modules.data.language",
|
||||||
--"modules.data.toolbar",
|
--"modules.data.toolbar",
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,17 @@
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
--[[
|
--[[
|
||||||
TODO
|
|
||||||
force bonus
|
|
||||||
quick health regeneration
|
|
||||||
|
|
||||||
Base point is equal to the amount of standard value in each parameter.
|
Base point is equal to the amount of standard value in each parameter.
|
||||||
|
|
||||||
CMMS CRS CCS CISB CHB CRDB PBR
|
CMMS CRS CCS CISB CHB CRDB PBR
|
||||||
STD 30 90 32 20 16 12 60
|
STD 20 60 24 10 12 8 40
|
||||||
= 260
|
= 174
|
||||||
|
|
||||||
MAX 60 180 64 40 32 24 120
|
MAX 40 120 48 20 24 16 80
|
||||||
= 480
|
= 348
|
||||||
]]
|
]]
|
||||||
points = {
|
points = {
|
||||||
base = 260,
|
base = 174,
|
||||||
increase_percentage_per_role_level = 0.03,
|
increase_percentage_per_role_level = 0.03,
|
||||||
role_name = "Member",
|
role_name = "Member",
|
||||||
},
|
},
|
||||||
@@ -27,8 +23,7 @@ return {
|
|||||||
name = "character_mining_speed_modifier",
|
name = "character_mining_speed_modifier",
|
||||||
scale = 1,
|
scale = 1,
|
||||||
cost = 10,
|
cost = 10,
|
||||||
max_value = 6,
|
max_value = 4,
|
||||||
initial_value = 3,
|
|
||||||
value_step = 0.5,
|
value_step = 0.5,
|
||||||
is_percentage = true,
|
is_percentage = true,
|
||||||
},
|
},
|
||||||
@@ -36,8 +31,7 @@ return {
|
|||||||
name = "character_running_speed_modifier",
|
name = "character_running_speed_modifier",
|
||||||
scale = 1,
|
scale = 1,
|
||||||
cost = 60,
|
cost = 60,
|
||||||
max_value = 3,
|
max_value = 2,
|
||||||
initial_value = 1.5,
|
|
||||||
value_step = 0.25,
|
value_step = 0.25,
|
||||||
is_percentage = true,
|
is_percentage = true,
|
||||||
},
|
},
|
||||||
@@ -45,33 +39,29 @@ return {
|
|||||||
name = "character_crafting_speed_modifier",
|
name = "character_crafting_speed_modifier",
|
||||||
scale = 1,
|
scale = 1,
|
||||||
cost = 4,
|
cost = 4,
|
||||||
max_value = 16,
|
max_value = 12,
|
||||||
initial_value = 8,
|
|
||||||
value_step = 1,
|
value_step = 1,
|
||||||
is_percentage = true,
|
is_percentage = true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "character_inventory_slots_bonus",
|
name = "character_inventory_slots_bonus",
|
||||||
cost = 2,
|
|
||||||
scale = 10,
|
scale = 10,
|
||||||
max_value = 200,
|
cost = 2,
|
||||||
initial_value = 100,
|
max_value = 100,
|
||||||
value_step = 10,
|
value_step = 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "character_health_bonus",
|
name = "character_health_bonus",
|
||||||
scale = 50,
|
scale = 50,
|
||||||
cost = 4,
|
cost = 4,
|
||||||
max_value = 400,
|
max_value = 300,
|
||||||
initial_value = 200,
|
|
||||||
value_step = 50,
|
value_step = 50,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "character_reach_distance_bonus",
|
name = "character_reach_distance_bonus",
|
||||||
cost = 1,
|
|
||||||
scale = 1,
|
scale = 1,
|
||||||
max_value = 24,
|
cost = 1,
|
||||||
initial_value = 12,
|
max_value = 16,
|
||||||
value_step = 2,
|
value_step = 2,
|
||||||
combined_bonus = {
|
combined_bonus = {
|
||||||
"character_resource_reach_distance_bonus",
|
"character_resource_reach_distance_bonus",
|
||||||
@@ -80,104 +70,15 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "personal_battery_recharge",
|
name = "personal_battery_recharge",
|
||||||
initial_value = 6,
|
|
||||||
max_value = 12,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 4,
|
scale = 4,
|
||||||
cost = 40,
|
cost = 40,
|
||||||
|
max_value = 8,
|
||||||
|
value_step = 1,
|
||||||
is_special = true,
|
is_special = true,
|
||||||
},
|
},
|
||||||
--[[
|
|
||||||
['character_item_pickup_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_loot_pickup_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_item_drop_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
},
|
},
|
||||||
force_bonus = {
|
force_bonus = {
|
||||||
--[[
|
|
||||||
['character_mining_speed_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 6,
|
|
||||||
value_step = 0.5,
|
|
||||||
scale = 1,
|
|
||||||
cost = 10,
|
|
||||||
is_percentage = true
|
|
||||||
},
|
|
||||||
['character_running_speed_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 3,
|
|
||||||
value_step = 0.25,
|
|
||||||
scale = 1,
|
|
||||||
cost = 40,
|
|
||||||
is_percentage = true
|
|
||||||
},
|
|
||||||
['character_crafting_speed_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 16,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 4,
|
|
||||||
is_percentage = true
|
|
||||||
},
|
|
||||||
['character_inventory_slots_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 200,
|
|
||||||
value_step = 10,
|
|
||||||
scale = 100,
|
|
||||||
cost = 2,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_health_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 400,
|
|
||||||
value_step = 50,
|
|
||||||
cost = 4,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_reach_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 24,
|
|
||||||
value_step = 2,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false,
|
|
||||||
combined_bonus = {
|
|
||||||
'character_resource_reach_distance_bonus',
|
|
||||||
'character_build_distance_bonus'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
['worker_robots_speed_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
]]
|
|
||||||
["worker_robots_battery_modifier"] = {
|
["worker_robots_battery_modifier"] = {
|
||||||
initial_value = 1,
|
|
||||||
max_value = 1,
|
max_value = 1,
|
||||||
value_step = 1,
|
value_step = 1,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
@@ -185,7 +86,6 @@ return {
|
|||||||
is_percentage = false,
|
is_percentage = false,
|
||||||
},
|
},
|
||||||
["worker_robots_storage_bonus"] = {
|
["worker_robots_storage_bonus"] = {
|
||||||
initial_value = 1,
|
|
||||||
max_value = 1,
|
max_value = 1,
|
||||||
value_step = 1,
|
value_step = 1,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
@@ -193,114 +93,13 @@ return {
|
|||||||
is_percentage = false,
|
is_percentage = false,
|
||||||
},
|
},
|
||||||
["following_robots_lifetime_modifier"] = {
|
["following_robots_lifetime_modifier"] = {
|
||||||
initial_value = 1,
|
|
||||||
max_value = 1,
|
max_value = 1,
|
||||||
value_step = 1,
|
value_step = 1,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
cost = 1,
|
cost = 1,
|
||||||
is_percentage = false,
|
is_percentage = false,
|
||||||
},
|
},
|
||||||
--[[
|
|
||||||
['character_item_pickup_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_loot_pickup_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_item_drop_distance_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 20,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['character_trash_slot_count'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['mining_drill_productivity_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['train_braking_force_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['laboratory_speed_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['laboratory_productivity_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['inserter_stack_size_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['stack_inserter_capacity_bonus'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
},
|
|
||||||
['artillery_range_modifier'] = {
|
|
||||||
initial_value = 0,
|
|
||||||
max_value = 0,
|
|
||||||
value_step = 0,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
},
|
},
|
||||||
surface_bonus = {
|
surface_bonus = {
|
||||||
--[[
|
|
||||||
['solar_power_multiplier'] = {
|
|
||||||
initial_value = 1,
|
|
||||||
max_value = 1000,
|
|
||||||
value_step = 1,
|
|
||||||
scale = 1,
|
|
||||||
cost = 1,
|
|
||||||
is_percentage = false
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ Roles.new_role("Moderator", "Mod")
|
|||||||
"command/clear-inventory",
|
"command/clear-inventory",
|
||||||
"command/kill-enemies",
|
"command/kill-enemies",
|
||||||
"command/remove-enemies",
|
"command/remove-enemies",
|
||||||
--'command/bonus',
|
|
||||||
"command/home",
|
"command/home",
|
||||||
"command/set-home",
|
"command/set-home",
|
||||||
"command/get-home",
|
"command/get-home",
|
||||||
@@ -167,7 +166,6 @@ Roles.new_role("Sponsor", "Spon")
|
|||||||
"gui/rocket-info/toggle-active",
|
"gui/rocket-info/toggle-active",
|
||||||
"gui/rocket-info/remote_launch",
|
"gui/rocket-info/remote_launch",
|
||||||
"gui/bonus",
|
"gui/bonus",
|
||||||
--"command/bonus",
|
|
||||||
"command/home",
|
"command/home",
|
||||||
"command/set-home",
|
"command/set-home",
|
||||||
"command/get-home",
|
"command/get-home",
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
--[[-- Commands Module - Bonus
|
|
||||||
- Adds a command that allows players to have increased stats
|
|
||||||
@data Bonus
|
|
||||||
]]
|
|
||||||
|
|
||||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
|
||||||
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
|
|
||||||
local config = require("modules.exp_legacy.config.bonus") --- @dep config.bonuses
|
|
||||||
local Commands = require("modules/exp_commands")
|
|
||||||
|
|
||||||
-- Stores the bonus for the player
|
|
||||||
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
|
|
||||||
local PlayerBonus = PlayerData.Settings:combine("Bonus")
|
|
||||||
PlayerBonus:set_default(0)
|
|
||||||
PlayerBonus:set_metadata{
|
|
||||||
permission = "command/bonus",
|
|
||||||
stringify = function(value)
|
|
||||||
if not value or value == 0 then
|
|
||||||
return "None set"
|
|
||||||
end
|
|
||||||
|
|
||||||
return value
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Apply a bonus to a player
|
|
||||||
local function apply_bonus(player, stage)
|
|
||||||
if not player.character then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(config.player_bonus) do
|
|
||||||
player[k] = v.value * stage / 10
|
|
||||||
|
|
||||||
if v.combined_bonus then
|
|
||||||
for i = 1, #v.combined_bonus, 1 do
|
|
||||||
player[v.combined_bonus[i]] = v.value * stage / 10
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- When store is updated apply new bonus to the player
|
|
||||||
PlayerBonus:on_update(function(player_name, player_bonus)
|
|
||||||
apply_bonus(game.players[player_name], player_bonus or 0)
|
|
||||||
end)
|
|
||||||
|
|
||||||
--- Changes the amount of bonus you receive
|
|
||||||
Commands.new("bonus", { "bonus.description" })
|
|
||||||
:optional("amount", { "bonus.arg-amount" }, Commands.types.integer_range(0, 10))
|
|
||||||
:register(function(player, amount)
|
|
||||||
--- @cast amount number?
|
|
||||||
if amount then
|
|
||||||
PlayerBonus:set(player, amount)
|
|
||||||
return Commands.status.success{ "bonus.set", amount }
|
|
||||||
else
|
|
||||||
return Commands.status.success{ "bonus.get", PlayerBonus:get(player) }
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
--- When a player respawns re-apply bonus
|
|
||||||
Event.add(defines.events.on_player_respawned, function(event)
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
apply_bonus(player, PlayerBonus:get(player))
|
|
||||||
end)
|
|
||||||
|
|
||||||
--- Remove bonus if a player no longer has access to the command
|
|
||||||
local function role_update(event)
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
if not Roles.player_allowed(player, "command/bonus") then
|
|
||||||
apply_bonus(player, 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- When a player dies allow them to have instant respawn
|
|
||||||
Event.add(defines.events.on_player_died, function(event)
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
|
|
||||||
if Roles.player_has_flag(player, "instant-respawn") then
|
|
||||||
player.ticks_to_respawn = 120
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Event.add(defines.events.on_player_created, function(event)
|
|
||||||
if event.player_index ~= 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(config.force_bonus) do
|
|
||||||
game.players[event.player_index].force[k] = v.value
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(config.surface_bonus) do
|
|
||||||
game.players[event.player_index].surface[k] = v.value
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Event.add(Roles.events.on_role_assigned, role_update)
|
|
||||||
Event.add(Roles.events.on_role_unassigned, role_update)
|
|
||||||
@@ -11,7 +11,7 @@ local config = require("modules/exp_legacy/config/bonus")
|
|||||||
local function apply_force_bonus(event)
|
local function apply_force_bonus(event)
|
||||||
local force = event.force
|
local force = event.force
|
||||||
for k, v in pairs(config.force_bonus) do
|
for k, v in pairs(config.force_bonus) do
|
||||||
force[k] = v.initial_value
|
force[k] = math.floor(v.max_value / 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ end
|
|||||||
local function apply_surface_bonus(event)
|
local function apply_surface_bonus(event)
|
||||||
local surface = assert(game.get_surface(event.surface_index))
|
local surface = assert(game.get_surface(event.surface_index))
|
||||||
for k, v in pairs(config.surface_bonus) do
|
for k, v in pairs(config.surface_bonus) do
|
||||||
surface[k] = v.initial_value
|
surface[k] = math.floor(v.max_value / 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ local Elements = {}
|
|||||||
--- @field cost number
|
--- @field cost number
|
||||||
--- @field scale number
|
--- @field scale number
|
||||||
--- @field max_value number
|
--- @field max_value number
|
||||||
--- @field initial_value number
|
|
||||||
--- @field is_percentage boolean
|
--- @field is_percentage boolean
|
||||||
--- @field is_special boolean
|
--- @field is_special boolean
|
||||||
--- @field value_step number
|
--- @field value_step number
|
||||||
@@ -229,7 +228,7 @@ Elements.bonus_slider = Gui.define("player_bonus/bonus_slider")
|
|||||||
local player = Gui.get_player(parent)
|
local player = Gui.get_player(parent)
|
||||||
local value = Elements.container.get_player_bonus(player, bonus_data.name)
|
local value = Elements.container.get_player_bonus(player, bonus_data.name)
|
||||||
if not value then
|
if not value then
|
||||||
value = bonus_data.initial_value
|
value = math.floor(bonus_data.initial_value / 2)
|
||||||
elements.apply_button.enabled = true
|
elements.apply_button.enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -290,7 +289,7 @@ function Elements.bonus_slider.reset_value(slider)
|
|||||||
local player = Gui.get_player(slider)
|
local player = Gui.get_player(slider)
|
||||||
local element_data = Elements.bonus_slider.data[slider]
|
local element_data = Elements.bonus_slider.data[slider]
|
||||||
local bonus_data = element_data.bonus_data
|
local bonus_data = element_data.bonus_data
|
||||||
local value = Elements.container.get_player_bonus(player, bonus_data.name) or bonus_data.initial_value
|
local value = Elements.container.get_player_bonus(player, bonus_data.name) or math.floor(bonus_data.initial_value / 2)
|
||||||
slider.slider_value = value
|
slider.slider_value = value
|
||||||
element_data.label.caption = Elements.bonus_slider.calculate_slider_caption(bonus_data, value)
|
element_data.label.caption = Elements.bonus_slider.calculate_slider_caption(bonus_data, value)
|
||||||
element_data.previous_value = value
|
element_data.previous_value = value
|
||||||
|
|||||||
Reference in New Issue
Block a user