mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-05 13:15:03 +02:00
tweaks
This commit is contained in:
parent
0e52cadfb9
commit
07336111bf
@ -819,16 +819,16 @@ function Public.create_car(ic, event)
|
||||
|
||||
local name, mined = get_player_entity(ic, player, ce)
|
||||
|
||||
if
|
||||
name == 'car' and ce.name == 'car' and not mined or name == 'car' and ce.name == 'tank' and not mined or
|
||||
name == 'tank' and ce.name == 'car' and not mined or
|
||||
name == 'tank' and ce.name == 'tank' and not mined or
|
||||
name == 'spidertron' and ce.name == 'car' and not mined or
|
||||
name == 'spidertron' and ce.name == 'tank' and not mined or
|
||||
name == 'spidertron' and ce.name == 'spidertron' and not mined
|
||||
then
|
||||
return player.print('Multiple vehicles are not supported at the moment.', Color.warning)
|
||||
end
|
||||
if
|
||||
name == 'car' and ce.name == 'car' and not mined or name == 'car' and ce.name == 'tank' and not mined or
|
||||
name == 'tank' and ce.name == 'car' and not mined or
|
||||
name == 'tank' and ce.name == 'tank' and not mined or
|
||||
name == 'spidertron' and ce.name == 'car' and not mined or
|
||||
name == 'spidertron' and ce.name == 'tank' and not mined or
|
||||
name == 'spidertron' and ce.name == 'spidertron' and not mined
|
||||
then
|
||||
return player.print('Multiple vehicles are not supported at the moment.', Color.warning)
|
||||
end
|
||||
|
||||
if string.sub(ce.surface.name, 0, #map_name) ~= map_name then
|
||||
return player.print('Multi-surface is not supported at the moment.', Color.warning)
|
||||
|
@ -55,6 +55,24 @@ local tile_damage = 50
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
||||
|
||||
local collapse_kill = {
|
||||
entities = {
|
||||
['laser-turret'] = true,
|
||||
['flamethrower-turret'] = true,
|
||||
['gun-turret'] = true,
|
||||
['artillery-turret'] = true,
|
||||
['landmine'] = true,
|
||||
['locomotive'] = true,
|
||||
['cargo-wagon'] = true,
|
||||
['car'] = true,
|
||||
['tank'] = true,
|
||||
['assembling-machine'] = true,
|
||||
['furnace'] = true,
|
||||
['steel-chest'] = true
|
||||
},
|
||||
enabled = true
|
||||
}
|
||||
|
||||
local death_messages = {
|
||||
'should have watched where they walked!',
|
||||
'was not careful enough!',
|
||||
@ -325,7 +343,8 @@ function Public.reset_map()
|
||||
game.map_settings.path_finder.max_work_done_per_tick = 4000
|
||||
Diff.gui_width = 20
|
||||
|
||||
Collapse.set_kill_entities(true)
|
||||
Collapse.set_kill_entities(false)
|
||||
Collapse.set_kill_specific_entities(collapse_kill)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
Collapse.set_max_line_size(Terrain.level_width)
|
||||
|
@ -2,7 +2,8 @@ local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {
|
||||
fullness_enabled = true
|
||||
fullness_enabled = true,
|
||||
warned = {}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@ -14,25 +15,46 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
local random = math.random
|
||||
local ceil = math.ceil
|
||||
|
||||
local function is_player_warned(player, reset)
|
||||
if reset and this.warned[player.index] then
|
||||
this.warned[player.index] = nil
|
||||
return
|
||||
end
|
||||
if not this.warned[player.index] then
|
||||
this.warned[player.index] = {
|
||||
count = 2
|
||||
}
|
||||
end
|
||||
this.warned[player.index].count = this.warned[player.index].count + 1
|
||||
return this.warned[player.index]
|
||||
end
|
||||
|
||||
local function compute_fullness(player)
|
||||
local warn_player = is_player_warned(player)
|
||||
local free_slots = player.get_main_inventory().count_empty_stacks()
|
||||
if free_slots == 0 then
|
||||
if player.character then
|
||||
player.character.health = player.character.health - random(50, 100)
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
local messages = {
|
||||
'Ouch.. That hurt! Better be careful now.',
|
||||
'Just a fleshwound.',
|
||||
'Better keep those hands to yourself or you might loose them.'
|
||||
}
|
||||
player.print(messages[random(1, #messages)], {r = 0.75, g = 0.0, b = 0.0})
|
||||
if player.character.health <= 0 then
|
||||
local damage = ceil((warn_player.count / 2) * warn_player.count)
|
||||
if player.character.health >= damage then
|
||||
player.character.damage(damage, 'player', 'explosion')
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
local messages = {
|
||||
'Ouch.. That hurt! Better be careful now.',
|
||||
'Just a fleshwound.',
|
||||
'Better keep those hands to yourself or you might loose them.'
|
||||
}
|
||||
player.print(messages[random(1, #messages)], {r = 0.75, g = 0.0, b = 0.0})
|
||||
else
|
||||
player.character.die('enemy')
|
||||
is_player_warned(player, true)
|
||||
game.print(player.name .. ' should have emptied their pockets.', {r = 0.75, g = 0.0, b = 0.0})
|
||||
return free_slots
|
||||
end
|
||||
end
|
||||
else
|
||||
is_player_warned(player, true)
|
||||
end
|
||||
return free_slots
|
||||
end
|
||||
|
@ -106,6 +106,21 @@ local function progress()
|
||||
if not tile.valid then
|
||||
return
|
||||
end
|
||||
if collapse.specific_entities.enabled then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
local entities = collapse.specific_entities.entities
|
||||
for _, e in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}}
|
||||
)
|
||||
) do
|
||||
if entities[e.name] and e.valid and e.health then
|
||||
e.die()
|
||||
elseif e.valid then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
if collapse.kill then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
for _, e in pairs(
|
||||
@ -115,8 +130,6 @@ local function progress()
|
||||
) do
|
||||
if e.valid and e.health then
|
||||
e.die()
|
||||
elseif e.valid then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -232,12 +245,23 @@ function Public.set_kill_entities(a)
|
||||
collapse.kill = a
|
||||
end
|
||||
|
||||
function Public.set_kill_specific_entities(tbl)
|
||||
if tbl then
|
||||
collapse.specific_entities = tbl
|
||||
else
|
||||
collapse.specific_entities = {
|
||||
enabled = false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
Public.set_surface(game.surfaces.nauvis)
|
||||
Public.set_position({0, 32})
|
||||
Public.set_max_line_size(256)
|
||||
Public.set_direction('north')
|
||||
Public.set_kill_entities(true)
|
||||
Public.set_kill_specific_entities()
|
||||
collapse.tiles = nil
|
||||
collapse.speed = 1
|
||||
collapse.amount = 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user