1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/maps/mountain_fortress_v3/loot.lua

82 lines
2.1 KiB
Lua
Raw Normal View History

2020-05-17 12:23:55 +02:00
local LootRaffle = require 'functions.loot_raffle'
local Public = {}
2020-08-09 20:22:33 +02:00
local random = math.random
local abs = math.abs
local floor = math.floor
2020-05-17 12:23:55 +02:00
local blacklist = {
2020-05-23 21:18:18 +02:00
['atomic-bomb'] = true,
2020-05-17 12:23:55 +02:00
['cargo-wagon'] = true,
2020-09-25 11:08:15 +02:00
['car'] = true,
['tank'] = true,
['spidertron'] = true,
2020-05-17 12:23:55 +02:00
['locomotive'] = true,
['artillery-wagon'] = true,
['fluid-wagon'] = true
}
function Public.add(surface, position, chest)
2020-08-09 20:22:33 +02:00
local budget = 48 + abs(position.y) * 1.75
budget = budget * random(25, 175) * 0.01
2020-05-17 12:23:55 +02:00
2020-08-09 20:22:33 +02:00
if random(1, 128) == 1 then
2020-05-17 12:23:55 +02:00
budget = budget * 4
2020-08-09 20:22:33 +02:00
chest = 'crash-site-chest-' .. random(1, 2)
2020-05-17 12:23:55 +02:00
end
2020-08-09 20:22:33 +02:00
if random(1, 256) == 1 then
2020-06-03 20:09:00 +02:00
budget = budget * 4
2020-08-09 20:22:33 +02:00
chest = 'crash-site-chest-' .. random(1, 2)
2020-06-03 20:09:00 +02:00
end
2020-05-17 12:23:55 +02:00
2020-08-09 20:22:33 +02:00
budget = floor(budget) + 1
2020-05-17 12:23:55 +02:00
local item_stacks = LootRaffle.roll(budget, 8, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
container.minable = false
for _ = 1, 3, 1 do
2020-08-09 20:22:33 +02:00
if random(1, 8) == 1 then
container.insert({name = 'explosives', count = random(25, 50)})
2020-05-17 12:23:55 +02:00
else
break
end
end
end
function Public.add_rare(surface, position, chest, magic)
2020-08-09 20:22:33 +02:00
local budget = magic * 48 + abs(position.y) * 1.75
budget = budget * random(25, 175) * 0.01
2020-05-17 12:23:55 +02:00
2020-08-09 20:22:33 +02:00
if random(1, 128) == 1 then
2020-06-03 20:09:00 +02:00
budget = budget * 6
2020-08-09 20:22:33 +02:00
chest = 'crash-site-chest-' .. random(1, 2)
2020-06-03 20:09:00 +02:00
end
2020-08-09 20:22:33 +02:00
if random(1, 128) == 1 then
2020-05-17 12:23:55 +02:00
budget = budget * 6
2020-08-09 20:22:33 +02:00
chest = 'crash-site-chest-' .. random(1, 2)
2020-05-17 12:23:55 +02:00
end
2020-08-09 20:22:33 +02:00
budget = floor(budget) + 1
2020-05-17 12:23:55 +02:00
local item_stacks = LootRaffle.roll(budget, 8, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
container.minable = false
for _ = 1, 3, 1 do
2020-08-09 20:22:33 +02:00
if random(1, 8) == 1 then
container.insert({name = 'explosives', count = random(25, 50)})
2020-05-17 12:23:55 +02:00
else
break
end
end
end
return Public