Добавлены все обновления от сообщества, вплоть до #148
2
Teleporters/data/entities/entities.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
local require = function(name) return require("data/entities/"..name) end
|
||||
require("teleporters/teleporters")
|
||||
BIN
Teleporters/data/entities/teleporters/hr-teleporter-closed.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 38 KiB |
BIN
Teleporters/data/entities/teleporters/hr-teleporter-open.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
Teleporters/data/entities/teleporters/teleporter-closed.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Teleporters/data/entities/teleporters/teleporter-explosion.ogg
Normal file
BIN
Teleporters/data/entities/teleporters/teleporter-explosion.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Teleporters/data/entities/teleporters/teleporter-icon.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
Teleporters/data/entities/teleporters/teleporter-open.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
Teleporters/data/entities/teleporters/teleporter-technology.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
194
Teleporters/data/entities/teleporters/teleporters.lua
Normal file
@@ -0,0 +1,194 @@
|
||||
local path = util.path("data/entities/teleporters/")
|
||||
local teleporter = util.copy(data.raw["land-mine"]["land-mine"])
|
||||
local names = require("shared")
|
||||
local name = names.entities.teleporter
|
||||
local localised_name = {name}
|
||||
|
||||
teleporter.name = name
|
||||
teleporter.localised_name = localised_name
|
||||
teleporter.trigger_radius = 1
|
||||
teleporter.timeout = 5 * 60
|
||||
teleporter.max_health = 200
|
||||
--teleporter.shooting_cursor_size = 0
|
||||
teleporter.dying_explosion = nil
|
||||
teleporter.action =
|
||||
{
|
||||
type = "direct",
|
||||
action_delivery =
|
||||
{
|
||||
type = "instant",
|
||||
target_effects =
|
||||
{
|
||||
{
|
||||
type = "create-sticker",
|
||||
sticker = names.entities.teleporter_sticker,
|
||||
trigger_created_entity = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
teleporter.force_die_on_attack = false
|
||||
teleporter.trigger_force = "all"
|
||||
--teleporter.create_ghost_on_death = false
|
||||
teleporter.order = name
|
||||
teleporter.picture_safe =
|
||||
{
|
||||
filename = path.."teleporter-closed.png",
|
||||
priority = "medium",
|
||||
width = 80,
|
||||
height = 80,
|
||||
hr_version = {
|
||||
filename = path.."hr-teleporter-closed.png",
|
||||
priority = "medium",
|
||||
width = 160,
|
||||
height = 160,
|
||||
scale = 0.5,
|
||||
}
|
||||
}
|
||||
teleporter.picture_set =
|
||||
{
|
||||
filename = path.."teleporter-open.png",
|
||||
priority = "medium",
|
||||
width = 80,
|
||||
height = 80,
|
||||
hr_version = {
|
||||
filename = path.."hr-teleporter-open.png",
|
||||
priority = "medium",
|
||||
width = 160,
|
||||
height = 160,
|
||||
scale = 0.5,
|
||||
}
|
||||
}
|
||||
teleporter.picture_set_enemy =
|
||||
{
|
||||
filename = path.."teleporter-open.png",
|
||||
priority = "medium",
|
||||
width = 80,
|
||||
height = 80,
|
||||
hr_version = {
|
||||
filename = path.."hr-teleporter-open.png",
|
||||
priority = "medium",
|
||||
width = 160,
|
||||
height = 160,
|
||||
scale = 0.5,
|
||||
}
|
||||
}
|
||||
teleporter.minable = {result = name, mining_time = 3}
|
||||
teleporter.flags =
|
||||
{
|
||||
--"not-blueprintable",
|
||||
"placeable-neutral",
|
||||
"placeable-player",
|
||||
"player-creation",
|
||||
"not-upgradable"
|
||||
}
|
||||
teleporter.collision_box = {{-1, -1},{1, 1}}
|
||||
teleporter.selection_box = {{-1, -1},{1, 1}}
|
||||
teleporter.map_color = {r = 0.5, g = 1, b = 1}
|
||||
|
||||
|
||||
local sticker =
|
||||
{
|
||||
type = "sticker",
|
||||
name = names.entities.teleporter_sticker,
|
||||
--icon = "__base__/graphics/icons/slowdown-sticker.png",
|
||||
flags = {},
|
||||
animation = util.empty_sprite(),
|
||||
duration_in_ticks = 1,
|
||||
--target_movement_modifier = 1
|
||||
}
|
||||
|
||||
|
||||
local teleporter_item = util.copy(data.raw.item["land-mine"])
|
||||
teleporter_item.name = name
|
||||
teleporter_item.localised_name = localised_name
|
||||
teleporter_item.place_result = name
|
||||
teleporter_item.icon = path.."teleporter-icon.png"
|
||||
teleporter_item.icon_size = 64
|
||||
teleporter_item.icon_mipmaps = 0
|
||||
teleporter_item.subgroup = "circuit-network"
|
||||
|
||||
|
||||
local fire = require("data/tf_util/tf_fire_util")
|
||||
|
||||
local teleporter_explosion = util.copy(data.raw.explosion.explosion)
|
||||
teleporter_explosion.name = "teleporter-explosion"
|
||||
teleporter_explosion.animations = fire.create_fire_pictures({scale = 1, animation_speed = 0.3})
|
||||
teleporter_explosion.sound =
|
||||
{
|
||||
filename = path.."teleporter-explosion.ogg",
|
||||
volume = 0.45
|
||||
}
|
||||
|
||||
local teleporter_explosion_2 = util.copy(teleporter_explosion)
|
||||
teleporter_explosion_2.name = "teleporter-explosion-no-sound"
|
||||
teleporter_explosion_2.sound = nil
|
||||
|
||||
local recipe = {
|
||||
type = "recipe",
|
||||
name = name,
|
||||
localised_name = localised_name,
|
||||
enabled = false,
|
||||
ingredients =
|
||||
{
|
||||
{"steel-plate", 45},
|
||||
{"advanced-circuit", 20},
|
||||
{"battery", 25},
|
||||
},
|
||||
energy_required = 5,
|
||||
result = name
|
||||
}
|
||||
|
||||
local technology =
|
||||
{
|
||||
type = "technology",
|
||||
name = name,
|
||||
localised_name = localised_name,
|
||||
localised_description = "",
|
||||
icon_size = 256,
|
||||
icon = path.."teleporter-technology.png",
|
||||
effects =
|
||||
{
|
||||
{
|
||||
type = "unlock-recipe",
|
||||
recipe = name
|
||||
}
|
||||
},
|
||||
unit =
|
||||
{
|
||||
count = 500,
|
||||
ingredients = {
|
||||
{"automation-science-pack", 1},
|
||||
{"logistic-science-pack", 1},
|
||||
{"chemical-science-pack", 1},
|
||||
},
|
||||
time = 30
|
||||
},
|
||||
prerequisites = {"advanced-electronics", "battery"},
|
||||
order = "y-a"
|
||||
}
|
||||
|
||||
local teleporter_flying_text = util.copy(data.raw["flying-text"]["tutorial-flying-text"])
|
||||
teleporter_flying_text.name = "teleporter-flying-text"
|
||||
|
||||
local hotkey_name = require"shared".hotkeys.focus_search
|
||||
local hotkey =
|
||||
{
|
||||
type = "custom-input",
|
||||
name = hotkey_name,
|
||||
linked_game_control = "focus-search",
|
||||
key_sequence = "Control + F"
|
||||
}
|
||||
|
||||
data:extend
|
||||
{
|
||||
teleporter,
|
||||
teleporter_item,
|
||||
teleporter_explosion,
|
||||
teleporter_explosion_2,
|
||||
recipe,
|
||||
technology,
|
||||
teleporter_flying_text,
|
||||
hotkey,
|
||||
sticker
|
||||
}
|
||||
BIN
Teleporters/data/tf_util/empty-sound.ogg
Normal file
BIN
Teleporters/data/tf_util/empty-sprite.png
Normal file
|
After Width: | Height: | Size: 126 B |
324
Teleporters/data/tf_util/prototype_util.lua
Normal file
@@ -0,0 +1,324 @@
|
||||
local rename_recipe = function(old, new)
|
||||
local recipes = data.raw.recipe
|
||||
for k, recipe in pairs (recipes) do
|
||||
if recipe.normal then
|
||||
for k, v in pairs(recipe.normal) do
|
||||
recipe[k] = v
|
||||
end
|
||||
recipe.normal = nil
|
||||
recipe.expensive = nil
|
||||
end
|
||||
for k, ingredient in pairs (recipe.ingredients) do
|
||||
if ingredient.name and ingredient.name == old then
|
||||
ingredient.name = new
|
||||
end
|
||||
if ingredient[1] and ingredient[1] == old then
|
||||
ingredient[1] = new
|
||||
end
|
||||
end
|
||||
if recipe.result and recipe.result == old then
|
||||
recipe.result = new
|
||||
end
|
||||
for k, product in pairs (recipe.products or {}) do
|
||||
if product.name and product.name == old then
|
||||
product.name = new
|
||||
end
|
||||
if product[1] and product[1] == old then
|
||||
product[1] = new
|
||||
end
|
||||
end
|
||||
-- Will have to handle technologies.. so lets do it only when nescessary
|
||||
--if recipe.name == old then
|
||||
-- recipe.name = new
|
||||
-- recipe.localised_name = new
|
||||
-- recipes[new] = recipe
|
||||
-- recipes[old] = nil
|
||||
--end
|
||||
end
|
||||
end
|
||||
|
||||
local rename_item = function(old, new)
|
||||
local items = data.raw.item
|
||||
for k, item in pairs (items) do
|
||||
if item.place_result and item.place_result == old then
|
||||
item.place_result = new
|
||||
end
|
||||
if item.name == old then
|
||||
item.name = new
|
||||
item.localised_name = new
|
||||
items[new] = item
|
||||
items[old] = nil
|
||||
rename_recipe(old, new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local rename_recipe = function(old, new)
|
||||
local recipes = data.raw.recipe
|
||||
for k, recipe in pairs (recipes) do
|
||||
if recipe.normal then
|
||||
for k, v in pairs(recipe.normal) do
|
||||
recipe[k] = v
|
||||
end
|
||||
recipe.normal = nil
|
||||
recipe.expensive = nil
|
||||
end
|
||||
for k, ingredient in pairs (recipe.ingredients) do
|
||||
if ingredient.name and ingredient.name == old then
|
||||
ingredient.name = new
|
||||
end
|
||||
if ingredient[1] and ingredient[1] == old then
|
||||
ingredient[1] = new
|
||||
end
|
||||
end
|
||||
if recipe.result and recipe.result == old then
|
||||
recipe.result = new
|
||||
end
|
||||
for k, product in pairs (recipe.products or {}) do
|
||||
if product.name and product.name == old then
|
||||
product.name = new
|
||||
end
|
||||
if product[1] and product[1] == old then
|
||||
product[1] = new
|
||||
end
|
||||
end
|
||||
-- Will have to handle technologies.. so lets do it only when nescessary
|
||||
--if recipe.name == old then
|
||||
-- recipe.name = new
|
||||
-- recipe.localised_name = new
|
||||
-- recipes[new] = recipe
|
||||
-- recipes[old] = nil
|
||||
--end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local remove_from_recipe = function(recipe, name)
|
||||
--log(name)
|
||||
if recipe.normal then
|
||||
--Screw this half-assed system
|
||||
for k, v in pairs (recipe.normal) do
|
||||
recipe[k] = v
|
||||
end
|
||||
recipe.normal = nil
|
||||
recipe.expensive = nil
|
||||
end
|
||||
|
||||
local result = recipe.result
|
||||
if result == name then
|
||||
return
|
||||
|
||||
end
|
||||
local ingredients = recipe.ingredients
|
||||
if ingredients then
|
||||
for i = #ingredients, 1, -1 do
|
||||
if (ingredients[i].name or ingredients[i][1]) == name then
|
||||
table.remove(ingredients, i)
|
||||
end
|
||||
end
|
||||
if #ingredients == 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local products = recipe.products
|
||||
if products then
|
||||
for i = #products, 1, -1 do
|
||||
if (products[i].name or products[i][1]) == name then
|
||||
table.remove(products, i)
|
||||
end
|
||||
end
|
||||
if #products == 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if recipe.main_product and recipe.main_product == name then
|
||||
recipe.main_product = nil
|
||||
end
|
||||
|
||||
return recipe
|
||||
end
|
||||
|
||||
local remove_technology = function(name)
|
||||
local technologies = data.raw.technology
|
||||
for k, tech in pairs (technologies) do
|
||||
local req = tech.prerequisites
|
||||
if req then
|
||||
for i = #req, 1, -1 do
|
||||
if req[i] == name then
|
||||
table.remove(req, i)
|
||||
end
|
||||
end
|
||||
if #req == 0 then
|
||||
tech.prerequisites = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
technologies[name] = nil
|
||||
end
|
||||
|
||||
local remove_item_from_technologies = function(name)
|
||||
local technologies = data.raw.technology
|
||||
for k, tech in pairs (technologies) do
|
||||
local packs = tech.unit.ingredients
|
||||
for i = #packs, 1, -1 do
|
||||
if (packs[i].name or packs[i][1]) == name then
|
||||
table.remove(packs, i)
|
||||
end
|
||||
end
|
||||
if #packs == 0 then
|
||||
remove_technology(tech.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_recipe_from_technologies = function(name)
|
||||
--log("Removing recipe from technologies: "..name)
|
||||
local technologies = data.raw.technology
|
||||
for k, technology in pairs (technologies) do
|
||||
local effects = technology.effects
|
||||
if effects then
|
||||
--log(technology.name.." = "..#effects)
|
||||
for i = #effects, 1, -1 do
|
||||
--log((effects[i].recipe or "nil").. " == "..name)
|
||||
if (effects[i].recipe == name) then
|
||||
--log("Removed from: "..k)
|
||||
table.remove(effects, i)
|
||||
end
|
||||
end
|
||||
if #effects == 0 then
|
||||
remove_technology(technology.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_item_from_recipes = function(name)
|
||||
if type(name) ~= "string" then error("I EXPECT A STRING") end
|
||||
--log("Removing item from recipes: "..name)
|
||||
local recipes = data.raw.recipe
|
||||
for k, recipe in pairs (recipes) do
|
||||
local result = remove_from_recipe(recipe, name)
|
||||
if not result then
|
||||
remove_recipe_from_technologies(recipe.name)
|
||||
recipes[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_from_items = function(name)
|
||||
if type(name) ~= "string" then error("I EXPECT A STRING") end
|
||||
local items = data.raw.item
|
||||
for k, item in pairs (items) do
|
||||
if item.place_result == name then
|
||||
remove_item_from_recipes(item.name)
|
||||
items[k] = nil
|
||||
return
|
||||
end
|
||||
if item.rocket_launch_product == name then
|
||||
item.rocket_launch_product = nil
|
||||
end
|
||||
if item.rocket_launch_products then
|
||||
util.remove_from_list(item.rocket_launch_products, name)
|
||||
end
|
||||
end
|
||||
local items = data.raw["item-with-entity-data"]
|
||||
for k, item in pairs (items) do
|
||||
if item.place_result == name then
|
||||
remove_item_from_recipes(item.name)
|
||||
items[k] = nil
|
||||
return
|
||||
end
|
||||
if item.rocket_launch_product == name then
|
||||
item.rocket_launch_product = nil
|
||||
end
|
||||
if item.rocket_launch_products then
|
||||
util.remove_from_list(item.rocket_launch_products, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local find_mention
|
||||
find_mention = function(table, name)
|
||||
for k, v in pairs (table) do
|
||||
if type(v) == "table" then
|
||||
find_mention(v, name)
|
||||
elseif k == name or ((type(v) == "string") and (v == name)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_from_achievements = function(name)
|
||||
for type_name, type in pairs (data.raw) do
|
||||
if string.find(type_name, "achievement") then
|
||||
for k, achievement in pairs (type) do
|
||||
if find_mention(achievement, name) then
|
||||
type[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_entity_prototype = function(ent)
|
||||
if not ent then return end
|
||||
--So, if we actually delete the prototype, we get some error about traversing old prototypes for migrations or some BS... so we just nuke all items and hide them
|
||||
--log(ent.name)
|
||||
remove_from_items(ent.name)
|
||||
remove_from_achievements(ent.name)
|
||||
ent.minable = nil
|
||||
ent.order = "Z-DELETED"
|
||||
ent.autoplace = nil
|
||||
end
|
||||
|
||||
local remove_from_minable = function(name)
|
||||
for k, type in pairs (data.raw) do
|
||||
for j, v in pairs (type) do
|
||||
if v.minable and v.minable.result == name then
|
||||
v.minable = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local remove_item_prototype = function(item)
|
||||
if not item then log("Well item to remove was nil anyway so great job") return end
|
||||
remove_item_from_recipes(item.name)
|
||||
remove_item_from_technologies(item.name)
|
||||
remove_from_minable(item.name)
|
||||
data.raw.item[item.name] = nil
|
||||
item = nil
|
||||
end
|
||||
|
||||
remove_technology_effect_type = function(dict)
|
||||
for k, tech in pairs (data.raw.technology) do
|
||||
local effects = tech.effects
|
||||
if effects then
|
||||
for i = #effects, 1, -1 do
|
||||
if dict[effects[i].type] then
|
||||
table.remove(effects, i)
|
||||
end
|
||||
end
|
||||
if #effects == 0 then
|
||||
remove_technology(tech.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local lib = {}
|
||||
lib.rename_item = rename_item
|
||||
lib.rename_recipe = rename_recipe
|
||||
lib.remove_from_achievements = remove_from_achievements
|
||||
lib.remove_from_items = remove_from_items
|
||||
lib.remove_item_from_recipes = remove_item_from_recipes
|
||||
lib.remove_item_from_technologies = remove_item_from_technologies
|
||||
lib.remove_recipe_from_technologies = remove_recipe_from_technologies
|
||||
lib.remove_entity_prototype = remove_entity_prototype
|
||||
lib.remove_item_prototype = remove_item_prototype
|
||||
lib.remove_technology_effect_type = remove_technology_effect_type
|
||||
lib.remove_technology = remove_technology
|
||||
|
||||
return lib
|
||||
48
Teleporters/data/tf_util/tf_fire_util.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
--Copy paste from base game
|
||||
local fire_util = {}
|
||||
local path = util.path("data/entities/teleporters/")
|
||||
|
||||
fire_util.create_fire_pictures = function(opts)
|
||||
local opts = opts or {}
|
||||
local fire_blend_mode = opts.blend_mode or "additive"
|
||||
local fire_animation_speed = opts.animation_speed or 0.5
|
||||
local fire_scale = opts.scale or 1
|
||||
local fire_tint = opts.tint or {r=1,g=1,b=1,a=1}
|
||||
local fire_flags = opts.flags or { "compressed" }
|
||||
return
|
||||
{
|
||||
{
|
||||
filename = path.."teleporter-explosion.png",
|
||||
draw_as_glow = true,
|
||||
priority = "high",
|
||||
line_length = 6,
|
||||
width = 44,
|
||||
height = 90,
|
||||
frame_count = 24,
|
||||
shift = util.by_pixel(-1,6),
|
||||
blend_mode = fire_blend_mode,
|
||||
animation_speed = fire_animation_speed,
|
||||
scale = fire_scale,
|
||||
tint = fire_tint,
|
||||
flags = fire_flags,
|
||||
hr_version =
|
||||
{
|
||||
filename = path.."hr-teleporter-explosion.png",
|
||||
draw_as_glow = true,
|
||||
priority = "high",
|
||||
line_length = 6,
|
||||
width = 88,
|
||||
height = 178,
|
||||
frame_count = 24,
|
||||
shift = util.by_pixel(-1,6),
|
||||
blend_mode = fire_blend_mode,
|
||||
animation_speed = fire_animation_speed,
|
||||
scale = fire_scale / 2,
|
||||
tint = fire_tint,
|
||||
flags = fire_flags,
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return fire_util
|
||||
254
Teleporters/data/tf_util/tf_util.lua
Normal file
@@ -0,0 +1,254 @@
|
||||
local util = require("util")
|
||||
|
||||
local is_sprite_def = function(array)
|
||||
return array.width and array.height and (array.filename or array.stripes or array.filenames)
|
||||
end
|
||||
|
||||
util.is_sprite_def = is_sprite_def
|
||||
|
||||
local recursive_hack_scale
|
||||
recursive_hack_scale = function(array, scale)
|
||||
for k, v in pairs (array) do
|
||||
if type(v) == "table" then
|
||||
if is_sprite_def(v) then
|
||||
v.scale = (v.scale or 1) * scale
|
||||
if v.shift then
|
||||
v.shift[1], v.shift[2] = v.shift[1] * scale, v.shift[2] * scale
|
||||
end
|
||||
end
|
||||
if v.source_offset then
|
||||
v.source_offset[1] = v.source_offset[1] * scale
|
||||
v.source_offset[2] = v.source_offset[2] * scale
|
||||
end
|
||||
if v.projectile_center then
|
||||
v.projectile_center[1] = v.projectile_center[1] * scale
|
||||
v.projectile_center[2] = v.projectile_center[2] * scale
|
||||
end
|
||||
if v.projectile_creation_distance then
|
||||
v.projectile_creation_distance = v.projectile_creation_distance * scale
|
||||
end
|
||||
recursive_hack_scale(v, scale)
|
||||
end
|
||||
end
|
||||
end
|
||||
util.recursive_hack_scale = recursive_hack_scale
|
||||
|
||||
local recursive_hack_animation_speed
|
||||
recursive_hack_animation_speed = function(array, scale)
|
||||
for k, v in pairs (array) do
|
||||
if type(v) == "table" then
|
||||
if is_sprite_def(v) then
|
||||
v.animation_speed = v.animation_speed * scale
|
||||
end
|
||||
recursive_hack_animation_speed(v, scale)
|
||||
end
|
||||
end
|
||||
end
|
||||
util.recursive_hack_animation_speed = recursive_hack_animation_speed
|
||||
|
||||
local recursive_hack_tint
|
||||
recursive_hack_tint = function(array, tint)
|
||||
for k, v in pairs (array) do
|
||||
if type(v) == "table" then
|
||||
if is_sprite_def(v) then
|
||||
v.tint = tint
|
||||
end
|
||||
recursive_hack_tint(v, tint)
|
||||
end
|
||||
end
|
||||
end
|
||||
util.recursive_hack_tint = recursive_hack_tint
|
||||
|
||||
local recursive_hack_make_hr
|
||||
recursive_hack_make_hr = function(prototype)
|
||||
for k, v in pairs (prototype) do
|
||||
if type(v) == "table" then
|
||||
if is_sprite_def(v) and v.hr_version then
|
||||
prototype[k] = v.hr_version
|
||||
--v.scale = v.scale * 0.5
|
||||
v.hr_version = nil
|
||||
end
|
||||
recursive_hack_make_hr(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
util.recursive_hack_make_hr = recursive_hack_make_hr
|
||||
|
||||
util.scale_box = function(box, scale)
|
||||
box[1][1] = box[1][1] * scale
|
||||
box[1][2] = box[1][2] * scale
|
||||
box[2][1] = box[2][1] * scale
|
||||
box[2][2] = box[2][2] * scale
|
||||
return box
|
||||
end
|
||||
|
||||
util.scale_boxes = function(prototype, scale)
|
||||
for k, v in pairs {"collision_box", "selection_box"} do
|
||||
local box = prototype[v]
|
||||
if box then
|
||||
local width = (box[2][1] - box[1][1]) * (scale / 2)
|
||||
local height = (box[2][2] - box[1][2]) * (scale / 2)
|
||||
local x = (box[1][1] + box[2][1]) / 2
|
||||
local y = (box[1][2] + box[2][2]) / 2
|
||||
box[1][1], box[2][1] = x - width, x + width
|
||||
box[1][2], box[2][2] = y - height, y + height
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
util.remove_flag = function(prototype, flag)
|
||||
if not prototype.flags then return end
|
||||
for k, v in pairs (prototype.flags) do
|
||||
if v == flag then
|
||||
table.remove(prototype.flags, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
util.add_flag = function(prototype, flag)
|
||||
if not prototype.flags then return end
|
||||
table.insert(prototype.flags, flag)
|
||||
end
|
||||
|
||||
util.base_player = function()
|
||||
|
||||
local player = util.table.deepcopy(data.raw.player.player or error("Wat man cmon why"))
|
||||
player.ticks_to_keep_gun = SU(600)
|
||||
player.ticks_to_keep_aiming_direction = SU(100)
|
||||
player.ticks_to_stay_in_combat = SU(600)
|
||||
util.remove_flag(player, "not-flammable")
|
||||
return player
|
||||
end
|
||||
|
||||
util.path = function(str)
|
||||
return "__Teleporters__/" .. str
|
||||
end
|
||||
|
||||
util.empty_sound = function()
|
||||
return
|
||||
{
|
||||
filename = util.path("data/tf_util/empty-sound.ogg"),
|
||||
volume = 0
|
||||
}
|
||||
end
|
||||
|
||||
util.empty_sprite = function()
|
||||
return
|
||||
{
|
||||
filename = util.path("data/tf_util/empty-sprite.png"),
|
||||
height = 1,
|
||||
width = 1,
|
||||
frame_count = 1
|
||||
}
|
||||
end
|
||||
|
||||
util.damage_type = function(name)
|
||||
if not data.raw["damage-type"][name] then
|
||||
data:extend{{type = "damage-type", name = name, localised_name = name}}
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
util.ammo_category = function(name)
|
||||
if not data.raw["ammo-category"][name] then
|
||||
data:extend{{type = "ammo-category", name = name, localised_name = name}}
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
util.base_gun = function(name)
|
||||
return
|
||||
{
|
||||
name = name,
|
||||
localised_name = name,
|
||||
type = "gun",
|
||||
stack_size = 1,
|
||||
flags = {}
|
||||
}
|
||||
end
|
||||
|
||||
util.base_ammo = function(name)
|
||||
return
|
||||
{
|
||||
name = name,
|
||||
localised_name = name,
|
||||
type = "ammo",
|
||||
stack_size = 1,
|
||||
magazine_size = 1,
|
||||
flags = {}
|
||||
}
|
||||
end
|
||||
|
||||
local base_speed = 0.25
|
||||
util.speed = function(multiplier)
|
||||
return multiplier * SD(base_speed)
|
||||
end
|
||||
|
||||
util.remove_from_list = function(list, name)
|
||||
local remove = table.remove
|
||||
for i = #list, 1, -1 do
|
||||
if list[i] == name then
|
||||
remove(list, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local recursive_hack_something
|
||||
recursive_hack_something = function(prototype, key, value)
|
||||
for k, v in pairs (prototype) do
|
||||
if type(v) == "table" then
|
||||
recursive_hack_something(v, key, value)
|
||||
end
|
||||
end
|
||||
prototype[key] = value
|
||||
end
|
||||
util.recursive_hack_something = recursive_hack_something
|
||||
|
||||
local recursive_hack_blend_mode
|
||||
recursive_hack_blend_mode = function(prototype, value)
|
||||
for k, v in pairs (prototype) do
|
||||
if type(v) == "table" then
|
||||
if util.is_sprite_def(v) then
|
||||
v.blend_mode = value
|
||||
end
|
||||
recursive_hack_blend_mode(v, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
util.copy = util.table.deepcopy
|
||||
|
||||
util.prototype = require("data/tf_util/prototype_util")
|
||||
|
||||
util.flying_unit_collision_mask = function()
|
||||
return {"not-colliding-with-itself", "layer-15"}
|
||||
end
|
||||
|
||||
util.ground_unit_collision_mask = function()
|
||||
return {"not-colliding-with-itself", "player-layer", "train-layer"}
|
||||
end
|
||||
|
||||
util.projectile_collision_mask = function()
|
||||
return {"layer-15", "player-layer", "train-layer"}
|
||||
end
|
||||
|
||||
util.shift_box = function(box, shift)
|
||||
local left_top = box[1]
|
||||
local right_bottom = box[2]
|
||||
left_top[1] = left_top[1] + shift[1]
|
||||
left_top[2] = left_top[2] + shift[2]
|
||||
right_bottom[1] = right_bottom[1] + shift[1]
|
||||
right_bottom[2] = right_bottom[2] + shift[2]
|
||||
return box
|
||||
end
|
||||
|
||||
|
||||
util.shift_layer = function(layer, shift)
|
||||
layer.shift = layer.shift or {0,0}
|
||||
layer.shift[1] = layer.shift[1] + shift[1]
|
||||
layer.shift[2] = layer.shift[2] + shift[2]
|
||||
return layer
|
||||
end
|
||||
|
||||
return util
|
||||