You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2026-06-20 16:32:28 +02:00
rpg and mtn v3 changes
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
local Misc = require 'commands.misc'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
activate_custom_buttons = false,
|
||||
bottom_right = false,
|
||||
bottom_quickbar_button = {}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
this = t
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
|
||||
local bottom_guis_frame = Gui.uid_name()
|
||||
local clear_corpse_button_name = Gui.uid_name()
|
||||
local bottom_quickbar_button_name = Gui.uid_name()
|
||||
|
||||
function Public.get_player_data(player, remove_user_data)
|
||||
if remove_user_data then
|
||||
if this.players[player.index] then
|
||||
this.players[player.index] = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
if not this.players[player.index] then
|
||||
this.players[player.index] = {}
|
||||
end
|
||||
return this.players[player.index]
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set(key, value)
|
||||
if key and (value or value == false) then
|
||||
this[key] = value
|
||||
return this[key]
|
||||
elseif key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
Event.on_init(
|
||||
function()
|
||||
this.players = {}
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset()
|
||||
this.players = {}
|
||||
end
|
||||
|
||||
----! Gui Functions ! ----
|
||||
|
||||
local function create_frame(player, rebuild)
|
||||
local gui = player.gui
|
||||
local frame = gui.screen[bottom_guis_frame]
|
||||
if frame and frame.valid then
|
||||
if rebuild then
|
||||
frame.destroy()
|
||||
else
|
||||
return frame
|
||||
end
|
||||
end
|
||||
|
||||
frame =
|
||||
player.gui.screen.add {
|
||||
type = 'frame',
|
||||
name = bottom_guis_frame,
|
||||
direction = 'vertical'
|
||||
}
|
||||
frame.style.padding = 3
|
||||
frame.style.minimal_height = 96
|
||||
frame.style.top_padding = 4
|
||||
|
||||
local inner_frame =
|
||||
frame.add {
|
||||
type = 'frame',
|
||||
direction = 'vertical'
|
||||
}
|
||||
inner_frame.style = 'quick_bar_inner_panel'
|
||||
|
||||
inner_frame.add {
|
||||
type = 'sprite-button',
|
||||
sprite = 'entity/behemoth-biter',
|
||||
name = clear_corpse_button_name,
|
||||
tooltip = {'commands.clear_corpse'},
|
||||
style = 'quick_bar_page_button'
|
||||
}
|
||||
|
||||
local bottom_quickbar_button =
|
||||
inner_frame.add {
|
||||
type = 'sprite-button',
|
||||
name = bottom_quickbar_button_name,
|
||||
style = 'quick_bar_page_button'
|
||||
}
|
||||
|
||||
this.bottom_quickbar_button[player.index] = {name = bottom_quickbar_button_name, frame = bottom_quickbar_button}
|
||||
|
||||
if this.bottom_quickbar_button.sprite and this.bottom_quickbar_button.tooltip then
|
||||
bottom_quickbar_button.sprite = this.bottom_quickbar_button.sprite
|
||||
bottom_quickbar_button.tooltip = this.bottom_quickbar_button.tooltip
|
||||
end
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
local function set_location(player)
|
||||
local frame = create_frame(player)
|
||||
local resolution = player.display_resolution
|
||||
local scale = player.display_scale
|
||||
|
||||
if this.players[player.index] and this.players[player.index].bottom_left then
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + 445) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
if this.bottom_right then
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + -528) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
else
|
||||
local experimental = get_game_version()
|
||||
if experimental then
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + 445) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
else
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + 258) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Activates the custom buttons
|
||||
---@param boolean
|
||||
function Public.activate_custom_buttons(value)
|
||||
if value then
|
||||
this.activate_custom_buttons = value
|
||||
else
|
||||
this.activate_custom_buttons = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Fetches if the custom buttons are activated
|
||||
function Public.is_custom_buttons_enabled()
|
||||
return this.activate_custom_buttons
|
||||
end
|
||||
|
||||
--- Sets the buttons to be aligned bottom right
|
||||
---@param boolean
|
||||
function Public.bottom_right(value)
|
||||
if value then
|
||||
this.bottom_right = value
|
||||
else
|
||||
this.bottom_right = false
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
clear_corpse_button_name,
|
||||
function(event)
|
||||
Misc.clear_corpses(event)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = game.players[event.player_index]
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_resolution_changed,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_respawned,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_died,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
local frame = player.gui.screen[bottom_guis_frame]
|
||||
if frame and frame.valid then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_scale_changed,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.bottom_guis_frame = bottom_guis_frame
|
||||
Public.set_location = set_location
|
||||
ComfyGui.screen_to_bypass(bottom_guis_frame)
|
||||
|
||||
return Public
|
||||
@@ -5,6 +5,7 @@ local Color = require 'utils.color_presets'
|
||||
local SessionData = require 'utils.datastore.session_data'
|
||||
local Utils = require 'utils.core'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
|
||||
local spaghett_entity_blacklist = {
|
||||
['logistic-chest-requester'] = true,
|
||||
@@ -100,6 +101,20 @@ local functions = {
|
||||
game.players[event.player_index].spectator = false
|
||||
end
|
||||
end,
|
||||
['comfy_panel_bottom_right_frame'] = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if event.element.switch_state == 'left' then
|
||||
local bottom_frame = BottomFrame.get_player_data(player)
|
||||
if not bottom_frame then
|
||||
return
|
||||
end
|
||||
bottom_frame.bottom_left = true
|
||||
BottomFrame.set_location(player)
|
||||
else
|
||||
BottomFrame.get_player_data(player, true)
|
||||
BottomFrame.set_location(player)
|
||||
end
|
||||
end,
|
||||
['comfy_panel_auto_hotbar_switch'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
global.auto_hotbar_enabled[event.player_index] = true
|
||||
@@ -348,6 +363,22 @@ local build_config_gui = (function(player, frame)
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
|
||||
if BottomFrame.is_custom_buttons_enabled() then
|
||||
switch_state = 'right'
|
||||
local bottom_frame = BottomFrame.get('players')
|
||||
if bottom_frame[player.index] then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_bottom_right_frame',
|
||||
'Button Location',
|
||||
'Toggle to select if you want the bottom button on the right side or the left side.'
|
||||
)
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
|
||||
if admin then
|
||||
label = scroll_pane.add({type = 'label', caption = 'Admin Settings'})
|
||||
label.style.font = 'default-bold'
|
||||
|
||||
+1
-163
@@ -4,8 +4,6 @@ local Server = require 'utils.server'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
@@ -23,10 +21,6 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
|
||||
local bottom_guis_frame = Gui.uid_name()
|
||||
local clear_corpse_button_name = Gui.uid_name()
|
||||
local bottom_quickbar_button_name = Gui.uid_name()
|
||||
|
||||
commands.add_command(
|
||||
'spaghetti',
|
||||
'Does spaghett.',
|
||||
@@ -506,170 +500,14 @@ function Public.reset()
|
||||
this.players = {}
|
||||
end
|
||||
|
||||
----! Gui Functions ! ----
|
||||
|
||||
local function create_frame(player, rebuild)
|
||||
local gui = player.gui
|
||||
local frame = gui.screen[bottom_guis_frame]
|
||||
if frame and frame.valid then
|
||||
if rebuild then
|
||||
frame.destroy()
|
||||
else
|
||||
return frame
|
||||
end
|
||||
end
|
||||
|
||||
frame =
|
||||
player.gui.screen.add {
|
||||
type = 'frame',
|
||||
name = bottom_guis_frame,
|
||||
direction = 'vertical'
|
||||
}
|
||||
frame.style.padding = 3
|
||||
frame.style.minimal_height = 96
|
||||
frame.style.top_padding = 4
|
||||
|
||||
local inner_frame =
|
||||
frame.add {
|
||||
type = 'frame',
|
||||
direction = 'vertical'
|
||||
}
|
||||
inner_frame.style = 'quick_bar_inner_panel'
|
||||
|
||||
inner_frame.add {
|
||||
type = 'sprite-button',
|
||||
sprite = 'entity/behemoth-biter',
|
||||
name = clear_corpse_button_name,
|
||||
tooltip = {'commands.clear_corpse'},
|
||||
style = 'quick_bar_page_button'
|
||||
}
|
||||
|
||||
local bottom_quickbar_button =
|
||||
inner_frame.add {
|
||||
type = 'sprite-button',
|
||||
name = bottom_quickbar_button_name,
|
||||
style = 'quick_bar_page_button'
|
||||
}
|
||||
|
||||
this.bottom_quickbar_button[player.index] = {name = bottom_quickbar_button_name, frame = bottom_quickbar_button}
|
||||
|
||||
if this.bottom_quickbar_button.sprite and this.bottom_quickbar_button.tooltip then
|
||||
bottom_quickbar_button.sprite = this.bottom_quickbar_button.sprite
|
||||
bottom_quickbar_button.tooltip = this.bottom_quickbar_button.tooltip
|
||||
end
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
local function set_location(player)
|
||||
local frame = create_frame(player)
|
||||
local resolution = player.display_resolution
|
||||
local scale = player.display_scale
|
||||
|
||||
if this.bottom_right then
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + -528) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
else
|
||||
local experimental = get_game_version()
|
||||
if experimental then
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + 445) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
else
|
||||
frame.location = {
|
||||
x = (resolution.width / 2) - ((54 + 258) * scale),
|
||||
y = (resolution.height - (96 * scale))
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Activates the custom buttons
|
||||
---@param boolean
|
||||
function Public.activate_custom_buttons(value)
|
||||
if value then
|
||||
this.activate_custom_buttons = value
|
||||
else
|
||||
this.activate_custom_buttons = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Sets the buttons to be aligned bottom right
|
||||
---@param boolean
|
||||
function Public.bottom_right(value)
|
||||
if value then
|
||||
this.bottom_right = value
|
||||
else
|
||||
this.bottom_right = false
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
clear_corpse_button_name,
|
||||
function(event)
|
||||
clear_corpses(event)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = game.players[event.player_index]
|
||||
on_player_joined_game(player)
|
||||
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_resolution_changed,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_respawned,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_died,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
local frame = player.gui.screen[bottom_guis_frame]
|
||||
if frame and frame.valid then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_scale_changed,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.activate_custom_buttons then
|
||||
set_location(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.bottom_guis_frame = bottom_guis_frame
|
||||
ComfyGui.screen_to_bypass(bottom_guis_frame)
|
||||
Public.clear_corpses = clear_corpses
|
||||
|
||||
return Public
|
||||
|
||||
@@ -98,6 +98,8 @@ one_punch_tooltip=Enabling this will have a chance of one-punching biters.\nOne-
|
||||
one_punch_globally=Enabled globally.\nOne-Punch only works if both ammo AND gun is unequipped.
|
||||
flameboots_label=Enable flame boots?
|
||||
flameboots_tooltip=When the bullets simply don´t bite.
|
||||
explosive_bullets_label=Enable explosive bullets?
|
||||
explosive_bullets_tooltip=Hurts the biters a bit extra
|
||||
magic_label=Enable spawning with raw-fish?
|
||||
magic_tooltip=When simply constructing items is not enough.\nNOTE! Use Raw-fish to cast spells.
|
||||
magic_spell=Select what entity to spawn
|
||||
|
||||
@@ -13,7 +13,6 @@ local Mining = require 'maps.mountain_fortress_v3.mining'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Traps = require 'maps.mountain_fortress_v3.traps'
|
||||
local Locomotive = require 'maps.mountain_fortress_v3.locomotive'
|
||||
local ExplosiveBullets = require 'maps.mountain_fortress_v3.explosive_gun_bullets'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Alert = require 'utils.alert'
|
||||
local Task = require 'utils.task'
|
||||
@@ -942,10 +941,6 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
if WPT.get('explosive_bullets') then
|
||||
ExplosiveBullets.explosive_bullets(event)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
|
||||
@@ -10,7 +10,7 @@ local Collapse = require 'modules.collapse'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local math2d = require 'math2d'
|
||||
local Commands = require 'commands.misc'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
@@ -1195,7 +1195,7 @@ function Public.on_player_left_game()
|
||||
end
|
||||
|
||||
function Public.is_creativity_mode_on()
|
||||
local creative_enabled = Commands.get('creative_enabled')
|
||||
local creative_enabled = BottomFrame.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
WD.set('next_wave', 1000)
|
||||
Collapse.start_now(true)
|
||||
@@ -1204,9 +1204,9 @@ function Public.is_creativity_mode_on()
|
||||
end
|
||||
|
||||
function Public.disable_creative()
|
||||
local creative_enabled = Commands.get('creative_enabled')
|
||||
local creative_enabled = BottomFrame.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
Commands.set('creative_enabled', false)
|
||||
BottomFrame.set('creative_enabled', false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -407,6 +407,7 @@ local function get_score_list()
|
||||
}
|
||||
return score_list
|
||||
end
|
||||
|
||||
for p, _ in pairs(score_force.players) do
|
||||
local score = score_force.players[p]
|
||||
insert(
|
||||
|
||||
@@ -237,7 +237,6 @@ function Public.add_player_to_permission_group(player, group, forced)
|
||||
locomotive_group.set_allows_action(defines.input_action.add_permission_group, false)
|
||||
locomotive_group.set_allows_action(defines.input_action.admin_action, false)
|
||||
locomotive_group.set_allows_action(defines.input_action.drop_item, false)
|
||||
locomotive_group.set_allows_action(defines.input_action.place_equipment, false)
|
||||
end
|
||||
|
||||
if not game.permissions.get_group('plebs') then
|
||||
@@ -258,7 +257,6 @@ function Public.add_player_to_permission_group(player, group, forced)
|
||||
not_trusted.set_allows_action(defines.input_action.add_permission_group, false)
|
||||
not_trusted.set_allows_action(defines.input_action.admin_action, false)
|
||||
not_trusted.set_allows_action(defines.input_action.drop_item, false)
|
||||
not_trusted.set_allows_action(defines.input_action.place_equipment, false)
|
||||
not_trusted.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
|
||||
not_trusted.set_allows_action(defines.input_action.connect_rolling_stock, false)
|
||||
end
|
||||
@@ -1163,6 +1161,7 @@ local function gui_click(event)
|
||||
player.name .. ' has bought the explosive bullet modifier for ' .. format_number(item.price) .. ' coins.'
|
||||
}
|
||||
)
|
||||
RPG_Settings.enable_explosive_bullets(true)
|
||||
this.explosive_bullets = true
|
||||
|
||||
redraw_market_items(data.item_frame, player, data.search_text)
|
||||
@@ -2303,8 +2302,8 @@ function Public.get_items()
|
||||
tooltip = ({'item-name.kr-creep-collector'}),
|
||||
upgrade = false,
|
||||
static = true,
|
||||
value = "coin"
|
||||
}
|
||||
value = 'coin'
|
||||
}
|
||||
end
|
||||
main_market_items['land-mine'] = {
|
||||
stack = 1,
|
||||
|
||||
@@ -31,7 +31,7 @@ local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local Commands = require 'commands.misc'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local Modifiers = require 'player_modifiers'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
|
||||
@@ -109,9 +109,9 @@ function Public.reset_map()
|
||||
Autostash.insert_into_wagon(true)
|
||||
Autostash.bottom_button(true)
|
||||
BuriedEnemies.reset()
|
||||
Commands.reset()
|
||||
Commands.activate_custom_buttons(true)
|
||||
Commands.bottom_right(true)
|
||||
BottomFrame.reset()
|
||||
BottomFrame.activate_custom_buttons(true)
|
||||
BottomFrame.bottom_right(true)
|
||||
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
@@ -133,6 +133,8 @@ function Public.reset_map()
|
||||
RPG_Settings.enable_one_punch_globally(false)
|
||||
RPG_Settings.enable_auto_allocate(true)
|
||||
RPG_Settings.disable_cooldowns_on_spells()
|
||||
RPG_Settings.enable_explosive_bullets_globally(true)
|
||||
RPG_Settings.enable_explosive_bullets(false)
|
||||
|
||||
Group.reset_groups()
|
||||
Group.alphanumeric_only(false)
|
||||
@@ -175,7 +177,7 @@ function Public.reset_map()
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
Score.init_player_table(player, true)
|
||||
Commands.insert_all_items(player)
|
||||
BottomFrame.insert_all_items(player)
|
||||
Modifiers.reset_player_modifiers(player)
|
||||
if player.gui.left['mvps'] then
|
||||
player.gui.left['mvps'].destroy()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Misc = require 'commands.misc'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local math_floor = math.floor
|
||||
local print_color = {r = 120, g = 255, b = 0}
|
||||
|
||||
@@ -464,7 +464,7 @@ local function create_gui_button(player)
|
||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
||||
end
|
||||
if this.bottom_button then
|
||||
local data = Misc.get('bottom_quickbar_button')
|
||||
local data = BottomFrame.get('bottom_quickbar_button')
|
||||
-- save it for later use
|
||||
data.tooltip = tooltip
|
||||
data.sprite = 'item/wooden-chest'
|
||||
@@ -527,7 +527,7 @@ local function on_gui_click(event)
|
||||
local player = game.players[event.player_index]
|
||||
local name = 'auto_stash'
|
||||
if this.bottom_button then
|
||||
local data = Misc.get('bottom_quickbar_button')
|
||||
local data = BottomFrame.get('bottom_quickbar_button')
|
||||
if data[player.index] then
|
||||
data = data[player.index]
|
||||
name = data.name
|
||||
|
||||
+25
-3
@@ -1,3 +1,4 @@
|
||||
local RPG_T = require 'modules.rpg.table'
|
||||
local radius = 3
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
@@ -25,6 +26,11 @@ local function splash_damage(surface, position, final_damage_amount)
|
||||
end
|
||||
|
||||
function Public.explosive_bullets(event)
|
||||
local is_explosive_bullets_enabled = RPG_T.get_explosive_bullets()
|
||||
if not is_explosive_bullets_enabled then
|
||||
return
|
||||
end
|
||||
|
||||
if random(1, 3) ~= 1 then
|
||||
return false
|
||||
end
|
||||
@@ -42,6 +48,21 @@ function Public.explosive_bullets(event)
|
||||
end
|
||||
|
||||
local player = event.cause
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local p = event.cause.player
|
||||
if not p or not p.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player_data = RPG_T.get('rpg_t')
|
||||
local rpg_player = player_data[p.index]
|
||||
if not rpg_player.explosive_bullets then
|
||||
return
|
||||
end
|
||||
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then
|
||||
return
|
||||
end
|
||||
@@ -62,9 +83,10 @@ function Public.explosive_bullets(event)
|
||||
local surface = player.surface
|
||||
local create = surface.create_entity
|
||||
|
||||
create({name = 'explosion', position = entity.position})
|
||||
|
||||
splash_damage(surface, entity.position, event.final_damage_amount)
|
||||
if entity.force.index ~= player.force.index then
|
||||
create({name = 'explosion', position = entity.position})
|
||||
splash_damage(surface, entity.position, event.final_damage_amount)
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
@@ -535,6 +535,7 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
dropdown_select_index3 = 1,
|
||||
allocate_index = 1,
|
||||
flame_boots = false,
|
||||
explosive_bullets = false,
|
||||
enable_entity_spawn = false,
|
||||
health_bar = rpg_t[player.index].health_bar,
|
||||
mana_bar = rpg_t[player.index].mana_bar,
|
||||
@@ -570,6 +571,7 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
dropdown_select_index3 = 1,
|
||||
allocate_index = 1,
|
||||
flame_boots = false,
|
||||
explosive_bullets = false,
|
||||
enable_entity_spawn = false,
|
||||
points_to_distribute = 0,
|
||||
last_floaty_text = visuals_delay,
|
||||
|
||||
@@ -566,6 +566,7 @@ Gui.on_click(
|
||||
local magic_pickup_gui_input = data.magic_pickup_gui_input
|
||||
local movement_speed_gui_input = data.movement_speed_gui_input
|
||||
local flame_boots_gui_input = data.flame_boots_gui_input
|
||||
local explosive_bullets_gui_input = data.explosive_bullets_gui_input
|
||||
local enable_entity_gui_input = data.enable_entity_gui_input
|
||||
local stone_path_gui_input = data.stone_path_gui_input
|
||||
local one_punch_gui_input = data.one_punch_gui_input
|
||||
@@ -610,6 +611,14 @@ Gui.on_click(
|
||||
end
|
||||
end
|
||||
|
||||
if explosive_bullets_gui_input and explosive_bullets_gui_input.valid then
|
||||
if not explosive_bullets_gui_input.state then
|
||||
rpg_t[player.index].explosive_bullets = false
|
||||
elseif explosive_bullets_gui_input.state then
|
||||
rpg_t[player.index].explosive_bullets = true
|
||||
end
|
||||
end
|
||||
|
||||
if movement_speed_gui_input and movement_speed_gui_input.valid then
|
||||
if not player_modifiers.disabled_modifier[player.index] then
|
||||
player_modifiers.disabled_modifier[player.index] = {}
|
||||
|
||||
@@ -10,6 +10,7 @@ local Math2D = require 'math2d'
|
||||
|
||||
--RPG Modules
|
||||
require 'modules.rpg.commands'
|
||||
local ExplosiveBullets = require 'modules.rpg.explosive_gun_bullets'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Functions = require 'modules.rpg.functions'
|
||||
local RPG_GUI = require 'modules.rpg.gui'
|
||||
@@ -528,6 +529,10 @@ local function on_entity_damaged(event)
|
||||
cause.get_inventory(defines.inventory.character_ammo)[cause.selected_gun_index].valid_for_read or
|
||||
cause.get_inventory(defines.inventory.character_guns)[cause.selected_gun_index].valid_for_read
|
||||
then
|
||||
local is_explosive_bullets_enabled = RPG.get_explosive_bullets()
|
||||
if is_explosive_bullets_enabled then
|
||||
ExplosiveBullets.explosive_bullets(event)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -655,6 +660,11 @@ local function on_entity_damaged(event)
|
||||
if entity.health <= 0 then
|
||||
entity.die(cause.force.name, cause)
|
||||
end
|
||||
|
||||
local is_explosive_bullets_enabled = RPG.get_explosive_bullets()
|
||||
if is_explosive_bullets_enabled then
|
||||
ExplosiveBullets.explosive_bullets(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
|
||||
@@ -304,6 +304,7 @@ function Public.extra_settings(player)
|
||||
local spell_gui_input2
|
||||
local spell_gui_input3
|
||||
local flame_boots_gui_input
|
||||
local explosive_bullets_gui_input
|
||||
local stone_path_gui_input
|
||||
local one_punch_gui_input
|
||||
local auto_allocate_gui_input
|
||||
@@ -429,6 +430,43 @@ function Public.extra_settings(player)
|
||||
end
|
||||
end
|
||||
|
||||
if rpg_extra.enable_explosive_bullets_globally then
|
||||
local explosive_bullets_label =
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = ({'rpg_settings.explosive_bullets_label'}),
|
||||
tooltip = ({'rpg_settings.explosive_bullets_tooltip'})
|
||||
}
|
||||
)
|
||||
|
||||
local explosive_bullets_label_style = explosive_bullets_label.style
|
||||
explosive_bullets_label_style.horizontally_stretchable = true
|
||||
explosive_bullets_label_style.height = 35
|
||||
explosive_bullets_label_style.vertical_align = 'center'
|
||||
|
||||
local explosive_bullet_input = setting_grid.add({type = 'flow'})
|
||||
local explosive_bullet_input_style = explosive_bullet_input.style
|
||||
explosive_bullet_input_style.height = 35
|
||||
explosive_bullet_input_style.vertical_align = 'center'
|
||||
local explosive_bullets
|
||||
if rpg_t[player.index].explosive_bullets then
|
||||
explosive_bullets = rpg_t[player.index].explosive_bullets
|
||||
else
|
||||
explosive_bullets = false
|
||||
end
|
||||
explosive_bullets_gui_input = create_input_element(explosive_bullet_input, 'boolean', explosive_bullets)
|
||||
|
||||
if rpg_t[player.index].level < 50 then
|
||||
explosive_bullets_gui_input.enabled = false
|
||||
explosive_bullets_gui_input.tooltip = ({'rpg_settings.low_level', 50})
|
||||
explosive_bullets_label.tooltip = ({'rpg_settings.low_level', 50})
|
||||
else
|
||||
explosive_bullets_gui_input.enabled = true
|
||||
explosive_bullets_gui_input.tooltip = ({'rpg_settings.explosive_bullets_tooltip'})
|
||||
end
|
||||
end
|
||||
|
||||
if rpg_extra.enable_mana then
|
||||
local mana_frame = inside_table.add({type = 'scroll-pane'})
|
||||
local mana_style = mana_frame.style
|
||||
@@ -628,6 +666,10 @@ function Public.extra_settings(player)
|
||||
data.flame_boots_gui_input = flame_boots_gui_input
|
||||
end
|
||||
|
||||
if rpg_extra.enable_explosive_bullets_globally then
|
||||
data.explosive_bullets_gui_input = explosive_bullets_gui_input
|
||||
end
|
||||
|
||||
if rpg_extra.enable_stone_path then
|
||||
data.stone_path_gui_input = stone_path_gui_input
|
||||
end
|
||||
|
||||
@@ -95,6 +95,8 @@ function Public.reset_table()
|
||||
this.rpg_extra.mana_limit = 1500
|
||||
this.rpg_extra.enable_wave_defense = false
|
||||
this.rpg_extra.enable_flame_boots = false
|
||||
this.rpg_extra.enable_explosive_bullets = false
|
||||
this.rpg_extra.enable_explosive_bullets_globally = false
|
||||
this.rpg_extra.mana_per_tick = 0.1
|
||||
this.rpg_extra.force_mana_per_tick = false
|
||||
this.rpg_extra.enable_stone_path = false
|
||||
@@ -269,6 +271,40 @@ function Public.enable_flame_boots(value)
|
||||
return this.rpg_extra.enable_flame_boots
|
||||
end
|
||||
|
||||
--- Enables/disabled explosive bullets globally.
|
||||
---@param value <boolean>
|
||||
function Public.enable_explosive_bullets_globally(value)
|
||||
if value then
|
||||
this.rpg_extra.enable_explosive_bullets_globally = value
|
||||
else
|
||||
this.rpg_extra.enable_explosive_bullets_globally = false
|
||||
end
|
||||
|
||||
return this.rpg_extra.enable_explosive_bullets_globally
|
||||
end
|
||||
|
||||
--- Fetches if the explosive bullets module is activated globally.
|
||||
function Public.get_explosive_bullets()
|
||||
return this.rpg_extra.enable_explosive_bullets_globally
|
||||
end
|
||||
|
||||
--- Enables/disabled explosive bullets.
|
||||
---@param value <boolean>
|
||||
function Public.enable_explosive_bullets(value)
|
||||
if value then
|
||||
this.rpg_extra.enable_explosive_bullets = value
|
||||
else
|
||||
this.rpg_extra.enable_explosive_bullets = false
|
||||
end
|
||||
|
||||
return this.rpg_extra.enable_explosive_bullets
|
||||
end
|
||||
|
||||
--- Fetches if the explosive bullets module is activated.
|
||||
function Public.get_explosive_bullets()
|
||||
return this.rpg_extra.enable_explosive_bullets
|
||||
end
|
||||
|
||||
--- Enables/disabled personal tax.
|
||||
---@param value <boolean>
|
||||
function Public.personal_tax_rate(value)
|
||||
|
||||
Reference in New Issue
Block a user