mirror of
https://github.com/peter-tanner/extended-crashsite.git
synced 2024-11-30 11:10:17 +08:00
0.1.0: Initial commit
This commit is contained in:
commit
727668b63e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.pdn
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 npc_strider
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
5
changelog.txt
Normal file
5
changelog.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.1.0
|
||||
Date: 2020-08-24
|
||||
Features:
|
||||
- Initial release
|
2
clean_changelog.sh
Normal file
2
clean_changelog.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
sed -i -e 's/\t/ /g' -e 's/\s*$//' changelog.txt
|
||||
#from factorioforums: https://forums.factorio.com/viewtopic.php?f=25&t=67140
|
204
control.lua
Normal file
204
control.lua
Normal file
|
@ -0,0 +1,204 @@
|
|||
|
||||
local util = require("util")
|
||||
local crash_site = require("crash-site")
|
||||
|
||||
local ship_parts =
|
||||
{
|
||||
{
|
||||
name = "crash-site-assembling-machine",
|
||||
variations = 2,
|
||||
angle_deviation = 0.07,
|
||||
max_distance = 40,
|
||||
min_separation = 16,
|
||||
fire_count = 1
|
||||
},
|
||||
{
|
||||
name = "crash-site-lab-repaired",
|
||||
angle_deviation = 0.07,
|
||||
max_distance = 15,
|
||||
fire_count = 0
|
||||
},
|
||||
{
|
||||
name = "crash-site-generator",
|
||||
angle_deviation = 0.06,
|
||||
max_distance = 15,
|
||||
fire_count = 0
|
||||
},
|
||||
{
|
||||
name = "crash-site-chest",
|
||||
variations = 2,
|
||||
angle_deviation = 0.075,
|
||||
max_distance = 40,
|
||||
min_separation = 16,
|
||||
fire_count = 0
|
||||
}
|
||||
}
|
||||
|
||||
local random = math.random
|
||||
|
||||
local rotate = function(offset, angle)
|
||||
local x = offset[1]
|
||||
local y = offset[2]
|
||||
local rotated_x = x * math.cos(angle) - y * math.sin(angle)
|
||||
local rotated_y = x * math.sin(angle) + y * math.cos(angle)
|
||||
return {rotated_x, rotated_y}
|
||||
end
|
||||
|
||||
local get_name = function(part, k)
|
||||
if not part.variations then return part.name end
|
||||
local variant = k or random(part.variations)
|
||||
return part.name.."-"..variant
|
||||
end
|
||||
|
||||
local get_lifetime = function(offset)
|
||||
--Generally, close to the ship, last longer.
|
||||
local distance = ((offset[1] * offset[1]) + (offset[2] * offset[2])) ^ 0.5
|
||||
local time = random(60 * 20, 60 * 30) - math.min(distance * 100, 15 * 60)
|
||||
return time
|
||||
end
|
||||
|
||||
local get_random_position = function(box, x_scale, y_scale)
|
||||
local x_scale = x_scale or 1
|
||||
local y_scale = y_scale or 1
|
||||
local x1 = box.left_top.x
|
||||
local y1 = box.left_top.y
|
||||
local x2 = box.right_bottom.x
|
||||
local y2 = box.right_bottom.y
|
||||
local x = ((x2 - x1) * x_scale * (random() - 0.5)) + ((x1 + x2) / 2)
|
||||
local y = ((y2 - y1) * y_scale * (random() - 0.5)) + ((y1 + y2) / 2)
|
||||
return {x, y}
|
||||
end
|
||||
|
||||
local entry_angle = 0.70
|
||||
local random = math.random
|
||||
local get_offset = function(part)
|
||||
local angle = entry_angle + ((random() - 0.5) * part.angle_deviation)
|
||||
angle = angle - 0.25
|
||||
angle = angle * math.pi * 2
|
||||
local distance = 8 + (random() * (part.max_distance or 40))
|
||||
local offset = rotate({distance, 0}, angle)
|
||||
return offset
|
||||
end
|
||||
|
||||
script.on_init(function()
|
||||
if remote.interfaces.freeplay then
|
||||
remote.call("freeplay", "set_disable_crashsite", false) -- That's the point of this mod... to have a crashsite, so we're force enabling it
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
script.on_event(defines.events.on_player_created, function(event)
|
||||
if not global.init_ran then
|
||||
global.init_ran = true
|
||||
|
||||
if remote.interfaces.freeplay then
|
||||
-- game.print("FREEPLAY")
|
||||
local player = game.players[event.player_index]
|
||||
local surface = player.surface
|
||||
local sps = surface.find_entities_filtered{position = player.force.get_spawn_position(surface), radius = 250, name = "crash-site-spaceship"} -- Just to confirm the spaceship loc
|
||||
local position = sps[1].position
|
||||
|
||||
local wreck_parts = {}
|
||||
|
||||
for k, part in pairs (ship_parts) do
|
||||
for k = 1, (part.variations or 1) do
|
||||
local name = get_name(part, k)
|
||||
if game.entity_prototypes[name.."-repaired-player"] then
|
||||
name=name.."-repaired-player"
|
||||
else
|
||||
name=name.."-player"
|
||||
end
|
||||
-- local name_ = get_name(part, k, "-repaired")
|
||||
for i = 1, part.repeat_count or 1 do
|
||||
|
||||
local part_position
|
||||
local count = 0
|
||||
local offset
|
||||
while true do
|
||||
offset = get_offset(part)
|
||||
local x = (position[1] or position.x) + offset[1]
|
||||
local y = (position[2] or position.y) + offset[2]
|
||||
part_position = {x, y}
|
||||
if surface.can_place_entity
|
||||
{
|
||||
name = name,
|
||||
position = part_position,
|
||||
force = "player",
|
||||
build_check_type = defines.build_check_type.ghost_place,
|
||||
forced = true
|
||||
} then
|
||||
-- game.print(count.. " " .. k .. " " .. surface.count_entities_filtered{position = part_position, radius = part.min_separation, limit = 1, type = game.entity_prototypes[name_].type})
|
||||
|
||||
if not part.min_separation then
|
||||
break
|
||||
elseif surface.count_entities_filtered{position = part_position, radius = part.min_separation, limit = 1, type = game.entity_prototypes[name].type} == 0 then
|
||||
break
|
||||
else
|
||||
end
|
||||
end
|
||||
count = count + 1
|
||||
if count > 40 then
|
||||
part_position = surface.find_non_colliding_position(name, part_position, 50, 4)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if part_position then
|
||||
local entity = surface.create_entity({
|
||||
name = name,
|
||||
position = part_position,
|
||||
force = "player"
|
||||
})
|
||||
-- Something dumb happening with simple-entity and a position that is not constant. Have to use repaired variant of entity!
|
||||
|
||||
local type = game.entity_prototypes[name].type
|
||||
if type == "assembling-machine" then
|
||||
entity.health = entity.health/6
|
||||
elseif type == "lab" then
|
||||
entity.health = entity.health/1.5
|
||||
elseif type == "container" then
|
||||
local count = random(0,2)
|
||||
if count > 0 then
|
||||
entity.insert({name="repair-pack",count=count})
|
||||
end
|
||||
end
|
||||
|
||||
if entity.get_output_inventory() and #entity.get_output_inventory() > 0 then
|
||||
wreck_parts[entity.unit_number] = entity
|
||||
end
|
||||
|
||||
for k, entity in pairs (surface.find_entities_filtered{type = {"tree", "simple-entity"}, position = part_position, radius = 1 + entity.get_radius()}) do
|
||||
if entity.type == "tree" then
|
||||
entity.die()
|
||||
else
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
if part.fire_count then
|
||||
for k = 1, part.fire_count do
|
||||
surface.create_entity
|
||||
{
|
||||
name = "crash-site-fire-flame",
|
||||
position = get_random_position(entity.bounding_box)
|
||||
}
|
||||
local explosions = surface.create_entity
|
||||
{
|
||||
name = "crash-site-fire-smoke",
|
||||
position = get_random_position(entity.bounding_box)
|
||||
}
|
||||
explosions.time_to_live = get_lifetime(offset)
|
||||
explosions.time_to_next_effect = random(30)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
-- game.print("NOT FREEPLAY")
|
||||
end
|
||||
end
|
||||
end)
|
11
crash_entities.txt
Normal file
11
crash_entities.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
crash-site-spaceship-wreck-small-{1..6}
|
||||
crash-site-spaceship-wreck-medium-{1..3}
|
||||
crash-site-spaceship-wreck-big-{1,2}
|
||||
crash-site-spaceship
|
||||
crash-site-chest-{1,2} GOOD
|
||||
crash-site-generator YES
|
||||
--- crash-site-electric-pole NO DO NOT PUT THIS ONE IN (INVISIBLE POLES)
|
||||
crash-site-assembling-machine-{1,2}-repaired GOOD
|
||||
crash-site-assembling-machine-{1,2}-broken GOOD
|
||||
crash-site-lab-repaired GOOD
|
||||
crash-site-lab-broken GOOD
|
75
data.lua
Normal file
75
data.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
--[[ Copyright (c) 2020 npc_strider
|
||||
* For direct use of code or graphics, credit is appreciated. See LICENSE.txt for more information.
|
||||
* This mod may contain modified code sourced from base/core Factorio
|
||||
*
|
||||
* data.lua
|
||||
* Recipes!!
|
||||
--]]
|
||||
|
||||
require("util")
|
||||
|
||||
local function make_wreck_item(name,order)
|
||||
return {
|
||||
type = "item",
|
||||
name = name.."-player",
|
||||
icon = "__base__/graphics/icons/"..name..".png",
|
||||
icon_size = 64, icon_mipmaps = 4,
|
||||
subgroup = "crash-site",
|
||||
order = "z[crash-site-spaceship]-"..order,
|
||||
place_result = name.."-player",
|
||||
stack_size = 1,
|
||||
flags = {"hidden"}
|
||||
}
|
||||
end
|
||||
|
||||
local entity = {
|
||||
{"crash-site-generator","electric-energy-interface"},
|
||||
{"crash-site-lab-repaired","lab"}
|
||||
}
|
||||
|
||||
for i=1,2 do
|
||||
entity[#entity+1] = {"crash-site-assembling-machine-"..i.."-repaired","assembling-machine"}
|
||||
entity[#entity+1] = {"crash-site-chest-"..i,"container"}
|
||||
end
|
||||
|
||||
for i=1, #entity do
|
||||
local e = entity[i]
|
||||
local newname = e[1].."-player"
|
||||
|
||||
local entity_player = util.table.deepcopy(data.raw[e[2]][e[1]])
|
||||
entity_player.name = newname
|
||||
|
||||
if e[1] == "crash-site-generator" then
|
||||
entity_player.energy_source = {
|
||||
type = "electric",
|
||||
buffer_capacity = "2.5MJ",
|
||||
usage_priority = "tertiary",
|
||||
input_flow_limit = "0kW",
|
||||
output_flow_limit = "200kW"
|
||||
}
|
||||
entity_player.energy_production = "200kW"
|
||||
entity_player.energy_usage = "0kW"
|
||||
end
|
||||
|
||||
entity_player.flags = {"placeable-neutral", "placeable-player", "player-creation", "not-rotatable"} -- I think all of them aren't rotatable - need to check some time
|
||||
entity_player.localised_name = {"entity-name."..e[1]}
|
||||
if entity_player.minable and not entity_player.minable.result then
|
||||
entity_player.minable.result = newname
|
||||
else
|
||||
entity_player.minable = {mining_time = 0.2, result = newname}
|
||||
end
|
||||
|
||||
|
||||
local split = {}
|
||||
for match in (newname.."-"):gmatch("(.-)-") do
|
||||
split[#split+1] = match
|
||||
end
|
||||
|
||||
local item_player
|
||||
|
||||
item_player = util.table.deepcopy(data.raw["item"][e[1]])
|
||||
item_player.name = newname
|
||||
item_player.place_result = newname
|
||||
|
||||
data:extend({entity_player,item_player})
|
||||
end
|
11
info.json
Normal file
11
info.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "Extended_Crashsite",
|
||||
"version": "0.1.0",
|
||||
"factorio_version": "1.0",
|
||||
"title": "Extended crash site",
|
||||
"author": "npc_strider(morley376)",
|
||||
"contact": "",
|
||||
"homepage": "http://steamcommunity.com/id/morley376",
|
||||
"dependencies": ["base >= 1.0.0"],
|
||||
"description": "The crash site now has basic assemblers, lab, fuel cell and containers from the spaceship"
|
||||
}
|
6
make.sh
Normal file
6
make.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
v=$(grep "\"version\"" info.json | sed 's|.*:||;s|[",]||g;s| ||g')
|
||||
n=$(grep "\"name\"" info.json | sed 's|.*:||;s|[",]||g;s| ||g')
|
||||
#echo ${n}_${v}.zip
|
||||
|
||||
powershell -c "\$files = Get-ChildItem -Path . -Exclude .git,*.sh,.pdn,.gitignore
|
||||
Compress-Archive -Path \$files -DestinationPath ../${n}_${v}.zip"
|
BIN
thumbnail.png
Normal file
BIN
thumbnail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 254 KiB |
Loading…
Reference in New Issue
Block a user