mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-11 14:49:24 +02:00
Add files via upload
This commit is contained in:
parent
1d49b6abd9
commit
e5cae17f70
@ -5,14 +5,14 @@ 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,
|
||||
-- ['cargo-wagon'] = true,
|
||||
-- ['locomotive'] = true,
|
||||
-- ['artillery-wagon'] = true,
|
||||
-- ['artillery-turret'] = true,
|
||||
-- ['fluid-wagon'] = true,
|
||||
-- ['land-mine'] = true,
|
||||
['car'] = true,
|
||||
['tank'] = true,
|
||||
['spidertron'] = true
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ market.weapons = {
|
||||
['shotgun'] = {value = 40, rarity = 2},
|
||||
['combat-shotgun'] = {value = 400, rarity = 5},
|
||||
['rocket-launcher'] = {value = 500, rarity = 6},
|
||||
['flamethrower'] = {value = 750, rarity = 6},
|
||||
['land-mine'] = {value = 3, rarity = 5}
|
||||
['flamethrower-turret'] = {value = 2000, rarity = 5},
|
||||
['land-mine'] = {value = 16, rarity = 4}
|
||||
}
|
||||
|
||||
market.ammo = {
|
||||
@ -50,11 +50,11 @@ market.caspules = {
|
||||
['poison-capsule'] = {value = 32, rarity = 6},
|
||||
['slowdown-capsule'] = {value = 8, rarity = 1},
|
||||
['defender-capsule'] = {value = 8, rarity = 1},
|
||||
['distractor-capsule'] = {value = 20, rarity = 9},
|
||||
['destroyer-capsule'] = {value = 32, rarity = 12},
|
||||
['discharge-defense-remote'] = {value = 2000, rarity = 8},
|
||||
['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 = 6, rarity = 1}
|
||||
['raw-fish'] = {value = 10, rarity = 1}
|
||||
}
|
||||
|
||||
market.armor = {
|
||||
@ -73,7 +73,7 @@ market.equipment = {
|
||||
['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 = 8000, 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},
|
||||
@ -154,7 +154,8 @@ market.wire = {
|
||||
['decider-combinator'] = {value = 16, rarity = 1},
|
||||
['constant-combinator'] = {value = 16, rarity = 1},
|
||||
['power-switch'] = {value = 16, rarity = 1},
|
||||
['programmable-speaker'] = {value = 24, rarity = 1}
|
||||
['programmable-speaker'] = {value = 24, rarity = 1},
|
||||
['landfill'] = {value = 5, rarity = 3}
|
||||
}
|
||||
|
||||
local function get_types()
|
||||
@ -269,6 +270,11 @@ function Public.get_random_item(rarity, sell, buy)
|
||||
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)
|
||||
@ -279,7 +285,7 @@ function Public.mountain_market(surface, position, rarity, buy)
|
||||
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
|
||||
|
133
maps/amap/biters_yield_coins.lua
Normal file
133
maps/amap/biters_yield_coins.lua
Normal file
@ -0,0 +1,133 @@
|
||||
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)
|
66
maps/amap/burden.lua
Normal file
66
maps/amap/burden.lua
Normal file
@ -0,0 +1,66 @@
|
||||
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)
|
@ -15,15 +15,20 @@ 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 asdasd = require 'modules.rpg.table'
|
||||
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"
|
||||
@ -35,6 +40,8 @@ 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"})
|
||||
@ -42,34 +49,44 @@ local function place_entity(surface, position)
|
||||
end
|
||||
|
||||
local function is_scrap_area(noise)
|
||||
if noise > 0.63 then return end
|
||||
if noise < -0.63 then return end
|
||||
if noise > 0.35 then return true end
|
||||
if noise < -0.35 then return true end
|
||||
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 = asdasd.get('rpg_t')
|
||||
local rpg = RPGtable.get('rpg_t')
|
||||
|
||||
local magic = rpg[player.index].magicka
|
||||
local magic = rpg[player.index].magicka
|
||||
|
||||
local msg = 'Oh, look, we found a treasure!'
|
||||
|
||||
Alert.alert_player(player, 5, msg)
|
||||
|
||||
|
||||
Loot.add_rare(entity.surface, entity.position, 'wooden-chest', magic)
|
||||
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", "turret", "unit", "tree"}, area = area})) do
|
||||
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
|
||||
surface.create_entity({name = e.name, position = position, force = "enemy"})
|
||||
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
|
||||
@ -77,31 +94,33 @@ end
|
||||
local vectors = {{0,0}, {1,0}, {-1,0}, {0,1}, {0,-1}}
|
||||
local function hidden_biter_pet(player, entity)
|
||||
|
||||
local pos = entity.position
|
||||
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)
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
@ -110,66 +129,65 @@ local function on_player_mined_entity(event)
|
||||
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
|
||||
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 = asdasd.get('rpg_t')
|
||||
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
|
||||
|
||||
|
||||
entity.surface.set_tiles({{name = 'stone-path', position = entity.position}}, true)
|
||||
end
|
||||
|
||||
--挖出汽车
|
||||
if random(1,712) < 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 = ({'found a car', 'you'})
|
||||
Alert.alert_player(player, 15, msg)
|
||||
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,120) < 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,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
|
||||
if random(1,150) < 2 then
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
hidden_treasure(player,entity)
|
||||
hidden_treasure(player,entity)
|
||||
|
||||
end
|
||||
end
|
||||
--挖出宠物
|
||||
if random(1,170) < 3 then
|
||||
local player = game.players[event.player_index]
|
||||
hidden_biter_pet(player,entity)
|
||||
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)
|
||||
if random(1,100) < 3 then
|
||||
local player = game.players[event.player_index]
|
||||
hidden_biter(player,entity)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
on_player_mined_entity(event)
|
||||
end
|
||||
|
||||
|
||||
--图块生成时
|
||||
local function on_chunk_generated(event)
|
||||
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
|
||||
@ -177,75 +195,103 @@ local function on_chunk_generated(event)
|
||||
local get_tile = surface.get_tile
|
||||
local position
|
||||
local noise
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
position = {x = left_top_x + x, y = left_top_y + y}
|
||||
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 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
|
||||
--中立建筑
|
||||
local tem_pos
|
||||
|
||||
|
||||
|
||||
--在我上面添加代码
|
||||
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)/20
|
||||
local w =math_abs(position.y)/20
|
||||
local maxs =q+w+15
|
||||
-- game.print(maxs)
|
||||
MT.mountain_market(surface,position,maxs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
place_entity(surface, 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^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
|
||||
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)/100
|
||||
local w =math_abs(position.y)/100
|
||||
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
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
local modifiers = Player_modifiers.get_table()
|
||||
--modifiers[player.index].character_mining_speed_modifier["caves"] = 3
|
||||
Player_modifiers.update_player_modifiers(player)
|
||||
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)
|
||||
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.025
|
||||
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_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
require "modules.rocks_yield_ore"
|
||||
--Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
require "maps.amap.rocks_yield_ore"
|
||||
|
187
maps/amap/diff.lua
Normal file
187
maps/amap/diff.lua
Normal file
@ -0,0 +1,187 @@
|
||||
|
||||
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 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')
|
||||
local heath = 1 + player_count * 0.05
|
||||
if heath >= 3 then
|
||||
heath = 3
|
||||
end
|
||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
||||
-- threat gain / wave
|
||||
local max_threat = 1 + player_count * 0.1
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
if wave_number > 850 then
|
||||
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
|
||||
end
|
||||
|
||||
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')
|
||||
local heath = 1 + player_count * 0.15
|
||||
if heath >= 3 then
|
||||
heath = 3
|
||||
end
|
||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
||||
-- threat gain / wave
|
||||
local max_threat = 1 + player_count * 0.1
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
if wave_number > 850 then
|
||||
max_threat = max_threat + wave_number * 0.004
|
||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
||||
wave_defense_table.threat_gain_multiplier = max_threat
|
||||
end
|
||||
|
||||
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')
|
||||
local heath = 1.2 + player_count * 0.1
|
||||
if heath >= 4 then
|
||||
heath = 4
|
||||
end
|
||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
||||
-- threat gain / wave
|
||||
local max_threat = 1 + player_count * 0.2
|
||||
if max_threat >= 4 then
|
||||
max_threat = 4
|
||||
end
|
||||
|
||||
if wave_number > 850 then
|
||||
max_threat = max_threat + wave_number * 0.005
|
||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
||||
wave_defense_table.threat_gain_multiplier = max_threat
|
||||
end
|
||||
|
||||
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
|
||||
damage_increase = wave_number * 0.001*k
|
||||
|
||||
game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase)
|
||||
game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase)
|
||||
|
||||
|
||||
end
|
||||
Event.on_nth_tick(1000, set_diff)
|
133
maps/amap/enemy_arty.lua
Normal file
133
maps/amap/enemy_arty.lua
Normal file
@ -0,0 +1,133 @@
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local arty_count = {}
|
||||
local Public = {}
|
||||
|
||||
local artillery_target_entities = {
|
||||
'character',
|
||||
'roboport',
|
||||
'furnace',
|
||||
|
||||
}
|
||||
|
||||
Global.register(
|
||||
arty_count,
|
||||
function(tbl)
|
||||
arty_count = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset_table()
|
||||
arty_count.max = 500
|
||||
arty_count.all = {}
|
||||
arty_count.count = 0
|
||||
arty_count.distance = 0
|
||||
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 ()
|
||||
game.print(arty_count.count)
|
||||
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, 1024)
|
||||
if roll <= 2 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_count.all+1]=arty
|
||||
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 name = event.entity.name
|
||||
local entity = event.entity
|
||||
local force = event.entity.force
|
||||
|
||||
if name == 'artillery-turret' and force.name == 'enemy' then
|
||||
|
||||
arty_count.count = arty_count.count -1
|
||||
|
||||
if arty_count.count <= 0 then
|
||||
arty_count.count = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function on_player_changed_position(event)
|
||||
local player = game.players[event.player_index]
|
||||
local position = player.position
|
||||
|
||||
local q =position.x*position.x
|
||||
local w =position.y*position.y
|
||||
local distance =math.sqrt(q+w)
|
||||
|
||||
if distance >= arty_count.distance-200 then
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.on_nth_tick(600, add_bullet)
|
||||
Event.on_init(on_init)
|
||||
|
||||
|
||||
return Public
|
@ -18,7 +18,7 @@ local this = {
|
||||
surface_cleared = false
|
||||
}
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['car'] = 1}
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['wood'] = 16}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
@ -618,30 +618,46 @@ function Public.on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
player.print('Protect the rocket silo. When the rocket launch is destroyed, the game fails. Resist insect attacks, build production lines, and win the game by launching rockets!')
|
||||
|
||||
|
||||
local reward = require 'maps.amap.main'.reward
|
||||
local player_data = get_player_data(player)
|
||||
if not player_data.first_join then
|
||||
local message = ({'main.greeting', player.name})
|
||||
Alert.alert_player(player, 15, message)
|
||||
|
||||
|
||||
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({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)
|
||||
|
||||
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({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)
|
||||
--player.teleport({x=0,y=0}, surface)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -653,7 +669,18 @@ function Public.is_creativity_mode_on()
|
||||
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
|
||||
@ -678,6 +705,48 @@ function Public.on_pre_player_left_game(event)
|
||||
}
|
||||
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 >= 12 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)
|
||||
@ -752,7 +821,9 @@ local disable_recipes = function()
|
||||
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()
|
||||
@ -763,8 +834,24 @@ function Public.disable_tech()
|
||||
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}
|
||||
@ -779,15 +866,22 @@ function Public.reset_table()
|
||||
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)
|
||||
|
File diff suppressed because it is too large
Load Diff
31
maps/amap/relax.lua
Normal file
31
maps/amap/relax.lua
Normal file
@ -0,0 +1,31 @@
|
||||
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)
|
@ -6,90 +6,256 @@ 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'
|
||||
function Public.spawn(surface, position)
|
||||
local this = WPT.get()
|
||||
this.rock = surface.create_entity{name = "rocket-silo", position = position, force=game.forces.player}
|
||||
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
|
||||
|
||||
this.rock.minable = false
|
||||
game.forces.player.set_spawn_position({0,0}, surface)
|
||||
|
||||
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 market = surface.create_entity{name = "market", position = {x=0, y=-10}, force=game.forces.player}
|
||||
local market_items = {
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = "raw-fish", count = 1}},
|
||||
{price = {{"coin", 1000}}, offer = {type = 'give-item', item = 'car', count = 1}},
|
||||
{price = {{"coin", 5000}}, offer = {type = 'give-item', item = 'tank', count = 1}},
|
||||
{price = {{"coin", 20000}}, offer = {type = 'give-item', item = 'spidertron', 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}}
|
||||
}
|
||||
market.last_user = nil
|
||||
if market ~= nil then
|
||||
market.destructible = false
|
||||
if market ~= nil then
|
||||
for _, item in pairs(market_items) do
|
||||
market.add_market_item(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
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 abc ()
|
||||
local this = WPT.get()
|
||||
|
||||
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
this.game_lost = true
|
||||
|
||||
game.forces.enemy.set_friend('player', true)
|
||||
game.print('设置敌军友好')
|
||||
game.forces.player.set_friend('enemy', true)
|
||||
game.print('设置敌军友好')
|
||||
--reset_map()
|
||||
this.game_reset_tick=5400
|
||||
|
||||
end
|
||||
|
||||
local function on_rocket_launched(Event)
|
||||
local wave_number = WD.get('wave_number')
|
||||
for _, p in pairs(game.connected_players) do
|
||||
Alert.alert_player(player, 25, 'You won the game at ' .. wave_number .. '.')
|
||||
end
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
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]
|
||||
local player = game.connected_players[k]
|
||||
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute+100
|
||||
player.insert{name='coin', count = '3000'}
|
||||
game.print('rocket was launch, all players will be rewarded with 100 skill points and 3000 gold coins.', {r = 0.22, g = 0.88, b = 0.22})
|
||||
end
|
||||
end
|
||||
local function on_entity_died(Event)
|
||||
local this = WPT.get()
|
||||
if Event.entity == this.rock then
|
||||
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})
|
||||
|
||||
--game.print('游戏失败!游戏稍后将自动重启',{r = 1, g = 0, b = 0, a = 0.5})
|
||||
local wave_number = WD.get('wave_number')
|
||||
|
||||
for _, p in pairs(game.connected_players) do
|
||||
|
||||
Alert.alert_player(p, 25, 'Rocket silo destroyed, game failed! You survived' .. wave_number .. 'wave,good luck next time')
|
||||
|
||||
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
|
||||
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('设置敌军友好')
|
||||
Reset_map()
|
||||
|
||||
--abc()
|
||||
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
|
||||
|
||||
--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('设置敌军友好')
|
||||
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 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)
|
||||
return Public
|
||||
Event.add(defines.events.on_market_item_purchased,on_market_item_purchased)
|
||||
return Public
|
||||
|
177
maps/amap/rocks_yield_ore.lua
Normal file
177
maps/amap/rocks_yield_ore.lua
Normal file
@ -0,0 +1,177 @@
|
||||
--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 x = 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 player = game.players[event.player_index]
|
||||
|
||||
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
|
||||
local stone_amount = math_floor(count * 0.15) + 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,7 +1,7 @@
|
||||
local Server = require 'utils.server'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Modifers = require 'player_modifiers'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WPT = require 'maps.amap.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
|
99
maps/amap/spider_health_booster.lua
Normal file
99
maps/amap/spider_health_booster.lua
Normal file
@ -0,0 +1,99 @@
|
||||
-- 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, v 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
|
@ -7,7 +7,7 @@ local Public = {}
|
||||
|
||||
local this = {
|
||||
active_surface_index = nil,
|
||||
surface_name = surface_name
|
||||
surface_name = surface_name,
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@ -17,21 +17,22 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['car'] = 1}
|
||||
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.1,
|
||||
['default_enable_all_autoplace_controls'] = true
|
||||
|
||||
['starting_area'] = 1.2,
|
||||
['default_enable_all_autoplace_controls'] = true,
|
||||
['water'] = 0.65
|
||||
|
||||
}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["coal"] = {frequency = "1", size = "1", richness = "0.7"},
|
||||
["stone"] = {frequency = "1", size = "1", richness = "0.7"},
|
||||
["copper-ore"] = {frequency = "1", size = "2", richness = "0.7"},
|
||||
["iron-ore"] = {frequency = "1", size = "2", richness = "0.7"},
|
||||
["crude-oil"] = {frequency = "1", size = "2", richness = "1"},
|
||||
["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,
|
||||
@ -42,6 +43,9 @@ function Public.create_surface()
|
||||
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
|
||||
@ -50,7 +54,10 @@ function Public.create_surface()
|
||||
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
|
||||
|
||||
|
@ -14,11 +14,29 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
Public.level_depth = 704
|
||||
Public.level_depth = 512
|
||||
Public.level_width = 512
|
||||
function Public.reset_table()
|
||||
-- @start
|
||||
-- these 3 are in case of stop/start/reloading the instance.
|
||||
-- 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
|
||||
@ -169,4 +187,4 @@ end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
||||
return Public
|
||||
|
2448
maps/amap/terrain.lua
Normal file
2448
maps/amap/terrain.lua
Normal file
File diff suppressed because it is too large
Load Diff
116
maps/amap/wall_health_booster.lua
Normal file
116
maps/amap/wall_health_booster.lua
Normal file
@ -0,0 +1,116 @@
|
||||
-- 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, v 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
|
Loading…
x
Reference in New Issue
Block a user