mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
tweaks
This commit is contained in:
parent
7d7775bd30
commit
94f2dc079c
@ -208,6 +208,9 @@ local function greet_player(nearby_characters)
|
||||
return false
|
||||
end
|
||||
for _, c in pairs(nearby_characters) do
|
||||
if not c.player then
|
||||
return
|
||||
end
|
||||
if c.player.index == this.grandmaster_greet_player_index then
|
||||
local str = texts['greetings'][math_random(1, #texts['greetings'])] .. ' '
|
||||
str = str .. c.player.name
|
||||
@ -235,6 +238,9 @@ local function talks(nearby_characters)
|
||||
local str
|
||||
if #nearby_characters == 1 then
|
||||
local c = nearby_characters[math_random(1, #nearby_characters)]
|
||||
if not c.player then
|
||||
return
|
||||
end
|
||||
str = c.player.name
|
||||
local symbols = {'. ', '! ', '. ', '! ', '? '}
|
||||
str = str .. symbols[math_random(1, #symbols)]
|
||||
@ -292,14 +298,15 @@ local function desync(event)
|
||||
)
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.player then
|
||||
game.print(
|
||||
'[color=blue]Grandmaster:[/color]: I got you this time! Back to work, ' ..
|
||||
event.cause.player.name .. '!',
|
||||
{r = 200, g = 0, b = 0}
|
||||
)
|
||||
event.cause.die('player', this.grandmaster)
|
||||
if not event.cause.player then
|
||||
return
|
||||
end
|
||||
game.print(
|
||||
'[color=blue]Grandmaster:[/color]: I got you this time! Back to work, ' ..
|
||||
event.cause.player.name .. '!',
|
||||
{r = 200, g = 0, b = 0}
|
||||
)
|
||||
event.cause.die('player', this.grandmaster)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -200,7 +200,7 @@ local function hidden_treasure(event)
|
||||
rare_treasure_chest_messages[math.random(1, #rare_treasure_chest_messages)],
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
Loot.add(event.entity.surface, event.entity.position, 'wooden-chest', magic)
|
||||
Loot.add_rare(event.entity.surface, event.entity.position, 'wooden-chest', magic)
|
||||
return
|
||||
end
|
||||
player.print(treasure_chest_messages[math.random(1, #treasure_chest_messages)], {r = 0.98, g = 0.66, b = 0.22})
|
||||
@ -358,7 +358,7 @@ local function on_entity_died(event)
|
||||
|
||||
if entity.type == 'unit' or entity.type == 'unit-spawner' then
|
||||
this.biters_killed = this.biters_killed + 1
|
||||
if math_random(1, 256) == 1 then
|
||||
if math_random(1, 512) == 1 then
|
||||
tick_tack_trap(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
@ -377,7 +377,7 @@ local function on_entity_died(event)
|
||||
hidden_worm(event.entity)
|
||||
return
|
||||
end
|
||||
if math_random(1, 160) == 1 then
|
||||
if math_random(1, 512) == 1 then
|
||||
tick_tack_trap(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
|
@ -5,8 +5,6 @@ local WPT = require 'maps.lumberjack.table'
|
||||
local RPG = require 'maps.lumberjack.rpg'
|
||||
require 'maps.lumberjack.locomotive_market'
|
||||
|
||||
local random = math.random
|
||||
|
||||
local Public = {}
|
||||
|
||||
local energy_upgrade = 50000000
|
||||
@ -241,6 +239,130 @@ local function set_player_spawn_and_refill_fish()
|
||||
game.forces.player.set_spawn_position({x = position.x, y = position.y}, this.locomotive_cargo.surface)
|
||||
end
|
||||
|
||||
local direction_lookup = {
|
||||
[-1] = {
|
||||
[1] = defines.direction.southwest,
|
||||
[0] = defines.direction.west,
|
||||
[-1] = defines.direction.northwest
|
||||
},
|
||||
[0] = {
|
||||
[1] = defines.direction.south,
|
||||
[-1] = defines.direction.north
|
||||
},
|
||||
[1] = {
|
||||
[1] = defines.direction.southeast,
|
||||
[0] = defines.direction.east,
|
||||
[-1] = defines.direction.northeast
|
||||
}
|
||||
}
|
||||
|
||||
local function rand_range(start, stop)
|
||||
local this = WPT.get_table()
|
||||
|
||||
if not this.rng then
|
||||
this.rng = game.create_random_generator()
|
||||
end
|
||||
|
||||
return this.rng(start, stop)
|
||||
end
|
||||
|
||||
local function get_axis(point, axis)
|
||||
local function safe_get(t, k)
|
||||
local res, value =
|
||||
pcall(
|
||||
function()
|
||||
return t[k]
|
||||
end
|
||||
)
|
||||
if res then
|
||||
return value
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
if point.position then
|
||||
return get_axis(point.position, axis)
|
||||
end
|
||||
|
||||
if point[axis] then
|
||||
return point[axis]
|
||||
end
|
||||
|
||||
if safe_get(point, 'target') then
|
||||
return get_axis(point.target, axis)
|
||||
end
|
||||
|
||||
if #point ~= 2 then
|
||||
log('get_axis: invalid point format')
|
||||
return nil
|
||||
end
|
||||
|
||||
if axis == 'x' then
|
||||
return point[1]
|
||||
end
|
||||
|
||||
return point[2]
|
||||
end
|
||||
|
||||
local function get_direction(src, dest)
|
||||
local src_x = get_axis(src, 'x')
|
||||
local src_y = get_axis(src, 'y')
|
||||
local dest_x = get_axis(dest, 'x')
|
||||
local dest_y = get_axis(dest, 'y')
|
||||
|
||||
local step = {
|
||||
x = nil,
|
||||
y = nil
|
||||
}
|
||||
|
||||
local precision = rand_range(1, 10)
|
||||
if dest_x - precision > src_x then
|
||||
step.x = 1
|
||||
elseif dest_x < src_x - precision then
|
||||
step.x = -1
|
||||
else
|
||||
step.x = 0
|
||||
end
|
||||
|
||||
if dest_y - precision > src_y then
|
||||
step.y = 1
|
||||
elseif dest_y < src_y - precision then
|
||||
step.y = -1
|
||||
else
|
||||
step.y = 0
|
||||
end
|
||||
|
||||
return direction_lookup[step.x][step.y]
|
||||
end
|
||||
|
||||
local function get_distance(a, b)
|
||||
local h = (get_axis(a, 'x') - get_axis(b, 'x')) ^ 2
|
||||
local v = (get_axis(a, 'y') - get_axis(b, 'y')) ^ 2
|
||||
|
||||
return math.sqrt(h + v)
|
||||
end
|
||||
|
||||
local function move_to(ent, trgt, min_distance)
|
||||
local state = {
|
||||
walking = false
|
||||
}
|
||||
|
||||
local distance = get_distance(trgt.position, ent.position)
|
||||
if min_distance < distance then
|
||||
local dir = get_direction(ent.position, trgt.position)
|
||||
if dir then
|
||||
state = {
|
||||
walking = true,
|
||||
direction = dir
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
ent.walking_state = state
|
||||
return state.walking
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local this = WPT.get_table()
|
||||
if this.energy_shared then
|
||||
@ -258,6 +380,8 @@ local function tick()
|
||||
if game.tick % 1800 == 0 then
|
||||
set_player_spawn_and_refill_fish()
|
||||
end
|
||||
--Public.spawn_player()
|
||||
|
||||
fish_tag()
|
||||
end
|
||||
end
|
||||
@ -322,6 +446,83 @@ function Public.render_train_hp()
|
||||
}
|
||||
end
|
||||
|
||||
function Public.spawn_player()
|
||||
local rnd = math.random
|
||||
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local position = this.locomotive.position
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
if not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not this.lumberjack_one or not this.lumberjack_one.valid then
|
||||
this.lumberjack_one =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = {position.x + 5, position.y},
|
||||
force = 'player',
|
||||
direction = 0
|
||||
}
|
||||
)
|
||||
this.lumberjack_one_caption =
|
||||
rendering.draw_text {
|
||||
text = 'Lumberjack',
|
||||
surface = surface,
|
||||
target = this.lumberjack_one,
|
||||
target_offset = {0, -2.25},
|
||||
color = {r = 0, g = 110, b = 33},
|
||||
scale = 0.75,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
if not this.lumberjack_two or not this.lumberjack_two.valid then
|
||||
this.lumberjack_two =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = {position.x + -5, position.y},
|
||||
force = 'player',
|
||||
direction = 0
|
||||
}
|
||||
)
|
||||
this.lumberjack_two_caption =
|
||||
rendering.draw_text {
|
||||
text = 'Lumberjack',
|
||||
surface = surface,
|
||||
target = this.lumberjack_two,
|
||||
target_offset = {0, -2.25},
|
||||
color = {r = 0, g = 110, b = 33},
|
||||
scale = 0.75,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if this.lumberjack_one and this.lumberjack_one.valid then
|
||||
if rnd(1, 32) == 1 then
|
||||
this.lumberjack_one.destroy()
|
||||
return
|
||||
end
|
||||
move_to(this.lumberjack_one, p, rnd(15, 50))
|
||||
end
|
||||
if this.lumberjack_two and this.lumberjack_two.valid then
|
||||
if rnd(1, 32) == 1 then
|
||||
this.lumberjack_two.destroy()
|
||||
return
|
||||
end
|
||||
move_to(this.lumberjack_two, p, rnd(15, 50))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.locomotive_spawn(surface, position)
|
||||
local this = WPT.get_table()
|
||||
for y = -6, 6, 2 do
|
||||
|
@ -72,6 +72,7 @@ local function create_forces_and_disable_tech()
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['optics'].researched = true
|
||||
game.forces.player.technologies['land-mine'].enabled = false
|
||||
Balance.init_enemy_weapon_damage()
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
@ -96,107 +97,7 @@ local function set_difficulty()
|
||||
wave_defense_table.wave_interval = 3600
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = WPT.get_table()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local get_score = Score.get_table()
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
wave_defense_table.math = 8
|
||||
if not this.train_reveal and not this.reveal_normally then
|
||||
this.revealed_spawn = game.tick + 100
|
||||
end
|
||||
|
||||
wave_defense_table.next_wave = game.tick + 3600 * 25
|
||||
|
||||
local map_gen_settings = {
|
||||
['seed'] = math_random(10000, 99999),
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
['default_enable_all_autoplace_controls'] = true,
|
||||
['autoplace_settings'] = {
|
||||
['entity'] = {treat_missing_as_default = false},
|
||||
['tile'] = {treat_missing_as_default = true},
|
||||
['decorative'] = {treat_missing_as_default = true}
|
||||
}
|
||||
}
|
||||
|
||||
if not this.active_surface_index then
|
||||
this.active_surface_index = game.create_surface('lumberjack', map_gen_settings).index
|
||||
this.active_surface = game.surfaces[this.active_surface_index]
|
||||
else
|
||||
game.forces.player.set_spawn_position({0, 25}, game.surfaces[this.active_surface_index])
|
||||
this.active_surface_index =
|
||||
Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
|
||||
this.active_surface = game.surfaces[this.active_surface_index]
|
||||
end
|
||||
|
||||
create_forces_and_disable_tech()
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
|
||||
surface.request_to_generate_chunks({0, 0}, 0.5)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
local p = surface.find_non_colliding_position('character-corpse', {2, 21}, 2, 2)
|
||||
surface.create_entity({name = 'character-corpse', position = p})
|
||||
|
||||
game.forces.player.set_spawn_position({0, 21}, surface)
|
||||
|
||||
global.friendly_fire_history = {}
|
||||
global.landfill_history = {}
|
||||
global.mining_history = {}
|
||||
get_score.score_table = {}
|
||||
global.difficulty_poll_closing_timeout = game.tick + 90000
|
||||
global.difficulty_player_votes = {}
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = 0.6
|
||||
|
||||
Collapse.set_kill_entities(false)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
Collapse.set_max_line_size(Terrain.level_depth)
|
||||
Collapse.set_surface(surface)
|
||||
Collapse.set_position({0, 162})
|
||||
Collapse.set_direction('north')
|
||||
Collapse.start_now(false)
|
||||
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
surface.daytime = 0.71
|
||||
surface.brightness_visual_weights = {1, 0, 0, 0}
|
||||
surface.freeze_daytime = false
|
||||
surface.solar_power_multiplier = 1
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.cargo_health = 10000
|
||||
this.cargo_max_health = 10000
|
||||
|
||||
Locomotive(surface, {x = -18, y = 25})
|
||||
render_train_hp()
|
||||
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = this.active_surface_index
|
||||
wave_defense_table.target = this.locomotive_cargo
|
||||
wave_defense_table.nest_building_density = 32
|
||||
wave_defense_table.game_lost = false
|
||||
wave_defense_table.spawn_position = {x = 0, y = 100}
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {-196, 74}, source = {-196, 74}, target = {196, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {-196, 74}, source = {-196, 74}, target = {196, 74}})
|
||||
|
||||
RPG.rpg_reset_all_players()
|
||||
|
||||
if game.forces.lumber_defense then
|
||||
Balance.init_enemy_weapon_damage()
|
||||
else
|
||||
log('lumber_defense not found')
|
||||
end
|
||||
|
||||
set_difficulty()
|
||||
|
||||
local function render_direction(surface)
|
||||
rendering.draw_text {
|
||||
text = 'Welcome to Lumberjack!',
|
||||
surface = surface,
|
||||
@ -270,6 +171,101 @@ function Public.reset_map()
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {-196, 74}, source = {-196, 74}, target = {196, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {-196, 74}, source = {-196, 74}, target = {196, 74}})
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = WPT.get_table()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local get_score = Score.get_table()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math_random(10000, 99999),
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
['default_enable_all_autoplace_controls'] = true,
|
||||
['autoplace_settings'] = {
|
||||
['entity'] = {treat_missing_as_default = false},
|
||||
['tile'] = {treat_missing_as_default = true},
|
||||
['decorative'] = {treat_missing_as_default = true}
|
||||
}
|
||||
}
|
||||
|
||||
if not this.active_surface_index then
|
||||
this.active_surface_index = game.create_surface('lumberjack', map_gen_settings).index
|
||||
this.active_surface = game.surfaces[this.active_surface_index]
|
||||
else
|
||||
game.forces.player.set_spawn_position({0, 25}, game.surfaces[this.active_surface_index])
|
||||
this.active_surface_index =
|
||||
Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
|
||||
this.active_surface = game.surfaces[this.active_surface_index]
|
||||
end
|
||||
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
wave_defense_table.math = 8
|
||||
if not this.train_reveal and not this.reveal_normally then
|
||||
this.revealed_spawn = game.tick + 100
|
||||
end
|
||||
|
||||
create_forces_and_disable_tech()
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
|
||||
surface.request_to_generate_chunks({0, 0}, 0.5)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
local p = surface.find_non_colliding_position('character-corpse', {2, 21}, 2, 2)
|
||||
surface.create_entity({name = 'character-corpse', position = p})
|
||||
|
||||
game.forces.player.set_spawn_position({0, 21}, surface)
|
||||
|
||||
global.friendly_fire_history = {}
|
||||
global.landfill_history = {}
|
||||
global.mining_history = {}
|
||||
get_score.score_table = {}
|
||||
global.difficulty_poll_closing_timeout = game.tick + 90000
|
||||
global.difficulty_player_votes = {}
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = 0.6
|
||||
|
||||
Collapse.set_kill_entities(false)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
Collapse.set_max_line_size(Terrain.level_depth)
|
||||
Collapse.set_surface(surface)
|
||||
Collapse.set_position({0, 162})
|
||||
Collapse.set_direction('north')
|
||||
Collapse.start_now(false)
|
||||
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
surface.daytime = 0.71
|
||||
surface.brightness_visual_weights = {1, 0, 0, 0}
|
||||
surface.freeze_daytime = false
|
||||
surface.solar_power_multiplier = 1
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.cargo_health = 10000
|
||||
this.cargo_max_health = 10000
|
||||
|
||||
Locomotive(surface, {x = -18, y = 25})
|
||||
render_train_hp()
|
||||
render_direction(surface)
|
||||
RPG.rpg_reset_all_players()
|
||||
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = this.active_surface_index
|
||||
wave_defense_table.target = this.locomotive_cargo
|
||||
wave_defense_table.nest_building_density = 32
|
||||
wave_defense_table.game_lost = false
|
||||
wave_defense_table.spawn_position = {x = 0, y = 100}
|
||||
wave_defense_table.next_wave = game.tick + 3600 * 25
|
||||
|
||||
set_difficulty()
|
||||
|
||||
local surfaces = {
|
||||
[surface.name] = shape
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ local function mining_chances_ores()
|
||||
{name = 'iron-ore', chance = 545},
|
||||
{name = 'copper-ore', chance = 545},
|
||||
{name = 'coal', chance = 545},
|
||||
{name = 'stone', chance = 545}
|
||||
{name = 'stone', chance = 545},
|
||||
{name = 'uranium-ore', chance = 200}
|
||||
}
|
||||
return data
|
||||
end
|
||||
@ -111,7 +112,7 @@ local function randomness(data)
|
||||
local second_harvest_amount
|
||||
|
||||
if entity.type == 'simple-entity' then
|
||||
harvest = 'uranium-ore'
|
||||
harvest = harvest_raffle_ores[math.random(1, size_of_ore_raffle)]
|
||||
second_harvest = 'stone'
|
||||
harvest_amount, second_harvest_amount = get_amount(data)
|
||||
else
|
||||
@ -122,18 +123,29 @@ local function randomness(data)
|
||||
|
||||
local position = {x = entity.position.x, y = entity.position.y}
|
||||
|
||||
player.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = '+' ..
|
||||
harvest_amount ..
|
||||
' [img=item/' ..
|
||||
harvest .. ']\n+' .. second_harvest_amount .. ' [img=item/' .. second_harvest .. ']',
|
||||
color = {r = math_random(1, 200), g = 160, b = 30}
|
||||
}
|
||||
)
|
||||
player.insert({name = second_harvest, count = second_harvest_amount})
|
||||
if second_harvest then
|
||||
player.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = '+' ..
|
||||
harvest_amount ..
|
||||
' [img=item/' ..
|
||||
harvest .. ']\n+' .. second_harvest_amount .. ' [img=item/' .. second_harvest .. ']',
|
||||
color = {r = math_random(1, 200), g = 160, b = 30}
|
||||
}
|
||||
)
|
||||
player.insert({name = second_harvest, count = second_harvest_amount})
|
||||
else
|
||||
player.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = '+' .. harvest_amount .. ' [img=item/' .. harvest .. ']',
|
||||
color = {r = math_random(1, 200), g = 160, b = 30}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
if harvest_amount > max_spill then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true)
|
||||
|
@ -16,6 +16,10 @@ local function reset_forces(new_surface, old_surface)
|
||||
f.reset_evolution()
|
||||
f.set_spawn_position(spawn, new_surface)
|
||||
end
|
||||
for _, tech in pairs(game.forces.player.technologies) do
|
||||
tech.researched = false
|
||||
game.player.force.set_saved_technology_progress(tech, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_players(surface)
|
||||
@ -67,6 +71,8 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
||||
game.delete_surface(old_surface)
|
||||
|
||||
local message = table.concat({grandmaster .. ' Welcome to ', this.original_surface_name, '!'})
|
||||
local message_to_discord = table.concat({'** Welcome to ', this.original_surface_name, '! **'})
|
||||
|
||||
if this.soft_reset_counter > 1 then
|
||||
message =
|
||||
table.concat(
|
||||
@ -81,7 +87,7 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
||||
)
|
||||
end
|
||||
game.print(message, {r = 0.98, g = 0.66, b = 0.22})
|
||||
Server.to_discord_embed(message)
|
||||
Server.to_discord_embed(message_to_discord)
|
||||
|
||||
return new_surface
|
||||
end
|
||||
|
@ -181,7 +181,7 @@ local trees = {'dead-grey-trunk', 'dead-grey-trunk', 'dry-tree'}
|
||||
|
||||
local noises = {
|
||||
['forest_location'] = {
|
||||
{modifier = 0.006, weight = 1},
|
||||
{modifier = 0.003, weight = 1},
|
||||
{modifier = 0.01, weight = 0.25},
|
||||
{modifier = 0.05, weight = 0.15},
|
||||
{modifier = 0.1, weight = 0.05}
|
||||
@ -550,7 +550,7 @@ local function process_level_9_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
@ -687,7 +687,7 @@ local function process_level_8_position(data)
|
||||
local large_caves = get_noise('large_caves', p, seed)
|
||||
if scrapyard > -0.15 and scrapyard < 0.15 then
|
||||
if math_floor(large_caves * 10) % 4 < 3 then
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
@ -813,7 +813,7 @@ local function process_level_7_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
@ -877,13 +877,19 @@ local function process_level_6_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
forest_look(data)
|
||||
if math_random(1, 100) > 25 then
|
||||
if math_random(1, 4) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -943,13 +949,19 @@ local function process_level_5_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
forest_look(data)
|
||||
if math_random(1, 100) > 25 then
|
||||
if math_random(1, 8) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'out-of-map', position = p}
|
||||
@ -1049,13 +1061,19 @@ local function process_level_4_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
forest_look(data)
|
||||
if math_random(1, 100) > 25 then
|
||||
if math_random(1, 8) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'out-of-map', position = p}
|
||||
end
|
||||
@ -1185,13 +1203,19 @@ local function process_level_3_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
forest_look(data)
|
||||
if math_random(1, 100) > 25 then
|
||||
if math_random(1, 8) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'out-of-map', position = p}
|
||||
end
|
||||
@ -1258,7 +1282,7 @@ local function process_level_2_position(data)
|
||||
markets[#markets + 1] = p
|
||||
end
|
||||
if math_random(1, 16) == 1 then
|
||||
entities[#entities + 1] = {name = trees[math_random(1, #trees)], position = p}
|
||||
forest_look(data, true)
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -1303,13 +1327,19 @@ local function process_level_2_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
forest_look(data)
|
||||
if math_random(1, 100) > 25 then
|
||||
if math_random(1, 8) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1428,14 +1458,18 @@ local function process_level_1_position(data)
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'grass-1', position = p}
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
|
||||
if math_random(1, 4028) == 1 then
|
||||
place_random_scrap_entity(surface, p)
|
||||
end
|
||||
|
||||
if math_random(1, 100) > 25 then
|
||||
forest_look(data)
|
||||
if math_random(1, 8) == 1 then
|
||||
forest_look(data, true)
|
||||
else
|
||||
forest_look(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1673,13 +1707,6 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
end
|
||||
|
||||
local p = this.locomotive.position
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered({area = {{p.x - 10, p.y - 10}, {p.x + 10, p.y + 10}}, type = 'simple-entity'})
|
||||
) do
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
out_of_map_area(data)
|
||||
end
|
||||
|
||||
|
@ -21,9 +21,9 @@ local nth_tick = 54001 -- nearest prime to 15 minutes in ticks
|
||||
|
||||
Global.register(
|
||||
{
|
||||
session=session,
|
||||
online_track=online_track,
|
||||
trusted=trusted
|
||||
session = session,
|
||||
online_track = online_track,
|
||||
trusted = trusted
|
||||
},
|
||||
function(tbl)
|
||||
session = tbl.session
|
||||
@ -35,12 +35,12 @@ Global.register(
|
||||
local Public = {}
|
||||
|
||||
if _DEBUG then
|
||||
printinfo =
|
||||
Token.register(
|
||||
function(data)
|
||||
game.print(serpent.block(data))
|
||||
end
|
||||
)
|
||||
printinfo =
|
||||
Token.register(
|
||||
function(data)
|
||||
game.print(serpent.block(data))
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
local try_download_data =
|
||||
@ -97,7 +97,7 @@ function Public.try_dl_data(key)
|
||||
else
|
||||
try_get_data(session_data_set, key, try_download_data)
|
||||
secs = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Tries to get data from the webpanel and updates the local table with values.
|
||||
@ -111,7 +111,7 @@ function Public.try_ul_data(key)
|
||||
else
|
||||
try_get_data(session_data_set, key, try_upload_data)
|
||||
secs = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Checks if a player exists within the table
|
||||
@ -159,7 +159,7 @@ Event.add(
|
||||
return
|
||||
end
|
||||
if game.is_multiplayer() then
|
||||
Public.try_dl_data(player.name)
|
||||
Public.try_dl_data(player.name)
|
||||
else
|
||||
session[player.name] = player.online_time
|
||||
end
|
||||
@ -174,7 +174,7 @@ Event.add(
|
||||
return
|
||||
end
|
||||
if game.is_multiplayer() then
|
||||
Public.try_ul_data(player.name)
|
||||
Public.try_ul_data(player.name)
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -188,4 +188,4 @@ Server.on_data_set_changed(
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
return Public
|
||||
|
@ -9,112 +9,367 @@ local math_floor = math.floor
|
||||
-- 2D simplex noise
|
||||
|
||||
local grad3 = {
|
||||
{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0},
|
||||
{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},
|
||||
{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}
|
||||
{1, 1, 0},
|
||||
{-1, 1, 0},
|
||||
{1, -1, 0},
|
||||
{-1, -1, 0},
|
||||
{1, 0, 1},
|
||||
{-1, 0, 1},
|
||||
{1, 0, -1},
|
||||
{-1, 0, -1},
|
||||
{0, 1, 1},
|
||||
{0, -1, 1},
|
||||
{0, 1, -1},
|
||||
{0, -1, -1}
|
||||
}
|
||||
|
||||
local p = {151,160,137,91,90,15,
|
||||
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
|
||||
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
|
||||
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
|
||||
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
|
||||
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
|
||||
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
|
||||
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
|
||||
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
|
||||
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
|
||||
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
|
||||
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
|
||||
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}
|
||||
local p = {
|
||||
151,
|
||||
160,
|
||||
137,
|
||||
91,
|
||||
90,
|
||||
15,
|
||||
131,
|
||||
13,
|
||||
201,
|
||||
95,
|
||||
96,
|
||||
53,
|
||||
194,
|
||||
233,
|
||||
7,
|
||||
225,
|
||||
140,
|
||||
36,
|
||||
103,
|
||||
30,
|
||||
69,
|
||||
142,
|
||||
8,
|
||||
99,
|
||||
37,
|
||||
240,
|
||||
21,
|
||||
10,
|
||||
23,
|
||||
190,
|
||||
6,
|
||||
148,
|
||||
247,
|
||||
120,
|
||||
234,
|
||||
75,
|
||||
0,
|
||||
26,
|
||||
197,
|
||||
62,
|
||||
94,
|
||||
252,
|
||||
219,
|
||||
203,
|
||||
117,
|
||||
35,
|
||||
11,
|
||||
32,
|
||||
57,
|
||||
177,
|
||||
33,
|
||||
88,
|
||||
237,
|
||||
149,
|
||||
56,
|
||||
87,
|
||||
174,
|
||||
20,
|
||||
125,
|
||||
136,
|
||||
171,
|
||||
168,
|
||||
68,
|
||||
175,
|
||||
74,
|
||||
165,
|
||||
71,
|
||||
134,
|
||||
139,
|
||||
48,
|
||||
27,
|
||||
166,
|
||||
77,
|
||||
146,
|
||||
158,
|
||||
231,
|
||||
83,
|
||||
111,
|
||||
229,
|
||||
122,
|
||||
60,
|
||||
211,
|
||||
133,
|
||||
230,
|
||||
220,
|
||||
105,
|
||||
92,
|
||||
41,
|
||||
55,
|
||||
46,
|
||||
245,
|
||||
40,
|
||||
244,
|
||||
102,
|
||||
143,
|
||||
54,
|
||||
65,
|
||||
25,
|
||||
63,
|
||||
161,
|
||||
1,
|
||||
216,
|
||||
80,
|
||||
73,
|
||||
209,
|
||||
76,
|
||||
132,
|
||||
187,
|
||||
208,
|
||||
89,
|
||||
18,
|
||||
169,
|
||||
200,
|
||||
196,
|
||||
135,
|
||||
130,
|
||||
116,
|
||||
188,
|
||||
159,
|
||||
86,
|
||||
164,
|
||||
100,
|
||||
109,
|
||||
198,
|
||||
173,
|
||||
186,
|
||||
3,
|
||||
64,
|
||||
52,
|
||||
217,
|
||||
226,
|
||||
250,
|
||||
124,
|
||||
123,
|
||||
5,
|
||||
202,
|
||||
38,
|
||||
147,
|
||||
118,
|
||||
126,
|
||||
255,
|
||||
82,
|
||||
85,
|
||||
212,
|
||||
207,
|
||||
206,
|
||||
59,
|
||||
227,
|
||||
47,
|
||||
16,
|
||||
58,
|
||||
17,
|
||||
182,
|
||||
189,
|
||||
28,
|
||||
42,
|
||||
223,
|
||||
183,
|
||||
170,
|
||||
213,
|
||||
119,
|
||||
248,
|
||||
152,
|
||||
2,
|
||||
44,
|
||||
154,
|
||||
163,
|
||||
70,
|
||||
221,
|
||||
153,
|
||||
101,
|
||||
155,
|
||||
167,
|
||||
43,
|
||||
172,
|
||||
9,
|
||||
129,
|
||||
22,
|
||||
39,
|
||||
253,
|
||||
19,
|
||||
98,
|
||||
108,
|
||||
110,
|
||||
79,
|
||||
113,
|
||||
224,
|
||||
232,
|
||||
178,
|
||||
185,
|
||||
112,
|
||||
104,
|
||||
218,
|
||||
246,
|
||||
97,
|
||||
228,
|
||||
251,
|
||||
34,
|
||||
242,
|
||||
193,
|
||||
238,
|
||||
210,
|
||||
144,
|
||||
12,
|
||||
191,
|
||||
179,
|
||||
162,
|
||||
241,
|
||||
81,
|
||||
51,
|
||||
145,
|
||||
235,
|
||||
249,
|
||||
14,
|
||||
239,
|
||||
107,
|
||||
49,
|
||||
192,
|
||||
214,
|
||||
31,
|
||||
181,
|
||||
199,
|
||||
106,
|
||||
157,
|
||||
184,
|
||||
84,
|
||||
204,
|
||||
176,
|
||||
115,
|
||||
121,
|
||||
50,
|
||||
45,
|
||||
127,
|
||||
4,
|
||||
150,
|
||||
254,
|
||||
138,
|
||||
236,
|
||||
205,
|
||||
93,
|
||||
222,
|
||||
114,
|
||||
67,
|
||||
29,
|
||||
24,
|
||||
72,
|
||||
243,
|
||||
141,
|
||||
128,
|
||||
195,
|
||||
78,
|
||||
66,
|
||||
215,
|
||||
61,
|
||||
156,
|
||||
180
|
||||
}
|
||||
local perm = {}
|
||||
for i=0,511 do
|
||||
perm[i+1] = p[bit32_band(i, 255) + 1]
|
||||
for i = 0, 511 do
|
||||
perm[i + 1] = p[bit32_band(i, 255) + 1]
|
||||
end
|
||||
|
||||
-- special case of dot with 3 inputs
|
||||
local function dot2(g, x, y)
|
||||
return x * g[1] + y *g[2]
|
||||
return x * g[1] + y * g[2]
|
||||
end
|
||||
|
||||
local function dot(g, ...)
|
||||
local v = {...}
|
||||
local sum = 0
|
||||
for i=1,#v do
|
||||
sum = sum + v[i] * g[i]
|
||||
end
|
||||
return sum
|
||||
local v = {...}
|
||||
local sum = 0
|
||||
for i = 1, #v do
|
||||
sum = sum + v[i] * g[i]
|
||||
end
|
||||
return sum
|
||||
end
|
||||
|
||||
local F2 = 0.5*(math.sqrt(3.0)-1.0)
|
||||
local G2 = (3.0-math.sqrt(3.0))/6.0
|
||||
local F2 = 0.5 * (math.sqrt(3.0) - 1.0)
|
||||
local G2 = (3.0 - math.sqrt(3.0)) / 6.0
|
||||
|
||||
function Simplex.d2(xin, yin,seed)
|
||||
xin = xin + seed
|
||||
yin = yin + seed
|
||||
local n0, n1, n2 -- Noise contributions from the three corners
|
||||
-- Skew the input space to determine which simplex cell we're in
|
||||
local s = (xin+yin)*F2; -- Hairy factor for 2D
|
||||
local i = math_floor(xin+s)
|
||||
local j = math_floor(yin+s)
|
||||
local t = (i+j)*G2
|
||||
local X0 = i-t -- Unskew the cell origin back to (x,y) space
|
||||
local Y0 = j-t
|
||||
local x0 = xin-X0 -- The x,y distances from the cell origin
|
||||
local y0 = yin-Y0
|
||||
-- For the 2D case, the simplex shape is an equilateral triangle.
|
||||
-- Determine which simplex we are in.
|
||||
local i1, j1 -- Offsets for second (middle) corner of simplex in (i,j) coords
|
||||
if x0 > y0 then
|
||||
i1 = 1
|
||||
j1 = 0 -- lower triangle, XY order: (0,0)->(1,0)->(1,1)
|
||||
else
|
||||
i1 = 0
|
||||
j1 = 1
|
||||
end-- upper triangle, YX order: (0,0)->(0,1)->(1,1)
|
||||
-- A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
|
||||
-- a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
|
||||
-- c = (3-sqrt(3))/6
|
||||
local x1 = x0 - i1 + G2 -- Offsets for middle corner in (x,y) unskewed coords
|
||||
local y1 = y0 - j1 + G2
|
||||
local x2 = x0 - 1 + 2 * G2 -- Offsets for last corner in (x,y) unskewed coords
|
||||
local y2 = y0 - 1 + 2 * G2
|
||||
function Simplex.d2(xin, yin, seed)
|
||||
xin = xin + seed
|
||||
yin = yin + seed
|
||||
local n0, n1, n2 -- Noise contributions from the three corners
|
||||
-- Skew the input space to determine which simplex cell we're in
|
||||
local s = (xin + yin) * F2 -- Hairy factor for 2D
|
||||
local i = math_floor(xin + s)
|
||||
local j = math_floor(yin + s)
|
||||
local t = (i + j) * G2
|
||||
local X0 = i - t -- Unskew the cell origin back to (x,y) space
|
||||
local Y0 = j - t
|
||||
local x0 = xin - X0 -- The x,y distances from the cell origin
|
||||
local y0 = yin - Y0
|
||||
-- For the 2D case, the simplex shape is an equilateral triangle.
|
||||
-- Determine which simplex we are in.
|
||||
local i1, j1 -- Offsets for second (middle) corner of simplex in (i,j) coords
|
||||
if x0 > y0 then
|
||||
i1 = 1
|
||||
j1 = 0 -- lower triangle, XY order: (0,0)->(1,0)->(1,1)
|
||||
else
|
||||
i1 = 0
|
||||
j1 = 1
|
||||
end
|
||||
-- upper triangle, YX order: (0,0)->(0,1)->(1,1)
|
||||
-- A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
|
||||
-- a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
|
||||
-- c = (3-sqrt(3))/6
|
||||
local x1 = x0 - i1 + G2 -- Offsets for middle corner in (x,y) unskewed coords
|
||||
local y1 = y0 - j1 + G2
|
||||
local x2 = x0 - 1 + 2 * G2 -- Offsets for last corner in (x,y) unskewed coords
|
||||
local y2 = y0 - 1 + 2 * G2
|
||||
|
||||
-- Work out the hashed gradient indices of the three simplex corners
|
||||
local ii = bit32_band(i, 255)
|
||||
local jj = bit32_band(j, 255)
|
||||
local gi0 = perm[ii + perm[jj+1]+1] % 12
|
||||
local gi1 = perm[ii + i1 + perm[jj + j1+1]+1] % 12
|
||||
local gi2 = perm[ii + 1 + perm[jj + 1+1]+1] % 12
|
||||
-- Work out the hashed gradient indices of the three simplex corners
|
||||
local ii = bit32_band(i, 255)
|
||||
local jj = bit32_band(j, 255)
|
||||
local gi0 = perm[ii + perm[jj + 1] + 1] % 12
|
||||
local gi1 = perm[ii + i1 + perm[jj + j1 + 1] + 1] % 12
|
||||
local gi2 = perm[ii + 1 + perm[jj + 1 + 1] + 1] % 12
|
||||
|
||||
-- Calculate the contribution from the three corners
|
||||
local t0 = 0.5 - x0 * x0 - y0 * y0
|
||||
if t0 < 0 then
|
||||
n0 = 0.0
|
||||
else
|
||||
t0 = t0 * t0
|
||||
n0 = t0 * t0 * dot2(grad3[gi0+1], x0, y0) -- (x,y) of grad3 used for 2D gradient
|
||||
end
|
||||
-- Calculate the contribution from the three corners
|
||||
local t0 = 0.5 - x0 * x0 - y0 * y0
|
||||
if t0 < 0 then
|
||||
n0 = 0.0
|
||||
else
|
||||
t0 = t0 * t0
|
||||
n0 = t0 * t0 * dot2(grad3[gi0 + 1], x0, y0) -- (x,y) of grad3 used for 2D gradient
|
||||
end
|
||||
|
||||
local t1 = 0.5 - x1 * x1 - y1 * y1
|
||||
if t1 < 0 then
|
||||
n1 = 0.0
|
||||
else
|
||||
t1 = t1 * t1
|
||||
n1 = t1 * t1 * dot2(grad3[gi1+1], x1, y1)
|
||||
end
|
||||
local t1 = 0.5 - x1 * x1 - y1 * y1
|
||||
if t1 < 0 then
|
||||
n1 = 0.0
|
||||
else
|
||||
t1 = t1 * t1
|
||||
n1 = t1 * t1 * dot2(grad3[gi1 + 1], x1, y1)
|
||||
end
|
||||
|
||||
local t2 = 0.5 - x2 * x2 - y2 * y2
|
||||
if t2 < 0 then
|
||||
n2 = 0.0
|
||||
else
|
||||
t2 = t2 * t2
|
||||
n2 = t2 * t2 * dot2(grad3[gi2+1], x2, y2)
|
||||
end
|
||||
local t2 = 0.5 - x2 * x2 - y2 * y2
|
||||
if t2 < 0 then
|
||||
n2 = 0.0
|
||||
else
|
||||
t2 = t2 * t2
|
||||
n2 = t2 * t2 * dot2(grad3[gi2 + 1], x2, y2)
|
||||
end
|
||||
|
||||
-- Add contributions from each corner to get the final noise value.
|
||||
-- The result is scaled to return values in the interval [-1,1].
|
||||
return 70.0 * (n0 + n1 + n2)
|
||||
-- Add contributions from each corner to get the final noise value.
|
||||
-- The result is scaled to return values in the interval [-1,1].
|
||||
return 70.0 * (n0 + n1 + n2)
|
||||
end
|
||||
|
||||
return Simplex
|
||||
return Simplex
|
||||
|
Loading…
x
Reference in New Issue
Block a user