mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-28 03:57:22 +02:00
Remove unused maps
This commit is contained in:
parent
8ba95142fa
commit
69a6165447
@ -1,313 +0,0 @@
|
||||
local Public = {}
|
||||
|
||||
local market = {}
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
|
||||
local blacklist = {
|
||||
-- ['cargo-wagon'] = true,
|
||||
-- ['locomotive'] = true,
|
||||
-- ['artillery-wagon'] = true,
|
||||
-- ['artillery-turret'] = true,
|
||||
-- ['fluid-wagon'] = true,
|
||||
-- ['land-mine'] = true,
|
||||
['car'] = true,
|
||||
['tank'] = true,
|
||||
['spidertron'] = true
|
||||
}
|
||||
|
||||
market.weapons = {
|
||||
['pistol'] = {value = 10, rarity = 1},
|
||||
['submachine-gun'] = {value = 50, rarity = 2},
|
||||
['shotgun'] = {value = 40, rarity = 2},
|
||||
['combat-shotgun'] = {value = 400, rarity = 5},
|
||||
['rocket-launcher'] = {value = 500, rarity = 6},
|
||||
['flamethrower-turret'] = {value = 2000, rarity = 5},
|
||||
['land-mine'] = {value = 16, rarity = 4}
|
||||
}
|
||||
|
||||
market.ammo = {
|
||||
['firearm-magazine'] = {value = 3, rarity = 1},
|
||||
['piercing-rounds-magazine'] = {value = 6, rarity = 4},
|
||||
['uranium-rounds-magazine'] = {value = 20, rarity = 8},
|
||||
['shotgun-shell'] = {value = 3, rarity = 1},
|
||||
['piercing-shotgun-shell'] = {value = 8, rarity = 5},
|
||||
['cannon-shell'] = {value = 8, rarity = 4},
|
||||
['explosive-cannon-shell'] = {value = 12, rarity = 5},
|
||||
['uranium-cannon-shell'] = {value = 16, rarity = 7},
|
||||
['explosive-uranium-cannon-shell'] = {value = 20, rarity = 8},
|
||||
['artillery-shell'] = {value = 64, rarity = 7},
|
||||
['rocket'] = {value = 45, rarity = 7},
|
||||
['explosive-rocket'] = {value = 50, rarity = 7},
|
||||
['atomic-bomb'] = {value = 11000, rarity = 10},
|
||||
['flamethrower-ammo'] = {value = 20, rarity = 6},
|
||||
['explosives'] = {value = 3, rarity = 1}
|
||||
}
|
||||
|
||||
market.caspules = {
|
||||
['grenade'] = {value = 16, rarity = 2},
|
||||
['cluster-grenade'] = {value = 64, rarity = 5},
|
||||
['poison-capsule'] = {value = 32, rarity = 6},
|
||||
['slowdown-capsule'] = {value = 8, rarity = 1},
|
||||
['defender-capsule'] = {value = 8, rarity = 1},
|
||||
['distractor-capsule'] = {value = 40, rarity = 3},
|
||||
['destroyer-capsule'] = {value = 80, rarity = 5},
|
||||
['discharge-defense-remote'] = {value = 300, rarity = 8},
|
||||
['artillery-targeting-remote'] = {value = 32, rarity = 7},
|
||||
['raw-fish'] = {value = 10, rarity = 1}
|
||||
}
|
||||
|
||||
market.armor = {
|
||||
['light-armor'] = {value = 25, rarity = 1},
|
||||
['heavy-armor'] = {value = 250, rarity = 4},
|
||||
['modular-armor'] = {value = 750, rarity = 5},
|
||||
['power-armor'] = {value = 2500, rarity = 6},
|
||||
['power-armor-mk2'] = {value = 20000, rarity = 10}
|
||||
}
|
||||
|
||||
market.equipment = {
|
||||
['solar-panel-equipment'] = {value = 240, rarity = 3},
|
||||
['fusion-reactor-equipment'] = {value = 9000, rarity = 7},
|
||||
['energy-shield-equipment'] = {value = 400, rarity = 6},
|
||||
['energy-shield-mk2-equipment'] = {value = 4000, rarity = 8},
|
||||
['battery-equipment'] = {value = 160, rarity = 2},
|
||||
['battery-mk2-equipment'] = {value = 2000, rarity = 8},
|
||||
['personal-laser-defense-equipment'] = {value = 2500, rarity = 7},
|
||||
['discharge-defense-equipment'] = {value = 5000, rarity = 7},
|
||||
['belt-immunity-equipment'] = {value = 200, rarity = 1},
|
||||
['exoskeleton-equipment'] = {value = 800, rarity = 3},
|
||||
['personal-roboport-equipment'] = {value = 500, rarity = 3},
|
||||
['personal-roboport-mk2-equipment'] = {value = 5000, rarity = 8},
|
||||
['night-vision-equipment'] = {value = 250, rarity = 1}
|
||||
}
|
||||
|
||||
market.defense = {
|
||||
['stone-wall'] = {value = 4, rarity = 1},
|
||||
['gate'] = {value = 8, rarity = 1},
|
||||
['repair-pack'] = {value = 8, rarity = 1},
|
||||
['gun-turret'] = {value = 64, rarity = 1},
|
||||
['laser-turret'] = {value = 1024, rarity = 6},
|
||||
['flamethrower-turret'] = {value = 2048, rarity = 6},
|
||||
['artillery-turret'] = {value = 8192, rarity = 8},
|
||||
['rocket-silo'] = {value = 64000, rarity = 10}
|
||||
}
|
||||
|
||||
market.logistic = {
|
||||
['wooden-chest'] = {value = 3, rarity = 1},
|
||||
['iron-chest'] = {value = 10, rarity = 2},
|
||||
['steel-chest'] = {value = 24, rarity = 3},
|
||||
['storage-tank'] = {value = 32, rarity = 4},
|
||||
['transport-belt'] = {value = 4, rarity = 1},
|
||||
['fast-transport-belt'] = {value = 8, rarity = 4},
|
||||
['express-transport-belt'] = {value = 24, rarity = 7},
|
||||
['underground-belt'] = {value = 8, rarity = 1},
|
||||
['fast-underground-belt'] = {value = 32, rarity = 4},
|
||||
['express-underground-belt'] = {value = 64, rarity = 7},
|
||||
['splitter'] = {value = 16, rarity = 1},
|
||||
['fast-splitter'] = {value = 48, rarity = 4},
|
||||
['express-splitter'] = {value = 128, rarity = 7},
|
||||
['loader'] = {value = 256, rarity = 2},
|
||||
['fast-loader'] = {value = 512, rarity = 5},
|
||||
['express-loader'] = {value = 768, rarity = 8},
|
||||
['burner-inserter'] = {value = 4, rarity = 1},
|
||||
['inserter'] = {value = 8, rarity = 1},
|
||||
['long-handed-inserter'] = {value = 12, rarity = 2},
|
||||
['fast-inserter'] = {value = 16, rarity = 4},
|
||||
['filter-inserter'] = {value = 24, rarity = 5},
|
||||
['stack-inserter'] = {value = 96, rarity = 6},
|
||||
['stack-filter-inserter'] = {value = 128, rarity = 7},
|
||||
['small-electric-pole'] = {value = 2, rarity = 1},
|
||||
['medium-electric-pole'] = {value = 12, rarity = 4},
|
||||
['big-electric-pole'] = {value = 24, rarity = 5},
|
||||
['substation'] = {value = 96, rarity = 8},
|
||||
['pipe'] = {value = 2, rarity = 1},
|
||||
['pipe-to-ground'] = {value = 8, rarity = 1},
|
||||
['pump'] = {value = 16, rarity = 4},
|
||||
['logistic-robot'] = {value = 28, rarity = 5},
|
||||
['construction-robot'] = {value = 28, rarity = 3},
|
||||
['logistic-chest-active-provider'] = {value = 128, rarity = 7},
|
||||
['logistic-chest-passive-provider'] = {value = 128, rarity = 6},
|
||||
['logistic-chest-storage'] = {value = 128, rarity = 6},
|
||||
['logistic-chest-buffer'] = {value = 128, rarity = 7},
|
||||
['logistic-chest-requester'] = {value = 128, rarity = 7},
|
||||
['roboport'] = {value = 4096, rarity = 8}
|
||||
}
|
||||
|
||||
market.vehicles = {
|
||||
['rail'] = {value = 4, rarity = 1},
|
||||
['train-stop'] = {value = 32, rarity = 3},
|
||||
['rail-signal'] = {value = 8, rarity = 5},
|
||||
['rail-chain-signal'] = {value = 8, rarity = 5},
|
||||
['locomotive'] = {value = 400, rarity = 4},
|
||||
['cargo-wagon'] = {value = 200, rarity = 4},
|
||||
['fluid-wagon'] = {value = 300, rarity = 5},
|
||||
['artillery-wagon'] = {value = 8192, rarity = 8},
|
||||
['car'] = {value = 80, rarity = 1},
|
||||
['tank'] = {value = 1800, rarity = 5}
|
||||
}
|
||||
|
||||
market.wire = {
|
||||
['small-lamp'] = {value = 4, rarity = 1},
|
||||
['red-wire'] = {value = 4, rarity = 1},
|
||||
['green-wire'] = {value = 4, rarity = 1},
|
||||
['arithmetic-combinator'] = {value = 16, rarity = 1},
|
||||
['decider-combinator'] = {value = 16, rarity = 1},
|
||||
['constant-combinator'] = {value = 16, rarity = 1},
|
||||
['power-switch'] = {value = 16, rarity = 1},
|
||||
['programmable-speaker'] = {value = 24, rarity = 1},
|
||||
['landfill'] = {value = 5, rarity = 3}
|
||||
}
|
||||
|
||||
local function get_types()
|
||||
local types = {}
|
||||
for k, _ in pairs(market) do
|
||||
types[#types + 1] = k
|
||||
end
|
||||
return types
|
||||
end
|
||||
|
||||
local function get_resource_market_sells()
|
||||
local sells = {
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'coal', count = 50}},
|
||||
{price = {{'coin', random(8, 16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
|
||||
{price = {{'coin', random(2, 4)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}
|
||||
}
|
||||
table.shuffle_table(sells)
|
||||
return sells
|
||||
end
|
||||
|
||||
local function get_resource_market_buys()
|
||||
local buys = {
|
||||
{price = {{'wood', random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'iron-ore', random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'copper-ore', random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'stone', random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'coal', random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'uranium-ore', random(8, 10)}}, offer = {type = 'give-item', item = 'coin'}},
|
||||
{price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(1, 2)}},
|
||||
{price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(3, 6)}},
|
||||
{price = {{'sulfuric-acid-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(4, 8)}},
|
||||
{price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(2, 4)}},
|
||||
{price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(2, 4)}},
|
||||
{price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = 'coin', count = random(3, 5)}}
|
||||
}
|
||||
table.shuffle_table(buys)
|
||||
return buys
|
||||
end
|
||||
|
||||
local function get_market_item_list(rarity)
|
||||
if rarity < 1 then
|
||||
rarity = 1
|
||||
end
|
||||
if rarity > 10 then
|
||||
rarity = 10
|
||||
end
|
||||
local types = get_types()
|
||||
local list = {}
|
||||
for i = 1, 9 do
|
||||
local branch = market[types[i]]
|
||||
for k, item in pairs(branch) do
|
||||
--if item.rarity <= rarity and item.rarity + 7 >= rarity then
|
||||
if item.rarity <= rarity then
|
||||
local price = random(floor(item.value * 0.75), floor(item.value * 1.25))
|
||||
if price < 1 then
|
||||
price = 1
|
||||
end
|
||||
if price > 64000 then
|
||||
price = 64000
|
||||
end
|
||||
list[#list + 1] = {price = {{'coin', price}}, offer = {type = 'give-item', item = k}}
|
||||
end
|
||||
end
|
||||
end
|
||||
if #list == 0 then
|
||||
return false
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
function Public.get_random_item(rarity, sell, buy)
|
||||
rarity = rarity or 0
|
||||
local items = get_market_item_list(rarity)
|
||||
if not items then
|
||||
return
|
||||
end
|
||||
if #items > 0 then
|
||||
table.shuffle_table(items)
|
||||
end
|
||||
|
||||
local items_return = {}
|
||||
|
||||
for i = 1, 25, 1 do
|
||||
local item = items[i]
|
||||
if not item then
|
||||
break
|
||||
end
|
||||
if not blacklist[item.offer.item] then
|
||||
items_return[#items_return + 1] = items[i]
|
||||
end
|
||||
end
|
||||
|
||||
if sell then
|
||||
local sells = get_resource_market_sells()
|
||||
for i = 1, random(1, 25), 1 do
|
||||
items_return[#items_return + 1] = sells[i]
|
||||
end
|
||||
end
|
||||
|
||||
if buy then
|
||||
local buys = get_resource_market_buys()
|
||||
for i = 1, random(1, 25), 1 do
|
||||
items_return[#items_return + 1] = buys[i]
|
||||
end
|
||||
end
|
||||
|
||||
return items_return
|
||||
end
|
||||
|
||||
function Public.mountain_market(surface, position, rarity, buy)
|
||||
if (rarity <= 1) then
|
||||
rarity = 1
|
||||
end
|
||||
-- game.print(rarity)
|
||||
local types = get_types()
|
||||
table.shuffle_table(types)
|
||||
local items = get_market_item_list(rarity)
|
||||
if not items then
|
||||
return
|
||||
end
|
||||
if #items > 0 then
|
||||
table.shuffle_table(items)
|
||||
end
|
||||
local mrk = surface.create_entity({name = 'market', position = position, force = 'neutral'})
|
||||
mrk.destructible = false
|
||||
for i = 1, random(5, 10), 1 do
|
||||
local item = items[i]
|
||||
if not item then
|
||||
break
|
||||
end
|
||||
if not blacklist[item.offer.item] then
|
||||
mrk.add_market_item(items[i])
|
||||
end
|
||||
end
|
||||
|
||||
local sells = get_resource_market_sells()
|
||||
for i = 1, random(1, 3), 1 do
|
||||
mrk.add_market_item(sells[i])
|
||||
end
|
||||
|
||||
if buy then
|
||||
local buys = get_resource_market_buys()
|
||||
for i = 1, random(1, 3), 1 do
|
||||
mrk.add_market_item(buys[i])
|
||||
end
|
||||
end
|
||||
|
||||
return mrk
|
||||
end
|
||||
|
||||
return Public
|
@ -1,200 +0,0 @@
|
||||
local WPT = require 'maps.amap.table'
|
||||
|
||||
local nom_msg = {'munch', 'munch', 'yum'}
|
||||
|
||||
local Public = {}
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
|
||||
local function feed_floaty_text(unit)
|
||||
unit.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = unit.position,
|
||||
text = nom_msg[random(1, #nom_msg)],
|
||||
color = {random(50, 100), 0, 255}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function floaty_hearts(entity, c)
|
||||
local position = {x = entity.position.x - 0.75, y = entity.position.y - 1}
|
||||
local b = 1.35
|
||||
for _ = 1, c, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + random(0, b * 20) * 0.1)
|
||||
}
|
||||
entity.surface.create_entity({name = 'flying-text', position = p, text = '♥', color = {random(150, 255), 0, 255}})
|
||||
end
|
||||
end
|
||||
|
||||
local function tame_unit_effects(player, entity)
|
||||
floaty_hearts(entity, 7)
|
||||
|
||||
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 find_unit(player, entity)
|
||||
local units =
|
||||
player.surface.find_entities_filtered(
|
||||
{
|
||||
type = 'unit',
|
||||
area = {{entity.position.x - 1, entity.position.y - 1}, {entity.position.x + 1, entity.position.y + 1}},
|
||||
limit = 1
|
||||
}
|
||||
)
|
||||
return units[1]
|
||||
end
|
||||
|
||||
local function feed_pet(unit)
|
||||
if unit.prototype.max_health == unit.health then
|
||||
return
|
||||
end
|
||||
unit.health = unit.health + 8 + floor(unit.prototype.max_health * 0.05)
|
||||
feed_floaty_text(unit)
|
||||
floaty_hearts(unit, random(1, 2))
|
||||
return true
|
||||
end
|
||||
|
||||
local function is_valid_player(player, unit)
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
if not player.character.valid then
|
||||
return
|
||||
end
|
||||
if player.surface.index ~= unit.surface.index then
|
||||
return
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function Public.biter_pets_tame_unit(player, unit, forced)
|
||||
local biter_pets = WPT.get('biter_pets')
|
||||
|
||||
if biter_pets[player.index] then
|
||||
return false
|
||||
end
|
||||
|
||||
if not forced then
|
||||
if random(1, floor(unit.prototype.max_health * 0.01) + 1) ~= 1 then
|
||||
feed_floaty_text(unit)
|
||||
return true
|
||||
end
|
||||
end
|
||||
if unit.force.index == player.force.index then
|
||||
return false
|
||||
end
|
||||
unit.ai_settings.allow_destroy_when_commands_fail = false
|
||||
unit.ai_settings.allow_try_return_to_spawner = false
|
||||
unit.force = player.force
|
||||
unit.set_command({type = defines.command.wander, distraction = defines.distraction.by_enemy})
|
||||
biter_pets[player.index] = {last_command = 0, entity = unit}
|
||||
tame_unit_effects(player, unit)
|
||||
return true
|
||||
end
|
||||
|
||||
function Public.tame_unit_for_closest_player(unit)
|
||||
local valid_players = {}
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if is_valid_player(player, unit) then
|
||||
table.insert(valid_players, player)
|
||||
end
|
||||
end
|
||||
|
||||
local nearest_player = valid_players[1]
|
||||
if not nearest_player then
|
||||
return
|
||||
end
|
||||
|
||||
Public.biter_pets_tame_unit(nearest_player, unit, true)
|
||||
end
|
||||
|
||||
local function command_unit(entity, player)
|
||||
if entity.surface ~= player.surface then
|
||||
return
|
||||
end
|
||||
local square_distance = (player.position.x - entity.position.x) ^ 2 + (player.position.y - entity.position.y) ^ 2
|
||||
|
||||
--Pet will follow, if the player is between a distance of 8 to 160 tiles away from it.
|
||||
if square_distance < 64 or square_distance > 25600 then
|
||||
entity.set_command({type = defines.command.wander, distraction = defines.distraction.by_enemy})
|
||||
else
|
||||
entity.set_command(
|
||||
{
|
||||
type = defines.command.go_to_location,
|
||||
destination_entity = player.character,
|
||||
radius = 4,
|
||||
distraction = defines.distraction.by_damage
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local biter_pets = WPT.get('biter_pets')
|
||||
|
||||
if random(1, 100) ~= 1 then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
if not biter_pets[player.index] then
|
||||
return
|
||||
end
|
||||
if not biter_pets[player.index].entity then
|
||||
biter_pets[player.index] = nil
|
||||
return
|
||||
end
|
||||
if not biter_pets[player.index].entity.valid then
|
||||
biter_pets[player.index] = nil
|
||||
return
|
||||
end
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
if biter_pets[player.index].last_command + 600 > game.tick then
|
||||
return
|
||||
end
|
||||
biter_pets[player.index].last_command = game.tick
|
||||
command_unit(biter_pets[player.index].entity, player)
|
||||
end
|
||||
|
||||
local function on_player_dropped_item(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.entity.stack.name ~= 'raw-fish' then
|
||||
return
|
||||
end
|
||||
local unit = find_unit(player, event.entity)
|
||||
if not unit then
|
||||
return
|
||||
end
|
||||
if Public.biter_pets_tame_unit(player, unit, false) then
|
||||
event.entity.destroy()
|
||||
return
|
||||
end
|
||||
if unit.force.index == player.force.index then
|
||||
feed_pet(unit)
|
||||
end
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_dropped_item, on_player_dropped_item)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
||||
return Public
|
@ -1,133 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local insert = table.insert
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
|
||||
local coin_yield = {
|
||||
['behemoth-biter'] = 5,
|
||||
['behemoth-spitter'] = 5,
|
||||
['behemoth-worm-turret'] = 20,
|
||||
['big-biter'] = 3,
|
||||
['big-spitter'] = 3,
|
||||
['big-worm-turret'] = 16,
|
||||
['biter-spawner'] = 32,
|
||||
['medium-biter'] = 2,
|
||||
['medium-spitter'] = 2,
|
||||
['medium-worm-turret'] = 12,
|
||||
['small-biter'] = 1,
|
||||
['small-spitter'] = 1,
|
||||
['small-worm-turret'] = 8,
|
||||
['spitter-spawner'] = 32
|
||||
}
|
||||
|
||||
local entities_that_earn_coins = {
|
||||
['artillery-turret'] = true,
|
||||
['gun-turret'] = true,
|
||||
['laser-turret'] = true,
|
||||
['flamethrower-turret'] = true
|
||||
}
|
||||
|
||||
--extra coins for "boss" biters from biter_health_booster.lua
|
||||
local function get_coin_count(entity)
|
||||
local coin_count = coin_yield[entity.name]
|
||||
if not coin_count then
|
||||
return
|
||||
end
|
||||
if not global.biter_health_boost_units then
|
||||
return coin_count
|
||||
end
|
||||
local unit_number = entity.unit_number
|
||||
if not unit_number then
|
||||
return coin_count
|
||||
end
|
||||
if not global.biter_health_boost_units[unit_number] then
|
||||
return coin_count
|
||||
end
|
||||
if not global.biter_health_boost_units[unit_number][3] then
|
||||
return coin_count
|
||||
end
|
||||
local m = 1 / global.biter_health_boost_units[unit_number][2]
|
||||
coin_count = floor(coin_count * m)
|
||||
if coin_count < 1 then
|
||||
return 1
|
||||
end
|
||||
return coin_count
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if entity.force.index ~= 2 then
|
||||
return
|
||||
end
|
||||
|
||||
local cause = event.cause
|
||||
|
||||
local coin_count = get_coin_count(entity)
|
||||
if not coin_count then
|
||||
return
|
||||
end
|
||||
|
||||
local players_to_reward = {}
|
||||
local p
|
||||
local reward_has_been_given = false
|
||||
|
||||
if cause then
|
||||
if cause.valid then
|
||||
if (cause and cause.name == 'character' and cause.player) then
|
||||
p = cause.player
|
||||
end
|
||||
|
||||
if cause.name == 'character' then
|
||||
insert(players_to_reward, cause)
|
||||
reward_has_been_given = true
|
||||
end
|
||||
if cause.type == 'car' then
|
||||
local player = cause.get_driver()
|
||||
local passenger = cause.get_passenger()
|
||||
if player then
|
||||
insert(players_to_reward, player.player)
|
||||
end
|
||||
if passenger then
|
||||
insert(players_to_reward, passenger.player)
|
||||
end
|
||||
reward_has_been_given = true
|
||||
end
|
||||
if cause.type == 'locomotive' then
|
||||
local train_passengers = cause.train.passengers
|
||||
if train_passengers then
|
||||
for _, passenger in pairs(train_passengers) do
|
||||
insert(players_to_reward, passenger)
|
||||
end
|
||||
reward_has_been_given = true
|
||||
end
|
||||
end
|
||||
for _, player in pairs(players_to_reward) do
|
||||
local forest_zone
|
||||
if p then
|
||||
forest_zone = RPG_Settings.get_value_from_player(p.index, 'forest_zone')
|
||||
end
|
||||
if forest_zone then
|
||||
if random(1, 12) == 1 then
|
||||
player.insert({name = 'coin', count = coin_count})
|
||||
end
|
||||
else
|
||||
player.insert({name = 'coin', count = coin_count})
|
||||
end
|
||||
end
|
||||
end
|
||||
if entities_that_earn_coins[cause.name] then
|
||||
event.entity.surface.spill_item_stack(cause.position, {name = 'coin', count = coin_count}, true)
|
||||
reward_has_been_given = true
|
||||
end
|
||||
end
|
||||
|
||||
if reward_has_been_given == false then
|
||||
event.entity.surface.spill_item_stack(event.entity.position, {name = 'coin', count = coin_count}, true)
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
@ -1,67 +0,0 @@
|
||||
--luacheck: ignore
|
||||
local Event = require 'utils.event'
|
||||
local Modifier = require 'player_modifiers'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local function validate_player(player)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
if not player.valid then
|
||||
return false
|
||||
end
|
||||
if not player.character then
|
||||
return false
|
||||
end
|
||||
if not player.connected then
|
||||
return false
|
||||
end
|
||||
if not game.players[player.name] then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function compute_fullness(player)
|
||||
local inv = player.get_inventory(defines.inventory.character_main)
|
||||
local max_stacks = #inv
|
||||
local num_stacks = 0
|
||||
|
||||
local contents = inv.get_contents()
|
||||
for item, count in pairs(contents) do
|
||||
local stack_size = 1
|
||||
if game.item_prototypes[item].stackable then
|
||||
stack_size = game.item_prototypes[item].stack_size
|
||||
end
|
||||
|
||||
num_stacks = num_stacks + count / stack_size
|
||||
end
|
||||
|
||||
return num_stacks / max_stacks
|
||||
end
|
||||
|
||||
local function check_burden(event)
|
||||
local player_modifiers = Modifier.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
local fullness = compute_fullness(player)
|
||||
-- player_modifiers[player.index].character_running_speed_modifier['randomness'] = 0.3 - fullness
|
||||
--player_modifiers[player.index].character_mining_speed_modifier['randomess'] = 0.3 - fullness
|
||||
-- Modifier.update_player_modifiers(player)
|
||||
if fullness >= 0.9 and fullness <= 0.901 then
|
||||
player.print('Maybe you should drop some of that inventory to lessen the burden.', Color.red)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init(event)
|
||||
script.on_event(defines.events.on_player_main_inventory_changed, check_burden)
|
||||
end
|
||||
|
||||
local function on_load(event)
|
||||
script.on_event(defines.events.on_player_main_inventory_changed, check_burden)
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.on_load(on_load)
|
@ -1,255 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local BiterRolls = require 'modules.wave_defense.biter_rolls'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local WPT = require 'maps.amap.table'
|
||||
|
||||
local traps = {}
|
||||
|
||||
Global.register(
|
||||
traps,
|
||||
function(t)
|
||||
traps = t
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
local sqrt = math.sqrt
|
||||
|
||||
local spawn_amount_rolls = {}
|
||||
for a = 48, 1, -1 do
|
||||
spawn_amount_rolls[#spawn_amount_rolls + 1] = floor(a ^ 5)
|
||||
end
|
||||
|
||||
local random_particles = {
|
||||
'dirt-2-stone-particle-medium',
|
||||
'dirt-4-dust-particle',
|
||||
'coal-particle'
|
||||
}
|
||||
|
||||
local s_random_particles = #random_particles
|
||||
|
||||
local function create_particles(data)
|
||||
local surface = data.surface
|
||||
local position = data.position
|
||||
local amount = data.amount
|
||||
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
for i = 1, amount, 1 do
|
||||
local m = random(6, 12)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_particle(
|
||||
{
|
||||
name = random_particles[random(1, s_random_particles)],
|
||||
position = position,
|
||||
frame_speed = 0.1,
|
||||
vertical_speed = 0.1,
|
||||
height = 0.1,
|
||||
movement = {m2 - (random(0, m) * 0.01), m2 - (random(0, m) * 0.01)}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_biters(data)
|
||||
local surface = data.surface
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
local position = data.position
|
||||
local h = floor(abs(position.y))
|
||||
local wave_number = WD.get('wave_number')
|
||||
local max_biters = WPT.get('biters')
|
||||
|
||||
if max_biters.amount >= max_biters.limit then
|
||||
return
|
||||
end
|
||||
|
||||
if not position then
|
||||
position = surface.find_non_colliding_position('small-biter', position, 10, 1)
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function trigger_health()
|
||||
local m = 0.0015
|
||||
|
||||
m = m * 1.05
|
||||
|
||||
local boosted_health = 1.25
|
||||
|
||||
if wave_number <= 10 then
|
||||
wave_number = 10
|
||||
end
|
||||
|
||||
boosted_health = boosted_health * (wave_number * 0.02)
|
||||
|
||||
local sum = boosted_health * 5
|
||||
|
||||
sum = sum + m
|
||||
|
||||
if sum >= 100 then
|
||||
sum = 100
|
||||
end
|
||||
|
||||
return sum
|
||||
end
|
||||
|
||||
BiterRolls.wave_defense_set_unit_raffle(h * 0.20)
|
||||
|
||||
local unit
|
||||
if random(1, 3) == 1 then
|
||||
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = position})
|
||||
max_biters.amount = max_biters.amount + 1
|
||||
else
|
||||
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position})
|
||||
max_biters.amount = max_biters.amount + 1
|
||||
end
|
||||
|
||||
if random(1, 32) == 1 then
|
||||
local sum = trigger_health()
|
||||
max_biters.amount = max_biters.amount + 1
|
||||
BiterHealthBooster.add_boss_unit(unit, sum, 0.38)
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_worms(data)
|
||||
local max_biters = WPT.get('biters')
|
||||
|
||||
if max_biters.amount >= max_biters.limit then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = data.surface
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
local position = data.position
|
||||
BiterRolls.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
|
||||
surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position})
|
||||
max_biters.amount = max_biters.amount + 1
|
||||
end
|
||||
|
||||
function Public.buried_biter(surface, position, max)
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
if not position.x then
|
||||
return
|
||||
end
|
||||
if not position.y then
|
||||
return
|
||||
end
|
||||
|
||||
local amount = 8
|
||||
local a = 0
|
||||
max = max or random(4, 6)
|
||||
|
||||
local ticks = amount * 30
|
||||
ticks = ticks + 90
|
||||
for t = 1, ticks, 1 do
|
||||
if not traps[game.tick + t] then
|
||||
traps[game.tick + t] = {}
|
||||
end
|
||||
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'create_particles',
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
|
||||
}
|
||||
|
||||
if t > 90 then
|
||||
if t % 30 == 29 then
|
||||
a = a + 1
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'spawn_biters',
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}}
|
||||
}
|
||||
if a >= max then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.buried_worm(surface, position)
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
if not position.x then
|
||||
return
|
||||
end
|
||||
if not position.y then
|
||||
return
|
||||
end
|
||||
|
||||
local amount = 8
|
||||
|
||||
local ticks = amount * 30
|
||||
ticks = ticks + 90
|
||||
local a = false
|
||||
for t = 1, ticks, 1 do
|
||||
if not traps[game.tick + t] then
|
||||
traps[game.tick + t] = {}
|
||||
end
|
||||
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'create_particles',
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
|
||||
}
|
||||
|
||||
if not a then
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'spawn_worms',
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}}
|
||||
}
|
||||
a = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local callbacks = {
|
||||
['create_particles'] = create_particles,
|
||||
['spawn_biters'] = spawn_biters,
|
||||
['spawn_worms'] = spawn_worms
|
||||
}
|
||||
|
||||
local function on_tick()
|
||||
local t = game.tick
|
||||
if not traps[t] then
|
||||
return
|
||||
end
|
||||
for _, token in pairs(traps[t]) do
|
||||
local callback = token.callback
|
||||
local data = token.data
|
||||
local cbl = callbacks[callback]
|
||||
if callbacks[callback] then
|
||||
cbl(data)
|
||||
end
|
||||
end
|
||||
traps[t] = nil
|
||||
end
|
||||
|
||||
function Public.reset()
|
||||
for k, _ in pairs(traps) do
|
||||
traps[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
|
||||
return Public
|
@ -1,292 +0,0 @@
|
||||
--luacheck: ignore
|
||||
--[[
|
||||
Exchange Strings
|
||||
|
||||
>>>eNp1UT1oFEEUfi/nkcsJonBNwMQrUtjsES/aHOFmTCMp1M5+b
|
||||
29OB/Z2ztldSLRwixQWQpo0pkmKNCZgJ2gXsVHQIGpjd5LGwiJBE
|
||||
AvhnNnd2VvX5IN5fPO9/xmAC3AbYuxTgKhdOeMI201vRMmk6ojBg
|
||||
ElLSJaXpxwZdpkluAqO6N7uLtGeKvNYf9Xq2D7TskqI5QqXwitWK
|
||||
PuB8P5VAsmYnyRGba2eDaXt8bCf5EZZJODOwZ3X0dos6DN6BPXRS
|
||||
B/Fhso/hBQqA5WWonTZEV4ghWv5LAi4d7dlhyutnmT3Q+Y5q61+6
|
||||
AZ84HImKwuN+RgzxYy+4H4QStbqcNufsuYbzWs6zjo17sTyVxoLM
|
||||
cqOy3s9gPp1dZb01oj4sPb8xrcHGwSTqRs0JUepst8xyrIht+ipr
|
||||
jlDrubqJN1/5kjSNFAt0qgKHZPEuaadiMf3Dh+/+P2ljX+eHX+62
|
||||
aEEj4yCOKkScCIzm081XplVwNQcktT1leCH9xo/CJZ1Rk2b7SfKR
|
||||
M0JwPPnzLV+EcxobVOmRrEX45fZ5NCQz6S4h3qIRV18Vpu32sQNs
|
||||
8kwoXSdIr1kvNPjEJXfhPwM3fGG70zbN7n+hUH+/4j8HgVljp7wD
|
||||
VXdsJuZ76VsGvWeHyfNjW7REoyhvvvAetn9CzJb1cQ=<<<
|
||||
]]
|
||||
--local List = require 'maps.chronosphere.production_list'
|
||||
--local Factories = require 'maps.chronosphere.production'
|
||||
local random = math.random
|
||||
local Alert = require 'utils.alert'
|
||||
require 'player_modifiers'
|
||||
require 'modules.rocks_broken_paint_tiles'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
local WPT = require 'maps.amap.table'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
local MT = require 'maps.amap.basic_markets'
|
||||
local RPGtable = require 'modules.rpg.table'
|
||||
local Loot = require 'maps.amap.loot'
|
||||
local get_noise = require 'utils.get_noise'
|
||||
local Player_modifiers = require 'player_modifiers'
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
local Public = {}
|
||||
local BiterRolls = require 'modules.wave_defense.biter_rolls'
|
||||
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
|
||||
local size_of_rock_raffle = #rock_raffle
|
||||
local Pets = require 'maps.amap.biter_pets'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
|
||||
local function place_entity(surface, position)
|
||||
if math_random(1, 3) ~= 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = position, force = 'neutral'})
|
||||
end
|
||||
end
|
||||
|
||||
local function is_scrap_area(noise)
|
||||
if noise > 0.67 then
|
||||
return
|
||||
end
|
||||
if noise < -0.67 then
|
||||
return
|
||||
end
|
||||
if noise > 0.33 then
|
||||
return true
|
||||
end
|
||||
if noise < -0.33 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function hidden_treasure(player, entity)
|
||||
local rpg = RPGtable.get('rpg_t')
|
||||
|
||||
local magic = rpg[player.index].magicka
|
||||
|
||||
local msg = 'look,you find a treasure'
|
||||
|
||||
Alert.alert_player(player, 5, msg)
|
||||
|
||||
Loot.add_rare(entity.surface, entity.position, 'wooden-chest', magic)
|
||||
end
|
||||
|
||||
local function register_spawner(spawner)
|
||||
local nests = WD.get('nests')
|
||||
if spawner.valid then
|
||||
nests[#nests + 1] = spawner
|
||||
end
|
||||
end
|
||||
|
||||
local function move_away_things(surface, area)
|
||||
for _, e in pairs(surface.find_entities_filtered({type = {'unit-spawner', 'unit', 'tree'}, area = area})) do
|
||||
local position = surface.find_non_colliding_position(e.name, e.position, 128, 4)
|
||||
if position then
|
||||
local entity = surface.create_entity({name = e.name, position = position, force = 'enemy'})
|
||||
e.destroy()
|
||||
-- if (entity.name == "biter-spawner" or entity.name == "spitter-spawner") and entity.force.name == "enemy" then
|
||||
-- register_spawner(entity)
|
||||
-- end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vectors = {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}}
|
||||
local function hidden_biter_pet(player, entity)
|
||||
local pos = entity.position
|
||||
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(pos.x ^ 2 + pos.y ^ 2) * 0.25)
|
||||
local unit
|
||||
if random(1, 3) == 1 then
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = pos})
|
||||
else
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = pos})
|
||||
end
|
||||
Pets.biter_pets_tame_unit(game.players[player.index], unit, true)
|
||||
end
|
||||
local function hidden_biter(player, entity)
|
||||
local pos = entity.position
|
||||
BiterRolls.wave_defense_set_worm_raffle(math.sqrt(pos.x ^ 2 + pos.y ^ 2) * 0.19)
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(pos.x ^ 2 + pos.y ^ 2) * 0.25)
|
||||
local roll = math.random(1, 3)
|
||||
local unit
|
||||
if roll == 1 then
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = pos})
|
||||
elseif roll == 2 then
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = pos})
|
||||
else
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = pos})
|
||||
end
|
||||
end
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if entity.type ~= 'simple-entity' then
|
||||
return
|
||||
end
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = {entity.position.x + v[1], entity.position.y + v[2]}
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
surface.set_tiles({{name = 'landfill', position = position}}, true)
|
||||
end
|
||||
end
|
||||
if event.player_index then
|
||||
game.players[event.player_index].insert({name = 'coin', count = 1})
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
--修复挖矿石路
|
||||
local rpg = RPGtable.get('rpg_t')
|
||||
local rpg_char = rpg[player.index]
|
||||
if rpg_char.stone_path then
|
||||
entity.surface.set_tiles({{name = 'stone-path', position = entity.position}}, true)
|
||||
end
|
||||
|
||||
--挖出汽车
|
||||
if random(1, 1024) < 2 then
|
||||
local position = {entity.position.x, entity.position.y}
|
||||
--local player = game.players[event.player_index]
|
||||
surface.create_entity({name = 'car', position = position, force = 'player'})
|
||||
Public.unstuck_player(player.index)
|
||||
local msg = ('you find a car!')
|
||||
Alert.alert_player(player, 15, msg)
|
||||
end
|
||||
--挖出虫巢
|
||||
|
||||
if random(1, 200) < 2 then
|
||||
local position = {entity.position.x, entity.position.y}
|
||||
local player = game.players[event.player_index]
|
||||
surface.create_entity({name = 'biter-spawner', position = position, force = 'enemy'})
|
||||
Public.unstuck_player(player.index)
|
||||
end
|
||||
--挖出宝藏
|
||||
if random(1, 150) < 2 then
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
hidden_treasure(player, entity)
|
||||
end
|
||||
--挖出宠物
|
||||
if random(1, 170) < 3 then
|
||||
local player = game.players[event.player_index]
|
||||
hidden_biter_pet(player, entity)
|
||||
end
|
||||
--来挖个虫子
|
||||
if random(1, 100) < 3 then
|
||||
local player = game.players[event.player_index]
|
||||
hidden_biter(player, entity)
|
||||
end
|
||||
end
|
||||
|
||||
--图块生成时
|
||||
local function on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
local this = WPT.get()
|
||||
if not (surface.index == game.surfaces[this.active_surface_index].index) then
|
||||
return
|
||||
end
|
||||
local seed = surface.map_gen_settings.seed
|
||||
local left_top_x = event.area.left_top.x
|
||||
local left_top_y = event.area.left_top.y
|
||||
local set_tiles = surface.set_tiles
|
||||
local get_tile = surface.get_tile
|
||||
local position
|
||||
local noise
|
||||
local tem_pos
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
position = {x = left_top_x + x, y = left_top_y + y}
|
||||
local q = position.x ^ 2
|
||||
local w = position.y ^ 2
|
||||
local maxs = math.sqrt(q + w)
|
||||
|
||||
if maxs <= 120 then
|
||||
if maxs > 117 then
|
||||
if surface.can_place_entity {name = 'stone-wall', position = {x = position.x, y = position.y}, force = game.forces.player} then
|
||||
surface.create_entity {name = 'stone-wall', position = {x = position.x, y = position.y}, force = game.forces.player}
|
||||
end
|
||||
end
|
||||
local h = math_abs(position.x)
|
||||
local k = math_abs(position.y)
|
||||
if maxs < 115 and maxs > 113 then
|
||||
if (1 == h % 7) or (1 == k % 7) then
|
||||
if surface.can_place_entity {name = 'gun-turret', position = position, force = game.forces.player} then
|
||||
local e = surface.create_entity {name = 'gun-turret', position = position, force = game.forces.player}
|
||||
e.insert {name = 'firearm-magazine', count = 30}
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if not get_tile(position).collides_with('resource-layer') then
|
||||
noise = get_noise('scrapyard', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
set_tiles({{name = 'dirt-' .. math_floor(math_abs(noise) * 12) % 4 + 3, position = position}}, true)
|
||||
|
||||
if maxs >= 3000 then
|
||||
local roll = math_random(1, 1024)
|
||||
if roll <= 2 then
|
||||
BiterRolls.wave_defense_set_worm_raffle(math.sqrt(position.x ^ 2 + position.y ^ 2) * 0.19)
|
||||
surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position, force = 'enemy'})
|
||||
end
|
||||
end
|
||||
if x + y > 33 and x + y < 40 then
|
||||
local b = math_random(1, 200)
|
||||
--宝藏
|
||||
if b < 3 then
|
||||
local chest = 'iron-chest'
|
||||
Loot.add(surface, position, chest)
|
||||
end
|
||||
--中立建筑
|
||||
|
||||
--在我上面添加代码
|
||||
end
|
||||
--商店代码
|
||||
if y == 1 then
|
||||
if x == 1 then
|
||||
local a = math_random(1, 8)
|
||||
if a == 1 then
|
||||
local q = math_abs(position.x) / 80
|
||||
local w = math_abs(position.y) / 80
|
||||
local maxs = math.floor(q + w)
|
||||
-- game.print(maxs)
|
||||
MT.mountain_market(surface, position, maxs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
place_entity(surface, position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
move_away_things(surface, event.area)
|
||||
end
|
||||
|
||||
function Public.unstuck_player(index)
|
||||
local player = game.get_player(index)
|
||||
local surface = player.surface
|
||||
local position = surface.find_non_colliding_position('character', player.position, 32, 0.5)
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
local function on_init()
|
||||
global.rocks_yield_ore_maximum_amount = 999
|
||||
global.rocks_yield_ore_base_amount = 100
|
||||
global.rocks_yield_ore_distance_modifier = 0.020
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
--Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
require 'maps.amap.rocks_yield_ore'
|
@ -1,179 +0,0 @@
|
||||
--luacheck: ignore
|
||||
local Event = require 'utils.event'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local WPT = require 'maps.amap.table'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local atry_talbe = require 'maps.amap.enemy_arty'
|
||||
local function calc_players()
|
||||
local players = game.connected_players
|
||||
local check_afk_players = WPT.get('check_afk_players')
|
||||
if not check_afk_players then
|
||||
return #players
|
||||
end
|
||||
local total = 0
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player.afk_time < 36000 then
|
||||
total = total + 1
|
||||
end
|
||||
end
|
||||
if total <= 0 then
|
||||
total = 1
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
local easy = function()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = calc_players()
|
||||
|
||||
wave_defense_table.max_active_biters = 768 + player_count * 180
|
||||
|
||||
if wave_defense_table.max_active_biters >= 4000 then
|
||||
wave_defense_table.max_active_biters = 4000
|
||||
end
|
||||
local wave_number = WD.get('wave_number')
|
||||
if wave_number >= 1500 then
|
||||
wave_number = 1500
|
||||
end
|
||||
-- threat gain / wave
|
||||
local max_threat = 1 + player_count * 0.1
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
max_threat = max_threat + wave_number * 0.0013
|
||||
|
||||
WD.set_biter_health_boost(wave_number * 0.002 + 1)
|
||||
wave_defense_table.threat_gain_multiplier = max_threat
|
||||
|
||||
wave_defense_table.wave_interval = 4200 - player_count * 30
|
||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
local mintime = 7500 - player_count * 150
|
||||
if mintime <= 6000 then
|
||||
mintime = 6000
|
||||
end
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = mintime
|
||||
-- game.map_settings.enemy_expansion.max_expansion_cooldown = 104000
|
||||
end
|
||||
local med = function()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = calc_players()
|
||||
|
||||
wave_defense_table.max_active_biters = 768 + player_count * 220
|
||||
|
||||
if wave_defense_table.max_active_biters >= 4000 then
|
||||
wave_defense_table.max_active_biters = 4000
|
||||
end
|
||||
local wave_number = WD.get('wave_number')
|
||||
-- threat gain / wave
|
||||
if wave_number >= 1500 then
|
||||
wave_number = 1500
|
||||
end
|
||||
local max_threat = 1 + player_count * 0.1
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
max_threat = max_threat + wave_number * 0.0013
|
||||
WD.set_biter_health_boost(wave_number * 0.002 + 1)
|
||||
wave_defense_table.threat_gain_multiplier = max_threat
|
||||
|
||||
wave_defense_table.wave_interval = 4200 - player_count * 45
|
||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
local mintime = 7500 - player_count * 240
|
||||
if mintime <= 3600 then
|
||||
mintime = 3600
|
||||
end
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = mintime
|
||||
-- game.map_settings.enemy_expansion.max_expansion_cooldown = 104000
|
||||
end
|
||||
local hard = function()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = calc_players()
|
||||
|
||||
wave_defense_table.max_active_biters = 768 + player_count * 280
|
||||
|
||||
if wave_defense_table.max_active_biters >= 4000 then
|
||||
wave_defense_table.max_active_biters = 4000
|
||||
end
|
||||
|
||||
local wave_number = WD.get('wave_number')
|
||||
-- threat gain / wave
|
||||
if wave_number >= 1500 then
|
||||
wave_number = 1500
|
||||
end
|
||||
local max_threat = 1 + player_count * 0.1
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
max_threat = max_threat + wave_number * 0.0013
|
||||
WD.set_biter_health_boost(wave_number * 0.002 + 1)
|
||||
wave_defense_table.threat_gain_multiplier = max_threat
|
||||
|
||||
wave_defense_table.wave_interval = 3900 - player_count * 60
|
||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
local mintime = 7500 - player_count * 300
|
||||
if mintime <= 3000 then
|
||||
mintime = 3000
|
||||
end
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = mintime
|
||||
-- game.map_settings.enemy_expansion.max_expansion_cooldown = 104000
|
||||
end
|
||||
|
||||
local set_diff = function()
|
||||
local game_lost = WPT.get('game_lost')
|
||||
if game_lost then
|
||||
return
|
||||
end
|
||||
|
||||
local diff = Difficulty.get()
|
||||
if diff.difficulty_vote_index == 1 then
|
||||
easy()
|
||||
end
|
||||
if diff.difficulty_vote_index == 2 then
|
||||
med()
|
||||
end
|
||||
if diff.difficulty_vote_index == 3 then
|
||||
hard()
|
||||
end
|
||||
|
||||
--med()
|
||||
local wave_number = WD.get('wave_number')
|
||||
local damage_increase = 0
|
||||
-- local any=wave_number+150
|
||||
-- local k= math.floor(any/1000)
|
||||
-- if k <= 1 then
|
||||
-- k =1
|
||||
-- end
|
||||
-- if k >= 5 then
|
||||
-- k =5
|
||||
-- end
|
||||
local k = math.sqrt(diff.difficulty_vote_index)
|
||||
if k <= 1 then
|
||||
k = 1
|
||||
end
|
||||
k = math.floor(k)
|
||||
damage_increase = wave_number * 0.001 * k
|
||||
game.forces.enemy.set_ammo_damage_modifier('artillery-shell', damage_increase)
|
||||
game.forces.enemy.set_ammo_damage_modifier('rocket', damage_increase)
|
||||
game.forces.enemy.set_ammo_damage_modifier('melee', damage_increase)
|
||||
game.forces.enemy.set_ammo_damage_modifier('biological', damage_increase)
|
||||
|
||||
local table = atry_talbe.get()
|
||||
local radius = math.floor(wave_number * 0.15) * k
|
||||
table.radius = 350 + radius
|
||||
local pace = wave_number * 0.0002 * k + 1
|
||||
if pace >= 2 then
|
||||
pace = 2
|
||||
end
|
||||
table.pace = pace
|
||||
end
|
||||
Event.on_nth_tick(600, set_diff)
|
@ -1,243 +0,0 @@
|
||||
--luacheck: ignore
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Task = require 'utils.task'
|
||||
local arty_count = {}
|
||||
local Public = {}
|
||||
local Token = require 'utils.token'
|
||||
local WPT = require 'maps.amap.table'
|
||||
local artillery_target_entities = {
|
||||
'character',
|
||||
'tank',
|
||||
'car',
|
||||
'radar',
|
||||
'lab',
|
||||
'furnace',
|
||||
'locomotive',
|
||||
'cargo-wagon',
|
||||
'fluid-wagon',
|
||||
'artillery-wagon',
|
||||
'artillery-turret',
|
||||
'laser-turret',
|
||||
'gun-turret',
|
||||
'flamethrower-turret',
|
||||
-- 'silo',
|
||||
'spidertron'
|
||||
}
|
||||
|
||||
Global.register(
|
||||
arty_count,
|
||||
function(tbl)
|
||||
arty_count = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset_table()
|
||||
arty_count.max = 200
|
||||
arty_count.all = {}
|
||||
arty_count.count = 0
|
||||
arty_count.pace = 1
|
||||
arty_count.radius = 350
|
||||
arty_count.distance = 1400
|
||||
arty_count.surface = {}
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return arty_count[key]
|
||||
else
|
||||
return arty_count
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set(key, value)
|
||||
if key and (value or value == false) then
|
||||
this[key] = value
|
||||
return this[key]
|
||||
elseif key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
Public.reset_table()
|
||||
end
|
||||
|
||||
local function add_bullet()
|
||||
for k, p in pairs(arty_count.all) do
|
||||
if arty_count.all[k].valid then
|
||||
arty_count.all[k].insert {name = 'artillery-shell', count = '5'}
|
||||
end
|
||||
end
|
||||
end
|
||||
local function on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
local left_top_x = event.area.left_top.x
|
||||
local left_top_y = event.area.left_top.y
|
||||
|
||||
local position
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
position = {x = left_top_x + x, y = left_top_y + y}
|
||||
local q = position.x * position.x
|
||||
local w = position.y * position.y
|
||||
local distance = math.sqrt(q + w)
|
||||
|
||||
if distance >= arty_count.distance then
|
||||
if arty_count.count >= arty_count.max then
|
||||
return
|
||||
else
|
||||
local roll = math.random(1, 2024)
|
||||
if roll == 1 then
|
||||
local arty = surface.create_entity {name = 'artillery-turret', position = position, force = 'enemy'}
|
||||
-- arty.insert{name='artillery-shell', count = '5'}
|
||||
--local k = #arty_count.all
|
||||
-- game.print(k)
|
||||
arty_count.all[arty.unit_number] = arty
|
||||
-- game.print(arty_count.all[1].name)
|
||||
arty_count.count = arty_count.count + 1
|
||||
-- game.print(arty_count.count)
|
||||
-- game.print(position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if arty_count.all[entity.unit_number] then
|
||||
arty_count.all[entity.unit_number] = nil
|
||||
arty_count.count = arty_count.count - 1
|
||||
end
|
||||
-- local force = entity.force
|
||||
-- local name = entity.name
|
||||
-- if name == 'artillery-turret' and force.name == 'enemy' then
|
||||
-- arty_count.all[entity.unit_number] = nil
|
||||
-- arty_count.count = arty_count.count -1
|
||||
--
|
||||
-- if arty_count.count <= 0 then
|
||||
-- arty_count.count = 0
|
||||
-- end
|
||||
end
|
||||
|
||||
function on_player_changed_position(event)
|
||||
local player = game.players[event.player_index]
|
||||
local surface = player.surface
|
||||
if not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
|
||||
local q = position.x * position.x
|
||||
local w = position.y * position.y
|
||||
local distance = math.sqrt(q + w)
|
||||
--artillery-targeting-remote
|
||||
game.print('123')
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'artillery-targeting-remote',
|
||||
position = position,
|
||||
force = 'enemy'
|
||||
-- target = position,
|
||||
-- speed = 0.001
|
||||
}
|
||||
)
|
||||
game.print('logging')
|
||||
end
|
||||
local artillery_target_callback =
|
||||
Token.register(
|
||||
function(data)
|
||||
local position = data.position
|
||||
local entity = data.entity
|
||||
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local tx, ty = position.x, position.y
|
||||
local pos = entity.position
|
||||
local x, y = pos.x, pos.y
|
||||
local dx, dy = tx - x, ty - y
|
||||
local d = dx * dx + dy * dy
|
||||
-- if d >= 1024 and d <= 441398 then -- 704 in depth~
|
||||
if entity.name == 'character' then
|
||||
entity.surface.create_entity {
|
||||
name = 'artillery-projectile',
|
||||
position = position,
|
||||
target = entity,
|
||||
force = 'enemy',
|
||||
speed = arty_count.pace
|
||||
}
|
||||
elseif entity.name ~= 'character' then
|
||||
entity.surface.create_entity {
|
||||
name = 'rocket',
|
||||
position = position,
|
||||
target = entity,
|
||||
force = 'enemy',
|
||||
speed = arty_count.pace
|
||||
}
|
||||
end
|
||||
end
|
||||
-- end
|
||||
)
|
||||
|
||||
local function do_artillery_turrets_targets()
|
||||
--local surface = arty_count.surface
|
||||
local this = WPT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
--选取重炮
|
||||
local roll_table = {}
|
||||
for index, arty in pairs(arty_count.all) do
|
||||
if arty.valid then
|
||||
roll_table[#roll_table + 1] = arty
|
||||
else
|
||||
arty_count.all[index] = nil -- <- if not valid, remove from table
|
||||
arty_count.count = arty_count.count - 1
|
||||
end
|
||||
end
|
||||
if #roll_table <= 0 then
|
||||
return
|
||||
end
|
||||
local roll = math.random(1, #roll_table)
|
||||
local position = roll_table[roll].position
|
||||
|
||||
--扫描区域
|
||||
-- local normal_area = {left_top = {-480, -480}, right_bottom = {480, 480}}
|
||||
-- game.print(123)
|
||||
-- normal_area= roll_table[roll].artillery_area
|
||||
-- game.print(12)
|
||||
local entities = surface.find_entities_filtered {position = position, radius = arty_count.radius, name = artillery_target_entities, force = game.forces.player}
|
||||
|
||||
-- local entities = surface.find_entities_filtered {area = normal_area, name = artillery_target_entities, force = 'player'}
|
||||
if #entities == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
--开火
|
||||
for i = 1, arty_count.count do
|
||||
local entity = entities[math.random(#entities)]
|
||||
--game.print(entity.position)
|
||||
if entity and entity.valid then
|
||||
local data = {position = position, entity = entity}
|
||||
Task.set_timeout_in_ticks(i * 60, artillery_target_callback, data)
|
||||
end
|
||||
end
|
||||
end
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
--Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
--Event.on_nth_tick(600, add_bullet)
|
||||
Event.on_nth_tick(10, do_artillery_turrets_targets)
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
File diff suppressed because it is too large
Load Diff
@ -1,876 +0,0 @@
|
||||
--luacheck: ignore
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Alert = require 'utils.alert'
|
||||
local WPT = require 'maps.amap.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local math2d = require 'math2d'
|
||||
local Commands = require 'commands.misc'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
refill_turrets = {index = 1},
|
||||
magic_crafters = {index = 1},
|
||||
magic_fluid_crafters = {index = 1},
|
||||
art_table = {index = 1},
|
||||
surface_cleared = false
|
||||
}
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['wood'] = 16}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
this = t
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
local remove = table.remove
|
||||
local sqrt = math.sqrt
|
||||
local magic_crafters_per_tick = 3
|
||||
local magic_fluid_crafters_per_tick = 8
|
||||
local tile_damage = 50
|
||||
|
||||
local artillery_target_entities = {
|
||||
'character',
|
||||
'tank',
|
||||
'car',
|
||||
'radar',
|
||||
'lab',
|
||||
'furnace',
|
||||
'locomotive',
|
||||
'cargo-wagon',
|
||||
'fluid-wagon',
|
||||
'artillery-wagon',
|
||||
'artillery-turret',
|
||||
'laser-turret',
|
||||
'gun-turret',
|
||||
'flamethrower-turret',
|
||||
'silo',
|
||||
'spidertron'
|
||||
}
|
||||
|
||||
function Public.get_player_data(player, remove_user_data)
|
||||
local players = WPT.get('players')
|
||||
if remove_user_data then
|
||||
if players[player.index] then
|
||||
players[player.index] = nil
|
||||
end
|
||||
end
|
||||
if not players[player.index] then
|
||||
players[player.index] = {}
|
||||
end
|
||||
return players[player.index]
|
||||
end
|
||||
|
||||
local get_player_data = Public.get_player_data
|
||||
|
||||
local function debug_str(msg)
|
||||
local debug = WPT.get('debug')
|
||||
if not debug then
|
||||
return
|
||||
end
|
||||
print('Mtn: ' .. msg)
|
||||
end
|
||||
|
||||
local function show_text(msg, pos, color, surface)
|
||||
if color == nil then
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg})
|
||||
else
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg, color = color})
|
||||
end
|
||||
end
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
local count = #tbl
|
||||
if index > count then
|
||||
return
|
||||
elseif index < count then
|
||||
tbl[index] = tbl[count]
|
||||
end
|
||||
|
||||
tbl[count] = nil
|
||||
end
|
||||
|
||||
local function do_refill_turrets()
|
||||
local refill_turrets = this.refill_turrets
|
||||
local index = refill_turrets.index
|
||||
|
||||
if index > #refill_turrets then
|
||||
refill_turrets.index = 1
|
||||
return
|
||||
end
|
||||
|
||||
local turret_data = refill_turrets[index]
|
||||
local turret = turret_data.turret
|
||||
|
||||
if not turret.valid then
|
||||
fast_remove(refill_turrets, index)
|
||||
return
|
||||
end
|
||||
|
||||
refill_turrets.index = index + 1
|
||||
|
||||
local data = turret_data.data
|
||||
if data.liquid then
|
||||
turret.fluidbox[1] = data
|
||||
elseif data then
|
||||
turret.insert(data)
|
||||
end
|
||||
end
|
||||
|
||||
local function do_turret_energy()
|
||||
local power_sources = this.power_sources
|
||||
|
||||
for index = 1, #power_sources do
|
||||
local ps_data = power_sources[index]
|
||||
if not (ps_data and ps_data.valid) then
|
||||
fast_remove(power_sources, index)
|
||||
return
|
||||
end
|
||||
|
||||
ps_data.energy = 0xfffff
|
||||
end
|
||||
end
|
||||
|
||||
local function do_magic_crafters()
|
||||
local magic_crafters = this.magic_crafters
|
||||
local limit = #magic_crafters
|
||||
if limit == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local index = magic_crafters.index
|
||||
|
||||
for i = 1, magic_crafters_per_tick do
|
||||
if index > limit then
|
||||
index = 1
|
||||
end
|
||||
|
||||
local data = magic_crafters[index]
|
||||
|
||||
local entity = data.entity
|
||||
if not entity.valid then
|
||||
fast_remove(magic_crafters, index)
|
||||
limit = limit - 1
|
||||
if limit == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
index = index + 1
|
||||
|
||||
local tick = game.tick
|
||||
local last_tick = data.last_tick
|
||||
local rate = data.rate
|
||||
|
||||
local count = (tick - last_tick) * rate
|
||||
|
||||
local fcount = floor(count)
|
||||
|
||||
if fcount > 1 then
|
||||
fcount = 1
|
||||
end
|
||||
|
||||
if fcount > 0 then
|
||||
entity.get_output_inventory().insert {name = data.item, count = fcount}
|
||||
data.last_tick = tick - (count - fcount) / rate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
magic_crafters.index = index
|
||||
end
|
||||
|
||||
local function do_magic_fluid_crafters()
|
||||
local magic_fluid_crafters = this.magic_fluid_crafters
|
||||
local limit = #magic_fluid_crafters
|
||||
|
||||
if limit == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local index = magic_fluid_crafters.index
|
||||
|
||||
for i = 1, magic_fluid_crafters_per_tick do
|
||||
if index > limit then
|
||||
index = 1
|
||||
end
|
||||
|
||||
local data = magic_fluid_crafters[index]
|
||||
|
||||
local entity = data.entity
|
||||
if not entity.valid then
|
||||
fast_remove(magic_fluid_crafters, index)
|
||||
limit = limit - 1
|
||||
if limit == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
index = index + 1
|
||||
|
||||
local tick = game.tick
|
||||
local last_tick = data.last_tick
|
||||
local rate = data.rate
|
||||
|
||||
local count = (tick - last_tick) * rate
|
||||
|
||||
local fcount = floor(count)
|
||||
|
||||
if fcount > 0 then
|
||||
local fluidbox_index = data.fluidbox_index
|
||||
local fb = entity.fluidbox
|
||||
|
||||
local fb_data = fb[fluidbox_index] or {name = data.item, amount = 0}
|
||||
fb_data.amount = fb_data.amount + fcount
|
||||
fb[fluidbox_index] = fb_data
|
||||
|
||||
data.last_tick = tick - (count - fcount) / rate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
magic_fluid_crafters.index = index
|
||||
end
|
||||
|
||||
local function tick()
|
||||
do_magic_crafters()
|
||||
do_magic_fluid_crafters()
|
||||
end
|
||||
|
||||
Public.deactivate_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = false
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.neutral_force =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.force = 'neutral'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.enemy_force =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.force = 'enemy'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.active_not_destructible_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = true
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_minable_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.minable = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_minable_and_ICW_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.minable = false
|
||||
ICW.register_wagon(entity, true)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_destructible_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.destructible = false
|
||||
entity.minable = false
|
||||
end
|
||||
end
|
||||
)
|
||||
Public.disable_active_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local disable_active_callback = Public.disable_active_callback
|
||||
|
||||
Public.power_source_callback =
|
||||
Token.register(
|
||||
function(turret)
|
||||
local power_sources = this.power_sources
|
||||
power_sources[#power_sources + 1] = turret
|
||||
end
|
||||
)
|
||||
|
||||
Public.magic_item_crafting_callback =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
entity.operable = false
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = callback_data.tech
|
||||
if tech then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local recipe = callback_data.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
else
|
||||
local furance_item = callback_data.furance_item
|
||||
if furance_item then
|
||||
local inv = entity.get_inventory(defines.inventory.furnace_result)
|
||||
inv.insert(furance_item)
|
||||
end
|
||||
end
|
||||
|
||||
local p = entity.position
|
||||
local x, y = p.x, p.y
|
||||
local distance = sqrt(x * x + y * y)
|
||||
|
||||
local output = callback_data.output
|
||||
if #output == 0 then
|
||||
add_magic_crafter_output(entity, output, distance)
|
||||
else
|
||||
for i = 1, #output do
|
||||
local o = output[i]
|
||||
add_magic_crafter_output(entity, o, distance)
|
||||
end
|
||||
end
|
||||
|
||||
if not callback_data.keep_active then
|
||||
Task.set_timeout_in_ticks(2, disable_active_callback, entity) -- causes problems with refineries.
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.magic_item_crafting_callback_weighted =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
entity.operable = false
|
||||
|
||||
local weights = callback_data.weights
|
||||
local loot = callback_data.loot
|
||||
|
||||
local p = entity.position
|
||||
|
||||
local i = random() * weights.total
|
||||
|
||||
local index = table.binary_search(weights, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
local stack = loot[index].stack
|
||||
if not stack then
|
||||
return
|
||||
end
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = stack.tech
|
||||
if tech then
|
||||
if force.technologies[tech] then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local recipe = stack.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
else
|
||||
local furance_item = stack.furance_item
|
||||
if furance_item then
|
||||
local inv = entity.get_inventory(defines.inventory.furnace_result)
|
||||
inv.insert(furance_item)
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = p.x, p.y
|
||||
local distance = sqrt(x * x + y * y)
|
||||
|
||||
local output = stack.output
|
||||
if #output == 0 then
|
||||
add_magic_crafter_output(entity, output, distance)
|
||||
else
|
||||
for o_i = 1, #output do
|
||||
local o = output[o_i]
|
||||
add_magic_crafter_output(entity, o, distance)
|
||||
end
|
||||
end
|
||||
|
||||
if not callback_data.keep_active then
|
||||
Task.set_timeout_in_ticks(2, disable_active_callback, entity) -- causes problems with refineries.
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
function Public.prepare_weighted_loot(loot)
|
||||
local total = 0
|
||||
local weights = {}
|
||||
|
||||
for i = 1, #loot do
|
||||
local v = loot[i]
|
||||
total = total + v.weight
|
||||
weights[#weights + 1] = total
|
||||
end
|
||||
|
||||
weights.total = total
|
||||
|
||||
return weights
|
||||
end
|
||||
|
||||
function Public.do_random_loot(entity, weights, loot)
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
entity.operable = false
|
||||
--entity.destructible = false
|
||||
|
||||
local i = random() * weights.total
|
||||
|
||||
local index = table.binary_search(weights, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
local stack = loot[index].stack
|
||||
if not stack then
|
||||
return
|
||||
end
|
||||
|
||||
local df = stack.distance_factor
|
||||
local count
|
||||
if df then
|
||||
local p = entity.position
|
||||
local x, y = p.x, p.y
|
||||
local d = sqrt(x * x + y * y)
|
||||
|
||||
count = stack.count + d * df
|
||||
else
|
||||
count = stack.count
|
||||
end
|
||||
|
||||
entity.insert {name = stack.name, count = count}
|
||||
end
|
||||
|
||||
function Public.remove_offline_players()
|
||||
local offline_players_enabled = WPT.get('offline_players_enabled')
|
||||
if not offline_players_enabled then
|
||||
return
|
||||
end
|
||||
local offline_players = WPT.get('offline_players')
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
if #offline_players > 0 then
|
||||
local later = {}
|
||||
for i = 1, #offline_players, 1 do
|
||||
if offline_players[i] and game.players[offline_players[i].index] and game.players[offline_players[i].index].connected then
|
||||
offline_players[i] = nil
|
||||
else
|
||||
if offline_players[i] and game.players[offline_players[i].index] and offline_players[i].tick < game.tick - 54000 then
|
||||
local name = offline_players[i].name
|
||||
player_inv[1] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_main)
|
||||
player_inv[2] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_armor)
|
||||
player_inv[3] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_guns)
|
||||
player_inv[4] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_ammo)
|
||||
player_inv[5] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_trash)
|
||||
local pos = game.forces.player.get_spawn_position(surface)
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
local inv = e.get_inventory(defines.inventory.character_main)
|
||||
e.character_inventory_slots_bonus = #player_inv[1]
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
for iii = 1, #player_inv[ii], 1 do
|
||||
if player_inv[ii][iii].valid then
|
||||
items[#items + 1] = player_inv[ii][iii]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #items > 0 then
|
||||
for item = 1, #items, 1 do
|
||||
if items[item].valid then
|
||||
inv.insert(items[item])
|
||||
end
|
||||
end
|
||||
|
||||
local message = ({'main.cleaner', name})
|
||||
local data = {
|
||||
position = pos
|
||||
}
|
||||
Alert.alert_all_players_location(data, message)
|
||||
|
||||
e.die('neutral')
|
||||
else
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
player_inv[ii].clear()
|
||||
end
|
||||
end
|
||||
offline_players[i] = nil
|
||||
else
|
||||
later[#later + 1] = offline_players[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, _ in pairs(offline_players) do
|
||||
offline_players[k] = nil
|
||||
end
|
||||
if #later > 0 then
|
||||
for i = 1, #later, 1 do
|
||||
offline_players[#offline_players + 1] = later[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function calc_players()
|
||||
local players = game.connected_players
|
||||
local check_afk_players = WPT.get('check_afk_players')
|
||||
if not check_afk_players then
|
||||
return #players
|
||||
end
|
||||
local total = 0
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player.afk_time < 36000 then
|
||||
total = total + 1
|
||||
end
|
||||
end
|
||||
if total <= 0 then
|
||||
total = 1
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
function Public.on_player_joined_game(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
local reward = require 'maps.amap.main'.reward
|
||||
local player_data = get_player_data(player)
|
||||
if not player_data.first_join then
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local wave_number = WD.get('wave_number')
|
||||
local this = WPT.get()
|
||||
|
||||
for i = 0, this.science do
|
||||
local point = math.floor(math.random(1, 5))
|
||||
local money = math.floor(math.random(1, 100))
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + point
|
||||
player.insert {name = 'coin', count = money}
|
||||
player.print({'amap.science', point, money}, {r = 0.22, g = 0.88, b = 0.22})
|
||||
end
|
||||
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + wave_number * 10
|
||||
|
||||
player_data.first_join = true
|
||||
player.print({'amap.joingame'})
|
||||
end
|
||||
if player.surface.index ~= active_surface_index then
|
||||
--player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 20, 1, false) or {x=0,y=0}, surface)
|
||||
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 20, 1, false) or {x = 0, y = 0}, surface)
|
||||
else
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 20, 1, false) or {x = 0, y = 0}, surface)
|
||||
--player.teleport({x=0,y=0}, surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.is_creativity_mode_on()
|
||||
local creative_enabled = Commands.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
WD.set('next_wave', 1000)
|
||||
Collapse.start_now(true)
|
||||
Public.set_difficulty()
|
||||
end
|
||||
end
|
||||
local function on_player_mined_entity(event)
|
||||
local name = event.entity.name
|
||||
local entity = event.entity
|
||||
local this = WPT.get()
|
||||
if name == 'flamethrower-turret' then
|
||||
this.flame = this.flame - 1
|
||||
|
||||
if this.flame <= 0 then
|
||||
this.flame = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
function Public.disable_creative()
|
||||
local creative_enabled = Commands.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
Commands.set('creative_enabled', false)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_pre_player_left_game(event)
|
||||
local offline_players_enabled = WPT.get('offline_players_enabled')
|
||||
if not offline_players_enabled then
|
||||
return
|
||||
end
|
||||
|
||||
local offline_players = WPT.get('offline_players')
|
||||
local player = game.players[event.player_index]
|
||||
local ticker = game.tick
|
||||
if player.character then
|
||||
offline_players[#offline_players + 1] = {
|
||||
index = event.player_index,
|
||||
name = player.name,
|
||||
tick = ticker
|
||||
}
|
||||
end
|
||||
end
|
||||
local on_player_or_robot_built_entity = function(event)
|
||||
--change_pos 改变位置
|
||||
local name = event.created_entity.name
|
||||
local entity = event.created_entity
|
||||
local this = WPT.get()
|
||||
if name == 'flamethrower-turret' then
|
||||
if this.flame >= 15 then
|
||||
game.print({'amap.too_many'})
|
||||
entity.destroy()
|
||||
else
|
||||
this.flame = this.flame + 1
|
||||
game.print({'amap.ok_many', this.flame})
|
||||
end
|
||||
end
|
||||
if name == 'stone-wall' then
|
||||
local this = WPT.get()
|
||||
if not this.change then
|
||||
local wave_defense_table = WD.get_table()
|
||||
local dx = entity.position.x - this.pos.x
|
||||
local dy = entity.position.y - this.pos.y
|
||||
|
||||
if dx < 0 then
|
||||
dx = -dx
|
||||
end
|
||||
if dy < 0 then
|
||||
dy = -dy
|
||||
end
|
||||
local d = dx + dy
|
||||
if d < 100 then
|
||||
this.change = true
|
||||
end
|
||||
end
|
||||
|
||||
--game.print(dx)
|
||||
--game.print(dy)
|
||||
--game.print('差值为')
|
||||
--game.print(d)
|
||||
--game.print('出生地为')
|
||||
--game.print(this.pos)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_respawned(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
if player_data.died then
|
||||
player_data.died = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_died(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
player_data.died = true
|
||||
end
|
||||
|
||||
function Public.on_player_changed_position(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
if not active_surface_index then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local map_name = 'amap'
|
||||
|
||||
if string.sub(player.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
local config_tile = WPT.get('void_or_tile')
|
||||
if config_tile == 'lab-dark-2' then
|
||||
if get_tile.valid and get_tile.name == 'lab-dark-2' then
|
||||
if random(1, 2) == 1 then
|
||||
if random(1, 2) == 1 then
|
||||
show_text('This path is not for players!', p, {r = 0.98, g = 0.66, b = 0.22}, surface)
|
||||
end
|
||||
player.surface.create_entity({name = 'fire-flame', position = player.position})
|
||||
player.character.health = player.character.health - tile_damage
|
||||
if player.character.health == 0 then
|
||||
player.character.die()
|
||||
local message = ({'main.death_message_' .. random(1, 7), player.name})
|
||||
game.print(message, {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if position.y >= 74 then
|
||||
player.teleport({position.x, position.y - 1}, surface)
|
||||
player.print(({'main.forcefield'}), {r = 0.98, g = 0.66, b = 0.22})
|
||||
if player.character then
|
||||
player.character.health = player.character.health - 5
|
||||
player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local disable_recipes = function()
|
||||
local force = game.forces.player
|
||||
force.recipes['car'].enabled = false
|
||||
force.recipes['tank'].enabled = false
|
||||
force.recipes['pistol'].enabled = false
|
||||
force.recipes['land-mine'].enabled = false
|
||||
force.recipes['spidertron-remote'].enabled = false
|
||||
-- force.recipes['flamethrower-turret'].enabled = false
|
||||
end
|
||||
|
||||
function Public.disable_tech()
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].researched = false
|
||||
disable_recipes()
|
||||
end
|
||||
|
||||
local disable_tech = Public.disable_tech
|
||||
function Public.on_research_finished(event)
|
||||
disable_tech()
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local name = event.entity.name
|
||||
|
||||
local entity = event.entity
|
||||
local this = WPT.get()
|
||||
if name == 'flamethrower-turret' then
|
||||
this.flame = this.flame - 1
|
||||
|
||||
if this.flame <= 0 then
|
||||
this.flame = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
Public.firearm_magazine_ammo = {name = 'firearm-magazine', count = 200}
|
||||
Public.piercing_rounds_magazine_ammo = {name = 'piercing-rounds-magazine', count = 200}
|
||||
Public.uranium_rounds_magazine_ammo = {name = 'uranium-rounds-magazine', count = 200}
|
||||
Public.light_oil_ammo = {name = 'light-oil', amount = 100}
|
||||
Public.artillery_shell_ammo = {name = 'artillery-shell', count = 15}
|
||||
Public.laser_turrent_power_source = {buffer_size = 2400000, power_production = 40000}
|
||||
|
||||
function Public.reset_table()
|
||||
this.power_sources = {index = 1}
|
||||
this.refill_turrets = {index = 1}
|
||||
this.magic_crafters = {index = 1}
|
||||
this.magic_fluid_crafters = {index = 1}
|
||||
end
|
||||
|
||||
local on_research_finished = Public.on_research_finished
|
||||
local on_player_joined_game = Public.on_player_joined_game
|
||||
local on_player_respawned = Public.on_player_respawned
|
||||
local on_player_died = Public.on_player_died
|
||||
local on_player_changed_position = Public.on_player_changed_position
|
||||
local on_pre_player_left_game = Public.on_pre_player_left_game
|
||||
|
||||
Event.add(defines.events.on_built_entity, on_player_or_robot_built_entity)
|
||||
Event.add(defines.events.on_robot_built_entity, on_player_or_robot_built_entity)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_robot_mined_entity, on_player_mined_entity)
|
||||
--Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game)
|
||||
Event.on_nth_tick(10, tick)
|
||||
Event.on_nth_tick(5, do_turret_energy)
|
||||
|
||||
return Public
|
@ -1,958 +0,0 @@
|
||||
local Utils = require 'utils.core'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local IC_Gui = require 'maps.amap.ic.gui'
|
||||
local WPT = require 'maps.amap.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Public = {}
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local function validate_entity(entity)
|
||||
if not (entity and entity.valid) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function log_err(ic, err)
|
||||
if ic.debug_mode then
|
||||
if type(err) == 'string' then
|
||||
log('IC: ' .. err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_trusted_system(this, player)
|
||||
if not this.trust_system[player.index] then
|
||||
this.trust_system[player.index] = {
|
||||
[player.name] = true
|
||||
}
|
||||
end
|
||||
|
||||
return this.trust_system[player.index]
|
||||
end
|
||||
|
||||
local function upperCase(str)
|
||||
return (str:gsub('^%l', string.upper))
|
||||
end
|
||||
|
||||
local function render_owner_text(renders, player, entity, new_owner)
|
||||
local 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
|
||||
}
|
||||
if renders[player.index] then
|
||||
rendering.destroy(renders[player.index])
|
||||
end
|
||||
if new_owner then
|
||||
renders[new_owner.index] =
|
||||
rendering.draw_text {
|
||||
text = '## - ' .. new_owner.name .. "'s " .. entity.name .. ' - ##',
|
||||
surface = entity.surface,
|
||||
target = entity,
|
||||
target_offset = {0, -2.6},
|
||||
color = color,
|
||||
scale = 1.05,
|
||||
font = 'default-large-semibold',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
else
|
||||
renders[player.index] =
|
||||
rendering.draw_text {
|
||||
text = '## - ' .. player.name .. "'s " .. entity.name .. ' - ##',
|
||||
surface = entity.surface,
|
||||
target = entity,
|
||||
target_offset = {0, -2.6},
|
||||
color = color,
|
||||
scale = 1.05,
|
||||
font = 'default-large-semibold',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
entity.color = color
|
||||
end
|
||||
|
||||
local function kill_doors(ic, car)
|
||||
if not validate_entity(car.entity) then
|
||||
return
|
||||
end
|
||||
for k, e in pairs(car.doors) do
|
||||
ic.doors[e.unit_number] = nil
|
||||
e.destroy()
|
||||
car.doors[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function get_owner_car_object(cars, player)
|
||||
for k, car in pairs(cars) do
|
||||
if car.owner == player.index then
|
||||
return k
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_entity_from_player_surface(cars, player)
|
||||
for k, car in pairs(cars) do
|
||||
if validate_entity(car.entity) then
|
||||
if validate_entity(car.surface) then
|
||||
if car.surface.index == player.surface.index then
|
||||
return car.entity
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_owner_car_surface(cars, player, target)
|
||||
for k, car in pairs(cars) do
|
||||
if car.owner == player.index then
|
||||
if validate_entity(car.surface) then
|
||||
if car.surface.index == target.surface.index then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_player_surface(ic, player)
|
||||
local surfaces = ic.surfaces
|
||||
for _, surface in pairs(surfaces) do
|
||||
if validate_entity(surface) then
|
||||
if surface.index == player.surface.index then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_player_entity(ic, player)
|
||||
local cars = ic.cars
|
||||
for k, car in pairs(cars) do
|
||||
if car.owner == player.index and type(car.entity) == 'boolean' then
|
||||
return car.name, true
|
||||
elseif car.owner == player.index then
|
||||
return car.name, false
|
||||
end
|
||||
end
|
||||
return false, false
|
||||
end
|
||||
|
||||
local function get_owner_car_name(ic, player)
|
||||
local cars = ic.cars
|
||||
local saved_surfaces = ic.saved_surfaces
|
||||
local index = saved_surfaces[player.index]
|
||||
for k, car in pairs(cars) do
|
||||
if not index then
|
||||
return false
|
||||
end
|
||||
if car.owner == player.index then
|
||||
return car.name
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_saved_entity(entity, index)
|
||||
if index and index.name ~= entity.name then
|
||||
local msg =
|
||||
table.concat(
|
||||
{
|
||||
'The built entity is not the same as the saved one. ',
|
||||
'Saved entity is: ' .. upperCase(index.name) .. ' - Built entity is: ' .. upperCase(entity.name) .. '. '
|
||||
}
|
||||
)
|
||||
return false, msg
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function replace_entity(cars, entity, index)
|
||||
local unit_number = entity.unit_number
|
||||
for k, car in pairs(cars) do
|
||||
if car.saved_entity == index.saved_entity then
|
||||
local c = car
|
||||
cars[unit_number] = c
|
||||
cars[unit_number].entity = entity
|
||||
cars[unit_number].saved_entity = nil
|
||||
cars[unit_number].transfer_entities = car.transfer_entities
|
||||
cars[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function replace_doors(doors, entity, index)
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
for k, door in pairs(doors) do
|
||||
local unit_number = entity.unit_number
|
||||
if index.saved_entity == door then
|
||||
doors[k] = unit_number
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function replace_surface(surfaces, entity, index)
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
for k, surface in pairs(surfaces) do
|
||||
local unit_number = entity.unit_number
|
||||
if tostring(index.saved_entity) == surface.name then
|
||||
if validate_entity(surface) then
|
||||
surface.name = tostring(unit_number)
|
||||
surfaces[unit_number] = surface
|
||||
surfaces[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function replace_surface_entity(cars, entity, index)
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
for _, car in pairs(cars) do
|
||||
local unit_number = entity.unit_number
|
||||
if index and index.saved_entity == car.saved_entity then
|
||||
if validate_entity(car.surface) then
|
||||
car.surface.name = tostring(unit_number)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function remove_logistics(car)
|
||||
local chests = car.transfer_entities
|
||||
for k, chest in pairs(chests) do
|
||||
car.transfer_entities[k] = nil
|
||||
chest.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local function set_new_area(ic, car)
|
||||
local new_area = ic.car_areas
|
||||
local name = car.name
|
||||
local apply_area = new_area[name]
|
||||
car.area = apply_area
|
||||
end
|
||||
|
||||
local function upgrade_surface(ic, player, entity)
|
||||
local ce = entity
|
||||
local saved_surfaces = ic.saved_surfaces
|
||||
local cars = ic.cars
|
||||
local door = ic.doors
|
||||
local surfaces = ic.surfaces
|
||||
local index = saved_surfaces[player.index]
|
||||
if not index then
|
||||
return
|
||||
end
|
||||
|
||||
if saved_surfaces[player.index] then
|
||||
local c = get_owner_car_object(cars, player)
|
||||
local car = ic.cars[c]
|
||||
if ce.name == 'spidertron' then
|
||||
car.name = 'spidertron'
|
||||
elseif ce.name == 'tank' then
|
||||
car.name = 'tank'
|
||||
end
|
||||
set_new_area(ic, car)
|
||||
remove_logistics(car)
|
||||
replace_entity(cars, ce, index)
|
||||
replace_doors(door, ce, index)
|
||||
replace_surface(surfaces, ce, index)
|
||||
replace_surface_entity(cars, ce, index)
|
||||
kill_doors(ic, car)
|
||||
Public.create_car_room(ic, car)
|
||||
saved_surfaces[player.index] = nil
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function save_surface(ic, entity, player)
|
||||
local car = ic.cars[entity.unit_number]
|
||||
|
||||
car.entity = false
|
||||
car.saved_entity = entity.unit_number
|
||||
|
||||
ic.saved_surfaces[player.index] = {saved_entity = entity.unit_number, name = entity.name}
|
||||
end
|
||||
|
||||
local function kick_players_out_of_vehicles(car)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local character = player.character
|
||||
if validate_entity(character) and character.driving then
|
||||
if car.surface == player.surface then
|
||||
character.driving = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function kick_players_from_surface(ic, car)
|
||||
if not validate_entity(car.surface) then
|
||||
return log_err('Car surface was not valid.')
|
||||
end
|
||||
if not car.entity or not car.entity.valid then
|
||||
local main_surface = game.surfaces[ic.allowed_surface]
|
||||
if validate_entity(main_surface) then
|
||||
for _, e in pairs(car.surface.find_entities_filtered({area = car.area})) do
|
||||
if validate_entity(e) and e.name == 'character' and e.player then
|
||||
e.player.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
return log_err('Car entity was not valid.')
|
||||
end
|
||||
|
||||
for _, e in pairs(car.surface.find_entities_filtered({area = car.area})) do
|
||||
if validate_entity(e) and e.name == 'character' and e.player then
|
||||
local p = car.entity.surface.find_non_colliding_position('character', car.entity.position, 128, 0.5)
|
||||
if p then
|
||||
e.player.teleport(p, car.entity.surface)
|
||||
else
|
||||
e.player.teleport(car.entity.position, car.entity.surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function kick_player_from_surface(ic, player, target)
|
||||
local cars = ic.cars
|
||||
|
||||
local main_surface = game.surfaces[ic.allowed_surface]
|
||||
if not validate_entity(main_surface) then
|
||||
return
|
||||
end
|
||||
|
||||
local c = get_owner_car_object(cars, player)
|
||||
local car = ic.cars[c]
|
||||
|
||||
if not validate_entity(car.entity) then
|
||||
return
|
||||
end
|
||||
|
||||
if validate_entity(player) then
|
||||
if validate_entity(target) then
|
||||
local locate = get_owner_car_surface(cars, player, target)
|
||||
if locate then
|
||||
local p = car.entity.surface.find_non_colliding_position('character', car.entity.position, 128, 0.5)
|
||||
if p then
|
||||
target.teleport(p, car.entity.surface)
|
||||
else
|
||||
target.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface)
|
||||
end
|
||||
target.print('You were kicked out of ' .. player.name .. ' vehicle.', Color.warning)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function restore_surface(ic, player, entity)
|
||||
local ce = entity
|
||||
local saved_surfaces = ic.saved_surfaces
|
||||
local cars = ic.cars
|
||||
local door = ic.doors
|
||||
local renders = ic.renders
|
||||
local surfaces = ic.surfaces
|
||||
local index = saved_surfaces[player.index]
|
||||
if not index then
|
||||
return
|
||||
end
|
||||
|
||||
if saved_surfaces[player.index] then
|
||||
local success, msg = get_saved_entity(ce, index)
|
||||
if not success then
|
||||
player.print(msg, Color.warning)
|
||||
return true
|
||||
end
|
||||
replace_entity(cars, ce, index)
|
||||
replace_doors(door, ce, index)
|
||||
replace_surface(surfaces, ce, index)
|
||||
replace_surface_entity(cars, ce, index)
|
||||
saved_surfaces[player.index] = nil
|
||||
render_owner_text(renders, player, ce)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function input_filtered(car_inv, chest, chest_inv, free_slots)
|
||||
local request_stacks = {}
|
||||
|
||||
local prototypes = game.item_prototypes
|
||||
for slot_index = 1, 30, 1 do
|
||||
local stack = chest.get_request_slot(slot_index)
|
||||
if stack then
|
||||
request_stacks[stack.name] = 10 * prototypes[stack.name].stack_size
|
||||
end
|
||||
end
|
||||
for i = 1, #car_inv - 1, 1 do
|
||||
if free_slots <= 0 then
|
||||
return
|
||||
end
|
||||
local stack = car_inv[i]
|
||||
if stack.valid_for_read then
|
||||
local request_stack = request_stacks[stack.name]
|
||||
if request_stack and request_stack > chest_inv.get_item_count(stack.name) then
|
||||
chest_inv.insert(stack)
|
||||
stack.clear()
|
||||
free_slots = free_slots - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function input_cargo(car, chest)
|
||||
if not chest.request_from_buffers then
|
||||
return
|
||||
end
|
||||
|
||||
local car_entity = car.entity
|
||||
if not validate_entity(car_entity) then
|
||||
return
|
||||
end
|
||||
|
||||
local car_inventory = car_entity.get_inventory(defines.inventory.car_trunk)
|
||||
if car_inventory.is_empty() then
|
||||
return
|
||||
end
|
||||
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
local free_slots = 0
|
||||
|
||||
for i = 1, chest_inventory.get_bar() - 1, 1 do
|
||||
if not chest_inventory[i].valid_for_read then
|
||||
free_slots = free_slots + 1
|
||||
end
|
||||
end
|
||||
|
||||
if chest.get_request_slot(1) then
|
||||
input_filtered(car_inventory, chest, chest_inventory, free_slots)
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, #car_inventory - 1, 1 do
|
||||
if free_slots <= 0 then
|
||||
return
|
||||
end
|
||||
if car_inventory[i].valid_for_read then
|
||||
chest_inventory.insert(car_inventory[i])
|
||||
car_inventory[i].clear()
|
||||
free_slots = free_slots - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function output_cargo(car, passive_chest)
|
||||
if not validate_entity(car.entity) then
|
||||
return
|
||||
end
|
||||
|
||||
if not passive_chest.valid then
|
||||
return
|
||||
end
|
||||
local chest1 = passive_chest.get_inventory(defines.inventory.chest)
|
||||
local chest2 = car.entity.get_inventory(defines.inventory.car_trunk)
|
||||
for k, v in pairs(chest1.get_contents()) do
|
||||
local t = {name = k, count = v}
|
||||
local c = chest2.insert(t)
|
||||
if (c > 0) then
|
||||
chest1.remove({name = k, count = c})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local transfer_functions = {
|
||||
['logistic-chest-requester'] = input_cargo,
|
||||
['logistic-chest-passive-provider'] = output_cargo
|
||||
}
|
||||
|
||||
local function construct_doors(ic, car)
|
||||
local area = car.area
|
||||
local surface = car.surface
|
||||
|
||||
for _, x in pairs({area.left_top.x - 1.5, area.right_bottom.x + 1.5}) do
|
||||
local p = {x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({{name = main_tile_name, position = {x = p.x + 0.5, y = p.y}}}, true)
|
||||
else
|
||||
surface.set_tiles({{name = main_tile_name, position = {x = p.x - 1, y = p.y}}}, true)
|
||||
end
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'car',
|
||||
position = {x, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)},
|
||||
force = 'neutral',
|
||||
create_build_effect_smoke = false
|
||||
}
|
||||
)
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
e.get_inventory(defines.inventory.fuel).insert({name = 'coal', count = 1})
|
||||
ic.doors[e.unit_number] = car.entity.unit_number
|
||||
car.doors[#car.doors + 1] = e
|
||||
end
|
||||
end
|
||||
|
||||
local function get_player_data(ic, player)
|
||||
local player_data = ic.players[player.index]
|
||||
if ic.players[player.index] then
|
||||
return player_data
|
||||
end
|
||||
local fallback = WPT.get('active_surface_index')
|
||||
if not fallback then
|
||||
fallback = 1
|
||||
end
|
||||
|
||||
ic.players[player.index] = {
|
||||
surface = 1,
|
||||
fallback_surface = tonumber(fallback),
|
||||
notified = false
|
||||
}
|
||||
return ic.players[player.index]
|
||||
end
|
||||
|
||||
local remove_car =
|
||||
Token.register(
|
||||
function(data)
|
||||
local player = data.player
|
||||
local car = data.car
|
||||
player.remove_item({name = car.name, count = 1})
|
||||
end
|
||||
)
|
||||
|
||||
function Public.save_car(ic, event)
|
||||
local entity = event.entity
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local car = ic.cars[entity.unit_number]
|
||||
|
||||
if not car then
|
||||
log_err('Car was not valid.')
|
||||
return
|
||||
end
|
||||
|
||||
local position = entity.position
|
||||
local health = entity.health
|
||||
|
||||
kick_players_out_of_vehicles(car)
|
||||
kick_players_from_surface(ic, car)
|
||||
get_player_data(ic, player)
|
||||
|
||||
if car.owner == player.index then
|
||||
save_surface(ic, entity, player)
|
||||
if not ic.players[player.index].notified then
|
||||
player.print(player.name .. ', the ' .. car.name .. ' has been saved', Color.success)
|
||||
|
||||
ic.players[player.index].notified = true
|
||||
|
||||
local wave_number = WD.get('wave_number')
|
||||
--game.print(type(wave_number))
|
||||
local a = 100
|
||||
|
||||
if (wave_number <= a) then
|
||||
player.print({'amap.usecar'}, Color.warning)
|
||||
else
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + 50
|
||||
player.print({'amap.usecar2'}, Color.success)
|
||||
end
|
||||
end
|
||||
else
|
||||
local p = game.players[car.owner]
|
||||
if not p then
|
||||
return
|
||||
end
|
||||
|
||||
log_err(ic, 'Owner of this vehicle is: ' .. p.name)
|
||||
save_surface(ic, entity, p)
|
||||
Utils.action_warning('{Car}', player.name .. ' has looted ' .. p.name .. '´s car.')
|
||||
player.print('This car was not yours to keep.', Color.warning)
|
||||
local params = {
|
||||
player = player,
|
||||
car = car
|
||||
}
|
||||
Task.set_timeout_in_ticks(10, remove_car, params)
|
||||
if ic.restore_on_theft then
|
||||
local e = player.surface.create_entity({name = car.name, position = position, force = player.force, create_build_effect_smoke = false})
|
||||
e.health = health
|
||||
restore_surface(ic, p, e)
|
||||
else
|
||||
p.insert({name = car.name, count = 1, health = health})
|
||||
p.print('Your car was stolen from you - the gods foresaw this and granted you a new one.', Color.info)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.kill_car(ic, entity)
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
|
||||
local entity_type = ic.entity_type
|
||||
|
||||
if not entity_type[entity.type] then
|
||||
return
|
||||
end
|
||||
|
||||
local car = ic.cars[entity.unit_number]
|
||||
local surface = car.surface
|
||||
kick_players_out_of_vehicles(car)
|
||||
kill_doors(ic, car)
|
||||
kick_players_from_surface(ic, car)
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = car.area})) do
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
end
|
||||
for _, x in pairs({car.area.left_top.x - 1.5, car.area.right_bottom.x + 1.5}) do
|
||||
local p = {x = x, y = car.area.left_top.y + ((car.area.right_bottom.y - car.area.left_top.y) * 0.5)}
|
||||
surface.set_tiles({{name = 'out-of-map', position = {x = p.x + 0.5, y = p.y}}}, true)
|
||||
surface.set_tiles({{name = 'out-of-map', position = {x = p.x - 1, y = p.y}}}, true)
|
||||
end
|
||||
car.entity.force.chart(surface, car.area)
|
||||
game.delete_surface(surface)
|
||||
ic.surfaces[entity.unit_number] = nil
|
||||
ic.cars[entity.unit_number] = nil
|
||||
end
|
||||
|
||||
function Public.validate_owner(ic, player, entity)
|
||||
if validate_entity(entity) then
|
||||
local cars = ic.cars
|
||||
local unit_number = entity.unit_number
|
||||
local car = cars[unit_number]
|
||||
if not car then
|
||||
return
|
||||
end
|
||||
if validate_entity(car.entity) then
|
||||
local p = game.players[car.owner]
|
||||
local list = get_trusted_system(ic, p)
|
||||
if p and p.valid and p.connected then
|
||||
if list[player.name] then
|
||||
return
|
||||
end
|
||||
end
|
||||
if p then
|
||||
if car.owner ~= player.index and player.driving then
|
||||
player.driving = false
|
||||
if not player.admin then
|
||||
return Utils.print_to(nil, '{Car} ' .. player.name .. ' tried to drive ' .. p.name .. '´s car.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Public.create_room_surface(ic, unit_number)
|
||||
if game.surfaces[tostring(unit_number)] then
|
||||
return game.surfaces[tostring(unit_number)]
|
||||
end
|
||||
|
||||
local map_gen_settings = {
|
||||
['width'] = 2,
|
||||
['height'] = 2,
|
||||
['water'] = 0,
|
||||
['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 = false}
|
||||
}
|
||||
}
|
||||
local surface = game.create_surface(tostring(unit_number), map_gen_settings)
|
||||
surface.freeze_daytime = true
|
||||
surface.daytime = 0.1
|
||||
surface.request_to_generate_chunks({16, 16}, 1)
|
||||
surface.force_generate_chunk_requests()
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
end
|
||||
ic.surfaces[unit_number] = surface
|
||||
return surface
|
||||
end
|
||||
|
||||
function Public.create_car_room(ic, car)
|
||||
local surface = car.surface
|
||||
local car_areas = ic.car_areas
|
||||
local entity_name = car.name
|
||||
local area = car_areas[entity_name]
|
||||
local tiles = {}
|
||||
|
||||
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
|
||||
for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do
|
||||
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
|
||||
end
|
||||
end
|
||||
for x = -3, 2, 1 do
|
||||
for y = area.right_bottom.y - 4, area.right_bottom.y - 2, 1 do
|
||||
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
|
||||
end
|
||||
end
|
||||
|
||||
local fishes = {}
|
||||
|
||||
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
|
||||
for y = -0, 1, 1 do
|
||||
tiles[#tiles + 1] = {name = 'water', position = {x, y}}
|
||||
fishes[#fishes + 1] = {name = 'fish', position = {x, y}}
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
for _, fish in pairs(fishes) do
|
||||
surface.create_entity(fish)
|
||||
end
|
||||
|
||||
construct_doors(ic, car)
|
||||
local mgs = surface.map_gen_settings
|
||||
mgs.width = area.right_bottom.x * 2
|
||||
mgs.height = area.right_bottom.y * 2
|
||||
surface.map_gen_settings = mgs
|
||||
local lx, ly, rx, ry = 4, 1, 5, 1
|
||||
|
||||
local position1 = {area.left_top.x + lx, area.left_top.y + ly}
|
||||
local position2 = {area.right_bottom.x - rx, area.left_top.y + ry}
|
||||
|
||||
local e1 =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'logistic-chest-requester',
|
||||
position = position1,
|
||||
force = 'neutral',
|
||||
create_build_effect_smoke = false
|
||||
}
|
||||
)
|
||||
e1.destructible = false
|
||||
e1.minable = false
|
||||
|
||||
local e2 =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'logistic-chest-passive-provider',
|
||||
position = position2,
|
||||
force = 'neutral',
|
||||
create_build_effect_smoke = false
|
||||
}
|
||||
)
|
||||
e2.destructible = false
|
||||
e2.minable = false
|
||||
car.transfer_entities = {e1, e2}
|
||||
return
|
||||
end
|
||||
|
||||
function Public.create_car(ic, event)
|
||||
local ce = event.created_entity
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
local map_name = ic.allowed_surface
|
||||
|
||||
local entity_type = ic.entity_type
|
||||
local un = ce.unit_number
|
||||
|
||||
if not un then
|
||||
return
|
||||
end
|
||||
|
||||
if not entity_type[ce.type] then
|
||||
return
|
||||
end
|
||||
|
||||
local name, mined = get_player_entity(ic, player)
|
||||
|
||||
if entity_type[name] and not mined then
|
||||
return player.print('Multiple vehicles are not supported at the moment.', Color.warning)
|
||||
end
|
||||
|
||||
if string.sub(ce.surface.name, 0, #map_name) ~= map_name then
|
||||
return player.print('Multi-surface is not supported at the moment.', Color.warning)
|
||||
end
|
||||
|
||||
if
|
||||
get_owner_car_name(ic, player) == 'car' and ce.name == 'tank' or get_owner_car_name(ic, player) == 'car' and ce.name == 'spidertron' or
|
||||
get_owner_car_name(ic, player) == 'tank' and ce.name == 'spidertron'
|
||||
then
|
||||
upgrade_surface(ic, player, ce)
|
||||
render_owner_text(ic.renders, player, ce)
|
||||
player.print('Your car-surface has been upgraded!', Color.success)
|
||||
return
|
||||
end
|
||||
|
||||
local saved_surface = restore_surface(ic, player, ce)
|
||||
if saved_surface then
|
||||
return
|
||||
end
|
||||
|
||||
local car_areas = ic.car_areas
|
||||
local car_area = car_areas[ce.name]
|
||||
|
||||
ic.cars[un] = {
|
||||
entity = ce,
|
||||
area = {
|
||||
left_top = {x = car_area.left_top.x, y = car_area.left_top.y},
|
||||
right_bottom = {x = car_area.right_bottom.x, y = car_area.right_bottom.y}
|
||||
},
|
||||
doors = {},
|
||||
owner = player.index,
|
||||
name = ce.name
|
||||
}
|
||||
|
||||
local car = ic.cars[un]
|
||||
|
||||
car.surface = Public.create_room_surface(ic, un)
|
||||
Public.create_car_room(ic, car)
|
||||
render_owner_text(ic.renders, player, ce)
|
||||
|
||||
return car
|
||||
end
|
||||
|
||||
function Public.remove_invalid_cars(ic)
|
||||
for k, car in pairs(ic.cars) do
|
||||
if type(car.entity) ~= 'boolean' then
|
||||
if not validate_entity(car.entity) then
|
||||
ic.cars[k] = nil
|
||||
for key, value in pairs(ic.doors) do
|
||||
if k == value then
|
||||
ic.doors[key] = nil
|
||||
end
|
||||
end
|
||||
kick_players_from_surface(ic, car)
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, surface in pairs(ic.surfaces) do
|
||||
if not ic.cars[tonumber(surface.name)] then
|
||||
game.delete_surface(surface)
|
||||
ic.surfaces[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.use_door_with_entity(ic, player, door)
|
||||
local player_data = get_player_data(ic, player)
|
||||
if player_data.state then
|
||||
player_data.state = player_data.state - 1
|
||||
if player_data.state == 0 then
|
||||
player_data.state = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not validate_entity(door) then
|
||||
return
|
||||
end
|
||||
local doors = ic.doors
|
||||
local cars = ic.cars
|
||||
|
||||
local car = false
|
||||
if doors[door.unit_number] then
|
||||
car = cars[doors[door.unit_number]]
|
||||
end
|
||||
if cars[door.unit_number] then
|
||||
car = cars[door.unit_number]
|
||||
end
|
||||
if not car then
|
||||
return
|
||||
end
|
||||
|
||||
local owner = game.players[car.owner]
|
||||
local list = get_trusted_system(ic, owner)
|
||||
if owner and owner.valid and player.connected then
|
||||
if not list[player.name] and not player.admin then
|
||||
player.driving = false
|
||||
return player.print('You have not been approved by ' .. owner.name .. ' to enter their vehicle.', Color.warning)
|
||||
end
|
||||
end
|
||||
|
||||
player_data.fallback_surface = car.entity.surface.index
|
||||
player_data.fallback_position = {car.entity.position.x, car.entity.position.y}
|
||||
|
||||
if car.entity.surface.name == player.surface.name then
|
||||
local surface = car.surface
|
||||
if validate_entity(car.entity) and car.owner == player.index then
|
||||
IC_Gui.add_toolbar(player)
|
||||
car.entity.minable = false
|
||||
end
|
||||
|
||||
if not validate_entity(surface) then
|
||||
return
|
||||
end
|
||||
|
||||
local area = car.area
|
||||
local x_vector = door.position.x - player.position.x
|
||||
local position
|
||||
if x_vector > 0 then
|
||||
position = {area.left_top.x + 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
else
|
||||
position = {area.right_bottom.x - 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
end
|
||||
local p = surface.find_non_colliding_position('character', position, 128, 0.5)
|
||||
if p then
|
||||
player.teleport(p, surface)
|
||||
else
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
player_data.surface = surface.index
|
||||
else
|
||||
if validate_entity(car.entity) and car.owner == player.index then
|
||||
IC_Gui.remove_toolbar(player)
|
||||
car.entity.minable = true
|
||||
end
|
||||
local surface = car.entity.surface
|
||||
local x_vector = (door.position.x / math.abs(door.position.x)) * 2
|
||||
local position = {car.entity.position.x + x_vector, car.entity.position.y}
|
||||
local surface_position = surface.find_non_colliding_position('character', position, 128, 0.5)
|
||||
if car.entity.type == 'car' or car.entity.name == 'spidertron' then
|
||||
player.teleport(surface_position, surface)
|
||||
player_data.state = 2
|
||||
player.driving = true
|
||||
else
|
||||
player.teleport(surface_position, surface)
|
||||
end
|
||||
player_data.surface = surface.index
|
||||
end
|
||||
end
|
||||
|
||||
function Public.item_transfer(ic)
|
||||
for _, car in pairs(ic.cars) do
|
||||
if validate_entity(car.entity) then
|
||||
if car.transfer_entities then
|
||||
for k, e in pairs(car.transfer_entities) do
|
||||
if validate_entity(e) then
|
||||
transfer_functions[e.name](car, e)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Public.kick_player_from_surface = kick_player_from_surface
|
||||
Public.get_player_surface = get_player_surface
|
||||
Public.get_entity_from_player_surface = get_entity_from_player_surface
|
||||
Public.get_owner_car_object = get_owner_car_object
|
||||
Public.render_owner_text = render_owner_text
|
||||
|
||||
return Public
|
@ -1,773 +0,0 @@
|
||||
local ICT = require 'maps.amap.ic.table'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Gui = require 'utils.gui'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Event = require 'utils.event'
|
||||
local rpgtable = require 'modules.rpg.table'
|
||||
local Loot = require 'maps.amap.loot'
|
||||
local Public = {}
|
||||
local Alert = require 'utils.alert'
|
||||
--! Gui Frames
|
||||
local save_add_player_button_name = Gui.uid_name()
|
||||
local save_transfer_car_button_name = Gui.uid_name()
|
||||
local discard_add_player_button_name = Gui.uid_name()
|
||||
local discard_transfer_car_button_name = Gui.uid_name()
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local draw_add_player_frame_name = Gui.uid_name()
|
||||
local draw_transfer_car_frame_name = Gui.uid_name()
|
||||
local main_toolbar_name = Gui.uid_name()
|
||||
local cool = Gui.uid_name()
|
||||
local gambel = Gui.uid_name()
|
||||
local buyxp = Gui.uid_name()
|
||||
local add_player_name = Gui.uid_name()
|
||||
local transfer_car_name = Gui.uid_name()
|
||||
local kick_player_name = Gui.uid_name()
|
||||
|
||||
local raise_event = script.raise_event
|
||||
local add_toolbar
|
||||
local remove_toolbar
|
||||
|
||||
local function increment(t, k)
|
||||
t[k] = true
|
||||
end
|
||||
|
||||
local function decrement(t, k)
|
||||
t[k] = nil
|
||||
end
|
||||
|
||||
local function create_player_table(player)
|
||||
local trust_system = ICT.get('trust_system')
|
||||
if not trust_system[player.index] then
|
||||
trust_system[player.index] = {
|
||||
[player.name] = true
|
||||
}
|
||||
end
|
||||
return trust_system[player.index]
|
||||
end
|
||||
|
||||
local function does_player_table_exist(player)
|
||||
local trust_system = ICT.get('trust_system')
|
||||
if not trust_system[player.index] then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function transfer_player_table(player, new_player)
|
||||
local trust_system = ICT.get('trust_system')
|
||||
if not trust_system[player.index] then
|
||||
return false
|
||||
end
|
||||
|
||||
if player.index == new_player.index then
|
||||
return false
|
||||
end
|
||||
|
||||
if not trust_system[new_player.index] then
|
||||
local Functions = require 'maps.amap.ic.functions'
|
||||
|
||||
trust_system[new_player.index] = trust_system[player.index]
|
||||
local name = new_player.name
|
||||
|
||||
if not trust_system[new_player.index][name] then
|
||||
increment(trust_system[new_player.index], name)
|
||||
end
|
||||
|
||||
local cars = ICT.get('cars')
|
||||
local renders = ICT.get('renders')
|
||||
local c = Functions.get_owner_car_object(cars, player)
|
||||
local car = cars[c]
|
||||
car.owner = new_player.index
|
||||
|
||||
Functions.render_owner_text(renders, player, car.entity, new_player)
|
||||
|
||||
remove_toolbar(player)
|
||||
add_toolbar(new_player)
|
||||
|
||||
trust_system[player.index] = nil
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
return trust_system[new_player.index]
|
||||
end
|
||||
|
||||
local function remove_main_frame(main_frame)
|
||||
Gui.remove_data_recursively(main_frame)
|
||||
main_frame.destroy()
|
||||
end
|
||||
|
||||
local function draw_add_player(frame)
|
||||
local main_frame =
|
||||
frame.add(
|
||||
{
|
||||
type = 'frame',
|
||||
name = draw_add_player_frame_name,
|
||||
caption = 'Add Player',
|
||||
direction = 'vertical'
|
||||
}
|
||||
)
|
||||
local main_frame_style = main_frame.style
|
||||
main_frame_style.width = 370
|
||||
main_frame_style.use_header_filler = true
|
||||
|
||||
local inside_frame = main_frame.add {type = 'frame', style = 'inside_shallow_frame'}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
local inside_table = inside_frame.add {type = 'table', column_count = 1}
|
||||
local inside_table_style = inside_table.style
|
||||
inside_table_style.vertical_spacing = 5
|
||||
inside_table_style.top_padding = 10
|
||||
inside_table_style.left_padding = 10
|
||||
inside_table_style.right_padding = 0
|
||||
inside_table_style.bottom_padding = 10
|
||||
inside_table_style.width = 325
|
||||
|
||||
local add_player_frame = main_frame.add({type = 'textfield', text = 'Name of the player.'})
|
||||
add_player_frame.style.width = 140
|
||||
|
||||
local bottom_flow = main_frame.add({type = 'flow', direction = 'horizontal'})
|
||||
|
||||
local left_flow = bottom_flow.add({type = 'flow'})
|
||||
left_flow.style.horizontal_align = 'left'
|
||||
left_flow.style.horizontally_stretchable = true
|
||||
|
||||
local close_button = left_flow.add({type = 'button', name = discard_add_player_button_name, caption = 'Discard'})
|
||||
close_button.style = 'back_button'
|
||||
close_button.style.maximal_width = 100
|
||||
|
||||
local right_flow = bottom_flow.add({type = 'flow'})
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
|
||||
local save_button = right_flow.add({type = 'button', name = save_add_player_button_name, caption = 'Save'})
|
||||
save_button.style = 'confirm_button'
|
||||
save_button.style.maximal_width = 100
|
||||
|
||||
Gui.set_data(save_button, add_player_frame)
|
||||
end
|
||||
|
||||
local function draw_transfer_car(frame)
|
||||
local main_frame =
|
||||
frame.add(
|
||||
{
|
||||
type = 'frame',
|
||||
name = draw_transfer_car_frame_name,
|
||||
caption = 'Transfer Car',
|
||||
direction = 'vertical'
|
||||
}
|
||||
)
|
||||
local main_frame_style = main_frame.style
|
||||
main_frame_style.width = 370
|
||||
main_frame_style.use_header_filler = true
|
||||
|
||||
local inside_frame = main_frame.add {type = 'frame', style = 'inside_shallow_frame'}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
local inside_table = inside_frame.add {type = 'table', column_count = 1}
|
||||
local inside_table_style = inside_table.style
|
||||
inside_table_style.vertical_spacing = 5
|
||||
inside_table_style.top_padding = 10
|
||||
inside_table_style.left_padding = 10
|
||||
inside_table_style.right_padding = 0
|
||||
inside_table_style.bottom_padding = 10
|
||||
inside_table_style.width = 325
|
||||
|
||||
local transfer_car_alert_frame = main_frame.add({type = 'label', caption = "Warning, this action can't be undone!"})
|
||||
transfer_car_alert_frame.style.font_color = {r = 255, g = 0, b = 0}
|
||||
local transfer_car_frame = main_frame.add({type = 'textfield', text = 'Name of the player.'})
|
||||
transfer_car_frame.style.width = 140
|
||||
|
||||
local bottom_flow = main_frame.add({type = 'flow', direction = 'horizontal'})
|
||||
|
||||
local left_flow = bottom_flow.add({type = 'flow'})
|
||||
left_flow.style.horizontal_align = 'left'
|
||||
left_flow.style.horizontally_stretchable = true
|
||||
|
||||
local close_button = left_flow.add({type = 'button', name = discard_transfer_car_button_name, caption = 'Discard'})
|
||||
close_button.style = 'back_button'
|
||||
close_button.style.maximal_width = 100
|
||||
|
||||
local right_flow = bottom_flow.add({type = 'flow'})
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
|
||||
local save_button = right_flow.add({type = 'button', name = save_transfer_car_button_name, caption = 'Save'})
|
||||
save_button.style = 'confirm_button'
|
||||
save_button.style.maximal_width = 100
|
||||
|
||||
Gui.set_data(save_button, transfer_car_frame)
|
||||
end
|
||||
|
||||
local function draw_players(data)
|
||||
local player_table = data.player_table
|
||||
local add_player_frame = data.add_player_frame
|
||||
local player = data.player
|
||||
local player_list = create_player_table(player)
|
||||
|
||||
for p, _ in pairs(player_list) do
|
||||
Gui.set_data(add_player_frame, p)
|
||||
local t_label =
|
||||
player_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = p
|
||||
}
|
||||
)
|
||||
t_label.style.minimal_width = 75
|
||||
t_label.style.horizontal_align = 'center'
|
||||
|
||||
local a_label =
|
||||
player_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = '✔️'
|
||||
}
|
||||
)
|
||||
a_label.style.minimal_width = 75
|
||||
a_label.style.horizontal_align = 'center'
|
||||
a_label.style.font = 'default-large-bold'
|
||||
|
||||
local kick_flow = player_table.add {type = 'flow'}
|
||||
local kick_player_button =
|
||||
kick_flow.add(
|
||||
{
|
||||
type = 'button',
|
||||
caption = 'Kick ' .. p,
|
||||
name = kick_player_name
|
||||
}
|
||||
)
|
||||
if player.name == t_label.caption then
|
||||
kick_player_button.enabled = false
|
||||
end
|
||||
kick_player_button.style.minimal_width = 75
|
||||
Gui.set_data(kick_player_button, p)
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_main_frame(player)
|
||||
local main_frame =
|
||||
player.gui.screen.add(
|
||||
{
|
||||
type = 'frame',
|
||||
name = main_frame_name,
|
||||
caption = 'Car Settings',
|
||||
direction = 'vertical',
|
||||
style = 'inner_frame_in_outer_frame'
|
||||
}
|
||||
)
|
||||
|
||||
main_frame.auto_center = true
|
||||
local main_frame_style = main_frame.style
|
||||
main_frame_style.width = 400
|
||||
main_frame_style.use_header_filler = true
|
||||
|
||||
local inside_frame = main_frame.add {type = 'frame', style = 'inside_shallow_frame'}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
|
||||
local inside_table = inside_frame.add {type = 'table', column_count = 1}
|
||||
local inside_table_style = inside_table.style
|
||||
inside_table_style.vertical_spacing = 5
|
||||
inside_table_style.top_padding = 10
|
||||
inside_table_style.left_padding = 10
|
||||
inside_table_style.right_padding = 0
|
||||
inside_table_style.bottom_padding = 10
|
||||
inside_table_style.width = 350
|
||||
|
||||
local add_player_frame = inside_table.add({type = 'button', caption = 'Add Player', name = add_player_name})
|
||||
local transfer_car_frame = inside_table.add({type = 'button', caption = 'Transfer Car', name = transfer_car_name})
|
||||
|
||||
local player_table =
|
||||
inside_table.add {
|
||||
type = 'table',
|
||||
column_count = 3,
|
||||
draw_horizontal_lines = true,
|
||||
draw_vertical_lines = true,
|
||||
vertical_centering = true
|
||||
}
|
||||
local player_table_style = player_table.style
|
||||
player_table_style.vertical_spacing = 10
|
||||
player_table_style.width = 350
|
||||
player_table_style.horizontal_spacing = 30
|
||||
|
||||
local name_label =
|
||||
player_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Name',
|
||||
tooltip = ''
|
||||
}
|
||||
)
|
||||
name_label.style.minimal_width = 75
|
||||
name_label.style.horizontal_align = 'center'
|
||||
|
||||
local trusted_label =
|
||||
player_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Allowed',
|
||||
tooltip = ''
|
||||
}
|
||||
)
|
||||
trusted_label.style.minimal_width = 75
|
||||
trusted_label.style.horizontal_align = 'center'
|
||||
|
||||
local operations_label =
|
||||
player_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Operations',
|
||||
tooltip = ''
|
||||
}
|
||||
)
|
||||
operations_label.style.minimal_width = 75
|
||||
operations_label.style.horizontal_align = 'center'
|
||||
|
||||
local data = {
|
||||
player_table = player_table,
|
||||
add_player_frame = add_player_frame,
|
||||
transfer_car_frame = transfer_car_frame,
|
||||
player = player
|
||||
}
|
||||
draw_players(data)
|
||||
|
||||
player.opened = main_frame
|
||||
end
|
||||
|
||||
local function toggle(player, recreate)
|
||||
local screen = player.gui.screen
|
||||
local main_frame = screen[main_frame_name]
|
||||
|
||||
if recreate and main_frame then
|
||||
local location = main_frame.location
|
||||
remove_main_frame(main_frame)
|
||||
draw_main_frame(player, location)
|
||||
return
|
||||
end
|
||||
if main_frame then
|
||||
remove_main_frame(main_frame)
|
||||
Tabs.comfy_panel_restore_left_gui(player)
|
||||
else
|
||||
Tabs.comfy_panel_clear_left_gui(player)
|
||||
draw_main_frame(player)
|
||||
end
|
||||
end
|
||||
|
||||
add_toolbar = function(player, remove)
|
||||
if remove then
|
||||
if player.gui.top[main_toolbar_name] then
|
||||
player.gui.top[cool].destroy()
|
||||
player.gui.top[buyxp].destroy()
|
||||
player.gui.top[gambel].destroy()
|
||||
player.gui.top[main_toolbar_name].destroy()
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
if player.gui.top[main_toolbar_name] then
|
||||
return
|
||||
end
|
||||
|
||||
local tooltip = 'contorl who can enter your car.'
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/spidertron',
|
||||
name = main_toolbar_name,
|
||||
tooltip = tooltip
|
||||
}
|
||||
)
|
||||
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/logistic-chest-storage',
|
||||
name = cool,
|
||||
tooltip = {'amap.openchest'}
|
||||
}
|
||||
)
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/coin',
|
||||
name = gambel,
|
||||
tooltip = {'amap.gambel'}
|
||||
}
|
||||
)
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/rocket-part',
|
||||
name = buyxp,
|
||||
tooltip = {'amap.buyxp'}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
remove_toolbar = function(player)
|
||||
local screen = player.gui.screen
|
||||
local main_frame = screen[main_frame_name]
|
||||
|
||||
if main_frame and main_frame.valid then
|
||||
remove_main_frame(main_frame)
|
||||
end
|
||||
|
||||
if player.gui.top[main_toolbar_name] then
|
||||
player.gui.top[main_toolbar_name].destroy()
|
||||
player.gui.top[cool].destroy()
|
||||
player.gui.top[buyxp].destroy()
|
||||
player.gui.top[gambel].destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
add_player_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
local player_frame = frame[draw_add_player_frame_name]
|
||||
if not player_frame or not player_frame.valid then
|
||||
draw_add_player(frame)
|
||||
else
|
||||
player_frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
transfer_car_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
local player_frame = frame[draw_transfer_car_frame_name]
|
||||
if not player_frame or not player_frame.valid then
|
||||
draw_transfer_car(frame)
|
||||
else
|
||||
player_frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
Gui.on_click(
|
||||
gambel,
|
||||
function(event)
|
||||
local player = event.player
|
||||
local something = player.get_inventory(defines.inventory.chest)
|
||||
for k, v in pairs(something.get_contents()) do
|
||||
local t = {name = k, count = v}
|
||||
if t.name == 'coin' then
|
||||
if v > 999 then
|
||||
player.remove_item {name = 'coin', count = '1000'}
|
||||
local roll = math.random(1, 100)
|
||||
if roll <= 36 then
|
||||
player.insert {name = 'coin', count = '2500'}
|
||||
player.print({'amap.gambel1'})
|
||||
return
|
||||
else
|
||||
player.print({'amap.gambel2'})
|
||||
return
|
||||
end
|
||||
else
|
||||
player.print({'amap.noenough'})
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
cool,
|
||||
function(event)
|
||||
local player = event.player
|
||||
local something = player.get_inventory(defines.inventory.chest)
|
||||
for k, v in pairs(something.get_contents()) do
|
||||
local t = {name = k, count = v}
|
||||
if t.name == 'coin' then
|
||||
if v > 2999 then
|
||||
player.remove_item {name = 'coin', count = '3000'}
|
||||
local luck = math.floor(math.random(1, 130))
|
||||
player.print({'amap.lucknb'})
|
||||
player.print(luck)
|
||||
local magic = luck * 5 + 100
|
||||
local msg = {'amap.whatopen'}
|
||||
Loot.cool(player.surface, player.surface.find_non_colliding_position('steel-chest', player.position, 20, 1, true) or player.position, 'steel-chest', magic)
|
||||
Alert.alert_player(player, 5, msg)
|
||||
return
|
||||
else
|
||||
player.print({'amap.noenough'})
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
Gui.on_click(
|
||||
buyxp,
|
||||
function(event)
|
||||
local player = event.player
|
||||
local something = player.get_inventory(defines.inventory.chest)
|
||||
for k, v in pairs(something.get_contents()) do
|
||||
local t = {name = k, count = v}
|
||||
if t.name == 'coin' then
|
||||
if v > 4999 then
|
||||
player.remove_item {name = 'coin', count = '5000'}
|
||||
local rpg_t = rpgtable.get('rpg_t')
|
||||
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + 1000
|
||||
local msg = {'amap.buyover'}
|
||||
Alert.alert_player(player, 5, msg)
|
||||
return
|
||||
else
|
||||
player.print({'amap.noenough'})
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
Gui.on_click(
|
||||
save_add_player_button_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local player_list = create_player_table(player)
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
local add_player_frame = Gui.get_data(event.element)
|
||||
|
||||
if frame and frame.valid then
|
||||
if add_player_frame and add_player_frame.valid and add_player_frame.text then
|
||||
local text = add_player_frame.text
|
||||
if not text then
|
||||
return
|
||||
end
|
||||
local player_to_add = game.get_player(text)
|
||||
if not player_to_add or not player_to_add.valid then
|
||||
return player.print('Target player was not valid.', Color.warning)
|
||||
end
|
||||
|
||||
local name = player_to_add.name
|
||||
|
||||
if not player_list[name] then
|
||||
player.print(name .. ' was added to your vehicle.', Color.info)
|
||||
player_to_add.print(player.name .. ' added you to their vehicle. You may now enter it.', Color.info)
|
||||
increment(player_list, name)
|
||||
else
|
||||
return player.print('Target player is already trusted.', Color.warning)
|
||||
end
|
||||
|
||||
remove_main_frame(event.element)
|
||||
|
||||
if player.gui.screen[main_frame_name] then
|
||||
toggle(player, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
save_transfer_car_button_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
local transfer_car_frame = Gui.get_data(event.element)
|
||||
|
||||
if frame and frame.valid then
|
||||
if transfer_car_frame and transfer_car_frame.valid and transfer_car_frame.text then
|
||||
local text = transfer_car_frame.text
|
||||
if not text then
|
||||
return
|
||||
end
|
||||
local player_to_add = game.get_player(text)
|
||||
if not player_to_add or not player_to_add.valid then
|
||||
return player.print('Target player was not valid.', Color.warning)
|
||||
end
|
||||
|
||||
local name = player_to_add.name
|
||||
local does_player_have_a_car = does_player_table_exist(name)
|
||||
if does_player_have_a_car then
|
||||
return player.print(name .. ' already has a vehicle.', Color.warning)
|
||||
end
|
||||
|
||||
local to_add = game.get_player(name)
|
||||
if not (to_add and to_add.valid) then
|
||||
return player.print(name .. ' does not exist.', Color.warning)
|
||||
end
|
||||
|
||||
local success = transfer_player_table(player, to_add)
|
||||
if not success then
|
||||
player.print('Please try again.', Color.warning)
|
||||
else
|
||||
player.print('You have successfully transferred your car to ' .. name, Color.success)
|
||||
to_add.print('You have become the rightfully owner of ' .. player.name .. "'s car!", Color.success)
|
||||
end
|
||||
|
||||
remove_main_frame(event.element)
|
||||
|
||||
if player.gui.screen[main_frame_name] then
|
||||
player.gui.screen[main_frame_name].destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
kick_player_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local player_list = create_player_table(player)
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
local player_name = Gui.get_data(event.element)
|
||||
local this = ICT.get()
|
||||
|
||||
if frame and frame.valid then
|
||||
if not player_name then
|
||||
return
|
||||
end
|
||||
local target = game.get_player(player_name)
|
||||
if not target or not target.valid then
|
||||
player.print('Target player was not valid.', Color.warning)
|
||||
return
|
||||
end
|
||||
local name = target.name
|
||||
|
||||
if player_list[name] then
|
||||
player.print(name .. ' was removed from your vehicle.', Color.info)
|
||||
decrement(player_list, name)
|
||||
raise_event(
|
||||
ICT.events.on_player_kicked_from_surface,
|
||||
{
|
||||
player = player,
|
||||
target = target,
|
||||
this = this
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
remove_main_frame(event.element)
|
||||
|
||||
if player.gui.screen[main_frame_name] then
|
||||
toggle(player, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
discard_add_player_button_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
local player_frame = frame[draw_add_player_frame_name]
|
||||
|
||||
if player_frame and player_frame.valid then
|
||||
player_frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
discard_transfer_car_button_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
local player_frame = frame[draw_transfer_car_frame_name]
|
||||
|
||||
if player_frame and player_frame.valid then
|
||||
player_frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
main_toolbar_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
|
||||
if frame and frame.valid then
|
||||
frame.destroy()
|
||||
else
|
||||
draw_main_frame(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.draw_main_frame = draw_main_frame
|
||||
Public.toggle = toggle
|
||||
Public.add_toolbar = add_toolbar
|
||||
Public.remove_toolbar = remove_toolbar
|
||||
|
||||
Event.add(
|
||||
defines.events.on_gui_closed,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
|
||||
if frame and frame.valid then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
@ -1,187 +0,0 @@
|
||||
require 'modules.check_fullness'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Functions = require 'maps.amap.ic.functions'
|
||||
local IC = require 'maps.amap.ic.table'
|
||||
local Minimap = require 'maps.amap.ic.minimap'
|
||||
local Public = {}
|
||||
|
||||
Public.reset = IC.reset
|
||||
Public.get_table = IC.get
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local ic = IC.get()
|
||||
|
||||
if entity.type == 'car' or entity.name == 'spidertron' then
|
||||
Minimap.kill_minimap(game.players[event.player_index])
|
||||
Functions.kill_car(ic, entity)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local ic = IC.get()
|
||||
|
||||
--Minimap.kill_minimap(game.players[event.player_index])
|
||||
|
||||
if entity.type == 'car' or entity.name == 'spidertron' then
|
||||
Functions.save_car(ic, event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_robot_mined_entity(event)
|
||||
local entity = event.entity
|
||||
|
||||
if not entity and not entity.valid then
|
||||
return
|
||||
end
|
||||
local ic = IC.get()
|
||||
|
||||
if entity.type == 'car' or entity.name == 'spidertron' then
|
||||
Functions.kill_car(ic, entity)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local ce = event.created_entity
|
||||
|
||||
if not ce or not ce.valid then
|
||||
return
|
||||
end
|
||||
if (ce.type == 'car' or ce.name == 'spidertron') ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local ic = IC.get()
|
||||
Functions.create_car(ic, event)
|
||||
end
|
||||
|
||||
local function on_player_driving_changed_state(event)
|
||||
local ic = IC.get()
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
Functions.use_door_with_entity(ic, player, event.entity)
|
||||
Functions.validate_owner(ic, player, event.entity)
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
local ic = IC.get()
|
||||
local tick = game.tick
|
||||
|
||||
if tick % 10 == 1 then
|
||||
Functions.item_transfer(ic)
|
||||
end
|
||||
|
||||
if tick % 240 == 0 then
|
||||
Minimap.update_minimap()
|
||||
end
|
||||
|
||||
if tick % 400 == 0 then
|
||||
Functions.remove_invalid_cars(ic)
|
||||
end
|
||||
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
|
||||
local ic = IC.get()
|
||||
if not ic.cars[entity.unit_number] then
|
||||
return
|
||||
end
|
||||
|
||||
Minimap.kill_minimap(game.players[event.player_index])
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not entity.unit_number then
|
||||
return
|
||||
end
|
||||
local ic = IC.get()
|
||||
local car = ic.cars[entity.unit_number]
|
||||
if not car then
|
||||
return
|
||||
end
|
||||
|
||||
Minimap.minimap(
|
||||
game.players[event.player_index],
|
||||
car.surface,
|
||||
{
|
||||
car.area.left_top.x + (car.area.right_bottom.x - car.area.left_top.x) * 0.5,
|
||||
car.area.left_top.y + (car.area.right_bottom.y - car.area.left_top.y) * 0.5
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
local element = event.element
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if event.element.name == 'minimap_button' then
|
||||
Minimap.minimap(player, false)
|
||||
elseif event.element.name == 'minimap_frame' or event.element.name == 'minimap_toggle_frame' then
|
||||
Minimap.toggle_minimap(event)
|
||||
elseif event.element.name == 'switch_auto_map' then
|
||||
Minimap.toggle_auto(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function trigger_on_player_kicked_from_surface(data)
|
||||
local player = data.player
|
||||
local target = data.target
|
||||
local this = data.this
|
||||
Functions.kick_player_from_surface(this, player, target)
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
Public.reset()
|
||||
end
|
||||
|
||||
local changed_surface = Minimap.changed_surface
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
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_player_driving_changed_state, on_player_driving_changed_state)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_player_changed_surface, changed_surface)
|
||||
Event.add(IC.events.on_player_kicked_from_surface, trigger_on_player_kicked_from_surface)
|
||||
return Public
|
@ -1,253 +0,0 @@
|
||||
local Public = {}
|
||||
|
||||
local ICT = require 'maps.amap.ic.table'
|
||||
local Functions = require 'maps.amap.ic.functions'
|
||||
local Gui = require 'maps.amap.ic.gui'
|
||||
|
||||
local function validate_player(player)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
if not player.valid then
|
||||
return false
|
||||
end
|
||||
if not player.character then
|
||||
return false
|
||||
end
|
||||
if not player.connected then
|
||||
return false
|
||||
end
|
||||
if not game.players[player.name] then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function create_button(player)
|
||||
local button =
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
name = 'minimap_button',
|
||||
sprite = 'utility/map',
|
||||
tooltip = 'Open or close minimap.'
|
||||
}
|
||||
)
|
||||
button.visible = false
|
||||
end
|
||||
|
||||
function Public.toggle_button(player)
|
||||
if not player.gui.top['minimap_button'] then
|
||||
create_button(player)
|
||||
end
|
||||
local ic = ICT.get()
|
||||
local button = player.gui.top['minimap_button']
|
||||
if Functions.get_player_surface(ic, player) then
|
||||
button.visible = true
|
||||
else
|
||||
button.visible = false
|
||||
end
|
||||
end
|
||||
|
||||
local function get_player_data(player)
|
||||
local ic = ICT.get()
|
||||
local player_data = ic.minimap[player.index]
|
||||
if ic.minimap[player.index] then
|
||||
return player_data
|
||||
end
|
||||
|
||||
ic.minimap[player.index] = {
|
||||
surface = ic.allowed_surface,
|
||||
zoom = 0.30,
|
||||
map_size = 360,
|
||||
auto_map = true
|
||||
}
|
||||
return ic.minimap[player.index]
|
||||
end
|
||||
|
||||
function Public.toggle_auto(player)
|
||||
local ic = ICT.get()
|
||||
local switch = player.gui.left.minimap_toggle_frame['switch_auto_map']
|
||||
if not switch or not switch.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if switch.switch_state == 'left' then
|
||||
ic.minimap[player.index].auto_map = true
|
||||
elseif switch.switch_state == 'right' then
|
||||
ic.minimap[player.index].auto_map = false
|
||||
end
|
||||
end
|
||||
|
||||
local function kill_minimap(player)
|
||||
local frame = player.gui.left.minimap_toggle_frame
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
if frame.visible then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local function kill_frame(player)
|
||||
if player.gui.left.minimap_toggle_frame then
|
||||
local element = player.gui.left.minimap_toggle_frame.minimap_frame
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
element.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_minimap(player, surface, position)
|
||||
local ic = ICT.get()
|
||||
surface = surface or game.surfaces[ic.allowed_surface]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local cars = ic.cars
|
||||
|
||||
local entity = Functions.get_entity_from_player_surface(cars, player)
|
||||
if not position then
|
||||
if not entity or not entity.valid then
|
||||
kill_minimap(player)
|
||||
kill_frame(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
position = position or entity.position
|
||||
local player_data = get_player_data(player)
|
||||
local frame = player.gui.left.minimap_toggle_frame
|
||||
if not frame then
|
||||
frame = player.gui.left.add({type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Minimap'})
|
||||
end
|
||||
frame.visible = true
|
||||
local element = frame['minimap_frame']
|
||||
if not element then
|
||||
element =
|
||||
player.gui.left.minimap_toggle_frame.add(
|
||||
{
|
||||
type = 'camera',
|
||||
name = 'minimap_frame',
|
||||
position = position,
|
||||
surface_index = surface.index,
|
||||
zoom = player_data.zoom,
|
||||
tooltip = 'LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.'
|
||||
}
|
||||
)
|
||||
element.style.margin = 1
|
||||
element.style.minimal_height = player_data.map_size
|
||||
element.style.minimal_width = player_data.map_size
|
||||
return
|
||||
end
|
||||
element.position = position
|
||||
end
|
||||
|
||||
function Public.minimap(player, surface, position)
|
||||
local frame = player.gui.left['minimap_toggle_frame']
|
||||
local ic = ICT.get()
|
||||
if frame and frame.visible then
|
||||
kill_minimap(player)
|
||||
else
|
||||
if Functions.get_player_surface(ic, player) and not surface and not position then
|
||||
draw_minimap(player)
|
||||
else
|
||||
draw_minimap(player, surface, position)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.update_minimap()
|
||||
local ic = ICT.get()
|
||||
for k, player in pairs(game.connected_players) do
|
||||
if Functions.get_player_surface(ic, player) and player.gui.left.minimap_toggle_frame then
|
||||
kill_frame(player)
|
||||
draw_minimap(player)
|
||||
else
|
||||
kill_minimap(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.toggle_minimap(event)
|
||||
local element = event.element
|
||||
if not element then
|
||||
return
|
||||
end
|
||||
if not element.valid then
|
||||
return
|
||||
end
|
||||
if element.name ~= 'minimap_frame' then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local player_data = get_player_data(player)
|
||||
if event.button == defines.mouse_button_type.right then
|
||||
player_data.zoom = player_data.zoom - 0.07
|
||||
if player_data.zoom < 0.07 then
|
||||
player_data.zoom = 0.07
|
||||
end
|
||||
element.zoom = player_data.zoom
|
||||
return
|
||||
end
|
||||
if event.button == defines.mouse_button_type.left then
|
||||
player_data.zoom = player_data.zoom + 0.07
|
||||
if player_data.zoom > 2 then
|
||||
player_data.zoom = 2
|
||||
end
|
||||
element.zoom = player_data.zoom
|
||||
return
|
||||
end
|
||||
if event.button == defines.mouse_button_type.middle then
|
||||
player_data.map_size = player_data.map_size + 50
|
||||
if player_data.map_size > 650 then
|
||||
player_data.map_size = 250
|
||||
end
|
||||
element.style.minimal_height = player_data.map_size
|
||||
element.style.minimal_width = player_data.map_size
|
||||
element.style.maximal_height = player_data.map_size
|
||||
element.style.maximal_width = player_data.map_size
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function Public.changed_surface(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
|
||||
local ic = ICT.get()
|
||||
local surface = game.surfaces[ic.allowed_surface]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local wd = player.gui.top['wave_defense']
|
||||
local diff = player.gui.top['difficulty_gui']
|
||||
|
||||
if Functions.get_player_surface(ic, player) then
|
||||
Public.toggle_button(player)
|
||||
Public.minimap(player, surface)
|
||||
if wd and wd.visible then
|
||||
wd.visible = false
|
||||
end
|
||||
if diff and diff.visible then
|
||||
diff.visible = false
|
||||
end
|
||||
elseif player.surface.index == surface.index then
|
||||
Gui.remove_toolbar(player)
|
||||
Public.toggle_button(player)
|
||||
kill_minimap(player)
|
||||
if wd and not wd.visible then
|
||||
wd.visible = true
|
||||
end
|
||||
if diff and not diff.visible then
|
||||
diff.visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Public.kill_minimap = kill_minimap
|
||||
|
||||
return Public
|
@ -1,87 +0,0 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {}
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {
|
||||
events = {
|
||||
on_player_kicked_from_surface = Event.generate_event_name('on_player_kicked_from_surface')
|
||||
}
|
||||
}
|
||||
|
||||
function Public.reset()
|
||||
if this.surfaces then
|
||||
for k, surface in pairs(this.surfaces) do
|
||||
if surface and surface.valid then
|
||||
game.delete_surface(surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, _ in pairs(this) do
|
||||
this[k] = nil
|
||||
end
|
||||
this.debug_mode = false
|
||||
this.restore_on_theft = false
|
||||
this.doors = {}
|
||||
this.cars = {}
|
||||
this.current_car_index = nil
|
||||
this.renders = {}
|
||||
this.saved_surfaces = {}
|
||||
this.allowed_surface = 'nauvis'
|
||||
this.trust_system = {}
|
||||
this.players = {}
|
||||
this.surfaces = {}
|
||||
this.minimap = {}
|
||||
this.entity_type = {
|
||||
['car'] = true,
|
||||
['tank'] = true,
|
||||
['spidertron'] = true,
|
||||
['spider-vehicle'] = true
|
||||
}
|
||||
this.car_areas = {
|
||||
['car'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 20}},
|
||||
['tank'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 40}},
|
||||
['spidertron'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 60}},
|
||||
['spider-vehicle'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 60}}
|
||||
}
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
function Public.set(key, value)
|
||||
if key and (value or value == false) then
|
||||
this[key] = value
|
||||
return this[key]
|
||||
elseif key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
function Public.set_car_area(tbl)
|
||||
if not tbl then
|
||||
return
|
||||
end
|
||||
|
||||
this.car_areas = tbl
|
||||
end
|
||||
|
||||
function Public.allowed_surface(value)
|
||||
if value then
|
||||
this.allowed_surface = value
|
||||
end
|
||||
return this.allowed_surface
|
||||
end
|
||||
|
||||
return Public
|
@ -1,156 +0,0 @@
|
||||
local LootRaffle = require 'functions.loot_raffle'
|
||||
|
||||
local Public = {}
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
local floor = math.floor
|
||||
local sqrt = math.sqrt
|
||||
|
||||
local blacklist = {
|
||||
['atomic-bomb'] = true,
|
||||
['cargo-wagon'] = true,
|
||||
['car'] = true,
|
||||
['tank'] = true,
|
||||
['spidertron'] = true,
|
||||
['locomotive'] = true,
|
||||
['artillery-wagon'] = true,
|
||||
['artillery-turret'] = true,
|
||||
['landfill'] = true,
|
||||
['discharge-defense-equipment'] = true,
|
||||
['discharge-defense-remote'] = true,
|
||||
['fluid-wagon'] = true,
|
||||
['pistol'] = true
|
||||
}
|
||||
|
||||
function Public.get_distance(position)
|
||||
local difficulty = sqrt(position.x ^ 2 + position.y ^ 2) * 0.0001
|
||||
return difficulty
|
||||
end
|
||||
|
||||
function Public.add(surface, position, chest)
|
||||
local budget = 48 + abs(position.y) * 1.75
|
||||
budget = budget * random(25, 175) * 0.01
|
||||
|
||||
if random(1, 128) == 1 then
|
||||
budget = budget * 4
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
if random(1, 256) == 1 then
|
||||
budget = budget * 4
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
|
||||
budget = floor(budget) + 1
|
||||
|
||||
local amount = random(1, 5)
|
||||
local base_amount = 12 * amount
|
||||
local distance_mod = Public.get_distance(position)
|
||||
|
||||
local result = base_amount + budget + distance_mod
|
||||
|
||||
local c = game.entity_prototypes[chest]
|
||||
local slots = c.get_inventory_size(defines.inventory.chest)
|
||||
|
||||
local item_stacks = LootRaffle.roll(result, slots, blacklist)
|
||||
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
end
|
||||
container.minable = false
|
||||
|
||||
if random(1, 8) == 1 then
|
||||
container.insert({name = 'coin', count = random(1, 32)})
|
||||
elseif random(1, 32) == 1 then
|
||||
container.insert({name = 'coin', count = random(1, 128)})
|
||||
elseif random(1, 128) == 1 then
|
||||
container.insert({name = 'coin', count = random(1, 256)})
|
||||
end
|
||||
|
||||
for _ = 1, 3, 1 do
|
||||
if random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = random(25, 50)})
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.add_rare(surface, position, chest, magic)
|
||||
local budget = magic * 48 + abs(position.y) * 1.75
|
||||
budget = budget * random(25, 175) * 0.01
|
||||
|
||||
if random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
|
||||
local amount = random(1, 5)
|
||||
local base_amount = 12 * amount
|
||||
local distance_mod = Public.get_distance(position)
|
||||
|
||||
budget = floor(budget) + 1
|
||||
|
||||
local result = base_amount + budget + distance_mod
|
||||
|
||||
local c = game.entity_prototypes[chest]
|
||||
local slots = c.get_inventory_size(defines.inventory.chest)
|
||||
|
||||
local item_stacks = LootRaffle.roll(result, slots, blacklist)
|
||||
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
end
|
||||
container.minable = false
|
||||
|
||||
for _ = 1, 3, 1 do
|
||||
if random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = random(25, 50)})
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.cool(surface, position, chest, magic)
|
||||
local budget = magic * 48 + abs(position.y) * 1.75
|
||||
budget = budget * random(25, 175) * 0.01
|
||||
|
||||
if random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. random(1, 2)
|
||||
end
|
||||
|
||||
local amount = random(1, 5)
|
||||
local base_amount = 12 * amount
|
||||
local distance_mod = Public.get_distance(position)
|
||||
|
||||
budget = floor(budget) + 1
|
||||
|
||||
local result = base_amount + budget + distance_mod
|
||||
|
||||
local c = game.entity_prototypes[chest]
|
||||
local slots = c.get_inventory_size(defines.inventory.chest)
|
||||
|
||||
local item_stacks = LootRaffle.roll(result, slots, blacklist)
|
||||
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
end
|
||||
|
||||
for _ = 1, 3, 1 do
|
||||
if random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = random(25, 50)})
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return Public
|
@ -1,664 +0,0 @@
|
||||
--luacheck: ignore
|
||||
require 'modules.rpg.main'
|
||||
require 'maps.amap.relax'
|
||||
require 'maps.amap.diff'
|
||||
local Functions = require 'maps.amap.functions'
|
||||
local IC = require 'maps.amap.ic.table'
|
||||
local CS = require 'maps.amap.surface'
|
||||
local Event = require 'utils.event'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local wall_health = require 'maps.amap.wall_health_booster'.set_health_modifier
|
||||
|
||||
local spider_health = require 'maps.amap.spider_health_booster'.set_health_modifier
|
||||
|
||||
local Map = require 'modules.map_info'
|
||||
local AntiGrief = require 'antigrief'
|
||||
--local Explosives = require 'modules.explosives'
|
||||
local WPT = require 'maps.amap.table'
|
||||
local Autostash = require 'modules.autostash'
|
||||
local BuriedEnemies = require 'maps.amap.buried_enemies'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG_Func = require 'modules.rpg.functions'
|
||||
local Commands = require 'commands.misc'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
local rock = require 'maps.amap.rock'
|
||||
local Loot = require 'maps.amap.loot'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
--local arty = require "maps.amap.enemy_arty"
|
||||
--require 'maps.amap.burden'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'maps.amap.biters_yield_coins'
|
||||
--require 'maps.amap.sort'
|
||||
local Public = {}
|
||||
local floor = math.floor
|
||||
local remove = table.remove
|
||||
--require 'modules.flamethrower_nerf'
|
||||
--加载地形
|
||||
require 'maps.amap.caves'
|
||||
require 'modules.surrounded_by_worms'
|
||||
require 'maps.amap.ic.main'
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
local init_new_force = function()
|
||||
local new_force = game.forces.protectors
|
||||
local enemy = game.forces.enemy
|
||||
if not new_force then
|
||||
new_force = game.create_force('protectors')
|
||||
end
|
||||
new_force.set_friend('enemy', true)
|
||||
enemy.set_friend('protectors', true)
|
||||
end
|
||||
local setting = function()
|
||||
--game.map_settings.enemy_evolution.destroy_factor = 0.004
|
||||
-- game.map_settings.enemy_evolution.pollution_factor = 0.000003
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = 6000
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = 104000
|
||||
--game.map_settings.enemy_evolution.time_factor = 0.00004
|
||||
game.map_settings.enemy_expansion.max_expansion_distance = 20
|
||||
game.map_settings.enemy_expansion.settler_group_min_size = 5
|
||||
game.map_settings.enemy_expansion.settler_group_max_size = 50
|
||||
|
||||
global.biter_health_boost_forces[game.forces.player.index] = 1
|
||||
game.forces.player.set_ammo_damage_modifier('artillery-shell', 0)
|
||||
game.forces.player.set_ammo_damage_modifier('melee', 0)
|
||||
game.forces.player.set_ammo_damage_modifier('biological', 0)
|
||||
local index = game.forces.player.index
|
||||
wall_health(index, 1)
|
||||
spider_health(index, 1)
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = WPT.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
|
||||
--创建一个地表
|
||||
this.active_surface_index = CS.create_surface()
|
||||
|
||||
Autostash.insert_into_furnace(true)
|
||||
Autostash.bottom_button(true)
|
||||
BuriedEnemies.reset()
|
||||
Commands.reset()
|
||||
Commands.activate_custom_buttons(true)
|
||||
Commands.bottom_right(false)
|
||||
|
||||
IC.reset()
|
||||
IC.allowed_surface('amap')
|
||||
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
|
||||
--记得后面改为失去一半经验!并且修订技能!
|
||||
local xp = {}
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
xp[player.index] = {}
|
||||
xp[player.index] = rpg_t[player.index].xp / 3
|
||||
|
||||
if xp[player.index] > 5000 then
|
||||
xp[player.index] = 5000
|
||||
end
|
||||
end
|
||||
|
||||
RPG_Func.rpg_reset_all_players()
|
||||
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
rpg_t[player.index].xp = xp[player.index]
|
||||
xp[player.index] = {}
|
||||
end
|
||||
|
||||
RPG_Settings.set_surface_name('amap')
|
||||
RPG_Settings.enable_health_and_mana_bars(true)
|
||||
RPG_Settings.enable_wave_defense(true)
|
||||
RPG_Settings.enable_mana(true)
|
||||
RPG_Settings.enable_flame_boots(true)
|
||||
RPG_Settings.enable_stone_path(true)
|
||||
RPG_Settings.enable_one_punch(true)
|
||||
RPG_Settings.enable_one_punch_globally(false)
|
||||
RPG_Settings.enable_auto_allocate(true)
|
||||
RPG_Settings.disable_cooldowns_on_spells()
|
||||
|
||||
--初始化部队
|
||||
init_new_force()
|
||||
--难度设置
|
||||
local Diff = Difficulty.get()
|
||||
Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = game.tick + 36000})
|
||||
Diff.gui_width = 20
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
--Explosives.set_surface_whitelist({[surface.name] = true})
|
||||
game.forces.player.set_spawn_position({0, 0}, surface)
|
||||
|
||||
local players = game.connected_players
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
Commands.insert_all_items(player)
|
||||
end
|
||||
|
||||
--生产火箭发射井
|
||||
rock.spawn(surface, {x = 0, y = 10})
|
||||
rock.market(surface)
|
||||
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = this.active_surface_index
|
||||
--记得修改目标!
|
||||
wave_defense_table.target = this.rock
|
||||
wave_defense_table.nest_building_density = 32
|
||||
wave_defense_table.game_lost = false
|
||||
-- wave_defense_table.set_evolution_time = true
|
||||
--生成随机位置!
|
||||
local positions = {x = 200, y = 200}
|
||||
positions.x = math.random(-200, 200)
|
||||
positions.y = math.random(-200, 200)
|
||||
|
||||
if positions.y < 75 and positions.y > -75 then
|
||||
if positions.y < 0 then
|
||||
positions.y = positions.y - 100
|
||||
else
|
||||
positions.y = positions.y + 100
|
||||
end
|
||||
end
|
||||
if positions.x < 75 and positions.x > -75 then
|
||||
if positions.x < 0 then
|
||||
positions.x = positions.x - 100
|
||||
else
|
||||
positions.x = positions.x + 100
|
||||
end
|
||||
end
|
||||
|
||||
wave_defense_table.spawn_position = positions
|
||||
this.pos = positions
|
||||
this.change = false
|
||||
this.science = 0
|
||||
--game.print(positions)
|
||||
WD.alert_boss_wave(true)
|
||||
WD.clear_corpses(false)
|
||||
WD.remove_entities(true)
|
||||
WD.enable_threat_log(true)
|
||||
WD.set_disable_threat_below_zero(true)
|
||||
WD.set_biter_health_boost(1.4)
|
||||
-- WD.set().wave_interval = 3300
|
||||
-- WD.set().threat_gain_multiplier = 4
|
||||
WD.set().next_wave = game.tick + 7200 * 15
|
||||
--初始化虫子科技
|
||||
|
||||
Functions.disable_tech()
|
||||
game.forces.player.set_spawn_position({0, 0}, surface)
|
||||
|
||||
Task.start_queue()
|
||||
Task.set_queue_speed(16)
|
||||
|
||||
this.chunk_load_tick = game.tick + 1200
|
||||
this.game_lost = false
|
||||
this.last = 0
|
||||
|
||||
global.worm_distance = 210
|
||||
global.average_worm_amount_per_chunk = 5
|
||||
|
||||
setting()
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
Public.reset_map()
|
||||
|
||||
local tooltip = {
|
||||
[1] = ({'amap.easy'}),
|
||||
[2] = ({'amap.med'}),
|
||||
[3] = ({'amap.hard'})
|
||||
}
|
||||
|
||||
Difficulty.set_tooltip(tooltip)
|
||||
|
||||
game.forces.player.research_queue_enabled = true
|
||||
local T = Map.Pop_info()
|
||||
T.localised_category = 'amap'
|
||||
T.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
T.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
|
||||
--Explosives.set_whitelist_entity('character')
|
||||
--Explosives.set_whitelist_entity('spidertron')
|
||||
--Explosives.set_whitelist_entity('car')
|
||||
--Explosives.set_whitelist_entity('tank')
|
||||
--地图设置
|
||||
|
||||
--setting()
|
||||
end
|
||||
local is_player_valid = function()
|
||||
local players = game.connected_players
|
||||
for _, player in pairs(players) do
|
||||
if player.connected and not player.character or not player.character.valid then
|
||||
if not player.admin then
|
||||
local player_data = Functions.get_player_data(player)
|
||||
if player_data.died then
|
||||
return
|
||||
end
|
||||
player.set_controller {type = defines.controllers.god}
|
||||
player.create_character()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local has_the_game_ended = function()
|
||||
local game_reset_tick = WPT.get('game_reset_tick')
|
||||
if game_reset_tick then
|
||||
if game_reset_tick < 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local this = WPT.get()
|
||||
|
||||
this.game_reset_tick = this.game_reset_tick - 30
|
||||
if this.game_reset_tick % 1800 == 0 then
|
||||
if this.game_reset_tick > 0 then
|
||||
local cause_msg
|
||||
if this.restart then
|
||||
cause_msg = 'restart'
|
||||
end
|
||||
|
||||
game.print(({'main.reset_in', cause_msg, this.game_reset_tick / 60}), {r = 0.22, g = 0.88, b = 0.22})
|
||||
end
|
||||
|
||||
if this.soft_reset and this.game_reset_tick == 0 then
|
||||
this.game_reset_tick = nil
|
||||
Public.reset_map()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local chunk_load = function()
|
||||
local chunk_load_tick = WPT.get('chunk_load_tick')
|
||||
if chunk_load_tick then
|
||||
if chunk_load_tick < game.tick then
|
||||
WPT.get().chunk_load_tick = nil
|
||||
Task.set_queue_speed(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local rondom = function(player, many)
|
||||
if not player.character or not player.character.valid then
|
||||
return
|
||||
end
|
||||
if many >= 500 then
|
||||
many = 500
|
||||
end
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local q = math.random(0, 19)
|
||||
local k = math.floor(many / 100)
|
||||
local get_point = k * 5 + 5
|
||||
if get_point >= 25 then
|
||||
get_point = 25
|
||||
end
|
||||
if q == 16 then
|
||||
if rpg_t[player.index].magicka < (get_point + 10) then
|
||||
-- player.print({'amap.nopoint'})
|
||||
-- player.remove_item{name='coin', count = '1000'}
|
||||
q = 17
|
||||
else
|
||||
rpg_t[player.index].magicka = rpg_t[player.index].magicka - get_point
|
||||
player.print({'amap.nb16', get_point + 10})
|
||||
return
|
||||
end
|
||||
end
|
||||
if q == 17 then
|
||||
if rpg_t[player.index].dexterity < (get_point + 10) then
|
||||
-- player.print({'amap.nopoint'})
|
||||
-- player.remove_item{name='coin', count = '1000'}
|
||||
q = 18
|
||||
else
|
||||
rpg_t[player.index].dexterity = rpg_t[player.index].dexterity - get_point
|
||||
player.print({'amap.nb17', get_point})
|
||||
return
|
||||
end
|
||||
end
|
||||
if q == 18 then
|
||||
if rpg_t[player.index].vitality < (get_point + 10) then
|
||||
-- player.print({'amap.nopoint'})
|
||||
-- player.remove_item{name='coin', count = '1000'}
|
||||
q = 15
|
||||
else
|
||||
rpg_t[player.index].vitality = rpg_t[player.index].vitality - get_point
|
||||
player.print({'amap.nb18', get_point})
|
||||
return
|
||||
end
|
||||
end
|
||||
if q == 15 then
|
||||
if rpg_t[player.index].strength < (get_point + 10) then
|
||||
local money = 1000 + 1000 * k
|
||||
player.print({'amap.nopoint', money})
|
||||
player.remove_item {name = 'coin', count = money}
|
||||
return
|
||||
else
|
||||
rpg_t[player.index].strength = rpg_t[player.index].strength - get_point
|
||||
player.print({'amap.nb15', get_point})
|
||||
return
|
||||
end
|
||||
end
|
||||
if q == 14 then
|
||||
local luck = 50 * k + 50
|
||||
if luck >= 400 then
|
||||
luck = 400
|
||||
end
|
||||
Loot.cool(player.surface, player.surface.find_non_colliding_position('steel-chest', player.position, 20, 1, true) or player.position, 'steel-chest', luck)
|
||||
player.print({'amap.nb14', luck})
|
||||
return
|
||||
elseif q == 13 then
|
||||
local money = 10000 + 1000 * k
|
||||
player.insert {name = 'coin', count = money}
|
||||
player.print({'amap.nb13', money})
|
||||
return
|
||||
elseif q == 12 then
|
||||
local get_xp = 100 + k * 50
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + get_xp
|
||||
player.print({'amap.nb12', get_xp})
|
||||
return
|
||||
elseif q == 11 then
|
||||
local amount = 10 + 10 * k
|
||||
player.insert {name = 'distractor-capsule', count = amount}
|
||||
player.print({'amap.nb11', amount})
|
||||
return
|
||||
elseif q == 10 then
|
||||
local amount = 100 + 100 * k
|
||||
player.insert {name = 'raw-fish', count = amount}
|
||||
player.print({'amap.nb10', amount})
|
||||
return
|
||||
elseif q == 9 then
|
||||
player.insert {name = 'raw-fish', count = '1'}
|
||||
player.print({'amap.nb9'})
|
||||
return
|
||||
elseif q == 8 then
|
||||
local lost_xp = 2000 + k * 200
|
||||
if rpg_t[player.index].xp < lost_xp then
|
||||
rpg_t[player.index].xp = 0
|
||||
return
|
||||
else
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp - lost_xp
|
||||
player.print({'amap.nb8', lost_xp})
|
||||
return
|
||||
end
|
||||
elseif q == 7 then
|
||||
player.print({'amap.nb7'})
|
||||
return
|
||||
elseif q == 6 then
|
||||
rpg_t[player.index].strength = rpg_t[player.index].strength + get_point
|
||||
player.print({'amap.nb6', get_point})
|
||||
return
|
||||
elseif q == 5 then
|
||||
player.print({'amap.nb5', get_point})
|
||||
rpg_t[player.index].magicka = rpg_t[player.index].magicka + get_point
|
||||
return
|
||||
elseif q == 4 then
|
||||
player.print({'amap.nb4', get_point})
|
||||
rpg_t[player.index].dexterity = rpg_t[player.index].dexterity + get_point
|
||||
return
|
||||
elseif q == 3 then
|
||||
player.print({'amap.nb3', get_point})
|
||||
rpg_t[player.index].vitality = rpg_t[player.index].vitality + get_point
|
||||
return
|
||||
elseif q == 2 then
|
||||
player.print({'amap.nb2', get_point})
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + get_point
|
||||
return
|
||||
elseif q == 1 then
|
||||
local money = 1000 + 1000 * k
|
||||
player.print({'amap.nbone', money})
|
||||
player.insert {name = 'coin', count = money}
|
||||
return
|
||||
elseif q == 0 then
|
||||
local money = 1000 + 1000 * k
|
||||
player.print({'amap.sorry', money})
|
||||
player.remove_item {name = 'coin', count = money}
|
||||
return
|
||||
elseif q == 19 then
|
||||
player.print({'amap.what'})
|
||||
return
|
||||
end
|
||||
end
|
||||
local timereward = function()
|
||||
local game_lost = WPT.get('game_lost')
|
||||
if game_lost then
|
||||
return
|
||||
end
|
||||
local this = WPT.get()
|
||||
local last = this.last
|
||||
local wave_number = WD.get('wave_number')
|
||||
if last < wave_number then
|
||||
if wave_number % 25 == 0 then
|
||||
game.print({'amap.roll'}, {r = 0.22, g = 0.88, b = 0.22})
|
||||
--biterbuff()
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
rondom(player, wave_number)
|
||||
k = k + 1
|
||||
end
|
||||
this.last = wave_number
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local getrawrad = function()
|
||||
local game_lost = WPT.get('game_lost')
|
||||
if game_lost then
|
||||
return
|
||||
end
|
||||
local this = WPT.get()
|
||||
local wave_number = WD.get('wave_number')
|
||||
if wave_number > this.number then
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + 10
|
||||
end
|
||||
this.number = wave_number
|
||||
-- game.print({'amap.getxpfromwave'})
|
||||
end
|
||||
end
|
||||
local function calc_players()
|
||||
local players = game.connected_players
|
||||
local check_afk_players = WPT.get('check_afk_players')
|
||||
if not check_afk_players then
|
||||
return #players
|
||||
end
|
||||
local total = 0
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player.afk_time < 36000 then
|
||||
total = total + 1
|
||||
end
|
||||
end
|
||||
if total <= 0 then
|
||||
total = 1
|
||||
end
|
||||
return total
|
||||
end
|
||||
local change = function()
|
||||
local this = WPT.get()
|
||||
local roll = this.roll
|
||||
if this.change then
|
||||
this.change = false
|
||||
this.change_dist = false
|
||||
if roll == 1 then
|
||||
if this.pos.x < 0 then
|
||||
this.pos.x = this.pos.x - 75
|
||||
else
|
||||
this.pos.x = this.pos.x + 75
|
||||
end
|
||||
elseif roll == 2 then
|
||||
if this.pos.y < 0 then
|
||||
this.pos.y = this.pos.y - 75
|
||||
else
|
||||
this.pos.y = this.pos.y + 75
|
||||
end
|
||||
elseif roll == 3 then
|
||||
if this.pos.y < 0 then
|
||||
this.pos.y = -this.pos.y + 75
|
||||
else
|
||||
this.pos.y = -this.pos.y - 75
|
||||
end
|
||||
elseif roll == 4 then
|
||||
if this.pos.x < 0 then
|
||||
this.pos.x = -this.pos.x + 75
|
||||
else
|
||||
this.pos.x = -this.pos.x - 75
|
||||
end
|
||||
elseif roll == 5 then
|
||||
if this.pos.x < 0 then
|
||||
this.pos.x = this.pos.x - 75
|
||||
else
|
||||
this.pos.x = this.pos.x + 75
|
||||
end
|
||||
if this.pos.y < 0 then
|
||||
this.pos.y = this.pos.y - 75
|
||||
else
|
||||
this.pos.y = this.pos.y + 75
|
||||
end
|
||||
elseif roll == 6 then
|
||||
if this.pos.y < 0 then
|
||||
this.pos.y = -this.pos.y + 75
|
||||
else
|
||||
this.pos.y = -this.pos.y - 75
|
||||
end
|
||||
|
||||
if this.pos.x < 0 then
|
||||
this.pos.x = -this.pos.x + 75
|
||||
else
|
||||
this.pos.x = -this.pos.x - 75
|
||||
end
|
||||
end
|
||||
end
|
||||
if this.change_dist then
|
||||
this.change_dist = false
|
||||
local k = roll
|
||||
if k == 1 then
|
||||
this.pos.y = -this.pos.y
|
||||
this.pos.x = -this.pos.x
|
||||
elseif k == 2 then
|
||||
this.pos.y = -this.pos.y
|
||||
elseif k == 3 then
|
||||
this.pos.x = -this.pos.x
|
||||
elseif k == 4 then
|
||||
this.pos.y = -this.pos.y
|
||||
elseif k == 5 then
|
||||
this.pos.y = -this.pos.y
|
||||
this.pos.x = -this.pos.x
|
||||
elseif k == 6 then
|
||||
this.pos.x = -this.pos.x
|
||||
end
|
||||
end
|
||||
end
|
||||
local single_rewrad = function()
|
||||
local game_lost = WPT.get('game_lost')
|
||||
if game_lost then
|
||||
return
|
||||
end
|
||||
local wave_number = WD.get('wave_number')
|
||||
if wave_number >= 10 then
|
||||
return
|
||||
end
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
local this = WPT.get()
|
||||
local player_count = calc_players()
|
||||
if this.single and player_count <= 2 and not this.first then
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + 200
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + 5000
|
||||
player.insert {name = 'coin', count = 10000}
|
||||
player.insert {name = 'tank', count = 1}
|
||||
game.print({'amap.single'})
|
||||
this.single = false
|
||||
end
|
||||
end
|
||||
this.first = false
|
||||
end
|
||||
|
||||
local on_tick = function()
|
||||
local tick = game.tick
|
||||
|
||||
if tick % 40 == 0 then
|
||||
-- pos()
|
||||
|
||||
--bigermap()
|
||||
|
||||
-- has_the_game_ended()
|
||||
is_player_valid()
|
||||
chunk_load()
|
||||
timereward()
|
||||
getrawrad()
|
||||
-- biterup()
|
||||
end
|
||||
if tick % 500 == 0 then
|
||||
change()
|
||||
end
|
||||
|
||||
if tick % 600 == 0 then
|
||||
local this = WPT.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local roll = this.roll
|
||||
wave_defense_table.spawn_position = this.pos
|
||||
if this.roll == 6 then
|
||||
this.roll = 1
|
||||
end
|
||||
this.roll = this.roll + 1
|
||||
end
|
||||
end
|
||||
|
||||
function on_research_finished(Event)
|
||||
local this = WPT.get()
|
||||
this.science = this.science + 1
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
local point = math.floor(math.random(1, 5))
|
||||
local money = math.floor(math.random(1, 100))
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + point
|
||||
player.insert {name = 'coin', count = money}
|
||||
-- player.print({'amap.science',point,money}, {r = 0.22, g = 0.88, b = 0.22})
|
||||
Alert.alert_player(player, 5, {'amap.science', point, money})
|
||||
k = k + 1
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_joined_game = function()
|
||||
local player_count = calc_players()
|
||||
if player_count <= 4 then
|
||||
RPG_Settings.points_per_level = 10
|
||||
else
|
||||
RPG_Settings.points_per_level = 5
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_left_game = function()
|
||||
local player_count = calc_players()
|
||||
if player_count <= 4 then
|
||||
RPG_Settings.points_per_level = 10
|
||||
else
|
||||
RPG_Settings.points_per_level = 5
|
||||
end
|
||||
end
|
||||
|
||||
local change_dis = function()
|
||||
local this = WPT.get()
|
||||
this.change_dist = true
|
||||
end
|
||||
Event.add_event_filter(defines.events.on_entity_damaged, {filter = 'final-damage-amount', comparison = '>', value = 0})
|
||||
Event.on_init(on_init)
|
||||
Event.on_nth_tick(10, on_tick)
|
||||
Event.on_nth_tick(7200, single_rewrad)
|
||||
Event.on_nth_tick(60, change_dis)
|
||||
--Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
--Event.add(defines.events.on_pre_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
return Public
|
@ -1,30 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local msg = {
|
||||
[1] = {'amap.relax1'},
|
||||
[2] = {'amap.relax2'},
|
||||
[3] = {'amap.relax3'},
|
||||
[4] = {'amap.relax4'},
|
||||
[5] = {'amap.relax5'},
|
||||
[6] = {'amap.relax6'},
|
||||
[7] = {'amap.relax7'},
|
||||
[8] = {'amap.relax8'},
|
||||
[9] = {'amap.relax9'},
|
||||
[10] = {'amap.relax10'},
|
||||
[11] = {'amap.relax11'},
|
||||
[12] = {'amap.relax12'},
|
||||
[13] = {'amap.relax13'},
|
||||
[14] = {'amap.relax14'},
|
||||
[15] = {'amap.relax15'},
|
||||
[16] = {'amap.relax16'},
|
||||
[17] = {'amap.relax17'},
|
||||
[18] = {'amap.relax18'},
|
||||
[19] = {'amap.relax19'},
|
||||
[20] = {'amap.relax20'}
|
||||
}
|
||||
|
||||
local on_tick = function()
|
||||
local roll = math.random(1, #msg)
|
||||
game.print(msg[roll], {r = 0.22, g = 0.88, b = 0.22})
|
||||
end
|
||||
|
||||
Event.on_nth_tick(108000, on_tick)
|
@ -1,259 +0,0 @@
|
||||
--luacheck: ignore
|
||||
local WPT = require 'maps.amap.table'
|
||||
local Event = require 'utils.event'
|
||||
local Public = {}
|
||||
local Alert = require 'utils.alert'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local wave_defense_table = WD.get_table()
|
||||
local Task = require 'utils.task'
|
||||
local Server = require 'utils.server'
|
||||
local wall_health = require 'maps.amap.wall_health_booster'.set_health_modifier
|
||||
local spider_health = require 'maps.amap.spider_health_booster'.set_health_modifier
|
||||
local urgrade_item = function(market)
|
||||
local this = WPT.get()
|
||||
local pirce_wall = this.health * 1000 + 10000
|
||||
local pirce_arty = this.arty * 1000 + 10000
|
||||
local biter_health = this.biter_health * 1000 + 7000
|
||||
local spider_health = this.spider_health * 1000 + 10000
|
||||
local pirce_biter_dam = this.biter_dam * 1000 + 7000
|
||||
if pirce_arty >= 50000 then
|
||||
pirce_arty = 50000
|
||||
end
|
||||
|
||||
if pirce_wall >= 50000 then
|
||||
pirce_wall = 50000
|
||||
end
|
||||
|
||||
if biter_health >= 50000 then
|
||||
biter_health = 50000
|
||||
end
|
||||
if spider_health >= 50000 then
|
||||
spider_health = 50000
|
||||
end
|
||||
if pirce_biter_dam >= 50000 then
|
||||
pirce_biter_dam = 50000
|
||||
end
|
||||
local health_wall = {price = {{'coin', pirce_wall}}, offer = {type = 'nothing', effect_description = {'amap.buy_health_wall'}}}
|
||||
local arty_dam = {price = {{'coin', pirce_arty}}, offer = {type = 'nothing', effect_description = {'amap.buy_arty_dam'}}}
|
||||
local player_biter_health = {price = {{'coin', biter_health}}, offer = {type = 'nothing', effect_description = {'amap.player_biter_health'}}}
|
||||
local spider_buy = {price = {{'coin', spider_health}}, offer = {type = 'nothing', effect_description = {'amap.player_spider_health'}}}
|
||||
local biter_dam = {price = {{'coin', pirce_biter_dam}}, offer = {type = 'nothing', effect_description = {'amap.player_biter_dam'}}}
|
||||
local buy_cap = {price = {{'coin', 50000}}, offer = {type = 'nothing', effect_description = {'amap.buy_cap'}}}
|
||||
market.add_market_item(health_wall)
|
||||
market.add_market_item(arty_dam)
|
||||
market.add_market_item(player_biter_health)
|
||||
market.add_market_item(spider_buy)
|
||||
market.add_market_item(biter_dam)
|
||||
market.add_market_item(buy_cap)
|
||||
end
|
||||
|
||||
local market_items = {
|
||||
{price = {{'coin', 5}}, offer = {type = 'give-item', item = 'raw-fish', count = 1}},
|
||||
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'car', count = 1}},
|
||||
{price = {{'coin', 15000}}, offer = {type = 'give-item', item = 'tank', count = 1}},
|
||||
{price = {{'coin', 60000}}, offer = {type = 'give-item', item = 'spidertron', count = 1}},
|
||||
{price = {{'coin', 500}}, offer = {type = 'give-item', item = 'spidertron-remote', count = 1}},
|
||||
--{price = {{"coin", 5000}}, offer = {type = 'give-item', item = 'locomotive', count = 1}},
|
||||
--{price = {{"coin", 5000}}, offer = {type = 'give-item', item = 'cargo-wagon', count = 1}},
|
||||
--{price = {{"coin", 5000}}, offer = {type = 'give-item', item = 'fluid-wagon', count = 1}}
|
||||
{price = {{'coin', 25000}}, offer = {type = 'give-item', item = 'tank-cannon', count = 1}},
|
||||
{price = {{'coin', 128}}, offer = {type = 'give-item', item = 'loader', count = 1}},
|
||||
{price = {{'coin', 512}}, offer = {type = 'give-item', item = 'fast-loader', count = 1}},
|
||||
{price = {{'coin', 4096}}, offer = {type = 'give-item', item = 'express-loader', count = 1}},
|
||||
{price = {{'raw-fish', 1}}, offer = {type = 'give-item', item = 'coin', count = 5}},
|
||||
{price = {{'coin', 5000}}, offer = {type = 'give-item', item = 'flamethrower-turret', count = 1}}
|
||||
}
|
||||
|
||||
function Public.spawn(surface, position)
|
||||
local this = WPT.get()
|
||||
this.rock = surface.create_entity {name = 'rocket-silo', position = position, force = game.forces.player}
|
||||
|
||||
this.rock.minable = false
|
||||
game.forces.player.set_spawn_position({0, 0}, surface)
|
||||
end
|
||||
|
||||
function Public.market(surface)
|
||||
local this = WPT.get()
|
||||
local market = surface.create_entity {name = 'market', position = {x = 0, y = -10}, force = game.forces.player}
|
||||
|
||||
market.last_user = nil
|
||||
if market ~= nil then
|
||||
market.destructible = false
|
||||
if market ~= nil then
|
||||
game.print(1)
|
||||
urgrade_item(market)
|
||||
for _, item in pairs(market_items) do
|
||||
market.add_market_item(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_rocket_launched(Event)
|
||||
local this = WPT.get()
|
||||
--game.print({'amap.times',this.times})
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
--local money = 1000 + this.times*1000
|
||||
local money = 10000
|
||||
local point = 1
|
||||
-- if money >= 50000 then
|
||||
-- money = 50000
|
||||
-- end
|
||||
-- if point >= 100 then
|
||||
-- point = 100
|
||||
-- end
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + point
|
||||
player.insert {name = 'coin', count = money}
|
||||
player.print({'amap.reward', this.times, point, money}, {r = 0.22, g = 0.88, b = 0.22})
|
||||
end
|
||||
if not this.pass then
|
||||
local wave_number = WD.get('wave_number')
|
||||
local msg = {'amap.pass', wave_number}
|
||||
for k, p in pairs(game.connected_players) do
|
||||
local player = game.connected_players[k]
|
||||
Alert.alert_player(player, 25, msg)
|
||||
end
|
||||
Server.to_discord_embed(table.concat({'** we win the game ! Record is ', wave_number}))
|
||||
this.pass = true
|
||||
end
|
||||
this.times = this.times + 1
|
||||
end
|
||||
|
||||
local function on_entity_died(Event)
|
||||
local this = WPT.get()
|
||||
if Event.entity == this.rock then
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.75}
|
||||
end
|
||||
--game.print({'amap.lost',wave_number}),{r = 1, g = 0, b = 0, a = 0.5})
|
||||
local wave_number = WD.get('wave_number')
|
||||
local msg = {'amap.lost', wave_number}
|
||||
for _, p in pairs(game.connected_players) do
|
||||
Alert.alert_player(p, 25, msg)
|
||||
end
|
||||
Server.to_discord_embed(table.concat({'** we lost the game ! Record is ', wave_number}))
|
||||
local Reset_map = require 'maps.amap.main'.reset_map
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
-- game.forces.enemy.set_friend('player', true)
|
||||
--game.print('设置右军友好')
|
||||
-- game.forces.player.set_friend('enemy', true)
|
||||
--game.print('设置敌军友好')
|
||||
--local game_reset_tick = WPT.get('game_reset_tick')
|
||||
-- game.print('GG,游戏结束,稍后自动重启',{r = 0.99, g = 0.00, b = 0.22})
|
||||
-- this.game_reset_tick = 5400
|
||||
|
||||
Reset_map()
|
||||
|
||||
--abc()
|
||||
end
|
||||
end
|
||||
|
||||
local function on_market_item_purchased(event)
|
||||
local player = game.players[event.player_index]
|
||||
local market = event.market
|
||||
local offer_index = event.offer_index
|
||||
local count = event.count
|
||||
local offers = market.get_market_items()
|
||||
local bought_offer = offers[offer_index].offer
|
||||
local this = WPT.get()
|
||||
local index = game.forces.player.index
|
||||
if bought_offer.type ~= 'nothing' then
|
||||
return
|
||||
end
|
||||
|
||||
if offer_index == 1 then
|
||||
local wave_number = WD.get('wave_number')
|
||||
local times = math.floor(wave_number / 100) + this.cap
|
||||
if this.health >= times then
|
||||
player.print({'amap.cap_upgrad'})
|
||||
local pirce_wall = this.health * 1000 + 10000
|
||||
if pirce_wall >= 50000 then
|
||||
pirce_wall = 50000
|
||||
end
|
||||
player.insert {name = 'coin', count = pirce_wall}
|
||||
return
|
||||
end
|
||||
this.health = this.health + 1
|
||||
wall_health(index, this.health * 0.1 + 1.1)
|
||||
game.print({'amap.buy_wall_over', player.name, this.health * 0.1 + 1})
|
||||
end
|
||||
|
||||
if offer_index == 2 then
|
||||
this.arty = this.arty + 1
|
||||
game.forces.player.set_ammo_damage_modifier('artillery-shell', this.arty * 0.1)
|
||||
game.print({'amap.buy_arty_over', player.name, this.arty * 0.1 + 1})
|
||||
end
|
||||
if offer_index == 3 then
|
||||
local wave_number = WD.get('wave_number')
|
||||
local times = math.floor(wave_number / 50) + this.cap
|
||||
if this.biter_health >= times then
|
||||
player.print({'amap.cap_upgrad'})
|
||||
local pirce_biter_dam = this.biter_health * 1000 + 7000
|
||||
if pirce_biter_dam >= 50000 then
|
||||
pirce_biter_dam = 50000
|
||||
end
|
||||
player.insert {name = 'coin', count = pirce_biter_dam}
|
||||
return
|
||||
end
|
||||
this.biter_health = this.biter_health + 1
|
||||
global.biter_health_boost_forces[game.forces.player.index] = this.biter_health * 0.1 + 1
|
||||
game.print({'amap.buy_player_biter_over', player.name, this.biter_health * 0.1 + 1})
|
||||
end
|
||||
if offer_index == 4 then
|
||||
local wave_number = WD.get('wave_number')
|
||||
local times = math.floor(wave_number / 100) + this.cap
|
||||
if this.spider_health >= times then
|
||||
player.print({'amap.cap_upgrad'})
|
||||
local spider_health = this.spider_health * 1000 + 10000
|
||||
if spider_health >= 50000 then
|
||||
spider_health = 50000
|
||||
end
|
||||
player.insert {name = 'coin', count = spider_health}
|
||||
return
|
||||
end
|
||||
this.spider_health = this.spider_health + 1
|
||||
spider_health(index, this.spider_health * 0.1 + 1.1)
|
||||
game.print({'amap.buy_spider_health_over', player.name, this.spider_health * 0.1 + 1})
|
||||
end
|
||||
if offer_index == 5 then
|
||||
local wave_number = WD.get('wave_number')
|
||||
local times = math.floor(wave_number / 100) + this.cap + 1
|
||||
if times >= 30 then
|
||||
times = 30
|
||||
end
|
||||
if this.biter_dam >= times then
|
||||
player.print({'amap.cap_upgrad'})
|
||||
local pirce_biter_dam = this.biter_dam * 1000 + 7000
|
||||
if pirce_biter_dam >= 50000 then
|
||||
pirce_biter_dam = 50000
|
||||
end
|
||||
player.insert {name = 'coin', count = pirce_biter_dam}
|
||||
return
|
||||
end
|
||||
this.biter_dam = this.biter_dam + 1
|
||||
local damage_increase = this.biter_dam * 0.1
|
||||
game.forces.player.set_ammo_damage_modifier('melee', damage_increase)
|
||||
game.forces.player.set_ammo_damage_modifier('biological', damage_increase)
|
||||
game.print({'amap.buy_biter_dam', player.name, this.biter_dam * 0.1 + 1})
|
||||
end
|
||||
|
||||
if offer_index == 6 then
|
||||
this.cap = this.cap + 1
|
||||
game.print({'amap.buy_cap_over', player.name, this.cap})
|
||||
end
|
||||
market.force.play_sound({path = 'utility/new_objective', volume_modifier = 0.75})
|
||||
market.clear_market_items()
|
||||
urgrade_item(market)
|
||||
for k, item in pairs(market_items) do
|
||||
market.add_market_item(item)
|
||||
end
|
||||
end
|
||||
Event.add(defines.events.on_rocket_launched, on_rocket_launched)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
|
||||
return Public
|
@ -1,194 +0,0 @@
|
||||
--destroying and mining rocks yields ore -- load as last module
|
||||
local max_spill = 60
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local rock_yield = {
|
||||
['rock-big'] = 1,
|
||||
['rock-huge'] = 2,
|
||||
['sand-rock-big'] = 1
|
||||
}
|
||||
|
||||
local particles = {
|
||||
['iron-ore'] = 'iron-ore-particle',
|
||||
['copper-ore'] = 'copper-ore-particle',
|
||||
['uranium-ore'] = 'coal-particle',
|
||||
['coal'] = 'coal-particle',
|
||||
['stone'] = 'stone-particle',
|
||||
['angels-ore1'] = 'iron-ore-particle',
|
||||
['angels-ore2'] = 'copper-ore-particle',
|
||||
['angels-ore3'] = 'coal-particle',
|
||||
['angels-ore4'] = 'iron-ore-particle',
|
||||
['angels-ore5'] = 'iron-ore-particle',
|
||||
['angels-ore6'] = 'iron-ore-particle'
|
||||
}
|
||||
|
||||
local function get_chances()
|
||||
local chances = {}
|
||||
|
||||
if game.entity_prototypes['angels-ore1'] then
|
||||
for i = 1, 6, 1 do
|
||||
table.insert(chances, {'angels-ore' .. i, 1})
|
||||
end
|
||||
table.insert(chances, {'coal', 2})
|
||||
return chances
|
||||
end
|
||||
|
||||
table.insert(chances, {'iron-ore', 25})
|
||||
table.insert(chances, {'copper-ore', 17})
|
||||
table.insert(chances, {'coal', 13})
|
||||
table.insert(chances, {'uranium-ore', 2})
|
||||
table.insert(chances, {'stone', 7})
|
||||
return chances
|
||||
end
|
||||
|
||||
local function set_raffle()
|
||||
global.rocks_yield_ore['raffle'] = {}
|
||||
for _, t in pairs(get_chances()) do
|
||||
for _ = 1, t[2], 1 do
|
||||
table.insert(global.rocks_yield_ore['raffle'], t[1])
|
||||
end
|
||||
end
|
||||
global.rocks_yield_ore['size_of_raffle'] = #global.rocks_yield_ore['raffle']
|
||||
end
|
||||
|
||||
local function create_particles(surface, name, position, amount, cause_position)
|
||||
local direction_mod = (-100 + math_random(0, 200)) * 0.0004
|
||||
local direction_mod_2 = (-100 + math_random(0, 200)) * 0.0004
|
||||
|
||||
if cause_position then
|
||||
direction_mod = (cause_position.x - position.x) * 0.025
|
||||
direction_mod_2 = (cause_position.y - position.y) * 0.025
|
||||
end
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(4, 10)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_particle(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
frame_speed = 1,
|
||||
vertical_speed = 0.130,
|
||||
height = 0,
|
||||
movement = {
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_amount(entity)
|
||||
local distance_to_center = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
|
||||
|
||||
local amount = global.rocks_yield_ore_base_amount + (distance_to_center * global.rocks_yield_ore_distance_modifier)
|
||||
if amount > global.rocks_yield_ore_maximum_amount then
|
||||
amount = global.rocks_yield_ore_maximum_amount
|
||||
end
|
||||
|
||||
local m = (70 + math_random(0, 60)) * 0.01
|
||||
|
||||
amount = math_floor(amount * rock_yield[entity.name] * m)
|
||||
if amount < 1 then
|
||||
amount = 1
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not rock_yield[entity.name] then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
event.buffer.clear()
|
||||
|
||||
local ore = global.rocks_yield_ore['raffle'][math_random(1, global.rocks_yield_ore['size_of_raffle'])]
|
||||
|
||||
local count = get_amount(entity)
|
||||
count = math_floor(count * (1 + player.force.mining_drill_productivity_bonus))
|
||||
|
||||
global.rocks_yield_ore['ores_mined'] = global.rocks_yield_ore['ores_mined'] + count
|
||||
global.rocks_yield_ore['rocks_broken'] = global.rocks_yield_ore['rocks_broken'] + 1
|
||||
|
||||
local position = {x = entity.position.x, y = entity.position.y}
|
||||
|
||||
local ore_amount = math_floor(count * 0.85) + 1
|
||||
|
||||
player.surface.create_entity({name = 'flying-text', position = position, text = '+' .. ore_amount .. ' [img=item/' .. ore .. ']', color = {r = 200, g = 160, b = 30}})
|
||||
create_particles(player.surface, particles[ore], position, 64, {x = player.position.x, y = player.position.y})
|
||||
|
||||
entity.destroy()
|
||||
|
||||
if ore_amount > max_spill then
|
||||
local k = player.insert({name = ore, count = ore_amount})
|
||||
ore_amount = ore_amount - k
|
||||
if ore_amount > 0 then
|
||||
-- player.surface.spill_item_stack(position,{name = ore, count = ore_amount}, true)
|
||||
player.character.health = player.character.health - player.character.health * 0.2 - 100
|
||||
player.print({'amap.bag_isfull'}, {r = 200, g = 0, b = 30})
|
||||
end
|
||||
else
|
||||
player.surface.spill_item_stack(position, {name = ore, count = ore_amount}, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not rock_yield[entity.name] then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = entity.surface
|
||||
local ore = global.rocks_yield_ore['raffle'][math_random(1, global.rocks_yield_ore['size_of_raffle'])]
|
||||
local pos = {entity.position.x, entity.position.y}
|
||||
create_particles(surface, particles[ore], pos, 16, false)
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 or event.cause.force.index == 3 then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.rocks_yield_ore = {}
|
||||
global.rocks_yield_ore['rocks_broken'] = 0
|
||||
global.rocks_yield_ore['ores_mined'] = 0
|
||||
set_raffle()
|
||||
|
||||
if not global.rocks_yield_ore_distance_modifier then
|
||||
global.rocks_yield_ore_distance_modifier = 0.25
|
||||
end
|
||||
if not global.rocks_yield_ore_base_amount then
|
||||
global.rocks_yield_ore_base_amount = 35
|
||||
end
|
||||
if not global.rocks_yield_ore_maximum_amount then
|
||||
global.rocks_yield_ore_maximum_amount = 150
|
||||
end
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
@ -1,110 +0,0 @@
|
||||
local Server = require 'utils.server'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Modifers = require 'player_modifiers'
|
||||
local WPT = require 'maps.amap.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function reset_forces(new_surface, old_surface)
|
||||
for _, f in pairs(game.forces) do
|
||||
local spawn = {
|
||||
x = game.forces.player.get_spawn_position(old_surface).x,
|
||||
y = game.forces.player.get_spawn_position(old_surface).y
|
||||
}
|
||||
f.reset()
|
||||
f.reset_evolution()
|
||||
f.set_spawn_position(spawn, new_surface)
|
||||
end
|
||||
for _, tech in pairs(game.forces.player.technologies) do
|
||||
tech.researched = false
|
||||
game.forces.player.set_saved_technology_progress(tech, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_players(surface)
|
||||
game.forces.player.set_spawn_position({-27, 25}, surface)
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function equip_players(player_starting_items, data)
|
||||
for k, player in pairs(game.players) do
|
||||
if player.character and player.character.valid then
|
||||
player.character.destroy()
|
||||
end
|
||||
if player.connected then
|
||||
if not player.character then
|
||||
player.set_controller({type = defines.controllers.god})
|
||||
player.create_character()
|
||||
end
|
||||
player.clear_items_inside()
|
||||
Modifers.update_player_modifiers(player)
|
||||
for item, amount in pairs(player_starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
else
|
||||
data.players[player.index] = nil
|
||||
Session.clear_player(player)
|
||||
game.remove_offline_players({player.index})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_items)
|
||||
local this = WPT.get()
|
||||
|
||||
if not this.soft_reset_counter then
|
||||
this.soft_reset_counter = 0
|
||||
end
|
||||
if not this.original_surface_name then
|
||||
this.original_surface_name = old_surface.name
|
||||
end
|
||||
this.soft_reset_counter = this.soft_reset_counter + 1
|
||||
|
||||
local new_surface = game.create_surface(this.original_surface_name .. '_' .. tostring(this.soft_reset_counter), map_gen_settings)
|
||||
new_surface.request_to_generate_chunks({0, 0}, 0.5)
|
||||
new_surface.force_generate_chunk_requests()
|
||||
|
||||
reset_forces(new_surface, old_surface)
|
||||
teleport_players(new_surface)
|
||||
equip_players(player_starting_items, this)
|
||||
|
||||
game.delete_surface(old_surface)
|
||||
|
||||
local radius = 512
|
||||
local area = {{x = -radius, y = -radius}, {x = radius, y = radius}}
|
||||
for _, entity in pairs(new_surface.find_entities_filtered {area = area, type = 'logistic-robot'}) do
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
for _, entity in pairs(new_surface.find_entities_filtered {area = area, type = 'construction-robot'}) do
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
local message = table.concat({mapkeeper .. ' 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(
|
||||
{
|
||||
mapkeeper,
|
||||
' The world has been reshaped, welcome to ',
|
||||
this.original_surface_name,
|
||||
' number ',
|
||||
tostring(this.soft_reset_counter),
|
||||
'!'
|
||||
}
|
||||
)
|
||||
end
|
||||
game.print(message, {r = 0.98, g = 0.66, b = 0.22})
|
||||
Server.to_discord_embed(message_to_discord)
|
||||
|
||||
return new_surface
|
||||
end
|
||||
|
||||
return Public
|
@ -1,478 +0,0 @@
|
||||
--this adds a button that stashes/sorts your inventory into nearby chests in some kind of intelligent way - mewmew
|
||||
-- modified by gerkiz
|
||||
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local math_floor = math.floor
|
||||
local print_color = {r = 120, g = 255, b = 0}
|
||||
|
||||
local autostash = {
|
||||
floating_text_y_offsets = {},
|
||||
whitelist = {},
|
||||
insert_into_wagon = false
|
||||
}
|
||||
|
||||
local Public = {}
|
||||
|
||||
Global.register(
|
||||
autostash,
|
||||
function(t)
|
||||
autostash = t
|
||||
end
|
||||
)
|
||||
|
||||
local function create_floaty_text(surface, position, name, count)
|
||||
if autostash.floating_text_y_offsets[position.x .. '_' .. position.y] then
|
||||
autostash.floating_text_y_offsets[position.x .. '_' .. position.y] = autostash.floating_text_y_offsets[position.x .. '_' .. position.y] - 0.5
|
||||
else
|
||||
autostash.floating_text_y_offsets[position.x .. '_' .. position.y] = 0
|
||||
end
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {
|
||||
position.x,
|
||||
position.y + autostash.floating_text_y_offsets[position.x .. '_' .. position.y]
|
||||
},
|
||||
text = {'', '-', count, ' ', game.item_prototypes[name].localised_name},
|
||||
color = {r = 255, g = 255, b = 255}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function chest_is_valid(chest)
|
||||
if chest.type == 'cargo-wagon' then
|
||||
local t = {}
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
|
||||
for index = 1, 40 do
|
||||
if chest_inventory.get_filter(index) ~= nil then
|
||||
local n = chest_inventory.get_filter(index)
|
||||
t[n] = true
|
||||
end
|
||||
end
|
||||
|
||||
if not next(t) then
|
||||
return false, {}
|
||||
end
|
||||
|
||||
return true, t
|
||||
end
|
||||
|
||||
for _, e in pairs(
|
||||
chest.surface.find_entities_filtered(
|
||||
{
|
||||
type = {'inserter', 'loader'},
|
||||
area = {{chest.position.x - 1, chest.position.y - 1}, {chest.position.x + 1, chest.position.y + 1}}
|
||||
}
|
||||
)
|
||||
) do
|
||||
if e.name ~= 'long-handed-inserter' then
|
||||
if e.position.x == chest.position.x then
|
||||
if e.direction == 0 or e.direction == 4 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if e.position.y == chest.position.y then
|
||||
if e.direction == 2 or e.direction == 6 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local i1 = chest.surface.find_entity('long-handed-inserter', {chest.position.x - 2, chest.position.y})
|
||||
if i1 then
|
||||
if i1.direction == 2 or i1.direction == 6 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
local i2 = chest.surface.find_entity('long-handed-inserter', {chest.position.x + 2, chest.position.y})
|
||||
if i2 then
|
||||
if i2.direction == 2 or i2.direction == 6 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local i3 = chest.surface.find_entity('long-handed-inserter', {chest.position.x, chest.position.y - 2})
|
||||
if i3 then
|
||||
if i3.direction == 0 or i3.direction == 4 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
local i4 = chest.surface.find_entity('long-handed-inserter', {chest.position.x, chest.position.y + 2})
|
||||
if i4 then
|
||||
if i4.direction == 0 or i4.direction == 4 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function sort_entities_by_distance(position, entities)
|
||||
local t = {}
|
||||
local distance
|
||||
local index
|
||||
local size_of_entities = #entities
|
||||
if size_of_entities < 2 then
|
||||
return
|
||||
end
|
||||
|
||||
for _, entity in pairs(entities) do
|
||||
distance = (entity.position.x - position.x) ^ 2 + (entity.position.y - position.y) ^ 2
|
||||
index = math_floor(distance) + 1
|
||||
if not t[index] then
|
||||
t[index] = {}
|
||||
end
|
||||
table.insert(t[index], entity)
|
||||
end
|
||||
|
||||
local i = 0
|
||||
for _, range in pairs(t) do
|
||||
for _, entity in pairs(range) do
|
||||
i = i + 1
|
||||
entities[i] = entity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_nearby_chests(player, a)
|
||||
local r = player.force.character_reach_distance_bonus + 10
|
||||
local r_square = r * r
|
||||
local chests = {}
|
||||
local size_of_chests = 0
|
||||
local area = {{player.position.x - r, player.position.y - r}, {player.position.x + r, player.position.y + r}}
|
||||
|
||||
area = a or area
|
||||
|
||||
local container_type = {'container', 'logistic-container', 'furnace'}
|
||||
local containers = {}
|
||||
local i = 0
|
||||
|
||||
if autostash.insert_into_wagon then
|
||||
table.insert(container_type, 'cargo-wagon')
|
||||
end
|
||||
|
||||
for _, e in pairs(player.surface.find_entities_filtered({type = container_type, area = area, force = 'player'})) do
|
||||
if ((player.position.x - e.position.x) ^ 2 + (player.position.y - e.position.y) ^ 2) <= r_square then
|
||||
i = i + 1
|
||||
containers[i] = e
|
||||
end
|
||||
end
|
||||
sort_entities_by_distance(player.position, containers)
|
||||
for _, entity in pairs(containers) do
|
||||
size_of_chests = size_of_chests + 1
|
||||
chests[size_of_chests] = entity
|
||||
end
|
||||
|
||||
return chests
|
||||
end
|
||||
|
||||
local function does_inventory_contain_item_type(inventory, item_subgroup)
|
||||
for name, _ in pairs(inventory.get_contents()) do
|
||||
local t = game.item_prototypes[name]
|
||||
if t and t.subgroup.name == item_subgroup then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function insert_item_into_chest(player_inventory, chests, filtered_chests, name, count, wagon)
|
||||
local container = {
|
||||
['container'] = true,
|
||||
['logistic-container'] = true
|
||||
}
|
||||
|
||||
local to_insert = math.floor(count / #chests)
|
||||
local variator = count % #chests
|
||||
|
||||
if wagon then
|
||||
-- Attempt to load filtered cargo wagon
|
||||
for _, chest in pairs(chests) do
|
||||
if chest.type == 'cargo-wagon' then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store into furnaces.
|
||||
for _, chest in pairs(chests) do
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.furnace_source)
|
||||
if chest_inventory and chest.type == 'furnace' then
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, chest in pairs(chests) do
|
||||
if chest.type == 'furnace' then
|
||||
local amount = to_insert
|
||||
if variator > 0 then
|
||||
amount = amount + 1
|
||||
variator = variator - 1
|
||||
end
|
||||
if amount <= 0 then
|
||||
return
|
||||
end
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = amount}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = amount})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in chests that already have the same item.
|
||||
for _, chest in pairs(chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
if chest_inventory.find_item_stack(name) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in empty chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
if chest_inventory.is_empty() then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in chests with same item subgroup.
|
||||
local item_subgroup = game.item_prototypes[name].subgroup.name
|
||||
if item_subgroup then
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
if does_inventory_contain_item_type(chest_inventory, item_subgroup) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in mixed chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = count}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function auto_stash(player, event)
|
||||
local button = event.button
|
||||
local shift = event.shift
|
||||
if not player.character then
|
||||
player.print('It seems that you are not in the realm of the living.', print_color)
|
||||
return
|
||||
end
|
||||
if not player.character.valid then
|
||||
player.print('It seems that you are not in the realm of the living.', print_color)
|
||||
return
|
||||
end
|
||||
local inventory = player.get_inventory(defines.inventory.character_main)
|
||||
if inventory.is_empty() then
|
||||
player.print('Inventory is empty.', print_color)
|
||||
return
|
||||
end
|
||||
local chests
|
||||
local r = 1
|
||||
local area = {{player.position.x - r, player.position.y - r}, {player.position.x + r, player.position.y + r}}
|
||||
if shift then
|
||||
if button == defines.mouse_button_type.right or button == defines.mouse_button_type.left and autostash.insert_into_wagon then
|
||||
chests = get_nearby_chests(player, area)
|
||||
end
|
||||
else
|
||||
chests = get_nearby_chests(player)
|
||||
end
|
||||
|
||||
if not chests[1] then
|
||||
player.print('No valid nearby containers found.', print_color)
|
||||
return
|
||||
end
|
||||
|
||||
local filtered_chests = {}
|
||||
local filtered_allowed
|
||||
for _, e in pairs(chests) do
|
||||
local is_valid, t = chest_is_valid(e)
|
||||
filtered_allowed = t
|
||||
if is_valid then
|
||||
filtered_chests[#filtered_chests + 1] = e
|
||||
end
|
||||
end
|
||||
|
||||
autostash.floating_text_y_offsets = {}
|
||||
|
||||
local hotbar_items = {}
|
||||
for i = 1, 100, 1 do
|
||||
local prototype = player.get_quick_bar_slot(i)
|
||||
if prototype then
|
||||
hotbar_items[prototype.name] = true
|
||||
end
|
||||
end
|
||||
|
||||
for name, count in pairs(inventory.get_contents()) do
|
||||
local is_resource = autostash.whitelist[name]
|
||||
|
||||
if not inventory.find_item_stack(name).grid and not hotbar_items[name] then
|
||||
if shift and autostash.insert_into_wagon then
|
||||
if button == defines.mouse_button_type.left then
|
||||
if is_resource then
|
||||
insert_item_into_chest(inventory, chests, filtered_chests, name, count, true)
|
||||
end
|
||||
end
|
||||
if button == defines.mouse_button_type.right then
|
||||
if filtered_allowed and is_resource and filtered_allowed[name] then
|
||||
insert_item_into_chest(inventory, chests, filtered_chests, name, count, true)
|
||||
end
|
||||
end
|
||||
elseif button == defines.mouse_button_type.right then
|
||||
if is_resource then
|
||||
insert_item_into_chest(inventory, chests, filtered_chests, name, count)
|
||||
end
|
||||
elseif button == defines.mouse_button_type.left then
|
||||
insert_item_into_chest(inventory, chests, filtered_chests, name, count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local c = autostash.floating_text_y_offsets
|
||||
for k, _ in pairs(c) do
|
||||
autostash.floating_text_y_offsets[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function create_gui_button(player)
|
||||
if player.gui.top.auto_stash then
|
||||
return
|
||||
end
|
||||
local tooltip
|
||||
if autostash.insert_into_wagon then
|
||||
tooltip =
|
||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores.\nSHIFT+LMB: Only ores to wagon\nSHIFT+RMB: Only ores onto filtered slots to wagon.'
|
||||
else
|
||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores.'
|
||||
end
|
||||
local b =
|
||||
player.gui.top.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/wooden-chest',
|
||||
name = 'auto_stash',
|
||||
tooltip = tooltip
|
||||
}
|
||||
)
|
||||
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
|
||||
b.style.font = 'heading-1'
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 38
|
||||
b.style.maximal_height = 38
|
||||
b.style.maximal_width = 38
|
||||
b.style.padding = 1
|
||||
b.style.margin = 0
|
||||
end
|
||||
|
||||
local function do_whitelist()
|
||||
local resources = game.entity_prototypes
|
||||
autostash.whitelist = {}
|
||||
for k, _ in pairs(resources) do
|
||||
if resources[k] and resources[k].type == 'resource' and resources[k].mineable_properties then
|
||||
if resources[k].mineable_properties.products[1] then
|
||||
local r = resources[k].mineable_properties.products[1].name
|
||||
autostash.whitelist[r] = true
|
||||
elseif resources[k].mineable_properties.products[2] then
|
||||
local r = resources[k].mineable_properties.products[2].name
|
||||
autostash.whitelist[r] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
create_gui_button(game.players[event.player_index])
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event.element then
|
||||
return
|
||||
end
|
||||
if not event.element.valid then
|
||||
return
|
||||
end
|
||||
if event.element.name == 'auto_stash' then
|
||||
auto_stash(game.players[event.player_index], event)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.insert_into_wagon(value)
|
||||
if value then
|
||||
autostash.insert_into_wagon = value or false
|
||||
end
|
||||
end
|
||||
|
||||
Event.on_configuration_changed = function()
|
||||
do_whitelist()
|
||||
log('[Autostash] on_configuration_changed was called, rebuilding resource whitelist.')
|
||||
end
|
||||
|
||||
Event.on_init(do_whitelist)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
return Public
|
@ -1,129 +0,0 @@
|
||||
-- All entities that own a unit_number of a chosen force gain damage resistance.
|
||||
-- ignores entity health regeneration
|
||||
|
||||
-- Use Public.set_health_modifier(force_index, modifier) to modify health.
|
||||
-- 1 = original health, 2 = 200% total health, 4 = 400% total health,..
|
||||
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Public = {}
|
||||
|
||||
local math_round = math.round
|
||||
|
||||
local fhb = {}
|
||||
Global.register(
|
||||
fhb,
|
||||
function(tbl)
|
||||
fhb = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.set_health_modifier(force_index, modifier)
|
||||
if not game.forces[force_index] then
|
||||
return
|
||||
end
|
||||
if not modifier then
|
||||
return
|
||||
end
|
||||
if not fhb[force_index] then
|
||||
fhb[force_index] = {}
|
||||
end
|
||||
fhb[force_index].m = math_round(1 / modifier, 4)
|
||||
end
|
||||
|
||||
function Public.reset_tables()
|
||||
for k, _ in pairs(fhb) do
|
||||
fhb[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local entity = event.entity
|
||||
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not (entity.name == 'spidertron') then
|
||||
return
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local boost = fhb[entity.force.index]
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
if not boost[unit_number] then
|
||||
boost[unit_number] = entity.prototype.max_health
|
||||
end
|
||||
|
||||
local new_health = boost[unit_number] - event.final_damage_amount * boost.m
|
||||
boost[unit_number] = new_health
|
||||
entity.health = new_health
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not (entity.name == 'spidertron') then
|
||||
return
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
local boost = fhb[entity.force.index]
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
boost[unit_number] = nil
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not (entity.name == 'spidertron') then
|
||||
return
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
local boost = fhb[entity.force.index]
|
||||
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
boost[unit_number] = entity.health
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
Public.reset_tables()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
|
||||
|
||||
return Public
|
@ -1,75 +0,0 @@
|
||||
local Global = require 'utils.global'
|
||||
local surface_name = 'amap'
|
||||
local Reset = require 'maps.amap.soft_reset'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local this = {
|
||||
active_surface_index = nil,
|
||||
surface_name = surface_name
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['wood'] = 16}
|
||||
|
||||
function Public.create_surface()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math.random(10000, 99999),
|
||||
['starting_area'] = 1.2,
|
||||
['default_enable_all_autoplace_controls'] = true,
|
||||
['water'] = 0.65
|
||||
}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
['coal'] = {frequency = '1', size = '1', richness = '1'},
|
||||
['stone'] = {frequency = '1', size = '1', richness = '1'},
|
||||
['copper-ore'] = {frequency = '1', size = '2', richness = '1'},
|
||||
['iron-ore'] = {frequency = '1', size = '2', richness = '1'},
|
||||
['crude-oil'] = {frequency = '2', size = '2', richness = '1'},
|
||||
['trees'] = {frequency = '1', size = '0.5', richness = '0.7'},
|
||||
['enemy-base'] = {frequency = '4', size = '2', richness = '1'}
|
||||
--["starting_area"] = 1.2,
|
||||
}
|
||||
if not this.active_surface_index then
|
||||
this.active_surface_index = game.create_surface(surface_name, map_gen_settings).index
|
||||
else
|
||||
this.active_surface_index = Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
|
||||
end
|
||||
|
||||
if not this.cleared_nauvis then
|
||||
local mgs = game.surfaces['nauvis'].map_gen_settings
|
||||
mgs.width = 16
|
||||
mgs.height = 16
|
||||
game.surfaces['nauvis'].map_gen_settings = mgs
|
||||
game.surfaces['nauvis'].clear()
|
||||
this.cleared_nauvis = true
|
||||
end
|
||||
--local size = game.surfaces[this.active_surface_index].map_gen_settings
|
||||
-- size.width = 512
|
||||
-- size.height = 512
|
||||
--game.surfaces[this.active_surface_index].map_gen_settings = size
|
||||
return this.active_surface_index
|
||||
end
|
||||
|
||||
function Public.get_active_surface()
|
||||
return this.active_surface
|
||||
end
|
||||
|
||||
function Public.get_surface_name()
|
||||
return this.surface_name
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
@ -1,189 +0,0 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
traps = {}
|
||||
}
|
||||
local Public = {}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
Public.level_depth = 512
|
||||
Public.level_width = 512
|
||||
function Public.reset_table()
|
||||
-- @start
|
||||
-- these 3 are in case of stop/start/reloading the instance
|
||||
this.biter_dam = 0
|
||||
this.cap = 2
|
||||
this.biter_health = 0
|
||||
this.change_dist = false
|
||||
this.spider_health = 0
|
||||
this.arty = 0
|
||||
this.health = 0
|
||||
this.flame = 0
|
||||
this.roll = 0
|
||||
this.pass = false
|
||||
this.single = true
|
||||
this.science = 0
|
||||
this.number = 0
|
||||
this.first = true
|
||||
this.times = 1
|
||||
this.change = false
|
||||
this.pos = {x = 0, y = 0}
|
||||
this.last = 0
|
||||
this.rock = nil
|
||||
this.soft_reset = true
|
||||
this.restart = false
|
||||
this.shutdown = false
|
||||
this.announced_message = false
|
||||
this.game_saved = false
|
||||
-- @end
|
||||
this.icw_locomotive = nil
|
||||
this.debug = false
|
||||
this.game_lost = false
|
||||
this.fullness_enabled = true
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.gap_between_zones = {
|
||||
set = false,
|
||||
gap = 900,
|
||||
neg_gap = -500,
|
||||
highest_pos = 0
|
||||
}
|
||||
this.force_chunk = false
|
||||
this.train_upgrades = 0
|
||||
this.biter_pets = {}
|
||||
this.flamethrower_damage = {}
|
||||
this.mined_scrap = 0
|
||||
this.biters_killed = 0
|
||||
this.cleared_nauvis = false
|
||||
this.locomotive_xp_aura = 40
|
||||
this.locomotive_pos = {tbl = {}}
|
||||
this.trusted_only_car_tanks = true
|
||||
this.xp_points = 0
|
||||
this.xp_points_upgrade = 0
|
||||
--!grief prevention
|
||||
this.enable_arties = 6 -- default to callback 6
|
||||
--!snip
|
||||
this.poison_deployed = false
|
||||
this.upgrades = {
|
||||
showed_text = false,
|
||||
landmine = {
|
||||
limit = 25,
|
||||
bought = 0,
|
||||
built = 0
|
||||
},
|
||||
flame_turret = {
|
||||
limit = 6,
|
||||
bought = 0,
|
||||
built = 0
|
||||
},
|
||||
unit_number = {
|
||||
landmine = {},
|
||||
flame_turret = {}
|
||||
}
|
||||
}
|
||||
this.aura_upgrades = 0
|
||||
this.pickaxe_tier = 1
|
||||
this.pickaxe_speed_per_purchase = 0.10
|
||||
this.health_upgrades = 0
|
||||
this.breached_wall = 1
|
||||
this.left_top = {
|
||||
x = 0,
|
||||
y = 0
|
||||
}
|
||||
this.biters = {
|
||||
amount = 0,
|
||||
limit = 512
|
||||
}
|
||||
this.traps = {}
|
||||
this.munch_time = true
|
||||
this.coin_amount = 1
|
||||
this.difficulty_set = false
|
||||
this.bonus_xp_on_join = 250
|
||||
this.main_market_items = {}
|
||||
this.spill_items_to_surface = false
|
||||
this.outside_chests = {}
|
||||
this.chests_linked_to = {}
|
||||
this.chest_limit_outside_upgrades = 1
|
||||
this.placed_trains_in_zone = {
|
||||
placed = 0,
|
||||
positions = {},
|
||||
limit = 2,
|
||||
randomized = false
|
||||
}
|
||||
this.marked_fixed_prices = {
|
||||
chest_limit_cost = 3000,
|
||||
health_cost = 10000,
|
||||
pickaxe_cost = 3000,
|
||||
aura_cost = 4000,
|
||||
xp_point_boost_cost = 5000,
|
||||
explosive_bullets_cost = 20000,
|
||||
flamethrower_turrets_cost = 3000,
|
||||
land_mine_cost = 2,
|
||||
skill_reset_cost = 100000
|
||||
}
|
||||
this.collapse_grace = true
|
||||
this.explosive_bullets = false
|
||||
this.locomotive_biter = nil
|
||||
this.disconnect_wagon = false
|
||||
this.offline_players_enabled = true
|
||||
this.offline_players = {}
|
||||
this.collapse_amount = false
|
||||
this.collapse_speed = false
|
||||
this.spawn_near_collapse = {
|
||||
active = true,
|
||||
total_pos = 35,
|
||||
compare = -150,
|
||||
compare_next = 200,
|
||||
distance_from = 2
|
||||
}
|
||||
this.spidertron_unlocked_at_wave = 11
|
||||
-- this.void_or_tile = 'lab-dark-2'
|
||||
this.void_or_tile = 'out-of-map'
|
||||
this.validate_spider = {}
|
||||
this.check_afk_players = true
|
||||
this.winter_mode = false
|
||||
this.sent_to_discord = false
|
||||
this.difficulty = {
|
||||
multiply = 0.25,
|
||||
highest = 10
|
||||
}
|
||||
|
||||
--!reset player tables
|
||||
for _, player in pairs(this.players) do
|
||||
player.died = false
|
||||
end
|
||||
end
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set(key, value)
|
||||
if key and (value or value == false) then
|
||||
this[key] = value
|
||||
return this[key]
|
||||
elseif key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
Public.reset_table()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
File diff suppressed because it is too large
Load Diff
@ -1,147 +0,0 @@
|
||||
-- All entities that own a unit_number of a chosen force gain damage resistance.
|
||||
-- ignores entity health regeneration
|
||||
|
||||
-- Use Public.set_health_modifier(force_index, modifier) to modify health.
|
||||
-- 1 = original health, 2 = 200% total health, 4 = 400% total health,..
|
||||
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Public = {}
|
||||
|
||||
local math_round = math.round
|
||||
|
||||
local fhb = {}
|
||||
Global.register(
|
||||
fhb,
|
||||
function(tbl)
|
||||
fhb = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.set_health_modifier(force_index, modifier)
|
||||
if not game.forces[force_index] then
|
||||
return
|
||||
end
|
||||
if not modifier then
|
||||
return
|
||||
end
|
||||
if not fhb[force_index] then
|
||||
fhb[force_index] = {}
|
||||
end
|
||||
fhb[force_index].m = math_round(1 / modifier, 4)
|
||||
end
|
||||
|
||||
function Public.reset_tables()
|
||||
for k, _ in pairs(fhb) do
|
||||
fhb[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local entity = event.entity
|
||||
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not (entity.name == 'stone-wall') then
|
||||
if not (entity.name == 'gun-turret') then
|
||||
if not (entity.name == 'laser-turret') then
|
||||
-- if not (entity.name == 'flamethrower-turret') then
|
||||
return
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local boost = fhb[entity.force.index]
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
if not boost[unit_number] then
|
||||
boost[unit_number] = entity.prototype.max_health
|
||||
end
|
||||
|
||||
local new_health = boost[unit_number] - event.final_damage_amount * boost.m
|
||||
boost[unit_number] = new_health
|
||||
entity.health = new_health
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not (entity.name == 'stone-wall') then
|
||||
if not (entity.name == 'gun-turret') then
|
||||
if not (entity.name == 'laser-turret') then
|
||||
-- if not (entity.name == 'flamethrower-turret') then
|
||||
return
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
local boost = fhb[entity.force.index]
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
boost[unit_number] = nil
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not (entity.name == 'stone-wall') then
|
||||
if not (entity.name == 'gun-turret') then
|
||||
if not (entity.name == 'laser-turret') then
|
||||
-- if not (entity.name == 'flamethrower-turret') then
|
||||
return
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local unit_number = entity.unit_number
|
||||
local boost = fhb[entity.force.index]
|
||||
|
||||
if not unit_number then
|
||||
return
|
||||
end
|
||||
if not boost then
|
||||
return
|
||||
end
|
||||
boost[unit_number] = entity.health
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
Public.reset_tables()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
|
||||
|
||||
return Public
|
@ -1,219 +0,0 @@
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local map_data = require 'maps.pidgeotto.layout'
|
||||
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
local floor = math.floor
|
||||
local scale = 1
|
||||
|
||||
local Public = {}
|
||||
|
||||
local tile_map = {
|
||||
[1] = false,
|
||||
[2] = true,
|
||||
[3] = 'concrete',
|
||||
[4] = 'deepwater-green',
|
||||
[5] = 'deepwater',
|
||||
[6] = 'dirt-1',
|
||||
[7] = 'dirt-2',
|
||||
[8] = 'dirt-3',
|
||||
[9] = 'dirt-4',
|
||||
[10] = 'dirt-5',
|
||||
[11] = 'dirt-6',
|
||||
[12] = 'dirt-7',
|
||||
[13] = 'dry-dirt',
|
||||
[14] = 'grass-1',
|
||||
[15] = 'grass-2',
|
||||
[16] = 'grass-3',
|
||||
[17] = 'grass-4',
|
||||
[18] = 'hazard-concrete-left',
|
||||
[19] = 'hazard-concrete-right',
|
||||
[20] = 'lab-dark-1',
|
||||
[21] = 'lab-dark-2',
|
||||
[22] = 'lab-white',
|
||||
[23] = 'out-of-map',
|
||||
[24] = 'red-desert-0',
|
||||
[25] = 'red-desert-1',
|
||||
[26] = 'red-desert-2',
|
||||
[27] = 'red-desert-3',
|
||||
[28] = 'sand-1',
|
||||
[29] = 'sand-2',
|
||||
[30] = 'sand-3',
|
||||
[31] = 'stone-path',
|
||||
[32] = 'water-green',
|
||||
[33] = 'water',
|
||||
[34] = 'water-shallow',
|
||||
[35] = 'black-refined-concrete'
|
||||
}
|
||||
|
||||
local rock_raffle = {
|
||||
'sand-rock-big',
|
||||
'sand-rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-huge'
|
||||
}
|
||||
|
||||
local function decompress()
|
||||
local decompressed = {}
|
||||
local data = map_data.data
|
||||
local height = map_data.height
|
||||
local width = map_data.width
|
||||
|
||||
for y = 1, height do
|
||||
local row = data[y]
|
||||
local u_row = {}
|
||||
decompressed[y] = u_row
|
||||
local x = 1
|
||||
for index = 1, #row, 2 do
|
||||
local pixel = row[index]
|
||||
local count = row[index + 1]
|
||||
|
||||
for _ = 1, count do
|
||||
u_row[x] = pixel
|
||||
x = x + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return decompressed, width, height
|
||||
end
|
||||
local tile_data, width, height = decompress()
|
||||
|
||||
local function get_pos(x, y)
|
||||
-- the plus one is because lua tables are one based.
|
||||
local half_width = floor(width / 2) + 1
|
||||
local half_height = floor(height / 2) + 1
|
||||
x = x / scale
|
||||
y = y / scale
|
||||
x = floor(x)
|
||||
y = floor(y)
|
||||
local x2 = x + half_width
|
||||
local y2 = y + half_height
|
||||
|
||||
if y2 > 0 and y2 <= height and x2 > 0 and x2 <= width then
|
||||
return tile_map[tile_data[y2][x2]]
|
||||
end
|
||||
end
|
||||
|
||||
local ores = {'coal', 'iron-ore', 'copper-ore', 'stone'}
|
||||
|
||||
local function plankton_territory(position, seed, ent)
|
||||
local noise = simplex_noise(position.x * 0.009, position.y * 0.009, seed)
|
||||
local d = 196
|
||||
|
||||
if get_pos(position.x, position.y) then
|
||||
return
|
||||
end
|
||||
|
||||
if position.x + position.y > (d * -1) - (abs(noise) * d * 3) and position.x > position.y - (d + (abs(noise) * d * 3)) then
|
||||
return 'out-of-map'
|
||||
end
|
||||
|
||||
local noise_2 = simplex_noise(position.x * 0.0075, position.y * 0.0075, seed + 10000)
|
||||
--if noise_2 > 0.87 then surface.set_tiles({{name = "deepwater-green", position = position}}, true) return true end
|
||||
if noise_2 > 0.87 then
|
||||
return 'deepwater-green'
|
||||
end
|
||||
if noise_2 > 0.75 then
|
||||
local i = floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
ent[#ent + 1] = {name = ores[i], position = position, amount = 1 + 2500 * abs(noise_2 * 3)}
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if noise_2 < -0.76 then
|
||||
local i = floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if noise_2 < -0.86 then
|
||||
ent[#ent + 1] = {name = 'uranium-ore', position = position, amount = 1 + 1000 * abs(noise_2 * 2)}
|
||||
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if random(1, 3) ~= 1 then
|
||||
ent[#ent + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = position}
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
|
||||
if noise < 0.12 and noise > -0.12 then
|
||||
local i = floor(noise * 32) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if random(1, 5) == 1 then
|
||||
ent[#ent + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = position}
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
|
||||
--surface.set_tiles({{name = "water", position = position}}, true)
|
||||
if random(1, 128) == 1 then
|
||||
ent[#ent + 1] = {name = 'fish', position = position}
|
||||
end
|
||||
|
||||
return 'water'
|
||||
end
|
||||
|
||||
local function get_random_ore(position)
|
||||
local noise = (position.x * 0.009)
|
||||
local i = floor(noise * 6) % 4 + 1
|
||||
local ore = ores[i]
|
||||
|
||||
return ore
|
||||
end
|
||||
|
||||
function Public.make_chunk(event)
|
||||
local map_name = 'pidgeotto'
|
||||
|
||||
if string.sub(event.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = event.surface
|
||||
|
||||
local x1 = event.area.left_top.x
|
||||
local y1 = event.area.left_top.y
|
||||
local x2 = event.area.right_bottom.x
|
||||
local y2 = event.area.right_bottom.y
|
||||
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
|
||||
local noise = {}
|
||||
local tiles = {}
|
||||
local ent = {}
|
||||
|
||||
for x = x1, x2 do
|
||||
for y = y1, y2 do
|
||||
local pos = {x = x, y = y}
|
||||
local new = get_pos(x, y)
|
||||
local ore = get_random_ore(pos)
|
||||
|
||||
if new and type(new) == 'string' then
|
||||
if new == 'lab-dark-2' then
|
||||
ent[#ent + 1] = {name = ore, position = pos, amount = 2500}
|
||||
else
|
||||
tiles[#tiles + 1] = {name = new, position = pos}
|
||||
end
|
||||
else
|
||||
local tile_to_set = plankton_territory(pos, seed, ent)
|
||||
if tile_to_set then
|
||||
noise[#noise + 1] = {name = tile_to_set, position = pos}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
surface.set_tiles(noise, true)
|
||||
for i = 1, #ent do
|
||||
if ent[i].amount then
|
||||
surface.create_entity({name = ent[i].name, position = ent[i].position, amount = ent[i].amount})
|
||||
else
|
||||
surface.create_entity({name = ent[i].name, position = ent[i].position})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
@ -1,99 +0,0 @@
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local boss_biter = {}
|
||||
local math_random = math.random
|
||||
local radius = 6
|
||||
local targets = {}
|
||||
local acid_splashes = {
|
||||
['big-biter'] = 'acid-stream-worm-medium',
|
||||
['behemoth-biter'] = 'acid-stream-worm-big',
|
||||
['big-spitter'] = 'acid-stream-worm-medium',
|
||||
['behemoth-spitter'] = 'acid-stream-worm-big'
|
||||
}
|
||||
local acid_lines = {
|
||||
['big-spitter'] = 'acid-stream-spitter-medium',
|
||||
['behemoth-spitter'] = 'acid-stream-spitter-big'
|
||||
}
|
||||
for x = radius * -1, radius, 1 do
|
||||
for y = radius * -1, radius, 1 do
|
||||
if math.sqrt(x ^ 2 + y ^ 2) <= radius then
|
||||
targets[#targets + 1] = {x = x, y = y}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function acid_nova(event)
|
||||
for _ = 1, math.random(16, 32) do
|
||||
local i = math.random(1, #targets)
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = acid_splashes[event.entity.name],
|
||||
position = event.entity.position,
|
||||
force = event.entity.force.name,
|
||||
source = event.entity.position,
|
||||
target = {x = event.entity.position.x + targets[i].x, y = event.entity.position.y + targets[i].y},
|
||||
max_range = radius,
|
||||
speed = 0.001
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
boss_biter.died = function(event)
|
||||
local acid_lines_delay = FDT.get('acid_lines_delay')
|
||||
if acid_splashes[event.entity.name] then
|
||||
acid_nova(event)
|
||||
end
|
||||
if acid_lines_delay[event.entity.unit_number] then
|
||||
FDT.get('acid_lines_delay')[event.entity.unit_number] = nil
|
||||
end
|
||||
FDT.get('boss_biters')[event.entity.unit_number] = nil
|
||||
end
|
||||
|
||||
local function acid_line(surface, name, source, target)
|
||||
local distance = math.sqrt((source.x - target.x) ^ 2 + (source.y - target.y) ^ 2)
|
||||
|
||||
if distance > 16 then
|
||||
return false
|
||||
end
|
||||
|
||||
local modifier = {(target.x - source.x) / distance, (target.y - source.y) / distance}
|
||||
|
||||
local position = {source.x, source.y}
|
||||
|
||||
for i = 1, distance + 4, 1 do
|
||||
if math_random(1, 3) == 1 then
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = source,
|
||||
force = 'enemy',
|
||||
source = source,
|
||||
target = position,
|
||||
max_range = 25,
|
||||
speed = 1
|
||||
}
|
||||
)
|
||||
end
|
||||
position = {position[1] + modifier[1], position[2] + modifier[2]}
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
boss_biter.damaged_entity = function(event)
|
||||
if acid_lines[event.cause.name] then
|
||||
local acid_lines_delay = FDT.get('acid_lines_delay')
|
||||
if not acid_lines_delay[event.cause.unit_number] then
|
||||
FDT.set('acid_lines_delay')[event.cause.unit_number] = 0
|
||||
end
|
||||
|
||||
if acid_lines_delay[event.cause.unit_number] < game.tick then
|
||||
if acid_line(event.cause.surface, acid_lines[event.cause.name], event.cause.position, event.entity.position) then
|
||||
FDT.set('acid_lines_delay')[event.cause.unit_number] = game.tick + 180
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return boss_biter
|
@ -1,72 +0,0 @@
|
||||
local radius = 9
|
||||
local math_random = math.random
|
||||
|
||||
local ammo_to_projectile_translation = {
|
||||
['shotgun-shell'] = 'shotgun-pellet',
|
||||
['piercing-shotgun-shell'] = 'piercing-shotgun-pellet'
|
||||
}
|
||||
|
||||
local function create_projectile(surface, position, target, name)
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = 'player',
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = 16,
|
||||
speed = 0.3
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function bounce(surface, position, ammo)
|
||||
if math_random(1, 3) ~= 1 then
|
||||
return
|
||||
end
|
||||
local valid_entities = {}
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}})) do
|
||||
if e.health then
|
||||
if e.force.name ~= 'player' then
|
||||
--local distance_from_center = math_sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
--if distance_from_center <= radius then
|
||||
valid_entities[#valid_entities + 1] = e
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not valid_entities[1] then
|
||||
return
|
||||
end
|
||||
|
||||
for _ = 1, math_random(3, 6), 1 do
|
||||
create_projectile(surface, position, valid_entities[math_random(1, #valid_entities)].position, ammo)
|
||||
end
|
||||
end
|
||||
|
||||
local function bouncy_shells(event)
|
||||
if event.damage_type.name ~= 'physical' then
|
||||
return false
|
||||
end
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then
|
||||
return false
|
||||
end
|
||||
local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index]
|
||||
if selected_weapon.name ~= 'combat-shotgun' and selected_weapon.name ~= 'shotgun' then
|
||||
return false
|
||||
end
|
||||
|
||||
local selected_ammo = player.get_inventory(defines.inventory.character_ammo)[player.selected_gun_index]
|
||||
if not selected_ammo then
|
||||
return
|
||||
end
|
||||
if not ammo_to_projectile_translation[selected_ammo.name] then
|
||||
return
|
||||
end
|
||||
|
||||
bounce(player.surface, event.entity.position, ammo_to_projectile_translation[selected_ammo.name])
|
||||
end
|
||||
|
||||
return bouncy_shells
|
@ -1,115 +0,0 @@
|
||||
local Server = require 'utils.server'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
commands.add_command(
|
||||
'scenario',
|
||||
'Usable only for admins - controls the scenario!',
|
||||
function(cmd)
|
||||
local p
|
||||
local player = game.player
|
||||
|
||||
if not player or not player.valid then
|
||||
p = log
|
||||
else
|
||||
p = player.print
|
||||
if not player.admin then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local param = cmd.parameter
|
||||
|
||||
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
|
||||
goto continue
|
||||
else
|
||||
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
|
||||
return
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
||||
local this = FDT.get()
|
||||
local reset_map = require 'maps.pidgeotto.main'.reset_game
|
||||
|
||||
if not this.reset_are_you_sure then
|
||||
this.reset_are_you_sure = true
|
||||
p('[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'restart' then
|
||||
if this.restart then
|
||||
this.reset_are_you_sure = nil
|
||||
this.restart = false
|
||||
this.soft_reset = true
|
||||
p('[SUCCESS] Soft-reset is enabled.')
|
||||
return
|
||||
else
|
||||
this.reset_are_you_sure = nil
|
||||
this.restart = true
|
||||
this.soft_reset = false
|
||||
if this.shutdown then
|
||||
this.shutdown = false
|
||||
end
|
||||
p('[WARNING] Soft-reset is disabled! Server will restart from scenario.')
|
||||
return
|
||||
end
|
||||
elseif param == 'restartnow' then
|
||||
this.reset_are_you_sure = nil
|
||||
p(player.name .. ' has restarted the game.')
|
||||
Server.start_scenario('pidgeotto')
|
||||
return
|
||||
elseif param == 'shutdown' then
|
||||
if this.shutdown then
|
||||
this.reset_are_you_sure = nil
|
||||
this.shutdown = false
|
||||
this.soft_reset = true
|
||||
p('[SUCCESS] Soft-reset is enabled.')
|
||||
return
|
||||
else
|
||||
this.reset_are_you_sure = nil
|
||||
this.shutdown = true
|
||||
this.soft_reset = false
|
||||
if this.restart then
|
||||
this.restart = false
|
||||
end
|
||||
p('[WARNING] Soft-reset is disabled! Server will shutdown.')
|
||||
return
|
||||
end
|
||||
elseif param == 'reset' then
|
||||
this.reset_are_you_sure = nil
|
||||
if player and player.valid then
|
||||
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
|
||||
else
|
||||
game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
reset_map()
|
||||
p('[WARNING] Game has been reset!')
|
||||
return
|
||||
end
|
||||
end
|
||||
)
|
||||
commands.add_command(
|
||||
'stop_generate_map',
|
||||
'Usable only for admins - controls the scenario!',
|
||||
function()
|
||||
local player = game.player
|
||||
|
||||
if player and player.valid then
|
||||
if not player.admin then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local stop_generating_map = FDT.get('stop_generating_map')
|
||||
if not stop_generating_map then
|
||||
FDT.set('stop_generating_map', true)
|
||||
player.print('Stopped generating the map!')
|
||||
else
|
||||
FDT.set('stop_generating_map', false)
|
||||
player.print('Resumed the generation of map!')
|
||||
end
|
||||
end
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local math_random = math.random
|
||||
|
||||
local rock_raffle = {'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
|
||||
|
||||
local function on_entity_died(event)
|
||||
local crumbly_walls_unlocked = FDT.get('crumbly_walls_unlocked')
|
||||
if not crumbly_walls_unlocked then
|
||||
return
|
||||
end
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if entity.name ~= 'stone-wall' then
|
||||
return
|
||||
end
|
||||
if math_random(1, 4) == 1 then
|
||||
return
|
||||
end
|
||||
entity.surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = entity.position, force = 'player'})
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
@ -1,42 +0,0 @@
|
||||
local radius = 3
|
||||
|
||||
local function splash_damage(surface, position, final_damage_amount)
|
||||
local damage = math.random(math.floor(final_damage_amount * 3), math.floor(final_damage_amount * 4))
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}})) do
|
||||
if e.valid and e.health then
|
||||
local distance_from_center = math.sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
local damage_distance_modifier = 1 - distance_from_center / radius
|
||||
if damage > 0 then
|
||||
if math.random(1, 3) == 1 then
|
||||
surface.create_entity({name = 'explosion', position = e.position})
|
||||
end
|
||||
e.damage(damage * damage_distance_modifier, 'player', 'explosion')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function explosive_bullets(event)
|
||||
if math.random(1, 3) ~= 1 then
|
||||
return false
|
||||
end
|
||||
if event.damage_type.name ~= 'physical' then
|
||||
return false
|
||||
end
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then
|
||||
return false
|
||||
end
|
||||
local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index]
|
||||
if selected_weapon.name ~= 'submachine-gun' and selected_weapon.name ~= 'pistol' then
|
||||
return false
|
||||
end
|
||||
|
||||
player.surface.create_entity({name = 'explosion', position = event.entity.position})
|
||||
|
||||
splash_damage(player.surface, event.entity.position, event.final_damage_amount)
|
||||
end
|
||||
|
||||
return explosive_bullets
|
@ -1,52 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local flame_boots = FDT.get('flame_boots')
|
||||
if not flame_boots then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
if player.character.driving then
|
||||
return
|
||||
end
|
||||
|
||||
if not flame_boots[player.index] then
|
||||
flame_boots[player.index] = {}
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].fuel then
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel < 0 then
|
||||
player.print('Your flame boots have worn out.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
flame_boots[player.index] = {}
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel % 500 == 0 then
|
||||
player.print('Fuel remaining: ' .. flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44})
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].step_history then
|
||||
flame_boots[player.index].step_history = {}
|
||||
end
|
||||
|
||||
local elements = #flame_boots[player.index].step_history
|
||||
|
||||
flame_boots[player.index].step_history[elements + 1] = {x = player.position.x, y = player.position.y}
|
||||
|
||||
if elements < 50 then
|
||||
return
|
||||
end
|
||||
|
||||
player.surface.create_entity({name = 'fire-flame', position = flame_boots[player.index].step_history[elements - 2]})
|
||||
|
||||
flame_boots[player.index].fuel = flame_boots[player.index].fuel - 1
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
@ -1,37 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local radius = 32
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
local laser_pointer_unlocked = FDT.get('laser_pointer_unlocked')
|
||||
if not laser_pointer_unlocked then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
local position = event.position
|
||||
local used_item = event.item
|
||||
if used_item.name ~= 'artillery-targeting-remote' then
|
||||
return
|
||||
end
|
||||
|
||||
for _, unit in pairs(player.surface.find_enemy_units(position, radius, 'player')) do
|
||||
if math.random(1, 2) == 1 then
|
||||
unit.set_command(
|
||||
{
|
||||
type = defines.command.go_to_location,
|
||||
destination = position,
|
||||
radius = 2,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = false
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,281 +0,0 @@
|
||||
require 'maps.pidgeotto.flame_boots'
|
||||
require 'maps.pidgeotto.trapped_capsules'
|
||||
require 'maps.pidgeotto.ultra_mines'
|
||||
require 'maps.pidgeotto.crumbly_walls'
|
||||
require 'maps.pidgeotto.vehicle_nanobots'
|
||||
require 'maps.pidgeotto.laser_pointer'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local slot_upgrade_offers = {
|
||||
[1] = {'gun-turret', 'gun turret'},
|
||||
[2] = {'laser-turret', 'laser turret'},
|
||||
[3] = {'artillery-turret', 'artillery turret'},
|
||||
[4] = {'flamethrower-turret', 'flamethrower turret'},
|
||||
[5] = {'land-mine', 'land mine'}
|
||||
}
|
||||
|
||||
local special_descriptions = {
|
||||
['explosive-bullets'] = 'Unlock Explosive Bullets - Submachine-Gun and Pistol gains a chance to deal splash damage.',
|
||||
['bouncy-shells'] = 'Unlock Bouncy Shells - Shotgun projectiles may bounce to multiple targets.',
|
||||
['trapped-capsules'] = 'Unlock Trapped Capsules - Combat robots will send a last deadly projectile to a nearby enemy when killed.',
|
||||
['ultra-mines'] = 'Unlock Ultra Mines - Careful with these...',
|
||||
['crumbly-walls'] = 'Unlock Crumbly Walls - Fortifications which crumble, may turn into rocks.',
|
||||
['vehicle-nanobots'] = 'Unlock Vehicle Nanobots - Vehicles repair rapidly while driving.',
|
||||
['laser-pointer'] = 'Unlock Laser Pointer - The biters are on a quest to slay the red (artillery) dot.'
|
||||
}
|
||||
|
||||
local function refresh_market_offers()
|
||||
local market = FDT.get('market')
|
||||
if not market or not market.valid then
|
||||
return
|
||||
end
|
||||
for i = 1, 100, 1 do
|
||||
local a = market.remove_market_item(1)
|
||||
if a == false then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local entity_limits = FDT.get('entity_limits')
|
||||
|
||||
local str1 = 'Gun Turret Slot for ' .. tostring(entity_limits['gun-turret'].limit * entity_limits['gun-turret'].slot_price)
|
||||
str1 = str1 .. ' Coins.'
|
||||
|
||||
local str2 = 'Laser Turret Slot for ' .. tostring(entity_limits['laser-turret'].limit * entity_limits['laser-turret'].slot_price)
|
||||
str2 = str2 .. ' Coins.'
|
||||
|
||||
local str3 = 'Artillery Slot for ' .. tostring(entity_limits['artillery-turret'].limit * entity_limits['artillery-turret'].slot_price)
|
||||
str3 = str3 .. ' Coins.'
|
||||
|
||||
local current_limit = 1
|
||||
if entity_limits['flamethrower-turret'].limit ~= 0 then
|
||||
current_limit = current_limit + entity_limits['flamethrower-turret'].limit
|
||||
end
|
||||
local str4 = 'Flamethrower Turret Slot for ' .. tostring(current_limit * entity_limits['flamethrower-turret'].slot_price)
|
||||
str4 = str4 .. ' Coins.'
|
||||
|
||||
local str5 = 'Landmine Slot for ' .. tostring(math.ceil((entity_limits['land-mine'].limit / 3) * entity_limits['land-mine'].slot_price))
|
||||
str5 = str5 .. ' Coins.'
|
||||
|
||||
local market_items = {
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str1}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str2}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str3}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str4}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str5}},
|
||||
{price = {{'coin', 5}}, offer = {type = 'give-item', item = 'raw-fish', count = 1}},
|
||||
{price = {{'coin', 1}}, offer = {type = 'give-item', item = 'wood', count = 8}},
|
||||
{price = {{'coin', 8}}, offer = {type = 'give-item', item = 'grenade', count = 1}},
|
||||
{price = {{'coin', 32}}, offer = {type = 'give-item', item = 'cluster-grenade', count = 1}},
|
||||
{price = {{'coin', 1}}, offer = {type = 'give-item', item = 'land-mine', count = 1}},
|
||||
{price = {{'coin', 80}}, offer = {type = 'give-item', item = 'car', count = 1}},
|
||||
{price = {{'coin', 1200}}, offer = {type = 'give-item', item = 'tank', count = 1}},
|
||||
{price = {{'coin', 3}}, offer = {type = 'give-item', item = 'cannon-shell', count = 1}},
|
||||
{price = {{'coin', 7}}, offer = {type = 'give-item', item = 'explosive-cannon-shell', count = 1}},
|
||||
{price = {{'coin', 50}}, offer = {type = 'give-item', item = 'gun-turret', count = 1}},
|
||||
{price = {{'coin', 300}}, offer = {type = 'give-item', item = 'laser-turret', count = 1}},
|
||||
{price = {{'coin', 450}}, offer = {type = 'give-item', item = 'artillery-turret', count = 1}},
|
||||
{price = {{'coin', 10}}, offer = {type = 'give-item', item = 'artillery-shell', count = 1}},
|
||||
{price = {{'coin', 25}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
|
||||
{price = {{'coin', 1}}, offer = {type = 'give-item', item = 'firearm-magazine', count = 1}},
|
||||
{price = {{'coin', 4}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine', count = 1}},
|
||||
{price = {{'coin', 2}}, offer = {type = 'give-item', item = 'shotgun-shell', count = 1}},
|
||||
{price = {{'coin', 6}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell', count = 1}},
|
||||
{price = {{'coin', 30}}, offer = {type = 'give-item', item = 'submachine-gun', count = 1}},
|
||||
{price = {{'coin', 250}}, offer = {type = 'give-item', item = 'combat-shotgun', count = 1}},
|
||||
{price = {{'coin', 450}}, offer = {type = 'give-item', item = 'flamethrower', count = 1}},
|
||||
{price = {{'coin', 25}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 1}},
|
||||
{price = {{'coin', 125}}, offer = {type = 'give-item', item = 'rocket-launcher', count = 1}},
|
||||
{price = {{'coin', 2}}, offer = {type = 'give-item', item = 'rocket', count = 1}},
|
||||
{price = {{'coin', 7}}, offer = {type = 'give-item', item = 'explosive-rocket', count = 1}},
|
||||
{price = {{'coin', 7500}}, offer = {type = 'give-item', item = 'atomic-bomb', count = 1}},
|
||||
{price = {{'coin', 40}}, offer = {type = 'give-item', item = 'poison-capsule', count = 1}},
|
||||
{price = {{'coin', 4}}, offer = {type = 'give-item', item = 'defender-capsule', count = 1}},
|
||||
{price = {{'coin', 10}}, offer = {type = 'give-item', item = 'light-armor', count = 1}},
|
||||
{price = {{'coin', 125}}, offer = {type = 'give-item', item = 'heavy-armor', count = 1}},
|
||||
{price = {{'coin', 350}}, offer = {type = 'give-item', item = 'modular-armor', count = 1}},
|
||||
{price = {{'coin', 1500}}, offer = {type = 'give-item', item = 'power-armor', count = 1}},
|
||||
{price = {{'coin', 12000}}, offer = {type = 'give-item', item = 'power-armor-mk2', count = 1}},
|
||||
{price = {{'coin', 50}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
|
||||
{price = {{'coin', 2250}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment', count = 1}},
|
||||
{price = {{'coin', 100}}, offer = {type = 'give-item', item = 'battery-equipment', count = 1}},
|
||||
{price = {{'coin', 200}}, offer = {type = 'give-item', item = 'energy-shield-equipment', count = 1}},
|
||||
{price = {{'coin', 850}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment', count = 1}},
|
||||
{price = {{'coin', 175}}, offer = {type = 'give-item', item = 'exoskeleton-equipment', count = 1}},
|
||||
{price = {{'coin', 125}}, offer = {type = 'give-item', item = 'night-vision-equipment', count = 1}},
|
||||
{price = {{'coin', 200}}, offer = {type = 'give-item', item = 'belt-immunity-equipment', count = 1}},
|
||||
{price = {{'coin', 250}}, offer = {type = 'give-item', item = 'personal-roboport-equipment', count = 1}},
|
||||
{price = {{'coin', 35}}, offer = {type = 'give-item', item = 'construction-robot', count = 1}},
|
||||
{price = {{'coin', 25}}, offer = {type = 'give-item', item = 'cliff-explosives', count = 1}}
|
||||
}
|
||||
|
||||
for _, item in pairs(market_items) do
|
||||
market.add_market_item(item)
|
||||
end
|
||||
|
||||
if not FDT.get('trapped_capsules_unlocked') then
|
||||
market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 3500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['trapped-capsules']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not FDT.get('explosive_bullets_unlocked') then
|
||||
market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 4500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['explosive-bullets']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not FDT.get('bouncy_shells_unlocked') then
|
||||
market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 10000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['bouncy-shells']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not FDT.get('vehicle_nanobots_unlocked') then
|
||||
market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 15000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['vehicle-nanobots']}
|
||||
}
|
||||
)
|
||||
end
|
||||
--[[
|
||||
if not crumbly_walls_unlocked then
|
||||
market.add_market_item({price = {{"coin", 35000}}, offer = {type = 'nothing', effect_description = special_descriptions["crumbly-walls"]}})
|
||||
end
|
||||
if not ultra_mines_unlocked then
|
||||
market.add_market_item({price = {{"coin", 45000}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
|
||||
end
|
||||
]]
|
||||
if not FDT.get('laser_pointer_unlocked') then
|
||||
market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 65000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['laser-pointer']}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function slot_upgrade(player, offer_index)
|
||||
local entity_limits = FDT.get('entity_limits')
|
||||
local price = entity_limits[slot_upgrade_offers[offer_index][1]].limit * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
|
||||
local gain = 1
|
||||
if offer_index == 5 then
|
||||
price = math.ceil((entity_limits[slot_upgrade_offers[offer_index][1]].limit / 3) * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price)
|
||||
gain = 3
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index][1] == 'flamethrower-turret' then
|
||||
price = (entity_limits[slot_upgrade_offers[offer_index][1]].limit + 1) * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
end
|
||||
|
||||
local coins_removed = player.remove_item({name = 'coin', count = price})
|
||||
if coins_removed ~= price then
|
||||
if coins_removed > 0 then
|
||||
player.insert({name = 'coin', count = coins_removed})
|
||||
end
|
||||
player.print('Not enough coins.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
return false
|
||||
end
|
||||
|
||||
entity_limits[slot_upgrade_offers[offer_index][1]].limit = entity_limits[slot_upgrade_offers[offer_index][1]].limit + gain
|
||||
game.print(player.name .. ' has bought a ' .. slot_upgrade_offers[offer_index][2] .. ' slot for ' .. price .. ' coins!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
|
||||
refresh_market_offers()
|
||||
end
|
||||
|
||||
local function on_market_item_purchased(event)
|
||||
local player = game.players[event.player_index]
|
||||
local market = event.market
|
||||
local offer_index = event.offer_index
|
||||
local offers = market.get_market_items()
|
||||
local bought_offer = offers[offer_index].offer
|
||||
if bought_offer.type ~= 'nothing' then
|
||||
return
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index] then
|
||||
if slot_upgrade(player, offer_index) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if offer_index < 50 then
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['explosive-bullets'] then
|
||||
game.print(player.name .. ' has unlocked explosive bullets.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('explosive_bullets_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['bouncy-shells'] then
|
||||
game.print(player.name .. ' has unlocked bouncy shells.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('bouncy_shells_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['trapped-capsules'] then
|
||||
game.print(player.name .. ' has unlocked trapped capsules!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('trapped_capsules_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['ultra-mines'] then
|
||||
game.print(player.name .. ' has unlocked ultra mines!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('ultra_mines_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['laser-pointer'] then
|
||||
game.print(player.name .. ' has unleashed the quest to slay the red dot!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('laser_pointer_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['crumbly-walls'] then
|
||||
game.print(player.name .. ' has unlocked crumbly walls!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('crumbly_walls_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions['vehicle-nanobots'] then
|
||||
game.print(player.name .. ' has unlocked vehicle nanobots!', {r = 0.22, g = 0.77, b = 0.44})
|
||||
FDT.set('vehicle_nanobots_unlocked', true)
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
if not event.entity then
|
||||
return
|
||||
end
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if event.entity.name == 'market' then
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
@ -1,55 +0,0 @@
|
||||
require 'maps.pidgeotto.boss_biters'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local explosive_bullets = require 'maps.pidgeotto.explosive_gun_bullets'
|
||||
local bouncy_shells = require 'maps.pidgeotto.bouncy_shells'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local function protect_market(event)
|
||||
if event.entity.name ~= 'market' then
|
||||
return
|
||||
end
|
||||
if event.cause then
|
||||
if event.cause.force.name == 'enemy' then
|
||||
return
|
||||
end
|
||||
end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
return true
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.entity then
|
||||
return
|
||||
end
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if protect_market(event) then
|
||||
return
|
||||
end
|
||||
|
||||
if not event.cause then
|
||||
return
|
||||
end
|
||||
local explosive_bullets_unlocked = FDT.get('explosive_bullets_unlocked')
|
||||
local bouncy_shells_unlocked = FDT.get('bouncy_shells_unlocked')
|
||||
|
||||
if event.cause.name ~= 'character' then
|
||||
return
|
||||
end
|
||||
|
||||
if explosive_bullets_unlocked then
|
||||
if explosive_bullets(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if bouncy_shells_unlocked then
|
||||
if bouncy_shells(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
@ -1,29 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local gain_multiplier = 4
|
||||
|
||||
local function on_research_finished(event)
|
||||
local research = event.research
|
||||
local force_name = research.force.name
|
||||
local shotgun_shell_damage_modifier_old = FDT.get('shotgun_shell_damage_modifier_old')
|
||||
|
||||
if not shotgun_shell_damage_modifier_old[force_name] then
|
||||
shotgun_shell_damage_modifier_old[force_name] = game.forces[force_name].get_ammo_damage_modifier('shotgun-shell') - 0.1
|
||||
end
|
||||
|
||||
if string.sub(research.name, 0, 26) == 'physical-projectile-damage' then
|
||||
local current_damage = game.forces[force_name].get_ammo_damage_modifier('shotgun-shell')
|
||||
local vanilla_gain = current_damage - shotgun_shell_damage_modifier_old[force_name]
|
||||
local additional_gain = vanilla_gain * (gain_multiplier - 1)
|
||||
game.forces[force_name].set_ammo_damage_modifier('shotgun-shell', current_damage + additional_gain)
|
||||
end
|
||||
|
||||
shotgun_shell_damage_modifier_old[force_name] = game.forces[force_name].get_ammo_damage_modifier('shotgun-shell')
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
game.forces.player.set_ammo_damage_modifier('shotgun-shell', 1)
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
@ -1,149 +0,0 @@
|
||||
-- one table to rule them all!
|
||||
local Global = require 'utils.global'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {}
|
||||
local Public = {}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset_table()
|
||||
-- @start
|
||||
-- these 3 are in case of stop/start/reloading the instance.
|
||||
this.soft_reset = true
|
||||
this.restart = false
|
||||
this.shutdown = false
|
||||
this.announced_message = false
|
||||
this.force_chunk = false
|
||||
this.chunk_load_tick = game.tick + 600
|
||||
-- @end
|
||||
this.game_has_ended = false
|
||||
this.game_reset = false
|
||||
this.spawn_area_generated = false
|
||||
this.results_sent = false
|
||||
|
||||
this.explosive_bullets_unlocked = false
|
||||
this.bouncy_shells_unlocked = false
|
||||
this.trapped_capsules_unlocked = false
|
||||
this.ultra_mines_unlocked = false
|
||||
this.laser_pointer_unlocked = false
|
||||
this.crumbly_walls_unlocked = false
|
||||
this.vehicle_nanobots_unlocked = false
|
||||
this.game_restart_timer = nil
|
||||
this.wave_count = 0
|
||||
this.wave_limit = 2000
|
||||
this.attack_wave_threat = nil
|
||||
this.market = nil
|
||||
this.market_age = nil
|
||||
this.last_reset = game.tick
|
||||
this.wave_interval = 3600
|
||||
this.wave_grace_period = game.tick + 72000
|
||||
-- this.wave_grace_period = game.tick + 3600
|
||||
this.boss_biters = {}
|
||||
this.acid_lines_delay = {}
|
||||
this.entity_limits = {
|
||||
['gun-turret'] = {placed = 1, limit = 1, str = 'gun turret', slot_price = 75},
|
||||
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
|
||||
['artillery-turret'] = {placed = 0, limit = 1, str = 'artillery turret', slot_price = 500},
|
||||
['flamethrower-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
|
||||
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 20}
|
||||
}
|
||||
this.difficulties_votes = {
|
||||
[1] = {wave_interval = 3800, amount_modifier = 0.92, strength_modifier = 0.85, boss_modifier = 5.0},
|
||||
[2] = {wave_interval = 3600, amount_modifier = 1.00, strength_modifier = 1.00, boss_modifier = 6.0},
|
||||
[3] = {wave_interval = 3400, amount_modifier = 1.08, strength_modifier = 1.25, boss_modifier = 7.0},
|
||||
[4] = {wave_interval = 3100, amount_modifier = 1.24, strength_modifier = 1.75, boss_modifier = 8.0},
|
||||
[5] = {wave_interval = 2700, amount_modifier = 1.48, strength_modifier = 2.50, boss_modifier = 9.0}
|
||||
}
|
||||
this.boss_waves = {
|
||||
[50] = {{name = 'big-biter', count = 3}},
|
||||
[100] = {{name = 'behemoth-biter', count = 1}},
|
||||
[150] = {{name = 'behemoth-spitter', count = 4}, {name = 'big-spitter', count = 16}},
|
||||
[200] = {
|
||||
{name = 'behemoth-biter', count = 4},
|
||||
{name = 'behemoth-spitter', count = 2},
|
||||
{name = 'big-biter', count = 32}
|
||||
},
|
||||
[250] = {
|
||||
{name = 'behemoth-biter', count = 8},
|
||||
{name = 'behemoth-spitter', count = 4},
|
||||
{name = 'big-spitter', count = 32}
|
||||
},
|
||||
[300] = {{name = 'behemoth-biter', count = 16}, {name = 'behemoth-spitter', count = 8}}
|
||||
}
|
||||
this.comfylatron_habitat = {
|
||||
left_top = {x = -1500, y = -1500},
|
||||
right_bottom = {x = -80, y = 1500}
|
||||
}
|
||||
this.shotgun_shell_damage_modifier_old = {}
|
||||
this.stop_generating_map = false
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return this[key]
|
||||
else
|
||||
return this
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set(key, value)
|
||||
if key and value == false then
|
||||
if this[key] then
|
||||
this[key] = false
|
||||
return this[key]
|
||||
end
|
||||
end
|
||||
if key and not value then
|
||||
if this[key] then
|
||||
this[key] = nil
|
||||
return
|
||||
end
|
||||
end
|
||||
if key and value then
|
||||
this[key] = value
|
||||
return this[key]
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_current_difficulty_wave_interval()
|
||||
local diff_index = Difficulty.get_difficulty_vote_index()
|
||||
if this.difficulties_votes[diff_index] then
|
||||
return this.difficulties_votes[diff_index].wave_interval
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_current_difficulty_boss_modifier()
|
||||
local diff_index = Difficulty.get_difficulty_vote_index()
|
||||
if this.difficulties_votes[diff_index] then
|
||||
return this.difficulties_votes[diff_index].boss_modifier
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_current_difficulty_strength_modifier()
|
||||
local diff_index = Difficulty.get_difficulty_vote_index()
|
||||
if this.difficulties_votes[diff_index] then
|
||||
return this.difficulties_votes[diff_index].strength_modifier
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_current_difficulty_amount_modifier()
|
||||
local diff_index = Difficulty.get_difficulty_vote_index()
|
||||
if this.difficulties_votes[diff_index] then
|
||||
return this.difficulties_votes[diff_index].amount_modifier
|
||||
end
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
Public.reset_table()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
@ -1,302 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local Builder = require 'maps.pidgeotto.b'
|
||||
local map_functions = require 'utils.tools.map_functions'
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math.random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local function get_replacement_tile(surface, position)
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
shuffle(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'grass-1'
|
||||
end
|
||||
|
||||
local function is_enemy_territory(p)
|
||||
if p.x - 64 < math_abs(p.y) then
|
||||
return false
|
||||
end
|
||||
--if p.x - 64 < p.y then return false end
|
||||
if p.x < 256 then
|
||||
return false
|
||||
end
|
||||
if p.x > 1024 then
|
||||
return false
|
||||
end
|
||||
if p.y > 512 then
|
||||
return false
|
||||
end
|
||||
if p.y < -512 then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function place_fish_market(surface, position)
|
||||
local market = surface.create_entity({name = 'market', position = position, force = 'player'})
|
||||
market.minable = false
|
||||
|
||||
return market
|
||||
end
|
||||
|
||||
local function enemy_territory(surface, left_top)
|
||||
if left_top.x < 256 then
|
||||
return
|
||||
end
|
||||
if left_top.x > 750 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 766 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -256 then
|
||||
return
|
||||
end
|
||||
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}}
|
||||
|
||||
if left_top.x > 300 then
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_enemy_territory(pos) then
|
||||
if math_random(1, 512) == 1 then
|
||||
if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then
|
||||
local entity
|
||||
if math_random(1, 4) == 1 then
|
||||
entity = surface.create_entity({name = 'spitter-spawner', force = 'decoratives', position = pos})
|
||||
else
|
||||
entity = surface.create_entity({name = 'biter-spawner', force = 'decoratives', position = pos})
|
||||
end
|
||||
entity.active = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = {'tree', 'cliff'}})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = 'resource'})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
surface.create_entity({name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000)})
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = area})) do
|
||||
if is_enemy_territory(tile.position) then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function fish_mouth(surface, left_top)
|
||||
if left_top.x > -1800 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 64 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -64 then
|
||||
return
|
||||
end
|
||||
if left_top.x < -2200 then
|
||||
return
|
||||
end
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20
|
||||
if pos.y <= 12 + noise and pos.y >= -12 + noise then
|
||||
surface.set_tiles({{name = 'water', position = pos}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_spawn_area(surface)
|
||||
local spawn_area_generated = FDT.get('spawn_area_generated')
|
||||
if spawn_area_generated then
|
||||
return
|
||||
end
|
||||
|
||||
surface.request_to_generate_chunks({0, 0}, 8)
|
||||
|
||||
local chunk_load_tick = FDT.get('chunk_load_tick')
|
||||
|
||||
if chunk_load_tick > game.tick then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_position_x = -128
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {254, -90}, source = {254, -90}, target = {254, 134}})
|
||||
surface.create_entity({name = 'electric-beam', position = {159, -90}, source = {159, -90}, target = {254, -90}})
|
||||
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-300, -256}, {300, 300}}})) do
|
||||
local noise = math_abs(simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16)
|
||||
if tile.position.x > -160 + noise then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true)
|
||||
end
|
||||
end
|
||||
|
||||
for _, entity in pairs(surface.find_entities_filtered({type = {'resource', 'cliff'}, area = {{-300, -256}, {300, 300}}})) do
|
||||
if entity.position.x > -300 + math_abs(simplex_noise(entity.position.x * 0.02, entity.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 32) then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local decorative_names = {}
|
||||
for k, v in pairs(game.decorative_prototypes) do
|
||||
if v.autoplace_specification then
|
||||
decorative_names[#decorative_names + 1] = k
|
||||
end
|
||||
end
|
||||
for x = -4, 4, 1 do
|
||||
for y = -3, 3, 1 do
|
||||
surface.regenerate_decorative(decorative_names, {{x, y}})
|
||||
end
|
||||
end
|
||||
|
||||
local _y = 80
|
||||
local ore_positions = {
|
||||
{x = spawn_position_x - 52, y = _y},
|
||||
{x = spawn_position_x - 52, y = _y * 0.5},
|
||||
{x = spawn_position_x - 52, y = 0},
|
||||
{x = spawn_position_x - 52, y = _y * -0.5},
|
||||
{x = spawn_position_x - 52, y = _y * -1}
|
||||
}
|
||||
shuffle(ore_positions)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 15, 1500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 15, 1500)
|
||||
map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, 'water', surface, 16)
|
||||
map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000)
|
||||
|
||||
local pos = surface.find_non_colliding_position('market', {spawn_position_x, 0}, 50, 1)
|
||||
local market = FDT.set('market', place_fish_market(surface, pos))
|
||||
|
||||
local r = 16
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{
|
||||
area = {
|
||||
{market.position.x - r, market.position.y - r},
|
||||
{market.position.x + r, market.position.y + r}
|
||||
},
|
||||
type = 'tree'
|
||||
}
|
||||
)
|
||||
) do
|
||||
local distance_to_center = math_sqrt((entity.position.x - market.position.x) ^ 2 + (entity.position.y - market.position.y) ^ 2)
|
||||
if distance_to_center < r then
|
||||
if math_random(1, r) > distance_to_center then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local turret_pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x + 5, 1}, 50, 1)
|
||||
local turret = surface.create_entity({name = 'gun-turret', position = turret_pos, force = 'player'})
|
||||
turret.insert({name = 'firearm-magazine', count = 32})
|
||||
|
||||
for x = -20, 20, 1 do
|
||||
for y = -20, 20, 1 do
|
||||
local market_pos = {x = market.position.x + x, y = market.position.y + y}
|
||||
local distance_to_center = x ^ 2 + y ^ 2
|
||||
if distance_to_center > 64 and distance_to_center < 225 then
|
||||
if math_random(1, 3) == 1 and surface.can_place_entity({name = 'wooden-chest', position = market_pos, force = 'player'}) then
|
||||
surface.create_entity({name = 'wooden-chest', position = market_pos, force = 'player'})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local area = {{x = -160, y = -96}, {x = 160, y = 96}}
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do
|
||||
if math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = 'fish', position = tile.position})
|
||||
end
|
||||
end
|
||||
|
||||
local character_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
game.forces['player'].set_spawn_position(character_pos, surface)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local spawn_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
player.teleport(spawn_pos, surface)
|
||||
end
|
||||
|
||||
local rr = 200
|
||||
local p = {x = -131, y = 5}
|
||||
game.forces.player.chart(
|
||||
surface,
|
||||
{
|
||||
{p.x - rr - 100, p.y - rr},
|
||||
{p.x + rr + 400, p.y + rr}
|
||||
}
|
||||
)
|
||||
|
||||
FDT.set('spawn_area_generated', true)
|
||||
end
|
||||
|
||||
local function process_chunk(left_top)
|
||||
local active_surface_index = FDT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
generate_spawn_area(surface, left_top)
|
||||
enemy_territory(surface, left_top)
|
||||
fish_mouth(surface, left_top)
|
||||
|
||||
local market = FDT.get('market')
|
||||
|
||||
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
|
||||
if market and market.valid then
|
||||
FDT.set('game_reset', false)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local map_name = 'pidgeotto'
|
||||
|
||||
if string.sub(event.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
if FDT.get('stop_generating_map') then
|
||||
return
|
||||
end
|
||||
|
||||
local left_top = event.area.left_top
|
||||
Builder.make_chunk(event)
|
||||
|
||||
process_chunk(left_top)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
@ -1,61 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local radius = 20
|
||||
|
||||
local whitelist = {
|
||||
['defender'] = 'explosive-cannon-projectile',
|
||||
['distractor'] = 'explosive-uranium-cannon-projectile',
|
||||
['destroyer'] = 'explosive-uranium-cannon-projectile'
|
||||
}
|
||||
|
||||
local function on_entity_died(event)
|
||||
local trapped_capsules_unlocked = FDT.get('trapped_capsules_unlocked')
|
||||
if not trapped_capsules_unlocked then
|
||||
return
|
||||
end
|
||||
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if not whitelist[event.entity.name] then
|
||||
return
|
||||
end
|
||||
|
||||
local valid_targets = {}
|
||||
local position = event.entity.position
|
||||
|
||||
for _, e in pairs(
|
||||
event.entity.surface.find_entities_filtered(
|
||||
{
|
||||
area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}},
|
||||
force = 'enemy'
|
||||
}
|
||||
)
|
||||
) do
|
||||
if e.health then
|
||||
local distance_from_center = math.sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
valid_targets[#valid_targets + 1] = e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not valid_targets[1] then
|
||||
return
|
||||
end
|
||||
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = whitelist[event.entity.name],
|
||||
position = position,
|
||||
force = 'player',
|
||||
source = position,
|
||||
target = valid_targets[math.random(1, #valid_targets)].position,
|
||||
max_range = 20,
|
||||
speed = 0.1
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
@ -1,51 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local radius = 8
|
||||
|
||||
local function damage_entities_around_target(entity, damage)
|
||||
for _, e in pairs(
|
||||
entity.surface.find_entities_filtered(
|
||||
{
|
||||
area = {
|
||||
{entity.position.x - radius, entity.position.y - radius},
|
||||
{entity.position.x + radius, entity.position.y + radius}
|
||||
}
|
||||
}
|
||||
)
|
||||
) do
|
||||
if e.health then
|
||||
if e.force.name ~= 'player' then
|
||||
local distance_from_center = math.sqrt((e.position.x - entity.position.x) ^ 2 + (e.position.y - entity.position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
e.damage(damage, 'player', 'explosion')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local ultra_mines_unlocked = FDT.get('ultra_mines_unlocked')
|
||||
if not ultra_mines_unlocked then
|
||||
return
|
||||
end
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if event.entity.name ~= 'land-mine' then
|
||||
return
|
||||
end
|
||||
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'big-artillery-explosion',
|
||||
position = event.entity.position
|
||||
}
|
||||
)
|
||||
|
||||
local damage = (1 + event.entity.force.get_ammo_damage_modifier('grenade')) * 250
|
||||
|
||||
damage_entities_around_target(event.entity, damage)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
@ -1,29 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local vehicle_nanobots_unlocked = FDT.get('vehicle_nanobots_unlocked')
|
||||
|
||||
if not vehicle_nanobots_unlocked then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
if not player.character.driving then
|
||||
return
|
||||
end
|
||||
if not player.vehicle then
|
||||
return
|
||||
end
|
||||
if not player.vehicle.valid then
|
||||
return
|
||||
end
|
||||
if player.vehicle.health == player.vehicle.prototype.max_health then
|
||||
return
|
||||
end
|
||||
player.vehicle.health = player.vehicle.health + player.vehicle.prototype.max_health * 0.005
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
Loading…
x
Reference in New Issue
Block a user