mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-20 03:29:26 +02:00
toxic jungle map
This commit is contained in:
parent
1497e5e0ce
commit
e2ad8805dc
118
map_gen/presets/toxic_jungle.lua
Normal file
118
map_gen/presets/toxic_jungle.lua
Normal file
@ -0,0 +1,118 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Event = require 'utils.event'
|
||||
local Perlin = require 'map_gen.shared.perlin_noise'
|
||||
|
||||
local enemy_seed = 420420
|
||||
|
||||
local market_items = require 'resources.market_items'
|
||||
table.remove(market_items, 8)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_research_finished,
|
||||
function(event)
|
||||
local p_force = game.forces.player
|
||||
local r = event.research
|
||||
|
||||
if r.name == 'flamethrower' then
|
||||
p_force.recipes['flamethrower'].enabled = false
|
||||
p_force.recipes['flamethrower-turret'].enabled = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local trees = {
|
||||
'tree-01',
|
||||
'tree-02',
|
||||
'tree-02-red',
|
||||
'tree-03',
|
||||
'tree-04',
|
||||
'tree-05',
|
||||
'tree-06',
|
||||
'tree-06-brown',
|
||||
'tree-07',
|
||||
'tree-08',
|
||||
'tree-08-brown',
|
||||
'tree-08-red',
|
||||
'tree-09',
|
||||
'tree-09-brown',
|
||||
'tree-09-red'
|
||||
}
|
||||
|
||||
local trees_count = #trees
|
||||
|
||||
local function tree_shape()
|
||||
local tree = trees[math.random(trees_count)]
|
||||
|
||||
return {name = tree}
|
||||
--, always_place = true}
|
||||
end
|
||||
|
||||
local worm_names = {'small-worm-turret', 'medium-worm-turret', 'big-worm-turret'}
|
||||
local spawner_names = {'biter-spawner', 'spitter-spawner'}
|
||||
local factor = 10 / (768 * 32)
|
||||
local max_chance = 1 / 6
|
||||
|
||||
local scale_factor = 32
|
||||
local sf = 1 / scale_factor
|
||||
local m = 1 / 850
|
||||
local function enemy(x, y, world)
|
||||
local d = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
|
||||
if d < 2 then
|
||||
return nil
|
||||
end
|
||||
|
||||
if d < 100 then
|
||||
return tree_shape()
|
||||
end
|
||||
|
||||
local threshold = 1 - d * m
|
||||
threshold = math.max(threshold, 0.25) -- -0.125)
|
||||
|
||||
x, y = x * sf, y * sf
|
||||
if Perlin.noise(x, y, enemy_seed) > threshold then
|
||||
if math.random(8) == 1 then
|
||||
local lvl
|
||||
if d < 400 then
|
||||
lvl = 1
|
||||
elseif d < 650 then
|
||||
lvl = 2
|
||||
else
|
||||
lvl = 3
|
||||
end
|
||||
|
||||
local chance = math.min(max_chance, d * factor)
|
||||
|
||||
if math.random() < chance then
|
||||
local worm_id
|
||||
if d > 1000 then
|
||||
local power = 1000 / d
|
||||
worm_id = math.ceil((math.random() ^ power) * lvl)
|
||||
else
|
||||
worm_id = math.random(lvl)
|
||||
end
|
||||
|
||||
return {name = worm_names[worm_id]}
|
||||
--, always_place = true}
|
||||
end
|
||||
else
|
||||
local chance = math.min(max_chance, d * factor)
|
||||
if math.random() < chance then
|
||||
local spawner_id = math.random(2)
|
||||
return {name = spawner_names[spawner_id]}
|
||||
--, always_place = true}
|
||||
end
|
||||
end
|
||||
else
|
||||
return tree_shape()
|
||||
end
|
||||
end
|
||||
|
||||
local map = b.full_shape
|
||||
|
||||
map = b.change_map_gen_tile(map, 'water', 'water-green')
|
||||
map = b.change_map_gen_tile(map, 'deepwater', 'deepwater-green')
|
||||
|
||||
map = b.apply_entity(map, enemy)
|
||||
|
||||
return map
|
@ -70,6 +70,7 @@ local tiles_per_tick = 32
|
||||
--shape = require "map_gen.presets.lines_and_squares"
|
||||
--shape = require "map_gen.presets.spiral_of_spirals"
|
||||
--shape = require "map_gen.presets.dino_island"
|
||||
--shape = require "map_gen.presets.toxic_jungle"
|
||||
--shape = require "map_gen.presets.test"
|
||||
|
||||
--shapes--
|
||||
|
@ -51,9 +51,7 @@ return {
|
||||
['aplavins'] = true,
|
||||
['apolomir'] = true,
|
||||
['argetlam_elda'] = true,
|
||||
['arizon'] = true,
|
||||
['arnietom'] = true,
|
||||
['artman40'] = true,
|
||||
['asddsa76'] = true,
|
||||
['assemblystorm'] = true,
|
||||
['b4x'] = true,
|
||||
@ -187,7 +185,6 @@ return {
|
||||
['merssedes'] = true,
|
||||
['mesohorknee'] = true,
|
||||
['mh'] = true,
|
||||
['miniman10000'] = true,
|
||||
['mithril_ryder'] = true,
|
||||
['mrkoss'] = true,
|
||||
['mrsjaakbraak'] = true,
|
||||
@ -261,7 +258,6 @@ return {
|
||||
['timmypwn'] = true,
|
||||
['toledini'] = true,
|
||||
['tomymy'] = true,
|
||||
['tonytroll'] = true,
|
||||
['toof_kitty'] = true,
|
||||
['trekie4747'] = true,
|
||||
['trevoqr'] = true,
|
||||
@ -357,7 +353,6 @@ return {
|
||||
['musa3299'] = true,
|
||||
['puycss'] = true,
|
||||
['Aronak'] = true,
|
||||
['samrrr'] = true,
|
||||
['Brathahn'] = true,
|
||||
['Bryce940'] = true,
|
||||
['kuumottaja'] = true,
|
||||
@ -456,5 +451,51 @@ return {
|
||||
['BTG'] = true,
|
||||
['Anubi5'] = true,
|
||||
['Slas'] = true,
|
||||
['McTheDerp'] = true
|
||||
['McTheDerp'] = true,
|
||||
['qwert33'] = true,
|
||||
['UA-IX'] = true,
|
||||
['Janakas'] = true,
|
||||
['Grooohm'] = true,
|
||||
['oafthor'] = true,
|
||||
['exbboi'] = true,
|
||||
['ClassAction'] = true,
|
||||
['Zhukovo'] = true,
|
||||
['Wolve'] = true,
|
||||
['liltaco'] = true,
|
||||
['BenSeidel'] = true,
|
||||
['kriskill000'] = true,
|
||||
['DUDv2'] = true,
|
||||
['Peterie'] = true,
|
||||
['Tomza'] = true,
|
||||
['DoITCreative'] = true,
|
||||
['Aspin'] = true,
|
||||
['samrrr'] = true,
|
||||
['johnm4jc'] = true,
|
||||
['Shinhan'] = true,
|
||||
['MINIMAN10000'] = true,
|
||||
['Latty319'] = true,
|
||||
['DoubleDough'] = true,
|
||||
['Jenus358'] = true,
|
||||
['redkyleb'] = true,
|
||||
['RAV416steam'] = true,
|
||||
['killer111995'] = true,
|
||||
['ichvii'] = true,
|
||||
['Artman40'] = true,
|
||||
['Arti20'] = true,
|
||||
['larshp'] = true,
|
||||
['Tafonath'] = true,
|
||||
['Zwulf'] = true,
|
||||
['ajicurry'] = true,
|
||||
['boksiora'] = true,
|
||||
['matthew1206'] = true,
|
||||
['improvshark'] = true,
|
||||
['cedrik1995'] = true,
|
||||
['kova66'] = true,
|
||||
['TonyTroll'] = true,
|
||||
['Amuxix'] = true,
|
||||
['360cow'] = true,
|
||||
['MangaFairy'] = true,
|
||||
['innocen3'] = true,
|
||||
['maxflo13'] = true,
|
||||
['Arizon'] = true
|
||||
}
|
||||
|
216
wood_market.lua
Normal file
216
wood_market.lua
Normal file
@ -0,0 +1,216 @@
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.global_token'
|
||||
local Task = require 'utils.Task'
|
||||
local PlayerStats = require 'player_stats'
|
||||
|
||||
local market_items = require 'resources.market_items'
|
||||
|
||||
for _, item in ipairs(market_items) do
|
||||
local price = item.price[1]
|
||||
price[1] = 'raw-wood'
|
||||
price[2] = price[2] * 4
|
||||
end
|
||||
|
||||
market_items[1].offer.effect_description = 'Temporary speed bonus - Price 40 Wood'
|
||||
market_items[2].offer.effect_description = 'Temporary mining bonus - Price 40 Wood'
|
||||
|
||||
table.insert(market_items, {price = {{'raw-wood', 4}}, offer = {type = 'give-item', item = 'raw-fish'}})
|
||||
|
||||
local function spawn_market(cmd)
|
||||
if not game.player or not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
local surface = game.player.surface
|
||||
|
||||
local player = game.player
|
||||
|
||||
local market_location = {x = player.position.x, y = player.position.y}
|
||||
market_location.y = market_location.y - 4
|
||||
|
||||
local market = surface.create_entity {name = 'market', position = market_location}
|
||||
market.destructible = false
|
||||
|
||||
for _, item in ipairs(market_items) do
|
||||
market.add_market_item(item)
|
||||
end
|
||||
end
|
||||
|
||||
local entity_drop_amount = {
|
||||
--[[['small-biter'] = {low = -62, high = 1},
|
||||
['small-spitter'] = {low = -62, high = 1},
|
||||
['medium-biter'] = {low = -14, high = 1},
|
||||
['medium-spitter'] = {low = -14, high = 1},
|
||||
['big-biter'] = {low = -2, high = 1},
|
||||
['big-spitter'] = {low = -2, high = 1},
|
||||
['behemoth-biter'] = {low = 1, high = 1},
|
||||
['behemoth-spitter'] = {low = 1, high = 1}, ]]
|
||||
['biter-spawner'] = {low = 5, high = 15},
|
||||
['spitter-spawner'] = {low = 5, high = 15},
|
||||
['small-worm-turret'] = {low = 2, high = 8},
|
||||
['medium-worm-turret'] = {low = 5, high = 15},
|
||||
['big-worm-turret'] = {low = 10, high = 20}
|
||||
}
|
||||
|
||||
local spill_items =
|
||||
Token.register(
|
||||
function(data)
|
||||
local stack = {name = 'raw-wood', count = data.count * 4}
|
||||
data.surface.spill_item_stack(data.position, stack, true)
|
||||
end
|
||||
)
|
||||
|
||||
local function wood_drop_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local bounds = entity_drop_amount[entity.name]
|
||||
if not bounds then
|
||||
return
|
||||
end
|
||||
|
||||
local count = math.random(bounds.low, bounds.high)
|
||||
|
||||
if count > 0 then
|
||||
Task.set_timeout_in_ticks(1, spill_items, {count = count, surface = entity.surface, position = entity.position})
|
||||
end
|
||||
end
|
||||
|
||||
local function reset_player_runningspeed(player)
|
||||
player.character_running_speed_modifier = global.player_speed_boost_records[player.index].pre_boost_modifier
|
||||
global.player_speed_boost_records[player.index] = nil
|
||||
end
|
||||
|
||||
local function boost_player_runningspeed(player, market)
|
||||
if global.player_speed_boost_records == nil then
|
||||
global.player_speed_boost_records = {}
|
||||
end
|
||||
|
||||
if global.player_speed_boost_records[player.index] == nil then
|
||||
global.player_speed_boost_records[player.index] = {
|
||||
start_tick = game.tick,
|
||||
pre_boost_modifier = player.character_running_speed_modifier,
|
||||
boost_lvl = 0
|
||||
}
|
||||
end
|
||||
local boost_msg = {
|
||||
[1] = '%s found the lost Dragon Scroll and got a lv.1 speed boost!',
|
||||
[2] = 'Guided by Master Oogway, %s got a lv.2 speed boost!',
|
||||
[3] = 'Kungfu Master %s defended the village and was awarded a lv.3 speed boost!',
|
||||
[4] = 'Travelled at the speed of light. %s saw a blackhole. Oops.'
|
||||
}
|
||||
global.player_speed_boost_records[player.index].boost_lvl =
|
||||
1 + global.player_speed_boost_records[player.index].boost_lvl
|
||||
player.character_running_speed_modifier = 1 + player.character_running_speed_modifier
|
||||
game.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
|
||||
if global.player_speed_boost_records[player.index].boost_lvl >= 4 then
|
||||
reset_player_runningspeed(player)
|
||||
player.character.die(player.force, market)
|
||||
end
|
||||
end
|
||||
|
||||
local function reset_player_miningspeed(player)
|
||||
player.character_mining_speed_modifier = global.player_mining_boost_records[player.index].pre_mining_boost_modifier
|
||||
global.player_mining_boost_records[player.index] = nil
|
||||
end
|
||||
|
||||
local function boost_player_miningspeed(player, market)
|
||||
if global.player_mining_boost_records == nil then
|
||||
global.player_mining_boost_records = {}
|
||||
end
|
||||
|
||||
if global.player_mining_boost_records[player.index] == nil then
|
||||
global.player_mining_boost_records[player.index] = {
|
||||
start_tick = game.tick,
|
||||
pre_mining_boost_modifier = player.character_mining_speed_modifier,
|
||||
boost_lvl = 0
|
||||
}
|
||||
end
|
||||
local boost_msg = {
|
||||
[1] = '%s is going on a tree harvest!',
|
||||
[2] = 'In search of a sharper axe, %s got a lv.2 mining boost!',
|
||||
[3] = 'Wood fiend, %s, has picked up a massive chain saw and is awarded a lv.3 mining boost!',
|
||||
[4] = 'Better learn to control that saw, %s, chopped off their legs. Oops.'
|
||||
}
|
||||
global.player_mining_boost_records[player.index].boost_lvl =
|
||||
1 + global.player_mining_boost_records[player.index].boost_lvl
|
||||
player.character_mining_speed_modifier = 1 + player.character_mining_speed_modifier
|
||||
game.print(string.format(boost_msg[global.player_mining_boost_records[player.index].boost_lvl], player.name))
|
||||
if global.player_mining_boost_records[player.index].boost_lvl >= 4 then
|
||||
reset_player_miningspeed(player)
|
||||
player.character.die(player.force, market)
|
||||
end
|
||||
end
|
||||
|
||||
local function market_item_purchased(event)
|
||||
local market = event.market
|
||||
if not market or not market.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local offer_index = event.offer_index
|
||||
local player_index = event.player_index
|
||||
|
||||
-- cost
|
||||
local market_item = market.get_market_items()[offer_index]
|
||||
local cost = market_item.price[1].amount * event.count
|
||||
|
||||
PlayerStats.change_fish_spent(player_index, cost)
|
||||
|
||||
if event.offer_index == 1 then -- Temporary speed bonus
|
||||
local player = game.players[player_index]
|
||||
boost_player_runningspeed(player, market)
|
||||
end
|
||||
|
||||
if event.offer_index == 2 then -- Temporary mining bonus
|
||||
local player = game.players[player_index]
|
||||
boost_player_miningspeed(player, market)
|
||||
end
|
||||
end
|
||||
|
||||
if not global.pet_command_rotation then
|
||||
global.pet_command_rotation = 1
|
||||
end
|
||||
|
||||
local function on_180_ticks()
|
||||
if game.tick % 900 == 0 then
|
||||
if global.player_speed_boost_records then
|
||||
for k, v in pairs(global.player_speed_boost_records) do
|
||||
if game.tick - v.start_tick > 3000 then
|
||||
reset_player_runningspeed(game.players[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
if global.player_mining_boost_records then
|
||||
for k, v in pairs(global.player_mining_boost_records) do
|
||||
if game.tick - v.start_tick > 6000 then
|
||||
reset_player_miningspeed(game.players[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function player_mined_entity(event)
|
||||
local buffer = event.buffer
|
||||
|
||||
if not buffer or not buffer.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local count = buffer.get_item_count('raw-wood')
|
||||
|
||||
if count > 0 then
|
||||
PlayerStats.change_fish_earned(event.player_index, count)
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command('market', 'Places a wood market near you. (Admins only)', spawn_market)
|
||||
|
||||
Event.on_nth_tick(180, on_180_ticks)
|
||||
|
||||
Event.add(defines.events.on_entity_died, wood_drop_entity_died)
|
||||
Event.add(defines.events.on_market_item_purchased, market_item_purchased)
|
||||
Event.add(defines.events.on_player_mined_entity, player_mined_entity)
|
Loading…
x
Reference in New Issue
Block a user