mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
commit
594c850839
@ -614,13 +614,22 @@ end
|
||||
local function on_player_cancelled_crafting(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local count = #event.items
|
||||
local crafting_queue_item_count = event.items.get_item_count()
|
||||
local player_inventory_free_slot_count = player.get_main_inventory().count_empty_stacks()
|
||||
local crafting_queue_canceled_item_slot_count = #event.items
|
||||
|
||||
if crafting_queue_canceled_item_slot_count > player_inventory_free_slot_count then
|
||||
player.character.character_inventory_slots_bonus = crafting_queue_canceled_item_slot_count + #player.get_main_inventory()
|
||||
for i = 1, crafting_queue_canceled_item_slot_count do
|
||||
player.character.get_main_inventory().insert(event.items[i])
|
||||
end
|
||||
player.character.die('player')
|
||||
|
||||
if count > 40 then
|
||||
Utils.action_warning(
|
||||
'{Crafting}',
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. count .. '.'
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafting_queue_canceled_item_slot_count .. ' slots) and was punished.'
|
||||
)
|
||||
|
||||
if not this.cancel_crafting_history[player.index] then
|
||||
this.cancel_crafting_history[player.index] = {}
|
||||
end
|
||||
@ -632,7 +641,7 @@ local function on_player_cancelled_crafting(event)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' canceled '
|
||||
str = str .. ' item ' .. event.recipe.name
|
||||
str = str .. ' count was a total of: ' .. count
|
||||
str = str .. ' count was a total of: ' .. crafting_queue_item_count
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(player.position.x)
|
||||
str = str .. ' Y:'
|
||||
|
@ -8,6 +8,11 @@ map_info_main_caption=--Desert Oasis--
|
||||
map_info_sub_caption=Survival in the dry sands.
|
||||
map_info_text=This is a harsh world, the heat is unbearable and the sand is sharp like diamonds.\nMake sure to stay properly hydrated.\nDrink some water from a pond, or sip it out of a barrel to stay refreshed.\n\nWe shall not attempt to travel without a proper vehicle.\nMany building foundations are not possible to be set up outside of the oasis.\nRailways between them however should be possible.\n\nLuckily the ship's moisture meter module did survive the crash.\nIt may come in handy!
|
||||
|
||||
[expanse]
|
||||
map_info_main_caption=-- E x p a n s e --
|
||||
map_info_sub_caption=
|
||||
map_info_text=The blue chests are hungry.\nFeed them and they will reward you with more land.\n\nThe friendly infini tree will provide you with all the wood you ever wanted.\nThe everlasting rock with be happy to provide resources for you.\n\nIf you find yourself stuck, put a reroll token, the small plane toy, in the chest to get a new offer.\nUnlocking chests may drop additional tokens.
|
||||
|
||||
[fish_defender]
|
||||
map_info_main_caption=--Fish Defender--
|
||||
map_info_sub_caption= *blb blubby blub*
|
||||
|
@ -2,20 +2,37 @@ local Price_raffle = require 'maps.expanse.price_raffle'
|
||||
local Public = {}
|
||||
|
||||
local price_modifiers = {
|
||||
["unit-spawner"] = -128,
|
||||
["unit-spawner"] = -256,
|
||||
["unit"] = -16,
|
||||
["turret"] = -128,
|
||||
["tree"] = -8,
|
||||
["simple-entity"] = -12,
|
||||
["cliff"] = -32,
|
||||
["water"] = -4,
|
||||
["water-green"] = -4,
|
||||
["deepwater"] = -4,
|
||||
["deepwater-green"] = -4,
|
||||
["simple-entity"] = 2,
|
||||
["cliff"] = -128,
|
||||
["water"] = -5,
|
||||
["water-green"] = -5,
|
||||
["deepwater"] = -5,
|
||||
["deepwater-green"] = -5,
|
||||
["water-mud"] = -6,
|
||||
["water-shallow"] = -6,
|
||||
}
|
||||
|
||||
local function reward_tokens(expanse, entity)
|
||||
local chance = expanse.token_chance % 1
|
||||
local count = math.floor(expanse.token_chance)
|
||||
|
||||
if chance > 0 then
|
||||
chance = math.floor(chance * 1000)
|
||||
if math.random(1, 1000) <= chance then
|
||||
entity.surface.spill_item_stack(entity.position, {name = "small-plane", count = 1}, true, nil, false)
|
||||
end
|
||||
end
|
||||
if count > 0 then
|
||||
for _ = 1, count, 1 do
|
||||
entity.surface.spill_item_stack(entity.position, {name = "small-plane", count = 1}, true, nil, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_cell_value(expanse, left_top)
|
||||
local square_size = expanse.square_size
|
||||
local value = square_size ^ 2
|
||||
@ -31,19 +48,20 @@ local function get_cell_value(expanse, left_top)
|
||||
value = value + price_modifiers[tile.name]
|
||||
end
|
||||
end
|
||||
|
||||
local distance = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2)
|
||||
local value = value * (distance * 0.005)
|
||||
|
||||
local ore_modifier = distance * 0.00025
|
||||
if ore_modifier > 0.5 then ore_modifier = 0.5 end
|
||||
|
||||
for _, entity in pairs(entities) do
|
||||
if price_modifiers[entity.type] then
|
||||
value = value + price_modifiers[entity.type]
|
||||
end
|
||||
end
|
||||
|
||||
local distance = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2)
|
||||
local value = value * (distance * expanse.price_distance_modifier)
|
||||
local ore_modifier = distance * 0.00025
|
||||
if ore_modifier > expanse.max_ore_price_modifier then ore_modifier = expanse.max_ore_price_modifier end
|
||||
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.type == "resource" then
|
||||
if entity.name == "crude-oil" then
|
||||
if entity.prototype.resource_category == "basic-fluid" then
|
||||
value = value + (entity.amount * ore_modifier * 0.01)
|
||||
else
|
||||
value = value + (entity.amount * ore_modifier)
|
||||
@ -96,7 +114,7 @@ end
|
||||
function Public.expand(expanse, left_top)
|
||||
local source_surface = game.surfaces[expanse.source_surface]
|
||||
if not source_surface then return end
|
||||
source_surface.request_to_generate_chunks({x = 0, y = 0}, 3)
|
||||
source_surface.request_to_generate_chunks(left_top, 3)
|
||||
source_surface.force_generate_chunk_requests()
|
||||
|
||||
local square_size = expanse.square_size
|
||||
@ -134,12 +152,17 @@ function Public.expand(expanse, left_top)
|
||||
|
||||
if game.tick == 0 then
|
||||
local a = math.floor(expanse.square_size * 0.5)
|
||||
surface.create_entity({name = "crude-oil", position = {a - 3, a}, amount = 300000})
|
||||
local e = surface.create_entity({name = "offshore-pump", force = "player", position = {a + 1, a}})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
for x = 1, 3, 1 do
|
||||
for y = 1, 3, 1 do
|
||||
surface.set_tiles({{name = "water", position = {a + x, a + y - 2}}}, true)
|
||||
end
|
||||
end
|
||||
surface.create_entity({name = "crude-oil", position = {a - 3, a}, amount = 1500000})
|
||||
surface.create_entity({name = "rock-big", position = {a, a}})
|
||||
surface.create_entity({name = "tree-0" .. math.random(1,9), position = {a, a - 1}})
|
||||
surface.spill_item_stack({a, a + 2}, {name = "small-plane", count = 1}, false, nil, false)
|
||||
surface.spill_item_stack({a + 0.5, a + 2.5}, {name = "small-plane", count = 1}, false, nil, false)
|
||||
surface.spill_item_stack({a - 0.5, a + 2.5}, {name = "small-plane", count = 1}, false, nil, false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -176,6 +199,18 @@ function Public.set_container(expanse, entity)
|
||||
|
||||
local inventory = container.entity.get_inventory(defines.inventory.chest)
|
||||
|
||||
if not inventory.is_empty() then
|
||||
local contents = inventory.get_contents()
|
||||
if contents["small-plane"] then
|
||||
local count_removed = inventory.remove({name = "small-plane", count = 1})
|
||||
if count_removed > 0 then
|
||||
init_container(expanse, entity)
|
||||
container = expanse.containers[entity.unit_number]
|
||||
game.print("The hungry chest has renewed it's offer! [gps=" .. math.floor(entity.position.x) .. "," .. math.floor(entity.position.y) .. ",expanse]")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for key, item_stack in pairs(container.price) do
|
||||
local count_removed = inventory.remove(item_stack)
|
||||
container.price[key].count = container.price[key].count - count_removed
|
||||
@ -186,15 +221,18 @@ function Public.set_container(expanse, entity)
|
||||
|
||||
if #container.price == 0 then
|
||||
Public.expand(expanse, container.left_top)
|
||||
local a = math.floor(expanse.square_size * 0.5)
|
||||
local expansion_position = {x = expanse.containers[entity.unit_number].left_top.x + a, y = expanse.containers[entity.unit_number].left_top.y + a}
|
||||
expanse.containers[entity.unit_number] = nil
|
||||
if not inventory.is_empty() then
|
||||
for name, count in pairs(inventory.get_contents()) do
|
||||
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, true, nil, false)
|
||||
end
|
||||
end
|
||||
reward_tokens(expanse, entity)
|
||||
entity.destructible = true
|
||||
entity.die()
|
||||
return
|
||||
return expansion_position
|
||||
end
|
||||
|
||||
for slot = 1, 30, 1 do
|
||||
|
@ -3,8 +3,7 @@ require 'modules.satellite_score'
|
||||
local Event = require 'utils.event'
|
||||
local Functions = require 'maps.expanse.functions'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local math_round = math.round
|
||||
local Map_info = require "modules.map_info"
|
||||
|
||||
local expanse = {}
|
||||
Global.register(
|
||||
@ -14,10 +13,28 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
local function set_nauvis()
|
||||
local surface = game.surfaces[1]
|
||||
local map_gen_settings = surface.map_gen_settings
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["coal"] = {frequency = 10, size = 0.7, richness = 0.5,},
|
||||
["stone"] = {frequency = 10, size = 0.7, richness = 0.5,},
|
||||
["copper-ore"] = {frequency = 10, size = 0.7, richness = 0.75,},
|
||||
["iron-ore"] = {frequency = 10, size = 0.7, richness = 1,},
|
||||
["uranium-ore"] = {frequency = 10, size = 0.5, richness = 1,},
|
||||
["crude-oil"] = {frequency = 25, size = 1.5, richness = 1.5,},
|
||||
["trees"] = {frequency = 1.5, size = 1, richness = 1},
|
||||
["enemy-base"] = {frequency = 10, size = 2, richness = 1},
|
||||
}
|
||||
map_gen_settings.starting_area = 0.25
|
||||
surface.map_gen_settings = map_gen_settings
|
||||
for chunk in surface.get_chunks() do
|
||||
surface.delete_chunk({chunk.x, chunk.y})
|
||||
end
|
||||
end
|
||||
|
||||
local function reset()
|
||||
expanse.containers = {}
|
||||
expanse.source_surface = 1
|
||||
expanse.square_size = 15
|
||||
|
||||
local map_gen_settings = {
|
||||
["water"] = 0,
|
||||
@ -42,6 +59,8 @@ local function reset()
|
||||
}
|
||||
game.create_surface("expanse", map_gen_settings)
|
||||
|
||||
--set_nauvis()
|
||||
|
||||
local source_surface = game.surfaces[expanse.source_surface]
|
||||
source_surface.request_to_generate_chunks({x = 0, y = 0}, 4)
|
||||
source_surface.force_generate_chunk_requests()
|
||||
@ -87,22 +106,26 @@ local function on_chunk_generated(event)
|
||||
event.surface.set_tiles(tiles, true)
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
local function container_opened(event)
|
||||
local entity = event.entity
|
||||
if not entity then return end
|
||||
if not entity.valid then return end
|
||||
if not entity.unit_number then return end
|
||||
if entity.force.index ~= 3 then return end
|
||||
Functions.set_container(expanse, entity)
|
||||
local expansion_position = Functions.set_container(expanse, entity)
|
||||
if expansion_position then
|
||||
local player = game.players[event.player_index]
|
||||
local colored_player_name = table.concat({"[color=", player.color.r * 0.6 + 0.35, ",", player.color.g * 0.6 + 0.35, ",", player.color.b * 0.6 + 0.35, "]", player.name, "[/color]"})
|
||||
game.print(colored_player_name .. " unlocked new grounds! [gps=" .. math.floor(expansion_position.x) .. "," .. math.floor(expansion_position.y) .. ",expanse]")
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
container_opened(event)
|
||||
end
|
||||
|
||||
local function on_gui_closed(event)
|
||||
local entity = event.entity
|
||||
if not entity then return end
|
||||
if not entity.valid then return end
|
||||
if not entity.unit_number then return end
|
||||
if entity.force.index ~= 3 then return end
|
||||
Functions.set_container(expanse, entity)
|
||||
container_opened(event)
|
||||
end
|
||||
|
||||
local ores = {"iron-ore", "iron-ore", "copper-ore", "coal"}
|
||||
@ -111,7 +134,8 @@ local function infini_rock(entity)
|
||||
local a = math.floor(expanse.square_size * 0.5)
|
||||
if entity.position.x == a and entity.position.y == a then
|
||||
entity.surface.create_entity({name = "rock-big", position = {a, a}})
|
||||
entity.surface.spill_item_stack(entity.position, {name = ores[math.random(1,4)], count = math.random(125, 250)}, true, nil, true)
|
||||
entity.surface.spill_item_stack(entity.position, {name = ores[math.random(1,4)], count = math.random(100, 200)}, true, nil, true)
|
||||
entity.surface.spill_item_stack(entity.position, {name = "stone", count = math.random(25, 50)}, true, nil, true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -138,15 +162,47 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_left_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
if not player.character.valid then return end
|
||||
local inventory = player.get_main_inventory()
|
||||
if not inventory then return end
|
||||
local removed_count = inventory.remove({name = "small-plane", count = 999})
|
||||
if removed_count > 0 then
|
||||
for _ = 1, removed_count, 1 do
|
||||
player.surface.spill_item_stack(player.position, {name = "small-plane", count = 1}, false, nil, false)
|
||||
end
|
||||
game.print(player.name .. " dropped their tokens! [gps=" .. math.floor(player.position.x) .. "," .. math.floor(player.position.y) .. "," .. player.surface.name .. "]")
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init(event)
|
||||
local T = Map_info.Pop_info()
|
||||
T.localised_category = "expanse"
|
||||
T.main_caption_color = {r = 170, g = 170, b = 0}
|
||||
T.sub_caption_color = {r = 120, g = 120, b = 0}
|
||||
|
||||
if not expanse.source_surface then expanse.source_surface = "nauvis" end
|
||||
if not expanse.token_chance then expanse.token_chance = 0.33 end
|
||||
if not expanse.price_distance_modifier then expanse.price_distance_modifier = 0.004 end
|
||||
if not expanse.max_ore_price_modifier then expanse.max_ore_price_modifier = 0.33 end
|
||||
if not expanse.square_size then expanse.square_size = 16 end
|
||||
|
||||
--[[
|
||||
expanse.token_chance = 2.5
|
||||
expanse.price_distance_modifier = 0.001
|
||||
expanse.max_ore_price_modifier = 0.01
|
||||
]]
|
||||
reset()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_entity_died, infini_resource)
|
||||
Event.add(defines.events.on_robot_mined_entity, infini_resource)
|
||||
Event.add(defines.events.on_player_mined_entity, infini_resource)
|
||||
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_mined_entity, infini_resource)
|
||||
Event.add(defines.events.on_robot_mined_entity, infini_resource)
|
@ -227,7 +227,7 @@ function Public.roll_item_stack(remaining_budget, blacklist)
|
||||
if not blacklist[item_name] and item_worth <= remaining_budget then break end
|
||||
end
|
||||
|
||||
local stack_size = game.item_prototypes[item_name].stack_size * 16
|
||||
local stack_size = game.item_prototypes[item_name].stack_size * 32
|
||||
|
||||
local item_count = 1
|
||||
|
||||
|
@ -78,6 +78,7 @@ local function distance(player)
|
||||
rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls
|
||||
WPT.set().breached_wall = breached_wall + 1
|
||||
WPT.set().placed_trains_in_zone.placed = 0
|
||||
WPT.set().placed_trains_in_zone.randomized = false
|
||||
WPT.set().placed_trains_in_zone.positions = {}
|
||||
raise_event(Balance.events.breached_wall, {})
|
||||
|
||||
|
@ -233,8 +233,9 @@ function Public.reset_map()
|
||||
RPG.set_surface_name('mountain_fortress_v3')
|
||||
RPG.enable_health_and_mana_bars(true)
|
||||
RPG.enable_wave_defense(true)
|
||||
RPG.enable_mana(false)
|
||||
RPG.enable_flame_boots(false)
|
||||
RPG.enable_mana(true)
|
||||
RPG.enable_flame_boots(true)
|
||||
RPG.personal_tax_rate(1)
|
||||
|
||||
disable_tech()
|
||||
|
||||
|
@ -87,14 +87,126 @@ local resource_loot = {
|
||||
recipe = 'stone-wall',
|
||||
output = {item = 'stone-wall', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 2
|
||||
weight = 10
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'iron-gear-wheel',
|
||||
output = {item = 'iron-gear-wheel', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 12
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'inserter',
|
||||
output = {item = 'inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 12
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'transport-belt',
|
||||
output = {item = 'transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'underground-belt',
|
||||
output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'small-electric-pole',
|
||||
output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'fast-transport-belt',
|
||||
output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 12 / 60 / 512}
|
||||
},
|
||||
weight = 5
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'fast-underground-belt',
|
||||
output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 12 / 60 / 512}
|
||||
},
|
||||
weight = 5
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'solar-panel',
|
||||
output = {item = 'solar-panel', min_rate = 1 / 4 / 60, distance_factor = 1 / 12 / 60 / 512}
|
||||
},
|
||||
weight = 3
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module',
|
||||
output = {item = 'productivity-module', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.9
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module',
|
||||
output = {item = 'effectivity-module', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.9
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module',
|
||||
output = {item = 'speed-module', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module-2',
|
||||
output = {item = 'productivity-module-2', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module-2',
|
||||
output = {item = 'effectivity-module-2', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module-2',
|
||||
output = {item = 'speed-module-2', min_rate = 1 / 4 / 60, distance_factor = 1 / 20 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module-3',
|
||||
output = {item = 'productivity-module-3', min_rate = 1 / 4 / 60, distance_factor = 1 / 30 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module-3',
|
||||
output = {item = 'effectivity-module-3', min_rate = 1 / 4 / 60, distance_factor = 1 / 30 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module-3',
|
||||
output = {item = 'speed-module-3', min_rate = 1 / 4 / 60, distance_factor = 1 / 30 / 60 / 512}
|
||||
},
|
||||
weight = 0.10
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +228,7 @@ local furnace_loot = {
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'steel-plate',
|
||||
output = {item = 'steel-plate', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
output = {item = 'steel-plate', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 15 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ function Public.reset_table()
|
||||
this.placed_trains_in_zone = {
|
||||
placed = 0,
|
||||
positions = {},
|
||||
limit = 5
|
||||
limit = 5,
|
||||
randomized = false
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -114,6 +114,12 @@ local function place_wagon(data)
|
||||
|
||||
local placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||
|
||||
if not placed_trains_in_zone.randomized then
|
||||
placed_trains_in_zone.limit = math.random(1, 5)
|
||||
placed_trains_in_zone.randomized = true
|
||||
placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||
end
|
||||
|
||||
if placed_trains_in_zone.placed >= placed_trains_in_zone.limit then
|
||||
return
|
||||
end
|
||||
@ -1416,7 +1422,7 @@ local function process_level_2_position(x, y, data)
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_noise('no_rocks_2', p, seed + 75000)
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
tiles[#tiles + 1] = {name = 'dirt-' .. math.floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
tiles[#tiles + 1] = {name = 'grass-' .. math.random(1, 4), position = p}
|
||||
if math.random(1, 512) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
@ -1426,7 +1432,7 @@ local function process_level_2_position(x, y, data)
|
||||
if math.random(1, 2048) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
tiles[#tiles + 1] = {name = 'grass-' .. math.random(1, 4), position = p}
|
||||
if math.random(1, 100) > 25 then
|
||||
entities[#entities + 1] = {name = rock_raffle[math.random(1, size_of_rock_raffle)], position = p}
|
||||
end
|
||||
@ -1508,9 +1514,9 @@ local function process_level_1_position(x, y, data)
|
||||
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if math.random(1, 8) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
end
|
||||
-- if math.random(1, 8) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
-- end
|
||||
end
|
||||
|
||||
local no_rocks = get_noise('no_rocks', p, seed + 25000)
|
||||
@ -1565,7 +1571,9 @@ local function process_level_1_position(x, y, data)
|
||||
end
|
||||
|
||||
Public.levels = {
|
||||
process_level_4_position,
|
||||
process_level_1_position,
|
||||
process_level_6_position,
|
||||
process_level_2_position,
|
||||
process_level_3_position,
|
||||
process_level_4_position,
|
||||
@ -1588,11 +1596,12 @@ local function is_out_of_map(p)
|
||||
end
|
||||
|
||||
local function process_bits(x, y, data)
|
||||
local levels = Public.levels
|
||||
local left_top_y = data.area.left_top.y
|
||||
local index = math.floor((math.abs(left_top_y / Public.level_depth)) % 13) + 1
|
||||
local process_level = Public.levels[index]
|
||||
local index = math.floor((math.abs(left_top_y / Public.level_depth)) % 15) + 1
|
||||
local process_level = levels[index]
|
||||
if not process_level then
|
||||
process_level = Public.levels[#Public.levels]
|
||||
process_level = levels[#levels]
|
||||
end
|
||||
|
||||
process_level(x, y, data)
|
||||
|
@ -47,7 +47,9 @@ local rpg_extra = {
|
||||
enable_health_and_mana_bars = false,
|
||||
enable_mana = false,
|
||||
enable_wave_defense = false,
|
||||
enable_flame_boots = false
|
||||
enable_flame_boots = false,
|
||||
mana_per_tick = 0.1,
|
||||
force_mana_per_tick = false
|
||||
}
|
||||
local rpg_frame_icons = {
|
||||
'entity/small-worm-turret',
|
||||
@ -111,7 +113,7 @@ local projectile_types = {
|
||||
['petroleum-gas-barrel'] = {name = 'flamethrower-fire-stream', count = 4, max_range = 24, tick_speed = 1},
|
||||
['light-oil-barrel'] = {name = 'flamethrower-fire-stream', count = 4, max_range = 24, tick_speed = 1},
|
||||
['heavy-oil-barrel'] = {name = 'flamethrower-fire-stream', count = 4, max_range = 24, tick_speed = 1},
|
||||
['sulfuric-acid-barrel'] = {
|
||||
['acid-stream-spitter-big'] = {
|
||||
name = 'acid-stream-spitter-big',
|
||||
count = 3,
|
||||
max_range = 16,
|
||||
@ -119,7 +121,7 @@ local projectile_types = {
|
||||
force = 'enemy'
|
||||
},
|
||||
['lubricant-barrel'] = {name = 'acid-stream-spitter-big', count = 3, max_range = 16, tick_speed = 1},
|
||||
['railgun-dart'] = {name = 'railgun-beam', count = 5, max_range = 40, tick_speed = 5},
|
||||
['railgun-beam'] = {name = 'railgun-beam', count = 5, max_range = 40, tick_speed = 5},
|
||||
['shotgun-shell'] = {name = 'shotgun-pellet', count = 16, max_range = 24, tick_speed = 1},
|
||||
['piercing-shotgun-shell'] = {name = 'piercing-shotgun-pellet', count = 16, max_range = 24, tick_speed = 1},
|
||||
['firearm-magazine'] = {name = 'shotgun-pellet', count = 16, max_range = 24, tick_speed = 1},
|
||||
@ -164,55 +166,243 @@ local conjure_items = {
|
||||
[1] = {
|
||||
name = 'Stone Wall',
|
||||
obj_to_create = 'stone-wall',
|
||||
level = '10',
|
||||
level = 10,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 60,
|
||||
mana_cost = 35,
|
||||
tick = 160,
|
||||
enabled = true
|
||||
},
|
||||
[2] = {
|
||||
name = 'Steel Chest',
|
||||
obj_to_create = 'steel-chest',
|
||||
level = '10',
|
||||
name = 'Wooden Chest',
|
||||
obj_to_create = 'wooden-chest',
|
||||
level = 2,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 60,
|
||||
mana_cost = 30,
|
||||
tick = 160,
|
||||
enabled = true
|
||||
},
|
||||
[3] = {
|
||||
name = 'Transport Belt',
|
||||
obj_to_create = 'transport-belt',
|
||||
level = '10',
|
||||
name = 'Iron Chest',
|
||||
obj_to_create = 'iron-chest',
|
||||
level = 10,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 60,
|
||||
tick = 260,
|
||||
enabled = true
|
||||
},
|
||||
[4] = {
|
||||
name = 'Sandy Rock',
|
||||
obj_to_create = 'sand-rock-big',
|
||||
level = '10',
|
||||
type = 'entity',
|
||||
mana_cost = 40,
|
||||
tick = 120,
|
||||
name = 'Steel Chest',
|
||||
obj_to_create = 'steel-chest',
|
||||
level = 15,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 360,
|
||||
enabled = true
|
||||
},
|
||||
[5] = {
|
||||
name = 'Smol Biter',
|
||||
obj_to_create = 'small-biter',
|
||||
level = '10',
|
||||
type = 'entity',
|
||||
name = 'Transport Belt',
|
||||
obj_to_create = 'transport-belt',
|
||||
level = 3,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 120,
|
||||
tick = 160,
|
||||
enabled = true
|
||||
},
|
||||
[6] = {
|
||||
name = 'Aoe Grenade',
|
||||
obj_to_create = 'grenade',
|
||||
level = '10',
|
||||
type = 'entity',
|
||||
name = 'Fast Transport Belt',
|
||||
obj_to_create = 'fast-transport-belt',
|
||||
level = 20,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 260,
|
||||
enabled = true
|
||||
},
|
||||
[7] = {
|
||||
name = 'Express Transport Belt',
|
||||
obj_to_create = 'express-transport-belt',
|
||||
level = 60,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 60,
|
||||
tick = 360,
|
||||
enabled = true
|
||||
},
|
||||
[8] = {
|
||||
name = 'Underground Belt',
|
||||
obj_to_create = 'underground-belt',
|
||||
level = 3,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 120,
|
||||
tick = 160,
|
||||
enabled = true
|
||||
},
|
||||
[9] = {
|
||||
name = 'Fast Underground Belt',
|
||||
obj_to_create = 'fast-underground-belt',
|
||||
level = 20,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 260,
|
||||
enabled = true
|
||||
},
|
||||
[10] = {
|
||||
name = 'Express Underground Belt',
|
||||
obj_to_create = 'express-underground-belt',
|
||||
level = 60,
|
||||
target = true,
|
||||
type = 'item',
|
||||
mana_cost = 60,
|
||||
tick = 360,
|
||||
enabled = true
|
||||
},
|
||||
[11] = {
|
||||
name = 'Sandy Rock',
|
||||
obj_to_create = 'sand-rock-big',
|
||||
level = 80,
|
||||
target = true,
|
||||
type = 'entity',
|
||||
mana_cost = 80,
|
||||
tick = 420,
|
||||
enabled = true
|
||||
},
|
||||
[12] = {
|
||||
name = 'Smol Biter',
|
||||
obj_to_create = 'small-biter',
|
||||
level = 50,
|
||||
target = true,
|
||||
biter = true,
|
||||
type = 'entity',
|
||||
mana_cost = 55,
|
||||
tick = 220,
|
||||
enabled = true
|
||||
},
|
||||
[13] = {
|
||||
name = 'Smol Spitter',
|
||||
obj_to_create = 'small-spitter',
|
||||
level = 50,
|
||||
target = true,
|
||||
biter = true,
|
||||
type = 'entity',
|
||||
mana_cost = 55,
|
||||
tick = 220,
|
||||
enabled = true
|
||||
},
|
||||
[14] = {
|
||||
name = 'Medium Biter',
|
||||
obj_to_create = 'medium-biter',
|
||||
level = 70,
|
||||
target = true,
|
||||
biter = true,
|
||||
type = 'entity',
|
||||
mana_cost = 77,
|
||||
tick = 420,
|
||||
enabled = true
|
||||
},
|
||||
[15] = {
|
||||
name = 'Medium Spitter',
|
||||
obj_to_create = 'medium-spitter',
|
||||
level = 70,
|
||||
target = true,
|
||||
type = 'entity',
|
||||
mana_cost = 77,
|
||||
tick = 420,
|
||||
enabled = true
|
||||
},
|
||||
[16] = {
|
||||
name = 'Bitter Spawner',
|
||||
obj_to_create = 'biter-spawner',
|
||||
level = 100,
|
||||
target = true,
|
||||
biter = true,
|
||||
type = 'entity',
|
||||
mana_cost = 300,
|
||||
tick = 1420,
|
||||
enabled = true
|
||||
},
|
||||
[17] = {
|
||||
name = 'Spitter Spawner',
|
||||
obj_to_create = 'spitter-spawner',
|
||||
level = 100,
|
||||
target = true,
|
||||
biter = true,
|
||||
type = 'entity',
|
||||
mana_cost = 300,
|
||||
tick = 1420,
|
||||
enabled = true
|
||||
},
|
||||
[18] = {
|
||||
name = 'AOE Grenade',
|
||||
obj_to_create = 'grenade',
|
||||
target = true,
|
||||
amount = 1,
|
||||
damage = true,
|
||||
force = 'player',
|
||||
level = 30,
|
||||
type = 'special',
|
||||
mana_cost = 60,
|
||||
tick = 420,
|
||||
enabled = true
|
||||
},
|
||||
[19] = {
|
||||
name = 'Big AOE Grenade',
|
||||
obj_to_create = 'cluster-grenade',
|
||||
target = true,
|
||||
amount = 2,
|
||||
damage = true,
|
||||
force = 'player',
|
||||
level = 50,
|
||||
type = 'special',
|
||||
mana_cost = 80,
|
||||
tick = 620,
|
||||
enabled = true
|
||||
},
|
||||
[20] = {
|
||||
name = 'Pointy Rocket',
|
||||
obj_to_create = 'rocket',
|
||||
range = 240,
|
||||
target = true,
|
||||
amount = 4,
|
||||
damage = true,
|
||||
force = 'enemy',
|
||||
level = 40,
|
||||
type = 'special',
|
||||
mana_cost = 60,
|
||||
tick = 420,
|
||||
enabled = true
|
||||
},
|
||||
[21] = {
|
||||
name = 'Bitter Spew',
|
||||
obj_to_create = 'acid-stream-spitter-big',
|
||||
target = true,
|
||||
amount = 1,
|
||||
range = 0,
|
||||
force = 'player',
|
||||
level = 70,
|
||||
type = 'special',
|
||||
mana_cost = 90,
|
||||
tick = 520,
|
||||
enabled = true
|
||||
},
|
||||
[22] = {
|
||||
name = 'Fire my lazors!!',
|
||||
obj_to_create = 'railgun-beam',
|
||||
target = false,
|
||||
amount = 3,
|
||||
damage = true,
|
||||
range = 240,
|
||||
force = 'player',
|
||||
level = 50,
|
||||
type = 'special',
|
||||
mana_cost = 66,
|
||||
tick = 320,
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
@ -356,7 +546,13 @@ local function get_heal_modifier(player)
|
||||
end
|
||||
|
||||
local function get_mana_modifier(player)
|
||||
return (rpg_t[player.index].magicka - 10) * 0.00505
|
||||
if rpg_t[player.index].level <= 40 then
|
||||
return (rpg_t[player.index].magicka - 10) * 0.02000
|
||||
elseif rpg_t[player.index].level <= 80 then
|
||||
return (rpg_t[player.index].magicka - 10) * 0.01800
|
||||
else
|
||||
return (rpg_t[player.index].magicka - 10) * 0.01400
|
||||
end
|
||||
end
|
||||
|
||||
local function get_life_on_hit(player)
|
||||
@ -413,7 +609,7 @@ local function update_player_stats(player)
|
||||
player_modifiers[player.index].character_loot_pickup_distance_bonus['rpg'] = math.round(v * 0.22, 3)
|
||||
player_modifiers[player.index].character_item_pickup_distance_bonus['rpg'] = math.round(v * 0.25, 3)
|
||||
player_modifiers[player.index].character_resource_reach_distance_bonus['rpg'] = math.round(v * 0.15, 3)
|
||||
rpg_t[player.index].mana_max = math.round(rpg_t[player.index].mana_max + math.round(v * 1, 3))
|
||||
rpg_t[player.index].mana_max = math.round(rpg_t[player.index].mana_max + math.round(v * 0.9, 3))
|
||||
|
||||
local dexterity = rpg_t[player.index].dexterity - 10
|
||||
player_modifiers[player.index].character_running_speed_modifier['rpg'] = math.round(dexterity * 0.0015, 3)
|
||||
@ -554,7 +750,7 @@ local function extra_settings(player)
|
||||
|
||||
local setting_grid = scroll_pane.add({type = 'table', column_count = 2})
|
||||
|
||||
local health_bar_gui_input = nil
|
||||
local health_bar_gui_input
|
||||
if rpg_extra.enable_health_and_mana_bars then
|
||||
local health_bar_label =
|
||||
setting_grid.add(
|
||||
@ -575,13 +771,16 @@ local function extra_settings(player)
|
||||
input_style.vertical_align = 'center'
|
||||
health_bar_gui_input = create_input_element(health_bar_input, 'boolean', rpg_t[player.index].show_bars)
|
||||
health_bar_gui_input.tooltip = 'Checked = true\nUnchecked = false'
|
||||
if not rpg_extra.enable_mana then
|
||||
health_bar_label.caption = 'Show health bar?'
|
||||
end
|
||||
end
|
||||
|
||||
local reset_label =
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Reset your skillpoints.',
|
||||
caption = 'Reset your skillpoints?',
|
||||
tooltip = ''
|
||||
}
|
||||
)
|
||||
@ -615,7 +814,7 @@ local function extra_settings(player)
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Enable item reach distance bonus.',
|
||||
caption = 'Enable item reach distance bonus?',
|
||||
tooltip = 'Don´t feeling like picking up others people loot?\nYou can toggle it here.'
|
||||
}
|
||||
)
|
||||
@ -645,7 +844,7 @@ local function extra_settings(player)
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Enable movement speed bonus.',
|
||||
caption = 'Enable movement speed bonus?',
|
||||
tooltip = 'Don´t feeling like running like the flash?\nYou can toggle it here.'
|
||||
}
|
||||
)
|
||||
@ -671,16 +870,16 @@ local function extra_settings(player)
|
||||
local movement_speed_gui_input = create_input_element(movement_speed_input, 'boolean', speed_mod)
|
||||
movement_speed_gui_input.tooltip = 'Checked = true\nUnchecked = false'
|
||||
|
||||
local enable_entity_gui_input = nil
|
||||
local conjure_gui_input = nil
|
||||
local flame_boots_gui_input = nil
|
||||
local enable_entity_gui_input
|
||||
local conjure_gui_input
|
||||
local flame_boots_gui_input
|
||||
|
||||
if rpg_extra.enable_flame_boots then
|
||||
local flame_boots_label =
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Enable flame boots.',
|
||||
caption = 'Enable flame boots?',
|
||||
tooltip = 'When the bullets simply don´t bite.'
|
||||
}
|
||||
)
|
||||
@ -716,8 +915,8 @@ local function extra_settings(player)
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Enable spawning entities with raw-fish.',
|
||||
tooltip = 'When simply constructing items is not enough.'
|
||||
caption = 'Enable spawning with raw-fish?',
|
||||
tooltip = 'When simply constructing items is not enough.\nNOTE! Use Raw-fish to cast spells.'
|
||||
}
|
||||
)
|
||||
|
||||
@ -769,11 +968,19 @@ local function extra_settings(player)
|
||||
if entity.type == 'item' then
|
||||
conjure_label.tooltip =
|
||||
conjure_label.tooltip ..
|
||||
'[item=' .. entity.obj_to_create .. '] requires ' .. entity.mana_cost .. ' mana to cast.\n'
|
||||
'[item=' ..
|
||||
entity.obj_to_create ..
|
||||
'] requires ' .. entity.mana_cost .. ' mana to cast. Level: ' .. entity.level .. '\n'
|
||||
elseif entity.type == 'entity' then
|
||||
conjure_label.tooltip =
|
||||
conjure_label.tooltip ..
|
||||
'[entity=' .. entity.obj_to_create .. '] requires ' .. entity.mana_cost .. ' mana to cast.\n'
|
||||
'[entity=' ..
|
||||
entity.obj_to_create ..
|
||||
'] requires ' .. entity.mana_cost .. ' mana to cast. Level: ' .. entity.level .. '\n'
|
||||
elseif entity.type == 'special' then
|
||||
conjure_label.tooltip =
|
||||
conjure_label.tooltip ..
|
||||
entity.name .. ' requires ' .. entity.mana_cost .. ' mana to cast. Level: ' .. entity.level .. '\n'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -784,7 +991,7 @@ local function extra_settings(player)
|
||||
movement_speed_gui_input = movement_speed_gui_input
|
||||
}
|
||||
|
||||
if rpg_extra.health_bar_gui_input then
|
||||
if rpg_extra.enable_health_and_mana_bars then
|
||||
data.health_bar_gui_input = health_bar_gui_input
|
||||
end
|
||||
|
||||
@ -1057,7 +1264,7 @@ local function draw_gui(player, forced)
|
||||
add_gui_description(tt, 'MANA\nBONUS', w1)
|
||||
local magic = rpg_t[player.index].magicka - 10
|
||||
local v = magic * 0.22
|
||||
value = '+ ' .. math.round(math.round(v * 1, 3))
|
||||
value = '+ ' .. (math.floor(get_mana_modifier(player) * 10) / 10)
|
||||
e = add_gui_stat(tt, value, w2)
|
||||
e.tooltip = 'Mana regen bonus: ' .. (math.floor(get_mana_modifier(player) * 10) / 10)
|
||||
end
|
||||
@ -1370,10 +1577,10 @@ local function on_entity_died(event)
|
||||
local amount = rpg_xp_yield[event.entity.name]
|
||||
amount = amount / 5
|
||||
if global.biter_health_boost then
|
||||
local health_pool = global.biter_health_boost_units[event.entity.unit_number]
|
||||
if health_pool then
|
||||
amount = amount * (1 / health_pool[2])
|
||||
end
|
||||
local health_pool = global.biter_health_boost_units[event.entity.unit_number]
|
||||
if health_pool then
|
||||
amount = amount * (1 / health_pool[2])
|
||||
end
|
||||
end
|
||||
|
||||
if rpg_extra.turret_kills_to_global_pool then
|
||||
@ -1457,7 +1664,7 @@ local function regen_health_player(players)
|
||||
end
|
||||
end
|
||||
if player.gui.left[main_frame_name] then
|
||||
draw_gui(player, true)
|
||||
draw_gui(player)
|
||||
end
|
||||
|
||||
::continue::
|
||||
@ -1471,7 +1678,9 @@ local function regen_health_player(players)
|
||||
player.character.prototype.max_health + player.character_health_bonus +
|
||||
player.force.character_health_bonus
|
||||
)
|
||||
if not rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
if not rpg_t[player.index].health_bar then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
end
|
||||
set_bar(player.character.health, max_life, rpg_t[player.index].health_bar)
|
||||
@ -1486,33 +1695,42 @@ local function regen_mana_player(players)
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
local mana_per_tick = get_mana_modifier(player)
|
||||
if mana_per_tick <= 0 then
|
||||
mana_per_tick = (math.floor(0.5 * 10) / 10)
|
||||
if mana_per_tick <= 0.1 then
|
||||
mana_per_tick = rpg_extra.mana_per_tick
|
||||
end
|
||||
mana_per_tick = (math.floor(mana_per_tick * 10) / 10)
|
||||
|
||||
if rpg_extra.force_mana_per_tick then
|
||||
mana_per_tick = 1
|
||||
end
|
||||
|
||||
if player and player.valid then
|
||||
if player.character and player.character.valid then
|
||||
if rpg_t[player.index].mana >= rpg_t[player.index].mana_max then
|
||||
return
|
||||
goto continue
|
||||
end
|
||||
rpg_t[player.index].mana = rpg_t[player.index].mana + mana_per_tick
|
||||
rpg_t[player.index].mana = (math.floor(rpg_t[player.index].mana * 10) / 10)
|
||||
|
||||
if rpg_t[player.index].mana >= rpg_t[player.index].mana_max then
|
||||
rpg_t[player.index].mana = rpg_t[player.index].mana_max
|
||||
end
|
||||
rpg_t[player.index].mana = (math.round(rpg_t[player.index].mana * 10) / 10)
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
||||
if rpg_extra.enable_health_and_mana_bars then
|
||||
if rpg_t[player.index].show_bars then
|
||||
if not rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
if not rpg_t[player.index].mana_bar then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
end
|
||||
set_bar(rpg_t[player.index].mana, rpg_t[player.index].mana_max, rpg_t[player.index].mana_bar, true)
|
||||
end
|
||||
end
|
||||
if player.gui.left[main_frame_name] then
|
||||
draw_gui(player, true)
|
||||
draw_gui(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1553,7 +1771,7 @@ local function give_player_flameboots(event)
|
||||
rpg_t[player.index].mana = 0
|
||||
end
|
||||
if player.gui.left[main_frame_name] then
|
||||
draw_gui(player, true)
|
||||
draw_gui(player)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1883,12 +2101,6 @@ local function on_player_joined_game(event)
|
||||
Public.gain_xp(player, rpg_extra.reward_new_players)
|
||||
end
|
||||
end
|
||||
if rpg_extra.enable_health_and_mana_bars then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
if rpg_extra.enable_mana then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
end
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
draw_level_text(p)
|
||||
end
|
||||
@ -1923,17 +2135,30 @@ local function splash_damage(surface, position, final_damage_amount)
|
||||
end
|
||||
|
||||
local function create_projectile(surface, name, position, force, target, max_range)
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = max_range,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
if max_range then
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = max_range,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
else
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
speed = 0.4
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_near_coord_modifier(range)
|
||||
@ -1947,31 +2172,61 @@ local function get_near_coord_modifier(range)
|
||||
return coord
|
||||
end
|
||||
|
||||
local function get_near_range(range)
|
||||
local r = math.random(1, math.floor(range * 2))
|
||||
for i = 1, 2, 1 do
|
||||
local r2 = math.random(1, math.floor(range * 2))
|
||||
if r2 < r then
|
||||
r = r2
|
||||
end
|
||||
local function damage_entity(e)
|
||||
if not e.health then
|
||||
return
|
||||
end
|
||||
|
||||
if e.force.name == 'player' then
|
||||
return
|
||||
end
|
||||
|
||||
e.surface.create_entity({name = 'water-splash', position = e.position})
|
||||
|
||||
if e.type == 'entity-ghost' then
|
||||
e.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
e.health = e.health - math.random(30, 90)
|
||||
if e.health <= 0 then
|
||||
e.die('enemy')
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
local function is_position_near(area, p)
|
||||
local status = false
|
||||
local function inside(pos)
|
||||
local lt = area.left_top
|
||||
local rb = area.right_bottom
|
||||
|
||||
return pos.x >= lt.x and pos.y >= lt.y and pos.x <= rb.x and pos.y <= rb.y
|
||||
local function floaty_hearts(entity, c)
|
||||
local position = {x = entity.position.x - 0.75, y = entity.position.y - 1}
|
||||
local b = 1.35
|
||||
for a = 1, c, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
entity.surface.create_entity(
|
||||
{name = 'flying-text', position = p, text = '♥', color = {math.random(150, 255), 0, 255}}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if inside(p, area) then
|
||||
status = true
|
||||
end
|
||||
local function tame_unit_effects(player, entity)
|
||||
floaty_hearts(entity, 7)
|
||||
|
||||
return status
|
||||
rendering.draw_text {
|
||||
text = '~' .. player.name .. "'s pet~",
|
||||
surface = player.surface,
|
||||
target = entity,
|
||||
target_offset = {0, -2.6},
|
||||
color = {
|
||||
r = player.color.r * 0.6 + 0.25,
|
||||
g = player.color.g * 0.6 + 0.25,
|
||||
b = player.color.b * 0.6 + 0.25,
|
||||
a = 1
|
||||
},
|
||||
scale = 1.05,
|
||||
font = 'default-large-semibold',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
@ -2022,6 +2277,10 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
if rpg_t[player.index].level <= object.level then
|
||||
return p('You lack the level to cast this spell.', Color.fail)
|
||||
end
|
||||
|
||||
local object_name = object.name
|
||||
local obj_name = object.obj_to_create
|
||||
|
||||
@ -2030,7 +2289,7 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
local radius = 10
|
||||
local radius = 15
|
||||
local area = {
|
||||
left_top = {x = position.x - radius, y = position.y - radius},
|
||||
right_bottom = {x = position.x + radius, y = position.y + radius}
|
||||
@ -2047,17 +2306,54 @@ local function on_player_used_capsule(event)
|
||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
||||
end
|
||||
|
||||
if projectile_types[obj_name] then
|
||||
local target_pos
|
||||
if object.target then
|
||||
target_pos = {position.x, position.y}
|
||||
elseif projectile_types[obj_name] then
|
||||
local coord_modifier = get_near_coord_modifier(projectile_types[obj_name].max_range)
|
||||
local proj_pos = {position.x + coord_modifier.x, position.y + coord_modifier.y}
|
||||
create_projectile(surface, obj_name, position, 'player', proj_pos, 0)
|
||||
target_pos = proj_pos
|
||||
end
|
||||
|
||||
local range
|
||||
if object.range then
|
||||
range = object.range
|
||||
else
|
||||
surface.create_entity({name = obj_name, position = position, force = 'player'})
|
||||
range = 0
|
||||
end
|
||||
|
||||
local force
|
||||
if object.force then
|
||||
force = object.force
|
||||
else
|
||||
force = 'player'
|
||||
end
|
||||
|
||||
if projectile_types[obj_name] then
|
||||
for i = 1, object.amount do
|
||||
local damage_area = {
|
||||
left_top = {x = position.x - 2, y = position.y - 2},
|
||||
right_bottom = {x = position.x + 2, y = position.y + 2}
|
||||
}
|
||||
create_projectile(surface, obj_name, position, force, target_pos, range)
|
||||
if object.damage then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = damage_area})) do
|
||||
damage_entity(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if object.biter then
|
||||
local e = surface.create_entity({name = obj_name, position = position, force = force})
|
||||
tame_unit_effects(player, e)
|
||||
else
|
||||
surface.create_entity({name = obj_name, position = position, force = force})
|
||||
end
|
||||
end
|
||||
|
||||
rpg_t[player.index].last_spawned = game.tick + object.tick
|
||||
if player.gui.left[main_frame_name] then
|
||||
draw_gui(player, true)
|
||||
draw_gui(player)
|
||||
end
|
||||
if rpg_extra.enable_health_and_mana_bars then
|
||||
if rpg_t[player.index].show_bars then
|
||||
@ -2140,7 +2436,7 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
rotated_entity_delay = 0,
|
||||
gui_refresh_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = true
|
||||
show_bars = false
|
||||
}
|
||||
rpg_t[player.index].points_to_distribute = old_points_to_distribute + total
|
||||
rpg_t[player.index].xp = old_xp
|
||||
@ -2169,7 +2465,7 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
rotated_entity_delay = 0,
|
||||
gui_refresh_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = true
|
||||
show_bars = false
|
||||
}
|
||||
end
|
||||
draw_gui_char_button(player)
|
||||
@ -2326,7 +2622,7 @@ function Public.enable_health_and_mana_bars(value)
|
||||
if value then
|
||||
rpg_extra.enable_health_and_mana_bars = value
|
||||
else
|
||||
return error('No value given.', 2)
|
||||
rpg_extra.enable_health_and_mana_bars = false
|
||||
end
|
||||
end
|
||||
|
||||
@ -2336,7 +2632,7 @@ function Public.enable_mana(value)
|
||||
if value then
|
||||
rpg_extra.enable_mana = value
|
||||
else
|
||||
return error('No value given.', 2)
|
||||
rpg_extra.enable_mana = false
|
||||
end
|
||||
end
|
||||
|
||||
@ -2347,7 +2643,7 @@ function Public.enable_wave_defense(value)
|
||||
if value then
|
||||
rpg_extra.enable_wave_defense = value
|
||||
else
|
||||
return error('No value given.', 2)
|
||||
rpg_extra.enable_wave_defense = false
|
||||
end
|
||||
end
|
||||
|
||||
@ -2357,7 +2653,17 @@ function Public.enable_flame_boots(value)
|
||||
if value then
|
||||
rpg_extra.enable_flame_boots = value
|
||||
else
|
||||
return error('No value given.', 2)
|
||||
rpg_extra.enable_flame_boots = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Enables/disabled personal tax.
|
||||
---@param value <boolean>
|
||||
function Public.personal_tax_rate(value)
|
||||
if value then
|
||||
rpg_extra.personal_tax_rate = value
|
||||
else
|
||||
rpg_extra.personal_tax_rate = nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -2454,15 +2760,23 @@ Gui.on_click(
|
||||
if health_bar_gui_input and health_bar_gui_input.valid then
|
||||
if not health_bar_gui_input.state then
|
||||
rpg_t[player.index].show_bars = false
|
||||
if rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
rendering.destroy(rpg_t[player.index].health_bar)
|
||||
if rpg_t[player.index].health_bar then
|
||||
if rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
rendering.destroy(rpg_t[player.index].health_bar)
|
||||
end
|
||||
end
|
||||
if rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rendering.destroy(rpg_t[player.index].mana_bar)
|
||||
if rpg_extra.enable_mana then
|
||||
if rpg_t[player.index].mana_bar then
|
||||
if rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rendering.destroy(rpg_t[player.index].mana_bar)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif health_bar_gui_input.state then
|
||||
rpg_t[player.index].show_bars = true
|
||||
if not rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
if not rpg_t[player.index].health_bar then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
end
|
||||
local max_life =
|
||||
@ -2471,14 +2785,25 @@ Gui.on_click(
|
||||
player.force.character_health_bonus
|
||||
)
|
||||
set_bar(player.character.health, max_life, rpg_t[player.index].health_bar)
|
||||
if not rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
if rpg_extra.enable_mana then
|
||||
if not rpg_t[player.index].mana_bar then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
end
|
||||
set_bar(
|
||||
rpg_t[player.index].mana,
|
||||
rpg_t[player.index].mana_max,
|
||||
rpg_t[player.index].mana_bar,
|
||||
true
|
||||
)
|
||||
end
|
||||
set_bar(rpg_t[player.index].mana, rpg_t[player.index].mana_max, rpg_t[player.index].mana_bar, true)
|
||||
end
|
||||
end
|
||||
|
||||
draw_gui(player, true)
|
||||
if player.gui.left[main_frame_name] then
|
||||
draw_gui(player, false)
|
||||
end
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ end
|
||||
|
||||
local function get_random_close_spawner(surface)
|
||||
local wave_defense_table = WD.get_table()
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner", force = 'enemy'})
|
||||
if not spawners[1] then return false end
|
||||
local center = wave_defense_table.target.position
|
||||
local spawner = spawners[math_random(1,#spawners)]
|
||||
|
Loading…
Reference in New Issue
Block a user