1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

Mtn v3 - more tweaks

This commit is contained in:
Gerkiz 2024-05-29 19:57:58 +02:00
parent 3cc738d22e
commit 98bbc7cabb
15 changed files with 318 additions and 103 deletions

View File

@ -882,16 +882,13 @@ remove_boost_movement_speed_on_respawn =
if not player or not player.valid then
return
end
if not data.tries then
data.tries = 0
end
Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost')
Modifiers.update_player_modifiers(player)
player.print('Movement speed bonus removed!', Color.info)
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = nil
rpg_t.has_boost_on_respawn = nil
end
)
@ -907,7 +904,11 @@ local boost_movement_speed_on_respawn =
end
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = true
if rpg_t.has_boost_on_respawn then
return
end
rpg_t.has_boost_on_respawn = true
Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost', 1)
Modifiers.update_player_modifiers(player)

View File

@ -689,6 +689,14 @@ local function create_gui_button(player, bottom_frame_data)
style = Gui.button_style
}
)
if button then
button.style.font_color = {165, 165, 165}
button.style.font = 'heading-3'
button.style.minimal_height = 36
button.style.maximal_height = 36
button.style.minimal_width = 40
button.style.padding = -2
end
else
button =
player.gui.top[auto_stash_button_name] or

View File

@ -23,6 +23,7 @@ local sub = string.sub
local angle_multipler = 2 * math.pi
local start_angle = -angle_multipler / 4
local update_rate = 4
local update_rate_progressbar = 2
local time_to_live = update_rate + 1
local draw_arc = rendering.draw_arc
@ -30,6 +31,7 @@ local draw_arc = rendering.draw_arc
--RPG Frames
local main_frame_name = Public.main_frame_name
local spell_gui_frame_name = Public.spell_gui_frame_name
local cooldown_indicator_name = Public.cooldown_indicator_name
local travelings = {
'bzzZZrrt',
@ -1199,6 +1201,95 @@ function Public.get_magicka(player)
return (rpg_t.magicka - 10) * 0.080
end
function Public.register_cooldown_for_spell(player)
local rpg_t = Public.get_value_from_player(player.index)
local active_spell = Public.get_spell_by_name(rpg_t, rpg_t.dropdown_select_name)
if not active_spell then
return
end
if not rpg_t.cooldowns then
rpg_t.cooldowns = {}
end
rpg_t.cooldowns[active_spell.entityName] = game.tick + active_spell.cooldown
end
function Public.is_cooldown_active_for_player(player)
local rpg_t = Public.get_value_from_player(player.index)
local active_spell = Public.get_spell_by_name(rpg_t, rpg_t.dropdown_select_name)
if not active_spell then
return false
end
if not rpg_t.cooldowns or not next(rpg_t.cooldowns) or not rpg_t.cooldowns[active_spell.entityName] then
return false
end
return rpg_t.cooldowns[active_spell.entityName] > game.tick
end
function Public.get_cooldown_progressbar_for_player(player)
local f = player.gui.screen[spell_gui_frame_name]
if not f then
return
end
local element = f[cooldown_indicator_name]
if not element or not element.valid then
return
end
return element
end
local show_cooldown_progressbar
show_cooldown_progressbar =
Token.register(
function(event)
local player_index = event.player_index
local player = game.get_player(player_index)
if not player or not player.valid then
return
end
local tick = event.tick
local now = game.tick
local element = Public.get_cooldown_progressbar_for_player(player)
if not element or not element.valid then
if now >= tick then
return
else
Task.set_timeout_in_ticks(update_rate_progressbar, show_cooldown_progressbar, event)
end
return
end
if now >= tick then
element.value = 0
return
end
local rpg_t = Public.get_value_from_player(player.index)
local active_spell = Public.get_spell_by_name(rpg_t, rpg_t.dropdown_select_name)
if event.name ~= active_spell.entityName then
Task.set_timeout_in_ticks(update_rate_progressbar, show_cooldown_progressbar, event)
return
end
local fade = ((tick - now) / event.delay)
element.value = fade
Task.set_timeout_in_ticks(update_rate_progressbar, show_cooldown_progressbar, event)
end
)
Public.show_cooldown_progressbar = show_cooldown_progressbar
local show_cooldown
show_cooldown =
Token.register(
@ -1212,6 +1303,8 @@ show_cooldown =
local tick = event.tick
local now = game.tick
if now >= tick then
local rpg_t = Public.get_value_from_player(player.index)
rpg_t.cooldown_enabled = nil
return
end
@ -1241,9 +1334,21 @@ show_cooldown =
Public.show_cooldown = show_cooldown
function Public.register_cooldown_for_player(player, spell)
local rpg_t = Public.get_value_from_player(player.index)
if rpg_t.cooldown_enabled then
return
end
if not rpg_t.cooldown_enabled then
rpg_t.cooldown_enabled = true
end
Task.set_timeout_in_ticks(update_rate, show_cooldown, {player_index = player.index, tick = game.tick + spell.cooldown, delay = spell.cooldown})
end
function Public.register_cooldown_for_player_progressbar(player, spell)
Task.set_timeout_in_ticks(update_rate, show_cooldown_progressbar, {player_index = player.index, tick = game.tick + spell.cooldown, delay = spell.cooldown, name = spell.entityName})
end
--- Gives connected player some bonus xp if the map was preemptively shut down.
-- amount (integer) -- 10 levels
-- local Public = require 'modules.rpg.table' Public.give_xp(512)
@ -1317,7 +1422,7 @@ function Public.rpg_reset_player(player, one_time_reset)
vitality = 10,
mana = 0,
mana_max = 0,
last_spawned = 0,
cooldowns = {},
dropdown_select_index = 1,
dropdown_select_name = Public.all_spells[1].name[1],
dropdown_select_index_1 = 1,
@ -1367,7 +1472,7 @@ function Public.rpg_reset_player(player, one_time_reset)
vitality = 10,
mana = 0,
mana_max = 0,
last_spawned = 0,
cooldowns = {},
dropdown_select_index = 1,
dropdown_select_name = Public.all_spells[1].name[1],
dropdown_select_index_1 = 1,

View File

@ -29,11 +29,18 @@ local spell_gui_frame_name = Public.spell_gui_frame_name
local spell1_button_name = Public.spell1_button_name
local spell2_button_name = Public.spell2_button_name
local spell3_button_name = Public.spell3_button_name
local cooldown_indicator_name = Public.cooldown_indicator_name
local round = math.round
local floor = math.floor
function Public.draw_gui_char_button(player)
local rpg_extra = Public.get('rpg_extra')
local tooltip = 'RPG'
if rpg_extra.enable_mana then
tooltip = 'RPG\nHold [color=yellow]SHIFT[/color] to quickly access the spells frame.'
end
if ComfyGui.get_mod_gui_top_frame() then
local b =
ComfyGui.add_mod_button(
@ -42,7 +49,7 @@ function Public.draw_gui_char_button(player)
type = 'sprite-button',
name = draw_main_frame_name,
caption = '[RPG]',
tooltip = 'RPG',
tooltip = tooltip,
style = Gui.button_style
}
)
@ -548,6 +555,23 @@ Gui.on_click(
return
end
if not Public.check_is_surface_valid(player) then
return
end
if event.shift then
local screen = player.gui.screen
local frame = screen[spell_gui_frame_name]
if frame and frame.valid then
Gui.remove_data_recursively(frame)
frame.destroy()
else
Public.spell_gui_settings(player)
end
return
end
toggle(player)
end
)
@ -734,7 +758,7 @@ Gui.on_click(
end
end
remove_target_frame(event.element)
remove_target_frame(frame)
if player.gui.screen[main_frame_name] then
toggle(player, true)
@ -870,6 +894,7 @@ Gui.on_click(
if is_spamming then
return
end
---@type LuaPlayer
local player = event.player
local screen = player.gui.screen
local frame = screen[spell_gui_frame_name]
@ -887,8 +912,22 @@ Gui.on_click(
if not rpg_t.enable_entity_spawn then
player.print({'rpg_settings.cast_spell_enabled_label'}, Color.success)
player.play_sound({path = 'utility/armor_insert', volume_modifier = 0.75})
if player.cursor_stack and player.cursor_stack.valid_for_read then
player.get_main_inventory().insert(player.cursor_stack)
player.cursor_stack.clear()
end
local fishy = player.get_main_inventory().find_item_stack('raw-fish')
if player.cursor_stack and fishy then
player.cursor_stack.transfer_stack(fishy)
end
rpg_t.enable_entity_spawn = true
else
if player.cursor_stack and player.cursor_stack.valid_for_read and player.cursor_stack.name == 'raw-fish' then
player.get_main_inventory().insert(player.cursor_stack)
player.cursor_stack.clear()
end
player.print({'rpg_settings.cast_spell_disabled_label'}, Color.warning)
player.play_sound({path = 'utility/cannot_build', volume_modifier = 0.75})
rpg_t.enable_entity_spawn = false
@ -943,7 +982,16 @@ Gui.on_click(
return
end
if event.shift then
ComfyGui.clear_all_center_frames(player)
Public.extra_settings(player)
return
end
if frame and frame.valid then
if frame[cooldown_indicator_name] then
frame[cooldown_indicator_name].value = 0
end
Public.update_spell_gui(player, 1)
end
end
@ -967,7 +1015,16 @@ Gui.on_click(
return
end
if event.shift then
ComfyGui.clear_all_center_frames(player)
Public.extra_settings(player)
return
end
if frame and frame.valid then
if frame[cooldown_indicator_name] then
frame[cooldown_indicator_name].value = 0
end
Public.update_spell_gui(player, 2)
end
end
@ -991,7 +1048,16 @@ Gui.on_click(
return
end
if event.shift then
ComfyGui.clear_all_center_frames(player)
Public.extra_settings(player)
return
end
if frame and frame.valid then
if frame[cooldown_indicator_name] then
frame[cooldown_indicator_name].value = 0
end
Public.update_spell_gui(player, 3)
end
end

View File

@ -20,6 +20,8 @@ local nth_tick = Public.nth_tick
--RPG Frames
local main_frame_name = Public.main_frame_name
local spell_gui_frame_name = Public.spell_gui_frame_name
local cooldown_indicator_name = Public.cooldown_indicator_name
local round = math.round
local floor = math.floor
@ -922,10 +924,6 @@ local function on_player_used_capsule(event)
return
end
if rpg_t.last_spawned >= game.tick then
return Public.cast_spell(player, true)
end
local mana = rpg_t.mana
local surface = player.surface
@ -934,6 +932,13 @@ local function on_player_used_capsule(event)
return
end
if spell.enforce_cooldown then
if Public.is_cooldown_active_for_player(player) then
Public.cast_spell(player, true)
return
end
end
local position = event.position
if not position then
return
@ -984,13 +989,6 @@ local function on_player_used_capsule(event)
force = 'player'
end
if spell.check_if_active then
if rpg_t.has_custom_spell_active then
Public.cast_spell(player, true)
return
end
end
local data = {
self = spell,
player = player,
@ -1027,10 +1025,18 @@ local function on_player_used_capsule(event)
StatData.get_data(player):increase('spells')
if spell.enforce_cooldown then
Public.register_cooldown_for_player(player, spell)
if player.gui.screen[spell_gui_frame_name] then
local f = player.gui.screen[spell_gui_frame_name]
if f then
if f[cooldown_indicator_name] then
Public.register_cooldown_for_player_progressbar(player, spell)
end
end
else
Public.register_cooldown_for_player(player, spell)
end
end
rpg_t.last_spawned = game.tick + spell.cooldown
Public.update_mana(player)
local reward_xp = spell.mana_cost * 0.085

View File

@ -15,6 +15,7 @@ local enable_spawning_frame_name = Public.enable_spawning_frame_name
local spell1_button_name = Public.spell1_button_name
local spell2_button_name = Public.spell2_button_name
local spell3_button_name = Public.spell3_button_name
local cooldown_indicator_name = Public.cooldown_indicator_name
local settings_level = Public.gui_settings_levels
@ -35,6 +36,7 @@ local function create_input_element(frame, type, value, items, index, tooltip)
if type == 'boolean' then
return frame.add({type = 'checkbox', state = value})
end
if type == 'label' then
local label = frame.add({type = 'label', caption = value})
label.style.font = 'default-listbox'
@ -47,9 +49,15 @@ local function create_input_element(frame, type, value, items, index, tooltip)
return frame.add({type = 'text-box', text = value})
end
local function create_custom_label_element(frame, sprite, localised_string, value, tooltip)
local function create_sprite(frame, sprite, localised_string, value, tooltip)
local t = frame.add({type = 'flow'})
t.add({type = 'label', caption = '[' .. sprite .. ']'})
local s = t.add({type = 'sprite', sprite = sprite})
if s then
s.style.minimal_width = 25
s.style.maximal_width = 25
s.style.minimal_height = 25
s.style.maximal_height = 25
end
local heading = t.add({type = 'label', caption = localised_string})
heading.tooltip = tooltip or ''
@ -131,11 +139,18 @@ function Public.update_spell_gui(player, spell_index)
local spell_2_data = Public.get_spell_by_name(rpg_t, rpg_t.dropdown_select_name_2)
local spell_3_data = Public.get_spell_by_name(rpg_t, rpg_t.dropdown_select_name_3)
spell_table[spell1_button_name].tooltip = spell_1_data and spell_1_data.name or '---'
local shift_tooltip = 'Hold [color=yellow]SHIFT[/color] while clicking a spell to quickly change your spells.'
local t1 = {'', {spell_1_data and spell_1_data.name and spell_1_data.name[1] or '---'}, '\n', shift_tooltip}
spell_table[spell1_button_name].tooltip = t1
spell_table[spell1_button_name].sprite = spell_1_data and spell_1_data.sprite
spell_table[spell2_button_name].tooltip = spell_2_data and spell_2_data.name or '---'
local t2 = {'', {spell_2_data and spell_2_data.name and spell_2_data.name[1] or '---'}, '\n', shift_tooltip}
spell_table[spell2_button_name].tooltip = t2
spell_table[spell2_button_name].sprite = spell_2_data.sprite
spell_table[spell3_button_name].tooltip = spell_3_data and spell_3_data.name or '---'
local t3 = {'', {spell_3_data and spell_3_data.name and spell_3_data.name[1] or '---'}, '\n', shift_tooltip}
spell_table[spell3_button_name].tooltip = t3
spell_table[spell3_button_name].sprite = spell_3_data.sprite
if rpg_t.dropdown_select_index_1 == rpg_t.dropdown_select_index then
@ -229,6 +244,16 @@ function Public.spell_gui_settings(player)
b1.style.font_color = {r = 0.98, g = 0.98, b = 0.98}
b2.style.font_color = {r = 0.98, g = 0.98, b = 0.98}
b3.style.font_color = {r = 0.98, g = 0.98, b = 0.98}
local cooldown =
main_frame.add(
{
type = 'progressbar',
name = cooldown_indicator_name,
tooltip = 'Shows the cooldown of the active spell.',
value = 0
}
)
cooldown.style.maximal_width = 170
Public.update_spell_gui(player, nil)
else
main_frame.destroy()
@ -732,6 +757,8 @@ function Public.settings_tooltip(player)
local normal_spell_pane = inside_table.add({type = 'scroll-pane'})
local ns = normal_spell_pane.style
ns.vertically_squashable = true
ns.minimal_width = 530
ns.maximal_width = 530
ns.bottom_padding = 5
ns.left_padding = 5
ns.right_padding = 5
@ -756,7 +783,7 @@ function Public.settings_tooltip(player)
for _, entity in pairs(spells) do
if entity.enabled then
local cooldown = (entity.cooldown / 60) .. 's'
local cooldown = (math.round(entity.cooldown / 60, 1)) .. 's'
if entity.type == 'item' then
local text = '[item=' .. entity.entityName .. '] ▪️ Level: [font=default-bold]' .. entity.level .. '[/font] Mana: [font=default-bold]' .. entity.mana_cost .. '[/font]. Cooldown: [font=default-bold]' .. cooldown .. '[/font]'
create_input_element(normal_spell_grid, 'label', text, nil, nil, entity.tooltip)
@ -770,6 +797,9 @@ function Public.settings_tooltip(player)
local special_spell_pane = inside_table.add({type = 'scroll-pane'})
local ss = special_spell_pane.style
ss.vertically_squashable = true
ss.maximal_height = 350
ss.minimal_width = 530
ss.maximal_width = 530
ss.bottom_padding = 5
ss.left_padding = 5
ss.right_padding = 5
@ -789,10 +819,10 @@ function Public.settings_tooltip(player)
for _, entity in pairs(spells) do
if entity.enabled then
local cooldown = (entity.cooldown / 60) .. 's'
local cooldown = (math.round(entity.cooldown / 60, 1)) .. 's'
if entity.type == 'special' then
local text = '▪️ Level: [font=default-bold]' .. entity.level .. '[/font] Mana: [font=default-bold]' .. entity.mana_cost .. '[/font]. Cooldown: [font=default-bold]' .. cooldown .. '[/font]'
create_custom_label_element(special_spell_grid, entity.special_sprite, entity.name, text, entity.tooltip)
create_sprite(special_spell_grid, entity.sprite, entity.name, text, entity.tooltip)
end
end
end

View File

@ -1,6 +1,7 @@
local Public = require 'modules.rpg.table'
local Task = require 'utils.task_token'
local Ai = require 'modules.ai'
local Gui = require 'utils.gui'
local Modifiers = require 'utils.player_modifiers'
local spells = {}
@ -12,7 +13,6 @@ local states = {
['support'] = 'poison-capsule-smoke'
}
local restore_movement_speed_token
local repeat_sound_token
local repair_buildings =
@ -45,18 +45,25 @@ repeat_sound_token =
local sound = event.sound or 'utility/armor_insert'
local spell_active = Public.get_value_from_player(player_index, 'has_custom_spell_active')
if spell_active then
if event.once then
player.play_sound {path = sound, volume_modifier = 1}
if player.character ~= nil then
player.character.surface.create_entity({name = 'water-splash', position = player.position})
end
Task.set_timeout_in_ticks(30, repeat_sound_token, event)
else
player.play_sound {path = sound, volume_modifier = 1}
return
end
local tick = event.tick
local now = game.tick
if now >= tick then
return
end
player.play_sound {path = sound, volume_modifier = 1}
if player.character ~= nil then
player.character.surface.create_entity({name = 'water-splash', position = player.position})
end
Task.set_timeout_in_ticks(30, repeat_sound_token, event)
end
)
@ -75,8 +82,7 @@ local x_marks_the_spot_token =
end
player.teleport(old_position, old_surface_index)
Public.set_active_spell_disabled(player_index)
Task.set_timeout_in_ticks(5, repeat_sound_token, {player_index = player.index, sound = 'utility/new_objective'})
Task.set_timeout_in_ticks(5, repeat_sound_token, {player_index = player.index, sound = 'utility/new_objective', once = true})
end
)
@ -159,26 +165,16 @@ local function area_of_effect(player, position, state, radius, callback, find_en
end
end
restore_movement_speed_token =
local restore_movement_speed_token =
Task.register(
function(event)
local player_index = event.player_index
local rpg_t = event.rpg_t
if rpg_t then
rpg_t.has_custom_spell_active = nil
end
local player = game.get_player(player_index)
if not player or not player.valid then
return
end
if not player.character or not player.character.valid then
Task.set_timeout_in_ticks(60, restore_movement_speed_token, {player_index = player_index, rpg_t = rpg_t})
return
end
Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'rpg_spell', 0)
Modifiers.update_player_modifiers(player)
end
@ -765,6 +761,7 @@ spells[#spells + 1] = {
sprite = 'recipe/explosive-cannon-shell',
tooltip = 'Spawns a explosive cannon shell where the mouse cursor is at',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return create_projectiles(data)
end
}
@ -785,6 +782,8 @@ spells[#spells + 1] = {
sprite = 'recipe/uranium-cannon-shell',
tooltip = 'Spawns a uranium cannon shell where the mouse cursor is at',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return create_projectiles(data)
end
}
@ -823,7 +822,6 @@ spells[#spells + 1] = {
enabled = true,
log_spell = true,
sprite = 'recipe/explosives',
special_sprite = 'recipe=explosives',
tooltip = 'Spawns a pointy explosive',
callback = function(data)
local self = data.self
@ -869,12 +867,13 @@ spells[#spells + 1] = {
enforce_cooldown = true,
log_spell = true,
sprite = 'recipe/repair-pack',
special_sprite = 'recipe=repair-pack',
tooltip = 'Repairs multiple entities in a range',
callback = function(data)
local self = data.self
local rpg_t = data.rpg_t
local player = data.player
Public.register_cooldown_for_spell(player)
local position = data.position
local range = Public.get_area_of_effect_range(player)
@ -914,12 +913,13 @@ spells[#spells + 1] = {
cooldown = 500,
enabled = true,
enforce_cooldown = true,
sprite = 'virtual-signal/signal-S',
special_sprite = 'virtual-signal=signal-S',
sprite = Gui.spew_icon,
tooltip = 'Creates a puddle of acid stream',
callback = function(data)
local self = data.self
local player = data.player
Public.register_cooldown_for_spell(player)
local position = data.position
local range = Public.get_area_of_effect_range(player)
@ -952,7 +952,6 @@ spells[#spells + 1] = {
cooldown = 320,
enabled = false,
sprite = 'entity/tank',
special_sprite = 'entity=tank',
tooltip = 'Spawns a tank',
callback = function(data)
return create_entity(data)
@ -971,7 +970,6 @@ spells[#spells + 1] = {
enabled = false,
log_spell = true,
sprite = 'entity/spidertron',
special_sprite = 'entity=spidertron',
tooltip = 'Spawns a spidertron',
callback = function(data)
return create_entity(data)
@ -993,9 +991,10 @@ spells[#spells + 1] = {
cooldown = 150,
enabled = true,
sprite = 'item/raw-fish',
special_sprite = 'item=raw-fish',
tooltip = 'Spawns some fishies',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return insert_onto(data)
end
}
@ -1016,9 +1015,10 @@ spells[#spells + 1] = {
cooldown = 150,
enabled = true,
sprite = 'item/explosives',
special_sprite = 'item=explosives',
tooltip = 'Spawns some explosives',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return insert_onto(data)
end
}
@ -1038,11 +1038,12 @@ spells[#spells + 1] = {
enabled = true,
log_spell = true,
sprite = 'entity/compilatron',
special_sprite = 'entity=compilatron',
tooltip = 'Spawns a suicide comfylatron',
callback = function(data)
local self = data.self
local player = data.player
Public.register_cooldown_for_spell(player)
local position = data.position
local surface = data.surface
@ -1067,9 +1068,10 @@ spells[#spells + 1] = {
cooldown = 150,
enabled = true,
sprite = 'recipe/distractor-capsule',
special_sprite = 'recipe=distractor-capsule',
tooltip = 'Spawns disctractors',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return create_projectiles(data)
end
}
@ -1089,9 +1091,10 @@ spells[#spells + 1] = {
cooldown = 150,
enabled = true,
sprite = 'recipe/defender-capsule',
special_sprite = 'recipe=defender-capsule',
tooltip = 'Spawns defenders',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return create_projectiles(data)
end
}
@ -1110,9 +1113,10 @@ spells[#spells + 1] = {
cooldown = 150,
enabled = true,
sprite = 'recipe/destroyer-capsule',
special_sprite = 'recipe=destroyer-capsule',
tooltip = 'Spawns destroyers',
callback = function(data)
Public.register_cooldown_for_spell(data.player)
return create_projectiles(data)
end
}
@ -1128,11 +1132,12 @@ spells[#spells + 1] = {
cooldown = 2000,
enabled = true,
log_spell = true,
sprite = 'virtual-signal/signal-W',
special_sprite = 'virtual-signal=signal-W',
sprite = Gui.warp_icon,
tooltip = 'Warps you back to base',
callback = function(data)
local player = data.player
Public.register_cooldown_for_spell(player)
local surface = data.surface
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
@ -1160,18 +1165,16 @@ spells[#spells + 1] = {
mana_cost = 340,
cooldown = 2000,
enforce_cooldown = true,
check_if_active = true,
enabled = true,
log_spell = true,
sprite = 'virtual-signal/signal-X',
special_sprite = 'virtual-signal=signal-X',
sprite = Gui.x_icon,
tooltip = 'Warps you back to the locomotive and after a couple of seconds you return to your previous location.',
callback = function(data)
local player = data.player
local surface = data.surface
local old_position = player.position
local rpg_t = data.rpg_t
rpg_t.has_custom_spell_active = true
Public.register_cooldown_for_spell(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
@ -1181,7 +1184,7 @@ spells[#spells + 1] = {
player.teleport(pos, surface)
end
Task.set_timeout_in_ticks(5, repeat_sound_token, {player_index = player.index})
Task.set_timeout_in_ticks(5, repeat_sound_token, {player_index = player.index, tick = game.tick + 600})
Task.set_timeout_in_ticks(600, x_marks_the_spot_token, {player_index = player.index, old_position = old_position, old_surface_index = surface.index})
Public.remove_mana(player, 340)
Public.cast_spell(player)
@ -1199,17 +1202,17 @@ spells[#spells + 1] = {
mana_cost = 340,
cooldown = 100,
enforce_cooldown = true,
check_if_active = false,
enabled = true,
log_spell = false,
sprite = 'virtual-signal/signal-T',
special_sprite = 'virtual-signal=signal-T',
sprite = Gui.tidal_icon,
tooltip = 'Spawns a tidal wave that pushes the enemies back.',
callback = function(data)
local player = data.player
local rpg_t = data.rpg_t
local cursor_position = data.position
Public.register_cooldown_for_spell(player)
local shape = 'cone'
if random(1, 2) == 1 then
@ -1233,18 +1236,17 @@ spells[#spells + 1] = {
level = 25,
type = 'special',
mana_cost = 100,
cooldown = 2000,
check_if_active = true,
enforce_cooldown = true,
cooldown = 300,
enabled = true,
log_spell = true,
sprite = 'virtual-signal/signal-info',
special_sprite = 'virtual-signal=signal-info',
sprite = 'item/exoskeleton-equipment',
tooltip = 'Gives you a temporary movement boost.',
callback = function(data)
local self = data.self
local player = data.player
local rpg_t = data.rpg_t
rpg_t.has_custom_spell_active = true
Public.register_cooldown_for_spell(player)
Public.remove_mana(player, self.mana_cost)
for _ = 1, 3 do
@ -1270,14 +1272,15 @@ spells[#spells + 1] = {
enabled = true,
enforce_cooldown = true,
log_spell = true,
sprite = 'virtual-signal/signal-info',
special_sprite = 'virtual-signal=signal-info',
sprite = Gui.berserk_icon,
tooltip = 'Damages enemies in radius when cast. Scales with player level.',
callback = function(data)
local self = data.self
local player = data.player
local position = data.position
Public.register_cooldown_for_spell(player)
local range = Public.get_area_of_effect_range(player)
local damage = Public.get_player_level(player)
@ -1336,12 +1339,12 @@ local drone_enemy = {
enabled = true,
enforce_cooldown = true,
log_spell = true,
sprite = 'virtual-signal/signal-info',
special_sprite = 'virtual-signal=signal-info',
sprite = 'entity/character',
tooltip = 'Creates a drone that searches for enemies and destroys them.',
callback = function(data)
local self = data.self
local player = data.player
Public.register_cooldown_for_spell(player)
local suc = Ai.create_char({player_index = player.index, command = 1, search_local = true})
if not suc then
Public.cast_spell(player, true)
@ -1368,12 +1371,12 @@ local drone_mine = {
enabled = true,
enforce_cooldown = true,
log_spell = true,
sprite = 'virtual-signal/signal-info',
special_sprite = 'virtual-signal=signal-info',
sprite = 'entity/character',
tooltip = 'Creates a drone that mines entities around you.',
callback = function(data)
local self = data.self
local player = data.player
Public.register_cooldown_for_spell(player)
local suc = Ai.create_char({player_index = player.index, command = 2, search_local = false})
if not suc then
Public.cast_spell(player, true)
@ -1586,9 +1589,6 @@ function Public.set_new_spell(tbl)
if not tbl.log_spell then
tbl.log_spell = false
end
if not tbl.check_if_active then
tbl.check_if_active = false
end
if not tbl.callback then
return error('A spell requires a callback. <function>', 2)
end

View File

@ -25,6 +25,7 @@ local enable_spawning_frame_name = Gui.uid_name()
local spell1_button_name = Gui.uid_name()
local spell2_button_name = Gui.uid_name()
local spell3_button_name = Gui.uid_name()
local cooldown_indicator_name = Gui.uid_name()
Global.register(
this,
@ -199,22 +200,6 @@ function Public.set_value_to_player(key, value, setter)
end
end
--- Sets set_active_spell_enabled as enabled.
---@param player_index string
function Public.set_active_spell_enabled(player_index)
if (this.rpg_t[player_index]) then
this.rpg_t[player_index].has_custom_spell_active = true
end
end
--- Sets set_active_spell_disabled as nil.
---@param player_index string
function Public.set_active_spell_disabled(player_index)
if this.rpg_t[player_index] then
this.rpg_t[player_index].has_custom_spell_active = false
end
end
--- Sets a new table to rpg_t table
---@param key string
---@param tbl table
@ -514,6 +499,7 @@ Public.enable_spawning_frame_name = enable_spawning_frame_name
Public.spell1_button_name = spell1_button_name
Public.spell2_button_name = spell2_button_name
Public.spell3_button_name = spell3_button_name
Public.cooldown_indicator_name = cooldown_indicator_name
local on_init = function()
Public.reset_table()

View File

@ -507,6 +507,14 @@ local function create_clear_corpse_frame(player, bottom_frame_data)
style = Gui.button_style
}
)
if button then
button.style.font_color = {165, 165, 165}
button.style.font = 'heading-3'
button.style.minimal_height = 36
button.style.maximal_height = 36
button.style.minimal_width = 40
button.style.padding = -2
end
else
button =
player.gui.top[clear_corpse_button_name] or

BIN
utils/files/berserk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
utils/files/spew.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
utils/files/tidal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
utils/files/warp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

BIN
utils/files/x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

View File

@ -50,6 +50,11 @@ Public.pin_black_icon = 'file/utils/files/pin-black.png'
Public.infinite_icon = 'file/utils/files/infinity.png'
Public.arrow_up_icon = 'file/utils/files/arrow-up.png'
Public.arrow_down_icon = 'file/utils/files/arrow-down.png'
Public.tidal_icon = 'file/utils/files/tidal.png'
Public.spew_icon = 'file/utils/files/spew.png'
Public.berserk_icon = 'file/utils/files/berserk.png'
Public.warp_icon = 'file/utils/files/warp.png'
Public.x_icon = 'file/utils/files/x.png'
Public.info_icon = 'file/utils/files/info.png'
Public.mod_gui_button_enabled = false