mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
commit
f15fa41c97
@ -32,9 +32,9 @@ require 'utils.gui'
|
||||
require 'utils.gui.player_list'
|
||||
require 'utils.gui.admin'
|
||||
require 'utils.gui.group'
|
||||
require 'utils.gui.poll'
|
||||
require 'utils.gui.score'
|
||||
require 'utils.gui.config'
|
||||
require 'utils.gui.poll'
|
||||
require 'utils.gui.server_select'
|
||||
require 'utils.freeplay'
|
||||
|
||||
|
@ -74,6 +74,7 @@ local Public = {}
|
||||
local raise_event = script.raise_event
|
||||
local floor = math.floor
|
||||
local remove = table.remove
|
||||
RPG.disable_cooldowns_on_spells()
|
||||
|
||||
local collapse_kill = {
|
||||
entities = {
|
||||
@ -178,7 +179,6 @@ function Public.reset_map()
|
||||
RPG.enable_aoe_punch_globally(false)
|
||||
RPG.enable_range_buffs(true)
|
||||
RPG.enable_auto_allocate(true)
|
||||
RPG.disable_cooldowns_on_spells()
|
||||
RPG.enable_explosive_bullets_globally(true)
|
||||
RPG.enable_explosive_bullets(false)
|
||||
RPG_Progression.toggle_module(false)
|
||||
|
@ -1,5 +1,8 @@
|
||||
local Public = require 'modules.rpg.table'
|
||||
|
||||
local Spells = require 'modules.rpg.spells'
|
||||
Public.spells = Spells
|
||||
|
||||
local Bullets = require 'modules.rpg.explosive_gun_bullets'
|
||||
Public.explosive_bullet = Bullets
|
||||
|
||||
@ -15,9 +18,6 @@ Public.gui = Gui
|
||||
local Settings = require 'modules.rpg.settings'
|
||||
Public.settings = Settings
|
||||
|
||||
local Spells = require 'modules.rpg.spells'
|
||||
Public.spells = Spells
|
||||
|
||||
local Commands = require 'modules.rpg.commands'
|
||||
Public.commands = Commands
|
||||
|
||||
|
@ -569,9 +569,16 @@ function Public.cast_spell(player, failed)
|
||||
}
|
||||
player.surface.create_entity({name = 'flying-text', position = p, text = '✔️', color = {255, math.random(0, 100), 0}})
|
||||
end
|
||||
player.play_sound {path = 'utility/scenario_message', volume_modifier = 0.50}
|
||||
player.play_sound {path = 'utility/scenario_message', volume_modifier = 1}
|
||||
else
|
||||
player.play_sound {path = 'utility/cannot_build', volume_modifier = 0.50}
|
||||
for _ = 1, 3, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
player.surface.create_entity({name = 'flying-text', position = p, text = '✖', color = {255, math.random(0, 100), 0}})
|
||||
end
|
||||
player.play_sound {path = 'utility/cannot_build', volume_modifier = 1}
|
||||
end
|
||||
end
|
||||
|
||||
@ -852,6 +859,7 @@ function Public.rpg_reset_all_players()
|
||||
rpg_extra.global_pool = 0
|
||||
end
|
||||
|
||||
-- local Public = require 'modules.rpg.table' Public.gain_xp(game.players['Gerkiz'], 5012, true)
|
||||
function Public.gain_xp(player, amount, added_to_pool, text)
|
||||
if not Public.validate_player(player) then
|
||||
return
|
||||
|
@ -1009,33 +1009,6 @@ local function on_player_joined_game(event)
|
||||
Public.update_player_stats(player)
|
||||
end
|
||||
|
||||
local function create_projectile(surface, name, position, force, target, max_range)
|
||||
if max_range then
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = max_range,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
else
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_near_coord_modifier(range)
|
||||
local coord = {x = (range * -1) + random(0, range * 2), y = (range * -1) + random(0, range * 2)}
|
||||
for i = 1, 5, 1 do
|
||||
@ -1117,7 +1090,7 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
local conjure_items = Public.get_spells()
|
||||
local conjure_items = Public.spells
|
||||
local projectile_types = Public.get_projectiles
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
@ -1215,100 +1188,21 @@ local function on_player_used_capsule(event)
|
||||
force = 'player'
|
||||
end
|
||||
|
||||
if object.entityName == 'suicidal_comfylatron' then
|
||||
Public.suicidal_comfylatron(position, surface)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif object.entityName == 'repair_aoe' then
|
||||
Public.repair_aoe(player, position)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif object.entityName == 'pointy_explosives' then
|
||||
local entities =
|
||||
player.surface.find_entities_filtered {
|
||||
force = player.force,
|
||||
type = 'container',
|
||||
area = {{position.x - 1, position.y - 1}, {position.x + 1, position.y + 1}}
|
||||
local data = {
|
||||
self = object,
|
||||
player = player,
|
||||
damage_entity = damage_entity,
|
||||
position = position,
|
||||
surface = surface,
|
||||
force = force,
|
||||
target_pos = target_pos,
|
||||
range = range,
|
||||
mana = rpg_t.mana,
|
||||
tame_unit_effects = tame_unit_effects,
|
||||
explosives = Explosives
|
||||
}
|
||||
|
||||
local detonate_chest
|
||||
for i = 1, #entities do
|
||||
local e = entities[i]
|
||||
detonate_chest = e
|
||||
end
|
||||
if detonate_chest and detonate_chest.valid then
|
||||
local success = Explosives.detonate_chest(detonate_chest)
|
||||
if success then
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
end
|
||||
elseif object.entityName == 'warp-gate' then
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
|
||||
if pos then
|
||||
player.teleport(pos, surface)
|
||||
else
|
||||
pos = game.forces.player.get_spawn_position(surface)
|
||||
player.teleport(pos, surface)
|
||||
end
|
||||
Public.remove_mana(player, 999999)
|
||||
Public.damage_player_over_time(player, random(8, 16))
|
||||
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
|
||||
Public.cast_spell(player)
|
||||
elseif object.capsule then -- spawn in capsules i.e objects that are usable with mouse-click
|
||||
player.insert({name = object.entityName, count = object.amount})
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif projectile_types[object.entityName] then -- projectiles
|
||||
for i = 1, object.amount do
|
||||
local damage_area = {
|
||||
left_top = {x = position.x - 2, y = position.y - 2},
|
||||
right_bottom = {x = position.x + 2, y = position.y + 2}
|
||||
}
|
||||
create_projectile(surface, projectile_types[object.entityName].name, position, force, target_pos, range)
|
||||
if object.damage then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = damage_area})) do
|
||||
damage_entity(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
else
|
||||
if object.target then -- rockets and such
|
||||
surface.create_entity({name = object.entityName, position = position, force = force, target = target_pos, speed = 1})
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif surface.can_place_entity {name = object.entityName, position = position} then
|
||||
if object.biter then
|
||||
local e = surface.create_entity({name = object.entityName, position = position, force = force})
|
||||
tame_unit_effects(player, e)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif object.aoe then
|
||||
for x = 1, -1, -1 do
|
||||
for y = 1, -1, -1 do
|
||||
local pos = {x = position.x + x, y = position.y + y}
|
||||
if surface.can_place_entity {name = object.entityName, position = pos} then
|
||||
if object.mana_cost > rpg_t.mana then
|
||||
break
|
||||
end
|
||||
local e = surface.create_entity({name = object.entityName, position = pos, force = force})
|
||||
e.direction = player.character.direction
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local e = surface.create_entity({name = object.entityName, position = position, force = force})
|
||||
e.direction = player.character.direction
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
else
|
||||
Public.cast_spell(player, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
object.callback(data)
|
||||
|
||||
local msg = player.name .. ' casted ' .. object.entityName .. '. '
|
||||
|
||||
@ -1323,8 +1217,6 @@ local function on_player_used_capsule(event)
|
||||
Public.gain_xp(player, reward_xp)
|
||||
|
||||
AntiGrief.insert_into_capsule_history(player, position, msg)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local function on_player_changed_surface(event)
|
||||
|
@ -1,9 +1,112 @@
|
||||
local Public = {}
|
||||
local Public = require 'modules.rpg.table'
|
||||
|
||||
function Public.conjure_items()
|
||||
local spells = {}
|
||||
local spells = {}
|
||||
local random = math.random
|
||||
|
||||
spells[#spells + 1] = {
|
||||
local function create_projectiles(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
local damage_entity = data.damage_entity
|
||||
local position = data.position
|
||||
local surface = data.surface
|
||||
local force = data.force
|
||||
local target_pos = data.target_pos
|
||||
local range = data.range
|
||||
|
||||
local function do_projectile(player_surface, name, _position, _force, target, max_range)
|
||||
player_surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = _position,
|
||||
force = _force,
|
||||
source = _position,
|
||||
target = target,
|
||||
max_range = max_range,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
if self.aoe then
|
||||
for _ = 1, self.amount do
|
||||
local damage_area = {
|
||||
left_top = {x = position.x - 2, y = position.y - 2},
|
||||
right_bottom = {x = position.x + 2, y = position.y + 2}
|
||||
}
|
||||
do_projectile(surface, self.entityName, position, force, target_pos, range)
|
||||
if self.damage then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = damage_area})) do
|
||||
damage_entity(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local damage_area = {
|
||||
left_top = {x = position.x - 2, y = position.y - 2},
|
||||
right_bottom = {x = position.x + 2, y = position.y + 2}
|
||||
}
|
||||
do_projectile(surface, self.entityName, position, force, target_pos, range)
|
||||
if self.damage then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = damage_area})) do
|
||||
damage_entity(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
|
||||
local function create_entity(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
local mana = data.mana
|
||||
local position = data.position
|
||||
local surface = data.surface
|
||||
local force = data.force
|
||||
local tame_unit_effects = data.tame_unit_effects
|
||||
|
||||
if self.biter then
|
||||
local e = surface.create_entity({name = self.entityName, position = position, force = force})
|
||||
tame_unit_effects(player, e)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
return
|
||||
end
|
||||
|
||||
if self.aoe then
|
||||
for x = 1, -1, -1 do
|
||||
for y = 1, -1, -1 do
|
||||
local pos = {x = position.x + x, y = position.y + y}
|
||||
if surface.can_place_entity {name = self.entityName, position = pos} then
|
||||
if self.mana_cost > mana then
|
||||
break
|
||||
end
|
||||
local e = surface.create_entity({name = self.entityName, position = pos, force = force})
|
||||
e.direction = player.character.direction
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if surface.can_place_entity {name = self.entityName, position = position} then
|
||||
local e = surface.create_entity({name = self.entityName, position = position, force = force})
|
||||
e.direction = player.character.direction
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
|
||||
local function insert_onto(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
|
||||
player.insert({name = self.entityName, count = self.amount})
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.stone-wall'},
|
||||
entityName = 'stone-wall',
|
||||
level = 1,
|
||||
@ -12,9 +115,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/stone-wall'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/stone-wall',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.wooden-chest'},
|
||||
entityName = 'wooden-chest',
|
||||
level = 1,
|
||||
@ -23,9 +129,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/wooden-chest'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/wooden-chest',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.iron-chest'},
|
||||
entityName = 'iron-chest',
|
||||
level = 10,
|
||||
@ -34,9 +143,12 @@ function Public.conjure_items()
|
||||
tick = 200,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/iron-chest'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/iron-chest',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.steel-chest'},
|
||||
entityName = 'steel-chest',
|
||||
level = 30,
|
||||
@ -45,9 +157,12 @@ function Public.conjure_items()
|
||||
tick = 300,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/steel-chest'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/steel-chest',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.transport-belt'},
|
||||
entityName = 'transport-belt',
|
||||
level = 1,
|
||||
@ -56,9 +171,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/transport-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/transport-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.fast-transport-belt'},
|
||||
entityName = 'fast-transport-belt',
|
||||
level = 10,
|
||||
@ -67,9 +185,12 @@ function Public.conjure_items()
|
||||
tick = 200,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/fast-transport-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/fast-transport-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.express-transport-belt'},
|
||||
entityName = 'express-transport-belt',
|
||||
level = 30,
|
||||
@ -78,9 +199,12 @@ function Public.conjure_items()
|
||||
tick = 300,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/express-transport-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/express-transport-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.underground-belt'},
|
||||
entityName = 'underground-belt',
|
||||
level = 1,
|
||||
@ -89,9 +213,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/underground-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/underground-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.fast-underground-belt'},
|
||||
entityName = 'fast-underground-belt',
|
||||
level = 10,
|
||||
@ -100,9 +227,12 @@ function Public.conjure_items()
|
||||
tick = 200,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/fast-underground-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/fast-underground-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.express-underground-belt'},
|
||||
entityName = 'express-underground-belt',
|
||||
level = 30,
|
||||
@ -111,9 +241,12 @@ function Public.conjure_items()
|
||||
tick = 300,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/express-underground-belt'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/express-underground-belt',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.pipe'},
|
||||
entityName = 'pipe',
|
||||
level = 1,
|
||||
@ -122,9 +255,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/pipe'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/pipe',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.pipe-to-ground'},
|
||||
entityName = 'pipe-to-ground',
|
||||
level = 1,
|
||||
@ -133,9 +269,12 @@ function Public.conjure_items()
|
||||
tick = 100,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'recipe/pipe-to-ground'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/pipe-to-ground',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.tree'},
|
||||
entityName = 'tree-05',
|
||||
level = 30,
|
||||
@ -144,9 +283,12 @@ function Public.conjure_items()
|
||||
tick = 350,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'entity/tree-05'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/tree-05',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.sand-rock-big'},
|
||||
entityName = 'sand-rock-big',
|
||||
level = 60,
|
||||
@ -155,9 +297,12 @@ function Public.conjure_items()
|
||||
tick = 350,
|
||||
aoe = true,
|
||||
enabled = true,
|
||||
sprite = 'entity/sand-rock-big'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/sand-rock-big',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.small-biter'},
|
||||
entityName = 'small-biter',
|
||||
level = 30,
|
||||
@ -166,9 +311,12 @@ function Public.conjure_items()
|
||||
mana_cost = 55,
|
||||
tick = 200,
|
||||
enabled = true,
|
||||
sprite = 'entity/small-biter'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/small-biter',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.small-spitter'},
|
||||
entityName = 'small-spitter',
|
||||
level = 30,
|
||||
@ -177,9 +325,12 @@ function Public.conjure_items()
|
||||
mana_cost = 55,
|
||||
tick = 200,
|
||||
enabled = true,
|
||||
sprite = 'entity/small-spitter'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/small-spitter',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.medium-biter'},
|
||||
entityName = 'medium-biter',
|
||||
level = 60,
|
||||
@ -188,9 +339,12 @@ function Public.conjure_items()
|
||||
mana_cost = 100,
|
||||
tick = 300,
|
||||
enabled = true,
|
||||
sprite = 'entity/medium-biter'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/medium-biter',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.medium-spitter'},
|
||||
entityName = 'medium-spitter',
|
||||
level = 60,
|
||||
@ -199,9 +353,12 @@ function Public.conjure_items()
|
||||
mana_cost = 100,
|
||||
tick = 300,
|
||||
enabled = true,
|
||||
sprite = 'entity/medium-spitter'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/medium-spitter',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.biter-spawner'},
|
||||
entityName = 'biter-spawner',
|
||||
level = 100,
|
||||
@ -210,9 +367,12 @@ function Public.conjure_items()
|
||||
mana_cost = 800,
|
||||
tick = 1420,
|
||||
enabled = false,
|
||||
sprite = 'entity/biter-spawner'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/biter-spawner',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'entity-name.spitter-spawner'},
|
||||
entityName = 'spitter-spawner',
|
||||
level = 100,
|
||||
@ -221,10 +381,13 @@ function Public.conjure_items()
|
||||
mana_cost = 800,
|
||||
tick = 1420,
|
||||
enabled = false,
|
||||
sprite = 'entity/spitter-spawner'
|
||||
}
|
||||
sprite = 'entity/spitter-spawner',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
|
||||
spells[#spells + 1] = {
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.shotgun-shell'},
|
||||
entityName = 'shotgun-shell',
|
||||
target = true,
|
||||
@ -236,9 +399,12 @@ function Public.conjure_items()
|
||||
mana_cost = 40,
|
||||
tick = 150,
|
||||
enabled = true,
|
||||
sprite = 'recipe/shotgun-shell'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/shotgun-shell',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.grenade'},
|
||||
entityName = 'grenade',
|
||||
target = true,
|
||||
@ -250,9 +416,12 @@ function Public.conjure_items()
|
||||
mana_cost = 100,
|
||||
tick = 150,
|
||||
enabled = true,
|
||||
sprite = 'recipe/grenade'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/grenade',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.cluster-grenade'},
|
||||
entityName = 'cluster-grenade',
|
||||
target = true,
|
||||
@ -264,9 +433,12 @@ function Public.conjure_items()
|
||||
mana_cost = 225,
|
||||
tick = 200,
|
||||
enabled = true,
|
||||
sprite = 'recipe/cluster-grenade'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/cluster-grenade',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.cannon-shell'},
|
||||
entityName = 'cannon-shell',
|
||||
target = true,
|
||||
@ -278,9 +450,12 @@ function Public.conjure_items()
|
||||
mana_cost = 125,
|
||||
tick = 150,
|
||||
enabled = true,
|
||||
sprite = 'recipe/cannon-shell'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/cannon-shell',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.explosive-cannon-shell'},
|
||||
entityName = 'explosive-cannon-shell',
|
||||
target = true,
|
||||
@ -292,9 +467,12 @@ function Public.conjure_items()
|
||||
mana_cost = 250,
|
||||
tick = 200,
|
||||
enabled = true,
|
||||
sprite = 'recipe/explosive-cannon-shell'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/explosive-cannon-shell',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.uranium-cannon-shell'},
|
||||
entityName = 'uranium-cannon-shell',
|
||||
target = true,
|
||||
@ -306,9 +484,12 @@ function Public.conjure_items()
|
||||
mana_cost = 400,
|
||||
tick = 200,
|
||||
enabled = true,
|
||||
sprite = 'recipe/uranium-cannon-shell'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/uranium-cannon-shell',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'item-name.rocket'},
|
||||
entityName = 'rocket',
|
||||
range = 240,
|
||||
@ -321,9 +502,12 @@ function Public.conjure_items()
|
||||
mana_cost = 60,
|
||||
tick = 320,
|
||||
enabled = true,
|
||||
sprite = 'recipe/rocket'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/rocket',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.pointy_explosives'},
|
||||
entityName = 'pointy_explosives',
|
||||
target = true,
|
||||
@ -336,9 +520,35 @@ function Public.conjure_items()
|
||||
mana_cost = 100,
|
||||
tick = 100,
|
||||
enabled = true,
|
||||
sprite = 'recipe/explosives'
|
||||
sprite = 'recipe/explosives',
|
||||
callback = function(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
local Explosives = data.explosives
|
||||
local position = data.position
|
||||
|
||||
local entities =
|
||||
player.surface.find_entities_filtered {
|
||||
force = player.force,
|
||||
type = 'container',
|
||||
area = {{position.x - 1, position.y - 1}, {position.x + 1, position.y + 1}}
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
|
||||
local detonate_chest
|
||||
for i = 1, #entities do
|
||||
local e = entities[i]
|
||||
detonate_chest = e
|
||||
end
|
||||
if detonate_chest and detonate_chest.valid then
|
||||
local success = Explosives.detonate_chest(detonate_chest)
|
||||
if success then
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
end
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.repair_aoe'},
|
||||
entityName = 'repair_aoe',
|
||||
target = true,
|
||||
@ -351,9 +561,18 @@ function Public.conjure_items()
|
||||
mana_cost = 150,
|
||||
tick = 100,
|
||||
enabled = true,
|
||||
sprite = 'recipe/repair-pack'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/repair-pack',
|
||||
callback = function(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
local position = data.position
|
||||
|
||||
Public.repair_aoe(player, position)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.acid_stream'},
|
||||
entityName = 'acid-stream-spitter-big',
|
||||
target = true,
|
||||
@ -366,9 +585,12 @@ function Public.conjure_items()
|
||||
mana_cost = 70,
|
||||
tick = 100,
|
||||
enabled = true,
|
||||
sprite = 'virtual-signal/signal-S'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'virtual-signal/signal-S',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.tank'},
|
||||
entityName = 'tank',
|
||||
amount = 1,
|
||||
@ -379,9 +601,12 @@ function Public.conjure_items()
|
||||
mana_cost = 10000, -- they who know, will know
|
||||
tick = 320,
|
||||
enabled = false,
|
||||
sprite = 'entity/tank'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/tank',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.spidertron'},
|
||||
entityName = 'spidertron',
|
||||
amount = 1,
|
||||
@ -392,9 +617,12 @@ function Public.conjure_items()
|
||||
mana_cost = 19500, -- they who know, will know
|
||||
tick = 320,
|
||||
enabled = false,
|
||||
sprite = 'entity/spidertron'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/spidertron',
|
||||
callback = function(data)
|
||||
create_entity(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.raw_fish'},
|
||||
entityName = 'raw-fish',
|
||||
target = false,
|
||||
@ -408,9 +636,12 @@ function Public.conjure_items()
|
||||
mana_cost = 140,
|
||||
tick = 320,
|
||||
enabled = true,
|
||||
sprite = 'item/raw-fish'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'item/raw-fish',
|
||||
callback = function(data)
|
||||
insert_onto(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.dynamites'},
|
||||
entityName = 'explosives',
|
||||
target = false,
|
||||
@ -424,9 +655,12 @@ function Public.conjure_items()
|
||||
mana_cost = 140,
|
||||
tick = 320,
|
||||
enabled = true,
|
||||
sprite = 'item/explosives'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'item/explosives',
|
||||
callback = function(data)
|
||||
insert_onto(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.comfylatron'},
|
||||
entityName = 'suicidal_comfylatron',
|
||||
target = false,
|
||||
@ -439,9 +673,19 @@ function Public.conjure_items()
|
||||
mana_cost = 150,
|
||||
tick = 320,
|
||||
enabled = true,
|
||||
sprite = 'entity/compilatron'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'entity/compilatron',
|
||||
callback = function(data)
|
||||
local self = data.self
|
||||
local player = data.player
|
||||
local position = data.position
|
||||
local surface = data.surface
|
||||
|
||||
Public.suicidal_comfylatron(position, surface)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, self.mana_cost)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.distractor'},
|
||||
entityName = 'distractor-capsule',
|
||||
target = true,
|
||||
@ -454,9 +698,12 @@ function Public.conjure_items()
|
||||
mana_cost = 220,
|
||||
tick = 320,
|
||||
enabled = true,
|
||||
sprite = 'recipe/distractor-capsule'
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
sprite = 'recipe/distractor-capsule',
|
||||
callback = function(data)
|
||||
create_projectiles(data)
|
||||
end
|
||||
}
|
||||
spells[#spells + 1] = {
|
||||
name = {'spells.warp'},
|
||||
entityName = 'warp-gate',
|
||||
target = true,
|
||||
@ -466,10 +713,24 @@ function Public.conjure_items()
|
||||
mana_cost = 340,
|
||||
tick = 2000,
|
||||
enabled = true,
|
||||
sprite = 'virtual-signal/signal-W'
|
||||
}
|
||||
return spells
|
||||
end
|
||||
sprite = 'virtual-signal/signal-W',
|
||||
callback = function(data)
|
||||
local player = data.player
|
||||
local surface = data.surface
|
||||
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
|
||||
if pos then
|
||||
player.teleport(pos, surface)
|
||||
else
|
||||
pos = game.forces.player.get_spawn_position(surface)
|
||||
player.teleport(pos, surface)
|
||||
end
|
||||
Public.remove_mana(player, 999999)
|
||||
Public.damage_player_over_time(player, random(8, 16))
|
||||
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
|
||||
Public.cast_spell(player)
|
||||
end
|
||||
}
|
||||
|
||||
Public.projectile_types = {
|
||||
['explosives'] = {name = 'grenade', count = 0.5, max_range = 32, tick_speed = 1},
|
||||
@ -510,4 +771,132 @@ Public.projectile_types = {
|
||||
['cliff-explosives'] = {name = 'cliff-explosives', count = 1, max_range = 48, tick_speed = 2}
|
||||
}
|
||||
|
||||
Public.get_projectiles = Public.projectile_types
|
||||
Public.spells = spells
|
||||
|
||||
--- Retrieves the spells table or a given spell.
|
||||
---@param key string
|
||||
function Public.get_spells(key)
|
||||
if game then
|
||||
return error('Calling Public.get_spells() after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
if Public.spells[key] then
|
||||
return Public.spells[key]
|
||||
else
|
||||
return Public.spells
|
||||
end
|
||||
end
|
||||
|
||||
--- Disables a spell.
|
||||
---@param key string/number
|
||||
-- Table would look like:
|
||||
-- Public.disable_spell({1, 2, 3, 4, 5, 6, 7, 8})
|
||||
function Public.disable_spell(key)
|
||||
if game then
|
||||
return error('Calling Public.disable_spell() after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
if type(key) == 'table' then
|
||||
for _, k in pairs(key) do
|
||||
Public.spells[k].enabled = false
|
||||
end
|
||||
elseif Public.spells[key] then
|
||||
Public.spells[key].enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Clears the spell table.
|
||||
function Public.clear_spell_table()
|
||||
if game then
|
||||
return error('Calling Public.clear_spell_table() after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
Public.spells = {}
|
||||
end
|
||||
|
||||
--- Adds a spell to the rpg_spells
|
||||
---@param tbl table
|
||||
function Public.set_new_spell(tbl)
|
||||
if game then
|
||||
return error('Calling Public.set_new_spell() after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
if tbl then
|
||||
if not tbl.name then
|
||||
return error('A spell requires a name. string', 2)
|
||||
end
|
||||
if not tbl.entityName then
|
||||
return error('A spell requires an object to create. string', 2)
|
||||
end
|
||||
if not tbl.target then
|
||||
return error('A spell requires position. boolean', 2)
|
||||
end
|
||||
if not tbl.amount then
|
||||
return error('A spell requires an amount of creation. <integer>', 2)
|
||||
end
|
||||
if not tbl.range then
|
||||
return error('A spell requires a range. <integer>', 2)
|
||||
end
|
||||
if not tbl.damage then
|
||||
return error('A spell requires damage. <damage-area=true/false>', 2)
|
||||
end
|
||||
if not tbl.force then
|
||||
return error('A spell requires a force. string', 2)
|
||||
end
|
||||
if not tbl.level then
|
||||
return error('A spell requires a level. <integer>', 2)
|
||||
end
|
||||
if not tbl.type then
|
||||
return error('A spell requires a type. <item/entity/special>', 2)
|
||||
end
|
||||
if not tbl.mana_cost then
|
||||
return error('A spell requires mana_cost. <integer>', 2)
|
||||
end
|
||||
if not tbl.tick then
|
||||
return error('A spell requires tick. <integer>', 2)
|
||||
end
|
||||
if not tbl.enabled then
|
||||
return error('A spell requires enabled. boolean', 2)
|
||||
end
|
||||
|
||||
Public.spells[#Public.spells + 1] = tbl
|
||||
end
|
||||
end
|
||||
|
||||
--- This rebuilds all spells. Make sure to make changes on_init if you don't
|
||||
-- want all spells enabled.
|
||||
function Public.rebuild_spells()
|
||||
local new_spells = {}
|
||||
local spell_names = {}
|
||||
|
||||
for i = 1, #spells do
|
||||
if spells[i].enabled then
|
||||
new_spells[#new_spells + 1] = spells[i]
|
||||
spell_names[#spell_names + 1] = spells[i].name
|
||||
end
|
||||
end
|
||||
|
||||
return new_spells, spell_names
|
||||
end
|
||||
|
||||
--- This will disable the cooldown of all spells.
|
||||
function Public.disable_cooldowns_on_spells()
|
||||
if game then
|
||||
return error('Calling Public.disable_cooldowns_on_spells() after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
local new_spells = {}
|
||||
|
||||
for i = 1, #spells do
|
||||
if spells[i].enabled then
|
||||
spells[i].tick = 0
|
||||
new_spells[#new_spells + 1] = spells[i]
|
||||
end
|
||||
end
|
||||
|
||||
Public.spells = new_spells
|
||||
|
||||
return new_spells
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -1,13 +1,11 @@
|
||||
-- one table to rule them all!
|
||||
local Global = require 'utils.global'
|
||||
local Spells = require 'modules.rpg.spells'
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local this = {
|
||||
rpg_extra = {},
|
||||
rpg_t = {},
|
||||
rpg_spells = Spells.conjure_items()
|
||||
rpg_t = {}
|
||||
}
|
||||
|
||||
--! Gui Frames
|
||||
@ -151,7 +149,7 @@ function Public.reset_table()
|
||||
end
|
||||
|
||||
--- Gets value from table
|
||||
---@param key <string>
|
||||
---@param key string
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
@ -161,8 +159,8 @@ function Public.get(key)
|
||||
end
|
||||
|
||||
--- Gets value from player rpg_t table
|
||||
---@param key <string>
|
||||
---@param value <string>
|
||||
---@param key string
|
||||
---@param value string
|
||||
function Public.get_value_from_player(key, value)
|
||||
if key and value then
|
||||
if (this.rpg_t[key] and this.rpg_t[key][value]) then
|
||||
@ -180,9 +178,9 @@ function Public.get_value_from_player(key, value)
|
||||
end
|
||||
|
||||
--- Sets value to player rpg_t table
|
||||
---@param key <string>
|
||||
---@param value <string>
|
||||
---@param setter <string>
|
||||
---@param key string
|
||||
---@param value string
|
||||
---@param setter string
|
||||
function Public.set_value_to_player(key, value, setter)
|
||||
if key and value then
|
||||
if (this.rpg_t[key] and this.rpg_t[key][value]) then
|
||||
@ -194,8 +192,8 @@ function Public.set_value_to_player(key, value, setter)
|
||||
end
|
||||
|
||||
--- Sets a new table to rpg_t table
|
||||
---@param key <string>
|
||||
---@param tbl <string>
|
||||
---@param key string
|
||||
---@param tbl string
|
||||
function Public.set_new_player_tbl(key, tbl)
|
||||
if key and tbl then
|
||||
if type(tbl) ~= 'table' then
|
||||
@ -208,7 +206,7 @@ function Public.set_new_player_tbl(key, tbl)
|
||||
end
|
||||
|
||||
--- Removes a player from rpg_t table
|
||||
---@param key <LuaPlayerIndex>
|
||||
---@param index number
|
||||
function Public.remove_player(index)
|
||||
if index then
|
||||
if this.rpg_t[index] then
|
||||
@ -218,7 +216,7 @@ function Public.remove_player(index)
|
||||
end
|
||||
|
||||
--- Sets value to table
|
||||
---@param key <string>
|
||||
---@param key string
|
||||
function Public.set(key)
|
||||
if key then
|
||||
return this[key]
|
||||
@ -250,7 +248,7 @@ function Public.toggle_debug_aoe_punch()
|
||||
end
|
||||
|
||||
--- Debug only - when you need to troubleshoot.
|
||||
---@param str <string>
|
||||
---@param str string
|
||||
function Public.debug_log(str)
|
||||
if not this.rpg_extra.debug then
|
||||
return
|
||||
@ -259,7 +257,7 @@ function Public.debug_log(str)
|
||||
end
|
||||
|
||||
--- Sets surface name for rpg_v2 to use
|
||||
---@param name <string>
|
||||
---@param name string
|
||||
function Public.set_surface_name(name)
|
||||
if name then
|
||||
this.rpg_extra.surface_name = name
|
||||
@ -272,7 +270,7 @@ end
|
||||
|
||||
--- Enables the bars that shows above the player character.
|
||||
--- If you disable mana but enable <enable_health_and_mana_bars> then only health will be shown
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_health_and_mana_bars(value)
|
||||
this.rpg_extra.enable_health_and_mana_bars = value or false
|
||||
|
||||
@ -280,7 +278,7 @@ function Public.enable_health_and_mana_bars(value)
|
||||
end
|
||||
|
||||
--- Enables the mana feature that allows players to spawn entities.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_mana(value)
|
||||
this.rpg_extra.enable_mana = value or false
|
||||
|
||||
@ -289,7 +287,7 @@ end
|
||||
|
||||
--- This should only be enabled if wave_defense is enabled.
|
||||
--- It boosts the amount of xp the players get after x amount of waves.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_wave_defense(value)
|
||||
this.rpg_extra.enable_wave_defense = value or false
|
||||
|
||||
@ -297,7 +295,7 @@ function Public.enable_wave_defense(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled flame boots.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_flame_boots(value)
|
||||
this.rpg_extra.enable_flame_boots = value or false
|
||||
|
||||
@ -305,7 +303,7 @@ function Public.enable_flame_boots(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled explosive bullets globally.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_explosive_bullets_globally(value)
|
||||
this.rpg_extra.enable_explosive_bullets_globally = value or false
|
||||
|
||||
@ -323,7 +321,7 @@ function Public.get_explosive_bullets()
|
||||
end
|
||||
|
||||
--- Enables/disabled explosive bullets.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_explosive_bullets(value)
|
||||
this.rpg_extra.enable_explosive_bullets = value or false
|
||||
|
||||
@ -336,7 +334,7 @@ function Public.get_range_buffs()
|
||||
end
|
||||
|
||||
--- Enables/disabled range buffs.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_range_buffs(value)
|
||||
this.rpg_extra.enable_range_buffs = value or false
|
||||
|
||||
@ -344,7 +342,7 @@ function Public.enable_range_buffs(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled personal tax.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.personal_tax_rate(value)
|
||||
this.rpg_extra.personal_tax_rate = value or false
|
||||
|
||||
@ -352,7 +350,7 @@ function Public.personal_tax_rate(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled stone-path-tile creation on mined.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_stone_path(value)
|
||||
this.rpg_extra.enable_stone_path = value or false
|
||||
|
||||
@ -360,7 +358,7 @@ function Public.enable_stone_path(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled auto-allocations of skill-points.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_auto_allocate(value)
|
||||
this.rpg_extra.enable_auto_allocate = value or false
|
||||
|
||||
@ -368,7 +366,7 @@ function Public.enable_auto_allocate(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled aoe_punch.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_aoe_punch(value)
|
||||
this.rpg_extra.enable_aoe_punch = value or false
|
||||
|
||||
@ -376,127 +374,13 @@ function Public.enable_aoe_punch(value)
|
||||
end
|
||||
|
||||
--- Enables/disabled aoe_punch.
|
||||
---@param value <boolean>
|
||||
---@param value boolean
|
||||
function Public.enable_aoe_punch_globally(value)
|
||||
this.rpg_extra.enable_aoe_punch_globally = value or false
|
||||
|
||||
return this.rpg_extra.enable_aoe_punch_globally
|
||||
end
|
||||
|
||||
--- Retrieves the spells table or a given spell.
|
||||
---@param key <string>
|
||||
function Public.get_spells(key)
|
||||
if this.rpg_spells[key] then
|
||||
return this.rpg_spells[key]
|
||||
else
|
||||
return this.rpg_spells
|
||||
end
|
||||
end
|
||||
|
||||
--- Disables a spell.
|
||||
---@param key <string/table>
|
||||
-- Table would look like:
|
||||
-- Public.disable_spell({1, 2, 3, 4, 5, 6, 7, 8})
|
||||
function Public.disable_spell(key)
|
||||
if type(key) == 'table' then
|
||||
for _, k in pairs(key) do
|
||||
this.rpg_spells[k].enabled = false
|
||||
end
|
||||
elseif this.rpg_spells[key] then
|
||||
this.rpg_spells[key].enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Clears the spell table.
|
||||
function Public.clear_spell_table()
|
||||
this.rpg_spells = {}
|
||||
end
|
||||
|
||||
--- Adds a spell to the rpg_spells
|
||||
---@param tbl <table>
|
||||
function Public.set_new_spell(tbl)
|
||||
if tbl then
|
||||
if not tbl.name then
|
||||
return error('A spell requires a name. <string>', 2)
|
||||
end
|
||||
if not tbl.entityName then
|
||||
return error('A spell requires an object to create. <string>', 2)
|
||||
end
|
||||
if not tbl.target then
|
||||
return error('A spell requires position. <boolean>', 2)
|
||||
end
|
||||
if not tbl.amount then
|
||||
return error('A spell requires an amount of creation. <integer>', 2)
|
||||
end
|
||||
if not tbl.range then
|
||||
return error('A spell requires a range. <integer>', 2)
|
||||
end
|
||||
if not tbl.damage then
|
||||
return error('A spell requires damage. <damage-area=true/false>', 2)
|
||||
end
|
||||
if not tbl.force then
|
||||
return error('A spell requires a force. <string>', 2)
|
||||
end
|
||||
if not tbl.level then
|
||||
return error('A spell requires a level. <integer>', 2)
|
||||
end
|
||||
if not tbl.type then
|
||||
return error('A spell requires a type. <item/entity/special>', 2)
|
||||
end
|
||||
if not tbl.mana_cost then
|
||||
return error('A spell requires mana_cost. <integer>', 2)
|
||||
end
|
||||
if not tbl.tick then
|
||||
return error('A spell requires tick. <integer>', 2)
|
||||
end
|
||||
if not tbl.enabled then
|
||||
return error('A spell requires enabled. <boolean>', 2)
|
||||
end
|
||||
|
||||
this.rpg_spells[#this.rpg_spells + 1] = tbl
|
||||
end
|
||||
end
|
||||
|
||||
--- This rebuilds all spells. Make sure to make changes on_init if you don't
|
||||
-- want all spells enabled.
|
||||
function Public.rebuild_spells(rebuild)
|
||||
local spells = this.rpg_spells
|
||||
|
||||
local new_spells = {}
|
||||
local spell_names = {}
|
||||
|
||||
for i = 1, #spells do
|
||||
if spells[i].enabled then
|
||||
new_spells[#new_spells + 1] = spells[i]
|
||||
spell_names[#spell_names + 1] = spells[i].name
|
||||
end
|
||||
end
|
||||
|
||||
if rebuild then
|
||||
this.rpg_spells = new_spells
|
||||
end
|
||||
|
||||
return new_spells, spell_names
|
||||
end
|
||||
|
||||
--- This will disable the cooldown of all spells.
|
||||
function Public.disable_cooldowns_on_spells()
|
||||
local spells = this.rpg_spells
|
||||
|
||||
local new_spells = {}
|
||||
|
||||
for i = 1, #spells do
|
||||
if spells[i].enabled then
|
||||
spells[i].tick = 0
|
||||
new_spells[#new_spells + 1] = spells[i]
|
||||
end
|
||||
end
|
||||
|
||||
this.rpg_spells = new_spells
|
||||
|
||||
return new_spells
|
||||
end
|
||||
|
||||
function Public.tweaked_crafting_items(tbl)
|
||||
if not tbl then
|
||||
return
|
||||
@ -511,7 +395,6 @@ function Public.tweaked_crafting_items(tbl)
|
||||
return this.tweaked_crafting_items
|
||||
end
|
||||
|
||||
Public.get_projectiles = Spells.projectile_types
|
||||
Public.settings_frame_name = settings_frame_name
|
||||
Public.save_button_name = save_button_name
|
||||
Public.discard_button_name = discard_button_name
|
||||
|
@ -20,7 +20,8 @@ local on_pre_hidden_handlers = {}
|
||||
local data = {}
|
||||
local element_map = {}
|
||||
local settings = {
|
||||
mod_gui_top_frame = false
|
||||
mod_gui_top_frame = false,
|
||||
disabled_tabs = {}
|
||||
}
|
||||
|
||||
Public.token =
|
||||
@ -318,6 +319,27 @@ function Public.get_disable_clear_invalid_data()
|
||||
return settings.disable_clear_invalid_data
|
||||
end
|
||||
|
||||
-- Disable a gui.
|
||||
---@param frame_name string
|
||||
---@param state boolean?
|
||||
function Public.set_disabled_tab(frame_name, state)
|
||||
if not frame_name then
|
||||
return
|
||||
end
|
||||
|
||||
settings.disabled_tabs[frame_name] = state or false
|
||||
end
|
||||
|
||||
-- Fetches if a gui is disabled.
|
||||
---@param frame_name string
|
||||
function Public.get_disabled_tab(frame_name)
|
||||
if not frame_name then
|
||||
return
|
||||
end
|
||||
|
||||
return settings.disabled_tabs[frame_name]
|
||||
end
|
||||
|
||||
-- Fetches the main frame name
|
||||
function Public.get_main_frame(player)
|
||||
if not player then
|
||||
@ -535,6 +557,7 @@ local function draw_main_frame(player)
|
||||
local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
|
||||
|
||||
for name, func in pairs(tabs) do
|
||||
if not settings.disabled_tabs[name] then
|
||||
if func.only_server_sided then
|
||||
local secs = Server.get_current_time()
|
||||
if secs then
|
||||
@ -566,6 +589,7 @@ local function draw_main_frame(player)
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, child in pairs(tabbed_pane.children) do
|
||||
child.style.padding = 8
|
||||
|
@ -1 +1,5 @@
|
||||
local Gui = require 'utils.gui'
|
||||
Gui.set_disabled_tab('Scoreboard', true)
|
||||
Gui.set_disabled_tab('Groups', true)
|
||||
|
||||
return require 'maps.pirates.main'
|
||||
|
Loading…
x
Reference in New Issue
Block a user