Skip to content

Instantly share code, notes, and snippets.

@td-shi
Created January 27, 2020 07:04
Show Gist options
  • Save td-shi/8a441124d8a65c9c7703991e8bca2662 to your computer and use it in GitHub Desktop.
Save td-shi/8a441124d8a65c9c7703991e8bca2662 to your computer and use it in GitHub Desktop.
Factorio Block spitter attack.
--For 0.13.13 and later there will be layer-10 through layer-15 that can be used.
local projectile_layer = "layer-13"
local suffix = "-blockable"
local function make_projectile_blockable (prototype_name)
local prototype = data.raw.projectile[prototype_name]
if not prototype then
return prototype_name
end
local newname = prototype.name .. "-blockable"
-- if it already exists don't duplicate
if not data.raw.projectile[newname] then
local proto = table.deepcopy(prototype)
proto.name = proto.name .. suffix
if proto.collision_box then
-- expand if all 0s
proto.collision_box = {
{
math.min(-0.1, proto.collision_box[1][1]),
math.min(-0.5, proto.collision_box[1][2]),
}, {
math.max(0.1, proto.collision_box[1][1]),
math.max(0.5, proto.collision_box[1][2]),
}
}
else
proto.collision_box = {
{
-0.1,
-0.5
}, {
0.1,
0.5
}
}
end
if proto.collision_mask then
table.insert(proto.collision_mask, projectile_layer)
else
proto.collision_mask = {projectile_layer}
end
data:extend({proto})
end
return newname
end
-- walls
for _, wall in pairs(data.raw.wall) do
wall.collision_mask = {"item-layer", "object-layer", "player-layer", "water-tile", projectile_layer}
end
{
"name": "block-spitters-attack",
"version": "0.1.1",
"title": "Block Spitters Attack",
"author": "ms-td",
"dependencies": ["base >= 0.16.0"],
"description": "壁がスピッターの攻撃を受け止められるようになる. Earendel氏のWalls Block Spittersから数値調整をオミットしたものです.",
"factorio_version": "0.16"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment