mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
Merge pull request #65 from ComfyFactory/adjustments
minor adjustments done to rpg, wave defense and mtn v3
This commit is contained in:
commit
f056414b84
@ -5,7 +5,6 @@ local SessionData = require 'utils.datastore.session_data'
|
|||||||
local Utils = require 'utils.core'
|
local Utils = require 'utils.core'
|
||||||
local Tabs = require 'comfy_panel.main'
|
local Tabs = require 'comfy_panel.main'
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
|
||||||
local Token = require 'utils.token'
|
local Token = require 'utils.token'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
|
|
||||||
@ -121,20 +120,6 @@ local functions = {
|
|||||||
game.players[event.player_index].spectator = false
|
game.players[event.player_index].spectator = false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
['comfy_panel_bottom_right_frame'] = function(event)
|
|
||||||
local player = game.get_player(event.player_index)
|
|
||||||
if event.element.switch_state == 'left' then
|
|
||||||
local bottom_frame = BottomFrame.get_player_data(player)
|
|
||||||
if not bottom_frame then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
bottom_frame.bottom_left = true
|
|
||||||
BottomFrame.set_location(player)
|
|
||||||
else
|
|
||||||
BottomFrame.get_player_data(player, true)
|
|
||||||
BottomFrame.set_location(player)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
['comfy_panel_auto_hotbar_switch'] = function(event)
|
['comfy_panel_auto_hotbar_switch'] = function(event)
|
||||||
if event.element.switch_state == 'left' then
|
if event.element.switch_state == 'left' then
|
||||||
global.auto_hotbar_enabled[event.player_index] = true
|
global.auto_hotbar_enabled[event.player_index] = true
|
||||||
@ -386,22 +371,6 @@ local function build_config_gui(data)
|
|||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
end
|
end
|
||||||
|
|
||||||
if BottomFrame.is_custom_buttons_enabled() then
|
|
||||||
switch_state = 'right'
|
|
||||||
local bottom_frame = BottomFrame.get('players')
|
|
||||||
if bottom_frame[player.index] then
|
|
||||||
switch_state = 'left'
|
|
||||||
end
|
|
||||||
add_switch(
|
|
||||||
scroll_pane,
|
|
||||||
switch_state,
|
|
||||||
'comfy_panel_bottom_right_frame',
|
|
||||||
'Button Location',
|
|
||||||
'Toggle to select if you want the bottom button on the right side or the left side.'
|
|
||||||
)
|
|
||||||
scroll_pane.add({type = 'line'})
|
|
||||||
end
|
|
||||||
|
|
||||||
if admin then
|
if admin then
|
||||||
label = scroll_pane.add({type = 'label', caption = 'Admin Settings'})
|
label = scroll_pane.add({type = 'label', caption = 'Admin Settings'})
|
||||||
label.style.font = 'default-bold'
|
label.style.font = 'default-bold'
|
||||||
|
@ -7,9 +7,7 @@ local Global = require 'utils.global'
|
|||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
players = {},
|
players = {},
|
||||||
activate_custom_buttons = false,
|
activate_custom_buttons = false
|
||||||
bottom_right = false,
|
|
||||||
bottom_quickbar_button = {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register(
|
Global.register(
|
||||||
|
@ -167,7 +167,7 @@ local item_worths = {
|
|||||||
['explosive-cannon-shell'] = 16,
|
['explosive-cannon-shell'] = 16,
|
||||||
['uranium-cannon-shell'] = 64,
|
['uranium-cannon-shell'] = 64,
|
||||||
['explosive-uranium-cannon-shell'] = 64,
|
['explosive-uranium-cannon-shell'] = 64,
|
||||||
['artillery-shell'] = 128,
|
['artillery-shell'] = 512,
|
||||||
['rocket'] = 6,
|
['rocket'] = 6,
|
||||||
['explosive-rocket'] = 8,
|
['explosive-rocket'] = 8,
|
||||||
['atomic-bomb'] = 8192,
|
['atomic-bomb'] = 8192,
|
||||||
@ -203,7 +203,7 @@ local item_worths = {
|
|||||||
['gun-turret'] = 64,
|
['gun-turret'] = 64,
|
||||||
['laser-turret'] = 1024,
|
['laser-turret'] = 1024,
|
||||||
['flamethrower-turret'] = 2048,
|
['flamethrower-turret'] = 2048,
|
||||||
['artillery-turret'] = 1024,
|
['artillery-turret'] = 9216,
|
||||||
['radar'] = 32,
|
['radar'] = 32,
|
||||||
['rocket-silo'] = 65536
|
['rocket-silo'] = 65536
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ change_returned=Shopkeeper has returned your change, for which you are infinitel
|
|||||||
notify_full_inventory_1=Your inventory is full. Try to stash your loot somewhere first.
|
notify_full_inventory_1=Your inventory is full. Try to stash your loot somewhere first.
|
||||||
notify_full_inventory_2=Your inventory is full. Join the warrior club today! Pump that STR stat some more!
|
notify_full_inventory_2=Your inventory is full. Join the warrior club today! Pump that STR stat some more!
|
||||||
new_items_at_market=New items have been unlocked at the locomotive market!
|
new_items_at_market=New items have been unlocked at the locomotive market!
|
||||||
|
discharge_unlocked=Discharge defense has now been unlocked at the market!
|
||||||
|
artillery_unlocked=Artillery has now been unlocked at the market!
|
||||||
|
|
||||||
|
|
||||||
[main_market]
|
[main_market]
|
||||||
|
@ -36,7 +36,7 @@ market.ammo = {
|
|||||||
['explosive-cannon-shell'] = {value = 12, rarity = 5},
|
['explosive-cannon-shell'] = {value = 12, rarity = 5},
|
||||||
['uranium-cannon-shell'] = {value = 16, rarity = 7},
|
['uranium-cannon-shell'] = {value = 16, rarity = 7},
|
||||||
['explosive-uranium-cannon-shell'] = {value = 20, rarity = 8},
|
['explosive-uranium-cannon-shell'] = {value = 20, rarity = 8},
|
||||||
['artillery-shell'] = {value = 64, rarity = 7},
|
['artillery-shell'] = {value = 1024, rarity = 7},
|
||||||
['rocket'] = {value = 45, rarity = 7},
|
['rocket'] = {value = 45, rarity = 7},
|
||||||
['explosive-rocket'] = {value = 50, rarity = 7},
|
['explosive-rocket'] = {value = 50, rarity = 7},
|
||||||
['atomic-bomb'] = {value = 11000, rarity = 10},
|
['atomic-bomb'] = {value = 11000, rarity = 10},
|
||||||
@ -52,8 +52,8 @@ market.caspules = {
|
|||||||
['defender-capsule'] = {value = 18, rarity = 1},
|
['defender-capsule'] = {value = 18, rarity = 1},
|
||||||
['distractor-capsule'] = {value = 68, rarity = 5},
|
['distractor-capsule'] = {value = 68, rarity = 5},
|
||||||
['destroyer-capsule'] = {value = 74, rarity = 7},
|
['destroyer-capsule'] = {value = 74, rarity = 7},
|
||||||
['discharge-defense-remote'] = {value = 2000, rarity = 8},
|
['discharge-defense-remote'] = {value = 9216, rarity = 8},
|
||||||
['artillery-targeting-remote'] = {value = 32, rarity = 7},
|
['artillery-targeting-remote'] = {value = 1024, rarity = 7},
|
||||||
['raw-fish'] = {value = 6, rarity = 1}
|
['raw-fish'] = {value = 6, rarity = 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ market.equipment = {
|
|||||||
['battery-equipment'] = {value = 160, rarity = 2},
|
['battery-equipment'] = {value = 160, rarity = 2},
|
||||||
['battery-mk2-equipment'] = {value = 2000, rarity = 8},
|
['battery-mk2-equipment'] = {value = 2000, rarity = 8},
|
||||||
['personal-laser-defense-equipment'] = {value = 2500, rarity = 7},
|
['personal-laser-defense-equipment'] = {value = 2500, rarity = 7},
|
||||||
['discharge-defense-equipment'] = {value = 8000, rarity = 7},
|
['discharge-defense-equipment'] = {value = 15000, rarity = 7},
|
||||||
['belt-immunity-equipment'] = {value = 200, rarity = 1},
|
['belt-immunity-equipment'] = {value = 200, rarity = 1},
|
||||||
['exoskeleton-equipment'] = {value = 800, rarity = 3},
|
['exoskeleton-equipment'] = {value = 800, rarity = 3},
|
||||||
['personal-roboport-equipment'] = {value = 500, rarity = 3},
|
['personal-roboport-equipment'] = {value = 500, rarity = 3},
|
||||||
@ -88,7 +88,7 @@ market.defense = {
|
|||||||
['gun-turret'] = {value = 64, rarity = 1},
|
['gun-turret'] = {value = 64, rarity = 1},
|
||||||
['laser-turret'] = {value = 1024, rarity = 6},
|
['laser-turret'] = {value = 1024, rarity = 6},
|
||||||
['flamethrower-turret'] = {value = 2048, rarity = 6},
|
['flamethrower-turret'] = {value = 2048, rarity = 6},
|
||||||
['artillery-turret'] = {value = 8192, rarity = 8},
|
['artillery-turret'] = {value = 9216, rarity = 8},
|
||||||
['rocket-silo'] = {value = 64000, rarity = 10}
|
['rocket-silo'] = {value = 64000, rarity = 10}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ market.vehicles = {
|
|||||||
['locomotive'] = {value = 400, rarity = 4},
|
['locomotive'] = {value = 400, rarity = 4},
|
||||||
['cargo-wagon'] = {value = 200, rarity = 4},
|
['cargo-wagon'] = {value = 200, rarity = 4},
|
||||||
['fluid-wagon'] = {value = 300, rarity = 5},
|
['fluid-wagon'] = {value = 300, rarity = 5},
|
||||||
['artillery-wagon'] = {value = 8192, rarity = 8},
|
['artillery-wagon'] = {value = 9216, rarity = 8},
|
||||||
['car'] = {value = 80, rarity = 1},
|
['car'] = {value = 80, rarity = 1},
|
||||||
['tank'] = {value = 1800, rarity = 5}
|
['tank'] = {value = 1800, rarity = 5}
|
||||||
}
|
}
|
||||||
|
@ -1,200 +0,0 @@
|
|||||||
local Event = require 'utils.event'
|
|
||||||
local WPT = require 'maps.mountain_fortress_v3.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
|
|
||||||
|
|
||||||
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
|
|
@ -13,6 +13,7 @@ local raise_event = script.raise_event
|
|||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
local sub = string.sub
|
||||||
local sqrt = math.sqrt
|
local sqrt = math.sqrt
|
||||||
local level_depth = WPT.level_depth
|
local level_depth = WPT.level_depth
|
||||||
|
|
||||||
@ -147,13 +148,13 @@ local function distance(player)
|
|||||||
|
|
||||||
local p = player.position
|
local p = player.position
|
||||||
|
|
||||||
local s = WPT.get('validate_spider')
|
local validate_spider = WPT.get('validate_spider')
|
||||||
if s[index] then
|
if validate_spider[index] then
|
||||||
local e = s[index]
|
local e = validate_spider[index]
|
||||||
if not (e and e.valid) then
|
if not (e and e.valid) then
|
||||||
s[index] = nil
|
validate_spider[index] = nil
|
||||||
end
|
end
|
||||||
compare_player_and_train(player, s[index])
|
compare_player_and_train(player, validate_spider[index])
|
||||||
end
|
end
|
||||||
|
|
||||||
compare_player_pos(player)
|
compare_player_pos(player)
|
||||||
@ -170,13 +171,15 @@ local function distance(player)
|
|||||||
local max_times = location >= max
|
local max_times = location >= max
|
||||||
if max_times then
|
if max_times then
|
||||||
if breach_max_times then
|
if breach_max_times then
|
||||||
|
local placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||||
|
local biters = WPT.get('biters')
|
||||||
rpg_extra.breached_walls = rpg_extra.breached_walls + 1
|
rpg_extra.breached_walls = rpg_extra.breached_walls + 1
|
||||||
rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls
|
rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls
|
||||||
WPT.set().breached_wall = breached_wall + 1
|
WPT.set('breached_wall', breached_wall + 1)
|
||||||
WPT.set().placed_trains_in_zone.placed = 0
|
placed_trains_in_zone.placed = 0
|
||||||
WPT.set().biters.amount = 0
|
biters.amount = 0
|
||||||
WPT.set().placed_trains_in_zone.randomized = false
|
placed_trains_in_zone.randomized = false
|
||||||
WPT.set().placed_trains_in_zone.positions = {}
|
placed_trains_in_zone.positions = {}
|
||||||
raise_event(Balance.events.breached_wall, {})
|
raise_event(Balance.events.breached_wall, {})
|
||||||
if WPT.get('breached_wall') == WPT.get('spidertron_unlocked_at_zone') then
|
if WPT.get('breached_wall') == WPT.get('spidertron_unlocked_at_zone') then
|
||||||
local main_market_items = WPT.get('main_market_items')
|
local main_market_items = WPT.get('main_market_items')
|
||||||
@ -223,9 +226,13 @@ end
|
|||||||
|
|
||||||
local function on_player_changed_position(event)
|
local function on_player_changed_position(event)
|
||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
|
local surface_name = player.surface.name
|
||||||
local map_name = 'mountain_fortress_v3'
|
local map_name = 'mountain_fortress_v3'
|
||||||
|
if random(1, 3) ~= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if string.sub(player.surface.name, 0, #map_name) ~= map_name then
|
if sub(surface_name, 0, #map_name) ~= map_name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,6 +59,37 @@ local function create_particles(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function trigger_health()
|
||||||
|
local wave_number = WD.get('wave_number')
|
||||||
|
local d = Diff.get()
|
||||||
|
local m = 0.0015
|
||||||
|
if d.difficulty_vote_index then
|
||||||
|
if not d.strength_modifier then
|
||||||
|
m = m * 1.05
|
||||||
|
else
|
||||||
|
m = m * d.strength_modifier
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
local function spawn_biters(data)
|
local function spawn_biters(data)
|
||||||
local surface = data.surface
|
local surface = data.surface
|
||||||
if not (surface and surface.valid) then
|
if not (surface and surface.valid) then
|
||||||
@ -66,9 +97,8 @@ local function spawn_biters(data)
|
|||||||
end
|
end
|
||||||
local position = data.position
|
local position = data.position
|
||||||
local h = floor(abs(position.y))
|
local h = floor(abs(position.y))
|
||||||
local wave_number = WD.get('wave_number')
|
|
||||||
local max_biters = WPT.get('biters')
|
local max_biters = WPT.get('biters')
|
||||||
local d = Diff.get()
|
|
||||||
|
|
||||||
if max_biters.amount >= max_biters.limit then
|
if max_biters.amount >= max_biters.limit then
|
||||||
return
|
return
|
||||||
@ -81,35 +111,6 @@ local function spawn_biters(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function trigger_health()
|
|
||||||
local m = 0.0015
|
|
||||||
if d.difficulty_vote_index then
|
|
||||||
if not d.strength_modifier then
|
|
||||||
m = m * 1.05
|
|
||||||
else
|
|
||||||
m = m * d.strength_modifier
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
BiterRolls.wave_defense_set_unit_raffle(h * 0.20)
|
||||||
|
|
||||||
local unit
|
local unit
|
||||||
@ -123,7 +124,9 @@ local function spawn_biters(data)
|
|||||||
|
|
||||||
if random(1, 45) == 1 then
|
if random(1, 45) == 1 then
|
||||||
local sum = trigger_health()
|
local sum = trigger_health()
|
||||||
max_biters.amount = max_biters.amount + 1
|
BiterHealthBooster.add_unit(unit, sum)
|
||||||
|
elseif random(1, 64) == 1 then
|
||||||
|
local sum = trigger_health()
|
||||||
BiterHealthBooster.add_boss_unit(unit, sum, 0.38)
|
BiterHealthBooster.add_boss_unit(unit, sum, 0.38)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -141,8 +144,16 @@ local function spawn_worms(data)
|
|||||||
end
|
end
|
||||||
local position = data.position
|
local position = data.position
|
||||||
BiterRolls.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
|
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})
|
local unit = surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position})
|
||||||
max_biters.amount = max_biters.amount + 1
|
max_biters.amount = max_biters.amount + 1
|
||||||
|
|
||||||
|
if random(1, 45) == 1 then
|
||||||
|
local sum = trigger_health()
|
||||||
|
BiterHealthBooster.add_unit(unit, sum)
|
||||||
|
elseif random(1, 64) == 1 then
|
||||||
|
local sum = trigger_health()
|
||||||
|
BiterHealthBooster.add_boss_unit(unit, sum, 0.38)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.buried_biter(surface, position)
|
function Public.buried_biter(surface, position)
|
||||||
|
@ -2,10 +2,8 @@ require 'modules.rocks_broken_paint_tiles'
|
|||||||
|
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local BiterRolls = require 'modules.wave_defense.biter_rolls'
|
|
||||||
local BuriedEnemies = require 'maps.mountain_fortress_v3.buried_enemies'
|
local BuriedEnemies = require 'maps.mountain_fortress_v3.buried_enemies'
|
||||||
local Loot = require 'maps.mountain_fortress_v3.loot'
|
local Loot = require 'maps.mountain_fortress_v3.loot'
|
||||||
local Pets = require 'maps.mountain_fortress_v3.biter_pets'
|
|
||||||
local RPG_Settings = require 'modules.rpg.table'
|
local RPG_Settings = require 'modules.rpg.table'
|
||||||
local Functions = require 'modules.rpg.functions'
|
local Functions = require 'modules.rpg.functions'
|
||||||
local Callbacks = require 'maps.mountain_fortress_v3.functions'
|
local Callbacks = require 'maps.mountain_fortress_v3.functions'
|
||||||
@ -33,7 +31,6 @@ local Public = {}
|
|||||||
local random = math.random
|
local random = math.random
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
local sqrt = math.sqrt
|
|
||||||
local round = math.round
|
local round = math.round
|
||||||
|
|
||||||
-- Use these settings for live
|
-- Use these settings for live
|
||||||
@ -123,18 +120,6 @@ local reset_game =
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local function exists()
|
|
||||||
local carriages = WPT.get('carriages')
|
|
||||||
local t = {}
|
|
||||||
for i = 1, #carriages do
|
|
||||||
local e = carriages[i]
|
|
||||||
if (e and e.valid) then
|
|
||||||
t[e.unit_number] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_random_weighted(weighted_table, item_index, weight_index)
|
local function get_random_weighted(weighted_table, item_index, weight_index)
|
||||||
local total_weight = 0
|
local total_weight = 0
|
||||||
item_index = item_index or 1
|
item_index = item_index or 1
|
||||||
@ -330,11 +315,11 @@ local function protect_entities(event)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local units = exists()
|
local carriages_numbers = WPT.get('carriages_numbers')
|
||||||
if is_protected(entity) then
|
if is_protected(entity) then
|
||||||
if (event.cause and event.cause.valid) then
|
if (event.cause and event.cause.valid) then
|
||||||
if event.cause.force.index == 2 then
|
if event.cause.force.index == 2 then
|
||||||
if units and units[entity.unit_number] then
|
if carriages_numbers and carriages_numbers[entity.unit_number] then
|
||||||
set_train_final_health(dmg, false)
|
set_train_final_health(dmg, false)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
@ -344,7 +329,7 @@ local function protect_entities(event)
|
|||||||
end
|
end
|
||||||
elseif not (event.cause and event.cause.valid) then
|
elseif not (event.cause and event.cause.valid) then
|
||||||
if event.force and event.force.index == 2 then
|
if event.force and event.force.index == 2 then
|
||||||
if units and units[entity.unit_number] then
|
if carriages_numbers and carriages_numbers[entity.unit_number] then
|
||||||
set_train_final_health(dmg, false)
|
set_train_final_health(dmg, false)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
@ -358,23 +343,6 @@ local function protect_entities(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hidden_biter_pet(player, entity)
|
|
||||||
if random(1, 1024) ~= 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = entity.position
|
|
||||||
|
|
||||||
BiterRolls.wave_defense_set_unit_raffle(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_treasure(player, entity)
|
local function hidden_treasure(player, entity)
|
||||||
local rpg = RPG_Settings.get('rpg_t')
|
local rpg = RPG_Settings.get('rpg_t')
|
||||||
local magic = rpg[player.index].magicka
|
local magic = rpg[player.index].magicka
|
||||||
@ -642,15 +610,6 @@ local mining_events = {
|
|||||||
16,
|
16,
|
||||||
'Treasure_Tier_7'
|
'Treasure_Tier_7'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
function(entity, index)
|
|
||||||
local player = game.get_player(index)
|
|
||||||
Public.unstuck_player(index)
|
|
||||||
hidden_biter_pet(player, entity)
|
|
||||||
end,
|
|
||||||
256,
|
|
||||||
'Pet'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
function(entity, index)
|
function(entity, index)
|
||||||
if Locomotive.is_around_train(entity) then
|
if Locomotive.is_around_train(entity) then
|
||||||
@ -943,9 +902,9 @@ local function on_player_repaired_entity(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
local units = exists()
|
local carriages_numbers = WPT.get('carriages_numbers')
|
||||||
|
|
||||||
if units[entity.unit_number] then
|
if carriages_numbers[entity.unit_number] then
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
local repair_speed = Functions.get_magicka(player)
|
local repair_speed = Functions.get_magicka(player)
|
||||||
if repair_speed <= 0 then
|
if repair_speed <= 0 then
|
||||||
|
@ -10,7 +10,7 @@ local Collapse = require 'modules.collapse'
|
|||||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||||
local math2d = require 'math2d'
|
local math2d = require 'math2d'
|
||||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
local Misc = require 'commands.misc'
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
power_sources = {index = 1},
|
power_sources = {index = 1},
|
||||||
@ -710,6 +710,7 @@ function Public.remove_offline_players()
|
|||||||
offline_players[i] = nil
|
offline_players[i] = nil
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = game.forces.player.get_spawn_position(surface)
|
local pos = game.forces.player.get_spawn_position(surface)
|
||||||
local e =
|
local e =
|
||||||
surface.create_entity(
|
surface.create_entity(
|
||||||
@ -1179,7 +1180,7 @@ function Public.on_player_left_game()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Public.is_creativity_mode_on()
|
function Public.is_creativity_mode_on()
|
||||||
local creative_enabled = BottomFrame.get('creative_enabled')
|
local creative_enabled = Misc.get('creative_enabled')
|
||||||
if creative_enabled then
|
if creative_enabled then
|
||||||
WD.set('next_wave', 1000)
|
WD.set('next_wave', 1000)
|
||||||
Collapse.start_now(true)
|
Collapse.start_now(true)
|
||||||
@ -1188,9 +1189,9 @@ function Public.is_creativity_mode_on()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Public.disable_creative()
|
function Public.disable_creative()
|
||||||
local creative_enabled = BottomFrame.get('creative_enabled')
|
local creative_enabled = Misc.get('creative_enabled')
|
||||||
if creative_enabled then
|
if creative_enabled then
|
||||||
BottomFrame.set('creative_enabled', false)
|
Misc.set('creative_enabled', false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1248,9 +1249,9 @@ function Public.on_player_changed_position(event)
|
|||||||
local surface = game.surfaces[active_surface_index]
|
local surface = game.surfaces[active_surface_index]
|
||||||
|
|
||||||
local p = {x = player.position.x, y = player.position.y}
|
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')
|
local config_tile = WPT.get('void_or_tile')
|
||||||
if config_tile == 'lab-dark-2' then
|
if config_tile == 'lab-dark-2' then
|
||||||
|
local get_tile = surface.get_tile(p)
|
||||||
if get_tile.valid and get_tile.name == '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
|
||||||
if random(1, 2) == 1 then
|
if random(1, 2) == 1 then
|
||||||
@ -1292,6 +1293,8 @@ local disable_recipes = function(force)
|
|||||||
force.recipes['locomotive'].enabled = false
|
force.recipes['locomotive'].enabled = false
|
||||||
force.recipes['pistol'].enabled = false
|
force.recipes['pistol'].enabled = false
|
||||||
force.recipes['spidertron-remote'].enabled = false
|
force.recipes['spidertron-remote'].enabled = false
|
||||||
|
force.recipes['discharge-defense-equipment'].enabled = false
|
||||||
|
force.recipes['discharge-defense-remote'].enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.disable_tech()
|
function Public.disable_tech()
|
||||||
@ -1305,8 +1308,6 @@ function Public.disable_tech()
|
|||||||
force.technologies['artillery-shell-range-1'].researched = false
|
force.technologies['artillery-shell-range-1'].researched = false
|
||||||
force.technologies['artillery-shell-speed-1'].enabled = false
|
force.technologies['artillery-shell-speed-1'].enabled = false
|
||||||
force.technologies['artillery-shell-speed-1'].researched = false
|
force.technologies['artillery-shell-speed-1'].researched = false
|
||||||
force.technologies['artillery'].enabled = false
|
|
||||||
force.technologies['artillery'].researched = false
|
|
||||||
force.technologies['optics'].researched = true
|
force.technologies['optics'].researched = true
|
||||||
force.technologies['railway'].researched = true
|
force.technologies['railway'].researched = true
|
||||||
force.technologies['land-mine'].enabled = false
|
force.technologies['land-mine'].enabled = false
|
||||||
|
@ -86,7 +86,7 @@ end
|
|||||||
local function on_tick()
|
local function on_tick()
|
||||||
local tick = game.tick
|
local tick = game.tick
|
||||||
|
|
||||||
if tick % 10 == 1 then
|
if tick % 20 == 1 then
|
||||||
Functions.item_transfer()
|
Functions.item_transfer()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -471,6 +471,10 @@ function Public.kill_wagon(icw, entity)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local wagon = icw.wagons[entity.unit_number]
|
local wagon = icw.wagons[entity.unit_number]
|
||||||
|
if not wagon then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local surface = wagon.surface
|
local surface = wagon.surface
|
||||||
kick_players_from_surface(wagon)
|
kick_players_from_surface(wagon)
|
||||||
kick_players_out_of_vehicles(wagon)
|
kick_players_out_of_vehicles(wagon)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
--local Power = require 'maps.mountain_fortress_v3.power'
|
|
||||||
local Market = require 'maps.mountain_fortress_v3.basic_markets'
|
local Market = require 'maps.mountain_fortress_v3.basic_markets'
|
||||||
local Generate = require 'maps.mountain_fortress_v3.generate'
|
local Generate = require 'maps.mountain_fortress_v3.generate'
|
||||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||||
@ -456,6 +455,25 @@ local function refill_fish()
|
|||||||
locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = 'raw-fish', count = random(2, 5)})
|
locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = 'raw-fish', count = random(2, 5)})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function set_carriages()
|
||||||
|
local locomotive = WPT.get('locomotive')
|
||||||
|
if not locomotive or not locomotive.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local carriages = locomotive.train.carriages
|
||||||
|
local t = {}
|
||||||
|
for i = 1, #carriages do
|
||||||
|
local e = carriages[i]
|
||||||
|
if (e and e.valid) then
|
||||||
|
t[e.unit_number] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
WPT.set('carriages_numbers', t)
|
||||||
|
WPT.set('carriages', locomotive.train.carriages)
|
||||||
|
end
|
||||||
|
|
||||||
local function set_locomotive_health()
|
local function set_locomotive_health()
|
||||||
local locomotive_health = WPT.get('locomotive_health')
|
local locomotive_health = WPT.get('locomotive_health')
|
||||||
local locomotive_max_health = WPT.get('locomotive_max_health')
|
local locomotive_max_health = WPT.get('locomotive_max_health')
|
||||||
@ -467,7 +485,6 @@ local function set_locomotive_health()
|
|||||||
WPT.set('locomotive_health', locomotive_max_health)
|
WPT.set('locomotive_health', locomotive_max_health)
|
||||||
end
|
end
|
||||||
rendering.set_text(WPT.get('health_text'), 'HP: ' .. round(locomotive_health) .. ' / ' .. round(locomotive_max_health))
|
rendering.set_text(WPT.get('health_text'), 'HP: ' .. round(locomotive_health) .. ' / ' .. round(locomotive_max_health))
|
||||||
WPT.set('carriages', locomotive.train.carriages)
|
|
||||||
local carriages = WPT.get('carriages')
|
local carriages = WPT.get('carriages')
|
||||||
if carriages then
|
if carriages then
|
||||||
for i = 1, #carriages do
|
for i = 1, #carriages do
|
||||||
@ -1692,17 +1709,33 @@ local function place_market()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_research_finished()
|
local function on_research_finished(event)
|
||||||
local market_announce = WPT.get('market_announce')
|
local research = event.research
|
||||||
if market_announce > game.tick then
|
if not research then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local name = research.name
|
||||||
|
|
||||||
|
if name == 'discharge-defense-equipment' then
|
||||||
|
local message = ({'locomotive.discharge_unlocked'})
|
||||||
|
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac', 0.1)
|
||||||
|
end
|
||||||
|
if name == 'artillery' then
|
||||||
|
local message = ({'locomotive.artillery_unlocked'})
|
||||||
|
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac', 0.1)
|
||||||
|
end
|
||||||
|
|
||||||
local locomotive = WPT.get('locomotive')
|
local locomotive = WPT.get('locomotive')
|
||||||
if not locomotive or not locomotive.valid then
|
if not locomotive or not locomotive.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local market_announce = WPT.get('market_announce')
|
||||||
|
if market_announce > game.tick then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local breached_wall = WPT.get('breached_wall')
|
local breached_wall = WPT.get('breached_wall')
|
||||||
add_random_loot_to_main_market(breached_wall)
|
add_random_loot_to_main_market(breached_wall)
|
||||||
local message = ({'locomotive.new_items_at_market'})
|
local message = ({'locomotive.new_items_at_market'})
|
||||||
@ -2227,6 +2260,45 @@ function Public.get_items()
|
|||||||
upgrade = false,
|
upgrade = false,
|
||||||
static = false
|
static = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if game.forces.player.technologies['discharge-defense-equipment'].researched then
|
||||||
|
main_market_items['discharge-defense-equipment'] = {
|
||||||
|
stack = 1,
|
||||||
|
value = 'coin',
|
||||||
|
price = 9216,
|
||||||
|
tooltip = ({'equipment-name.discharge-defense-equipment'}),
|
||||||
|
upgrade = false,
|
||||||
|
static = false
|
||||||
|
}
|
||||||
|
main_market_items['discharge-defense-remote'] = {
|
||||||
|
stack = 1,
|
||||||
|
value = 'coin',
|
||||||
|
price = 1024,
|
||||||
|
tooltip = ({'item-name.discharge-defense-remote'}),
|
||||||
|
upgrade = false,
|
||||||
|
static = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if game.forces.player.technologies['artillery'].researched then
|
||||||
|
main_market_items['artillery-turret'] = {
|
||||||
|
stack = 1,
|
||||||
|
value = 'coin',
|
||||||
|
price = 9216,
|
||||||
|
tooltip = ({'item-name.artillery-turret'}),
|
||||||
|
upgrade = false,
|
||||||
|
static = false
|
||||||
|
}
|
||||||
|
main_market_items['artillery-shell'] = {
|
||||||
|
stack = 1,
|
||||||
|
value = 'coin',
|
||||||
|
price = 1024,
|
||||||
|
tooltip = ({'item-name.artillery-shell'}),
|
||||||
|
upgrade = false,
|
||||||
|
static = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
main_market_items['wood'] = {
|
main_market_items['wood'] = {
|
||||||
stack = 50,
|
stack = 50,
|
||||||
value = 'coin',
|
value = 'coin',
|
||||||
@ -2477,5 +2549,6 @@ Event.add(defines.events.on_robot_mined_entity, on_player_and_robot_mined_entity
|
|||||||
Event.add(defines.events.on_console_chat, on_console_chat)
|
Event.add(defines.events.on_console_chat, on_console_chat)
|
||||||
Event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
|
Event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
|
||||||
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||||
|
Event.add(defines.events.on_train_created, set_carriages)
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
@ -32,7 +32,6 @@ local Task = require 'utils.task'
|
|||||||
local Token = require 'utils.token'
|
local Token = require 'utils.token'
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'antigrief'
|
||||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
|
||||||
local Misc = require 'commands.misc'
|
local Misc = require 'commands.misc'
|
||||||
local Modifiers = require 'player_modifiers'
|
local Modifiers = require 'player_modifiers'
|
||||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||||
@ -132,11 +131,7 @@ function Public.reset_map()
|
|||||||
|
|
||||||
Autostash.insert_into_furnace(true)
|
Autostash.insert_into_furnace(true)
|
||||||
Autostash.insert_into_wagon(true)
|
Autostash.insert_into_wagon(true)
|
||||||
Autostash.bottom_button(true)
|
|
||||||
BuriedEnemies.reset()
|
BuriedEnemies.reset()
|
||||||
BottomFrame.reset()
|
|
||||||
BottomFrame.activate_custom_buttons(true)
|
|
||||||
BottomFrame.bottom_right(true)
|
|
||||||
|
|
||||||
Poll.reset()
|
Poll.reset()
|
||||||
ICW.reset()
|
ICW.reset()
|
||||||
@ -152,7 +147,7 @@ function Public.reset_map()
|
|||||||
RPG_Settings.enable_wave_defense(true)
|
RPG_Settings.enable_wave_defense(true)
|
||||||
RPG_Settings.enable_mana(true)
|
RPG_Settings.enable_mana(true)
|
||||||
RPG_Settings.enable_flame_boots(true)
|
RPG_Settings.enable_flame_boots(true)
|
||||||
RPG_Settings.personal_tax_rate(0.3)
|
RPG_Settings.personal_tax_rate(0.4)
|
||||||
RPG_Settings.enable_stone_path(true)
|
RPG_Settings.enable_stone_path(true)
|
||||||
RPG_Settings.enable_one_punch(true)
|
RPG_Settings.enable_one_punch(true)
|
||||||
RPG_Settings.enable_one_punch_globally(false)
|
RPG_Settings.enable_one_punch_globally(false)
|
||||||
@ -179,6 +174,7 @@ function Public.reset_map()
|
|||||||
|
|
||||||
game.forces.player.set_spawn_position({-27, 25}, surface)
|
game.forces.player.set_spawn_position({-27, 25}, surface)
|
||||||
game.forces.player.manual_mining_speed_modifier = 0
|
game.forces.player.manual_mining_speed_modifier = 0
|
||||||
|
game.forces.player.set_ammo_damage_modifier('artillery-shell', -0.95)
|
||||||
|
|
||||||
BiterHealthBooster.set_active_surface(tostring(surface.name))
|
BiterHealthBooster.set_active_surface(tostring(surface.name))
|
||||||
BiterHealthBooster.acid_nova(true)
|
BiterHealthBooster.acid_nova(true)
|
||||||
@ -399,15 +395,10 @@ end
|
|||||||
local compare_collapse_and_train = function()
|
local compare_collapse_and_train = function()
|
||||||
local collapse_pos = Collapse.get_position()
|
local collapse_pos = Collapse.get_position()
|
||||||
local locomotive = WPT.get('locomotive')
|
local locomotive = WPT.get('locomotive')
|
||||||
local carriages = WPT.get('carriages')
|
|
||||||
if not (locomotive and locomotive.valid) then
|
if not (locomotive and locomotive.valid) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not carriages then
|
|
||||||
WPT.set().carriages = locomotive.train.carriages
|
|
||||||
end
|
|
||||||
|
|
||||||
local c_y = collapse_pos.y
|
local c_y = collapse_pos.y
|
||||||
local t_y = locomotive.position.y
|
local t_y = locomotive.position.y
|
||||||
|
|
||||||
|
@ -90,7 +90,6 @@ function Public.reset_table()
|
|||||||
this.game_saved = false
|
this.game_saved = false
|
||||||
-- @end
|
-- @end
|
||||||
this.icw_locomotive = nil
|
this.icw_locomotive = nil
|
||||||
this.debug = false
|
|
||||||
this.game_lost = false
|
this.game_lost = false
|
||||||
this.fullness_enabled = true
|
this.fullness_enabled = true
|
||||||
this.locomotive_health = 10000
|
this.locomotive_health = 10000
|
||||||
@ -103,7 +102,6 @@ function Public.reset_table()
|
|||||||
}
|
}
|
||||||
this.force_chunk = false
|
this.force_chunk = false
|
||||||
this.train_upgrades = 0
|
this.train_upgrades = 0
|
||||||
this.biter_pets = {}
|
|
||||||
this.flamethrower_damage = {}
|
this.flamethrower_damage = {}
|
||||||
this.mined_scrap = 0
|
this.mined_scrap = 0
|
||||||
this.biters_killed = 0
|
this.biters_killed = 0
|
||||||
|
@ -261,15 +261,15 @@ local function wall(data)
|
|||||||
local seed = data.seed
|
local seed = data.seed
|
||||||
local p = {x = x + data.top_x, y = y + data.top_y}
|
local p = {x = x + data.top_x, y = y + data.top_y}
|
||||||
|
|
||||||
local small_caves = get_perlin('small_caves', p, seed + 300000)
|
local small_caves = get_perlin('small_caves', p, seed + 204000)
|
||||||
local cave_ponds = get_perlin('cave_rivers', p, seed + 150000)
|
local cave_ponds = get_perlin('cave_rivers', p, seed + 120400)
|
||||||
if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then
|
if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then
|
||||||
if small_caves > 0.02 or cave_ponds > 0.02 then
|
if small_caves > 0.02 or cave_ponds > 0.02 then
|
||||||
if small_caves > 0.005 then
|
if small_caves > 0.005 then
|
||||||
tiles[#tiles + 1] = {name = 'water', position = p}
|
tiles[#tiles + 1] = {name = 'water', position = p}
|
||||||
else
|
else
|
||||||
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
||||||
if random(1, 32) == 1 then
|
if random(1, 26) == 1 then
|
||||||
entities[#entities + 1] = {
|
entities[#entities + 1] = {
|
||||||
name = 'land-mine',
|
name = 'land-mine',
|
||||||
position = p,
|
position = p,
|
||||||
@ -285,7 +285,7 @@ local function wall(data)
|
|||||||
|
|
||||||
if random(1, 5) ~= 1 then
|
if random(1, 5) ~= 1 then
|
||||||
entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = p}
|
entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = p}
|
||||||
if random(1, 32) == 1 then
|
if random(1, 26) == 1 then
|
||||||
entities[#entities + 1] = {
|
entities[#entities + 1] = {
|
||||||
name = 'land-mine',
|
name = 'land-mine',
|
||||||
position = p,
|
position = p,
|
||||||
@ -383,7 +383,7 @@ local function wall(data)
|
|||||||
spawn_turret(entities, p, 4)
|
spawn_turret(entities, p, 4)
|
||||||
elseif random(1, 2) == 1 then
|
elseif random(1, 2) == 1 then
|
||||||
spawn_turret(entities, p, 5)
|
spawn_turret(entities, p, 5)
|
||||||
elseif random(1, 8) == 1 then
|
elseif random(1, 12) == 1 then
|
||||||
spawn_turret(entities, p, enable_arties)
|
spawn_turret(entities, p, enable_arties)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ local WPT = require 'maps.mountain_fortress_v3.table'
|
|||||||
|
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*', 'OOF'}
|
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*', '( ͡° ͜ʖ ͡°)'}
|
||||||
|
|
||||||
local kaboom_weights = {
|
local kaboom_weights = {
|
||||||
{name = 'grenade', chance = 7},
|
{name = 'grenade', chance = 7},
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local print_color = {r = 120, g = 255, b = 0}
|
local print_color = {r = 120, g = 255, b = 0}
|
||||||
|
|
||||||
@ -12,7 +11,6 @@ local this = {
|
|||||||
whitelist = {},
|
whitelist = {},
|
||||||
insert_into_furnace = false,
|
insert_into_furnace = false,
|
||||||
insert_into_wagon = false,
|
insert_into_wagon = false,
|
||||||
bottom_button = false,
|
|
||||||
small_radius = 2
|
small_radius = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,38 +537,23 @@ local function create_gui_button(player)
|
|||||||
else
|
else
|
||||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
||||||
end
|
end
|
||||||
if this.bottom_button then
|
local b =
|
||||||
local data = BottomFrame.get('bottom_quickbar_button')
|
player.gui.top.add(
|
||||||
-- save it for later use
|
{
|
||||||
data.tooltip = tooltip
|
type = 'sprite-button',
|
||||||
data.sprite = 'item/wooden-chest'
|
sprite = 'item/wooden-chest',
|
||||||
|
name = 'auto_stash',
|
||||||
if data[player.index] then
|
tooltip = tooltip
|
||||||
data = data[player.index]
|
}
|
||||||
if data.frame and data.frame.valid then
|
)
|
||||||
data.frame.sprite = 'item/wooden-chest'
|
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
|
||||||
data.frame.tooltip = tooltip
|
b.style.font = 'heading-1'
|
||||||
end
|
b.style.minimal_height = 40
|
||||||
end
|
b.style.maximal_width = 40
|
||||||
else
|
b.style.minimal_width = 38
|
||||||
local b =
|
b.style.maximal_height = 38
|
||||||
player.gui.top.add(
|
b.style.padding = 1
|
||||||
{
|
b.style.margin = 0
|
||||||
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 = 40
|
|
||||||
b.style.maximal_width = 40
|
|
||||||
b.style.minimal_width = 38
|
|
||||||
b.style.maximal_height = 38
|
|
||||||
b.style.padding = 1
|
|
||||||
b.style.margin = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_whitelist()
|
local function do_whitelist()
|
||||||
@ -613,13 +596,6 @@ local function on_gui_click(event)
|
|||||||
end
|
end
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
local name = 'auto_stash'
|
local name = 'auto_stash'
|
||||||
if this.bottom_button then
|
|
||||||
local data = BottomFrame.get('bottom_quickbar_button')
|
|
||||||
if data[player.index] then
|
|
||||||
data = data[player.index]
|
|
||||||
name = data.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if event.element.name == name then
|
if event.element.name == name then
|
||||||
auto_stash(player, event)
|
auto_stash(player, event)
|
||||||
@ -642,14 +618,6 @@ function Public.insert_into_wagon(value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.bottom_button(value)
|
|
||||||
if value then
|
|
||||||
this.bottom_button = value
|
|
||||||
else
|
|
||||||
this.bottom_button = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Event.on_configuration_changed(do_whitelist)
|
Event.on_configuration_changed(do_whitelist)
|
||||||
|
|
||||||
Event.on_init(do_whitelist)
|
Event.on_init(do_whitelist)
|
||||||
|
@ -67,10 +67,10 @@ local function on_gui_click(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
|
|
||||||
local index = element.name
|
local index = element.name
|
||||||
if not rpg_t[player.index][index] then
|
if not rpg_t[index] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not player.character then
|
if not player.character then
|
||||||
@ -78,27 +78,27 @@ local function on_gui_click(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if shift then
|
if shift then
|
||||||
local count = rpg_t[player.index].points_to_distribute
|
local count = rpg_t.points_to_distribute
|
||||||
if not count then
|
if not count then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].points_to_distribute = 0
|
rpg_t.points_to_distribute = 0
|
||||||
rpg_t[player.index][index] = rpg_t[player.index][index] + count
|
rpg_t[index] = rpg_t[index] + count
|
||||||
if not rpg_t[player.index].reset then
|
if not rpg_t.reset then
|
||||||
rpg_t[player.index].total = rpg_t[player.index].total + count
|
rpg_t.total = rpg_t.total + count
|
||||||
end
|
end
|
||||||
RPG_GUI.toggle(player, true)
|
RPG_GUI.toggle(player, true)
|
||||||
RPG_GUI.update_player_stats(player)
|
RPG_GUI.update_player_stats(player)
|
||||||
elseif event.button == defines.mouse_button_type.right then
|
elseif event.button == defines.mouse_button_type.right then
|
||||||
for _ = 1, points_per_level, 1 do
|
for _ = 1, points_per_level, 1 do
|
||||||
if rpg_t[player.index].points_to_distribute <= 0 then
|
if rpg_t.points_to_distribute <= 0 then
|
||||||
RPG_GUI.toggle(player, true)
|
RPG_GUI.toggle(player, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute - 1
|
rpg_t.points_to_distribute = rpg_t.points_to_distribute - 1
|
||||||
rpg_t[player.index][index] = rpg_t[player.index][index] + 1
|
rpg_t[index] = rpg_t[index] + 1
|
||||||
if not rpg_t[player.index].reset then
|
if not rpg_t.reset then
|
||||||
rpg_t[player.index].total = rpg_t[player.index].total + 1
|
rpg_t.total = rpg_t.total + 1
|
||||||
end
|
end
|
||||||
RPG_GUI.update_player_stats(player)
|
RPG_GUI.update_player_stats(player)
|
||||||
end
|
end
|
||||||
@ -106,14 +106,14 @@ local function on_gui_click(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if rpg_t[player.index].points_to_distribute <= 0 then
|
if rpg_t.points_to_distribute <= 0 then
|
||||||
RPG_GUI.toggle(player, true)
|
RPG_GUI.toggle(player, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute - 1
|
rpg_t.points_to_distribute = rpg_t.points_to_distribute - 1
|
||||||
rpg_t[player.index][index] = rpg_t[player.index][index] + 1
|
rpg_t[index] = rpg_t[index] + 1
|
||||||
if not rpg_t[player.index].reset then
|
if not rpg_t.reset then
|
||||||
rpg_t[player.index].total = rpg_t[player.index].total + 1
|
rpg_t.total = rpg_t.total + 1
|
||||||
end
|
end
|
||||||
RPG_GUI.update_player_stats(player)
|
RPG_GUI.update_player_stats(player)
|
||||||
RPG_GUI.toggle(player, true)
|
RPG_GUI.toggle(player, true)
|
||||||
@ -338,7 +338,7 @@ local function regen_mana_player(players)
|
|||||||
local player = players[i]
|
local player = players[i]
|
||||||
local mana_per_tick = Functions.get_mana_modifier(player)
|
local mana_per_tick = Functions.get_mana_modifier(player)
|
||||||
local rpg_extra = RPG.get('rpg_extra')
|
local rpg_extra = RPG.get('rpg_extra')
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
if mana_per_tick <= 0.1 then
|
if mana_per_tick <= 0.1 then
|
||||||
mana_per_tick = rpg_extra.mana_per_tick
|
mana_per_tick = rpg_extra.mana_per_tick
|
||||||
end
|
end
|
||||||
@ -349,17 +349,17 @@ local function regen_mana_player(players)
|
|||||||
|
|
||||||
if player and player.valid and not player.in_combat then
|
if player and player.valid and not player.in_combat then
|
||||||
if player.character and player.character.valid then
|
if player.character and player.character.valid then
|
||||||
if rpg_t[player.index].mana < 0 then
|
if rpg_t.mana < 0 then
|
||||||
rpg_t[player.index].mana = 0
|
rpg_t.mana = 0
|
||||||
end
|
end
|
||||||
if rpg_t[player.index].mana >= rpg_t[player.index].mana_max then
|
if rpg_t.mana >= rpg_t.mana_max then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana + mana_per_tick
|
rpg_t.mana = rpg_t.mana + mana_per_tick
|
||||||
if rpg_t[player.index].mana >= rpg_t[player.index].mana_max then
|
if rpg_t.mana >= rpg_t.mana_max then
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana_max
|
rpg_t.mana = rpg_t.mana_max
|
||||||
end
|
end
|
||||||
rpg_t[player.index].mana = (math.round(rpg_t[player.index].mana * 10) / 10)
|
rpg_t.mana = (math.round(rpg_t.mana * 10) / 10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -370,6 +370,11 @@ local function regen_mana_player(players)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function give_player_flameboots(player)
|
local function give_player_flameboots(player)
|
||||||
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
|
if not rpg_t.flame_boots then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not player.character then
|
if not player.character then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -377,39 +382,33 @@ local function give_player_flameboots(player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local rpg_t = RPG.get('rpg_t')
|
if not rpg_t.mana then
|
||||||
|
|
||||||
if not rpg_t[player.index].mana then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not rpg_t[player.index].flame_boots then
|
if rpg_t.mana <= 0 then
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if rpg_t[player.index].mana <= 0 then
|
|
||||||
player.print(({'rpg_main.flame_boots_worn_out'}), {r = 0.22, g = 0.77, b = 0.44})
|
player.print(({'rpg_main.flame_boots_worn_out'}), {r = 0.22, g = 0.77, b = 0.44})
|
||||||
rpg_t[player.index].flame_boots = false
|
rpg_t.flame_boots = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if rpg_t[player.index].mana % 500 == 0 then
|
if rpg_t.mana % 500 == 0 then
|
||||||
player.print(({'rpg_main.flame_mana_remaining', rpg_t[player.index].mana}), {r = 0.22, g = 0.77, b = 0.44})
|
player.print(({'rpg_main.flame_mana_remaining', rpg_t.mana}), {r = 0.22, g = 0.77, b = 0.44})
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = player.position
|
local p = player.position
|
||||||
|
|
||||||
player.surface.create_entity({name = 'fire-flame', position = p})
|
player.surface.create_entity({name = 'fire-flame', position = p})
|
||||||
|
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - 5
|
rpg_t.mana = rpg_t.mana - 5
|
||||||
if rpg_t[player.index].mana <= 0 then
|
if rpg_t.mana <= 0 then
|
||||||
rpg_t[player.index].mana = 0
|
rpg_t.mana = 0
|
||||||
end
|
end
|
||||||
if player.gui.screen[main_frame_name] then
|
if player.gui.screen[main_frame_name] then
|
||||||
local f = player.gui.screen[main_frame_name]
|
local f = player.gui.screen[main_frame_name]
|
||||||
local data = Gui.get_data(f)
|
local data = Gui.get_data(f)
|
||||||
if data.mana and data.mana.valid then
|
if data.mana and data.mana.valid then
|
||||||
data.mana.caption = rpg_t[player.index].mana
|
data.mana.caption = rpg_t.mana
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -590,11 +589,11 @@ local function on_entity_damaged(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local enable_one_punch = RPG.get('rpg_extra').enable_one_punch
|
local enable_one_punch = RPG.get('rpg_extra').enable_one_punch
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(cause.player.index)
|
||||||
|
|
||||||
--Cause a one punch.
|
--Cause a one punch.
|
||||||
if enable_one_punch then
|
if enable_one_punch then
|
||||||
if rpg_t[cause.player.index].one_punch then
|
if rpg_t.one_punch then
|
||||||
if math.random(0, 999) < Functions.get_one_punch_chance(cause.player) * 10 then
|
if math.random(0, 999) < Functions.get_one_punch_chance(cause.player) * 10 then
|
||||||
one_punch(cause, entity, damage)
|
one_punch(cause, entity, damage)
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
@ -713,11 +712,11 @@ local function on_player_rotated_entity(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
if rpg_t[player.index].rotated_entity_delay > game.tick then
|
if rpg_t.rotated_entity_delay > game.tick then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].rotated_entity_delay = game.tick + 20
|
rpg_t.rotated_entity_delay = game.tick + 20
|
||||||
Functions.gain_xp(player, 0.20)
|
Functions.gain_xp(player, 0.20)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -793,12 +792,12 @@ local function on_pre_player_mined_item(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
if rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y then
|
if rpg_t.last_mined_entity_position.x == event.entity.position.x and rpg_t.last_mined_entity_position.y == event.entity.position.y then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
rpg_t.last_mined_entity_position.x = entity.position.x
|
||||||
rpg_t[player.index].last_mined_entity_position.y = entity.position.y
|
rpg_t.last_mined_entity_position.y = entity.position.y
|
||||||
|
|
||||||
local distance_multiplier = math.floor(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)) * 0.0005 + 1
|
local distance_multiplier = math.floor(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)) * 0.0005 + 1
|
||||||
|
|
||||||
@ -813,7 +812,7 @@ local function on_pre_player_mined_item(event)
|
|||||||
local f = player.gui.screen[main_frame_name]
|
local f = player.gui.screen[main_frame_name]
|
||||||
local data = Gui.get_data(f)
|
local data = Gui.get_data(f)
|
||||||
if data.exp_gui and data.exp_gui.valid then
|
if data.exp_gui and data.exp_gui.valid then
|
||||||
data.exp_gui.caption = math.floor(rpg_t[player.index].xp)
|
data.exp_gui.caption = math.floor(rpg_t.xp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -856,8 +855,8 @@ end
|
|||||||
|
|
||||||
local function on_player_respawned(event)
|
local function on_player_respawned(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
if not rpg_t[player.index] then
|
if not rpg_t then
|
||||||
Functions.rpg_reset_player(player)
|
Functions.rpg_reset_player(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -869,9 +868,9 @@ end
|
|||||||
|
|
||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
local rpg_extra = RPG.get('rpg_extra')
|
local rpg_extra = RPG.get('rpg_extra')
|
||||||
if not rpg_t[player.index] then
|
if not rpg_t then
|
||||||
Functions.rpg_reset_player(player)
|
Functions.rpg_reset_player(player)
|
||||||
if rpg_extra.reward_new_players > 10 then
|
if rpg_extra.reward_new_players > 10 then
|
||||||
Functions.gain_xp(player, rpg_extra.reward_new_players)
|
Functions.gain_xp(player, rpg_extra.reward_new_players)
|
||||||
@ -1019,27 +1018,27 @@ local function on_player_used_capsule(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local rpg_t = RPG.get('rpg_t')
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
|
|
||||||
if not rpg_t[player.index].enable_entity_spawn then
|
if not rpg_t.enable_entity_spawn then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = player.print
|
local p = player.print
|
||||||
|
|
||||||
if rpg_t[player.index].last_spawned >= game.tick then
|
if rpg_t.last_spawned >= game.tick then
|
||||||
return p(({'rpg_main.mana_casting_too_fast', player.name}), Color.warning)
|
return p(({'rpg_main.mana_casting_too_fast', player.name}), Color.warning)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mana = rpg_t[player.index].mana
|
local mana = rpg_t.mana
|
||||||
local surface = player.surface
|
local surface = player.surface
|
||||||
|
|
||||||
local object = conjure_items[rpg_t[player.index].dropdown_select_index]
|
local object = conjure_items[rpg_t.dropdown_select_index]
|
||||||
if not object then
|
if not object then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if rpg_t[player.index].level < object.level then
|
if rpg_t.level < object.level then
|
||||||
return p(({'rpg_main.low_level'}), Color.fail)
|
return p(({'rpg_main.low_level'}), Color.fail)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1094,14 +1093,14 @@ local function on_player_used_capsule(event)
|
|||||||
if object.obj_to_create == 'suicidal_comfylatron' then
|
if object.obj_to_create == 'suicidal_comfylatron' then
|
||||||
Functions.suicidal_comfylatron(position, surface)
|
Functions.suicidal_comfylatron(position, surface)
|
||||||
p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success)
|
p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
elseif object.obj_to_create == 'warp-gate' then
|
elseif object.obj_to_create == 'warp-gate' then
|
||||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||||
rpg_t[player.index].mana = 0
|
rpg_t.mana = 0
|
||||||
Functions.damage_player_over_time(player, math.random(8, 16))
|
Functions.damage_player_over_time(player, math.random(8, 16))
|
||||||
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
|
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
|
||||||
p(({'rpg_main.warped_ok'}), Color.info)
|
p(({'rpg_main.warped_ok'}), Color.info)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
elseif projectile_types[obj_name] then -- projectiles
|
elseif projectile_types[obj_name] then -- projectiles
|
||||||
for i = 1, object.amount do
|
for i = 1, object.amount do
|
||||||
local damage_area = {
|
local damage_area = {
|
||||||
@ -1116,16 +1115,16 @@ local function on_player_used_capsule(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
else
|
else
|
||||||
if object.target then -- rockets and such
|
if object.target then -- rockets and such
|
||||||
surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1})
|
surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1})
|
||||||
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
elseif object.obj_to_create == 'fish' then -- spawn in some fish
|
elseif object.obj_to_create == 'fish' then -- spawn in some fish
|
||||||
player.insert({name = 'raw-fish', count = object.amount})
|
player.insert({name = 'raw-fish', count = object.amount})
|
||||||
p(({'rpg_main.object_spawned', 'raw-fish'}), Color.success)
|
p(({'rpg_main.object_spawned', 'raw-fish'}), Color.success)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
elseif surface.can_place_entity {name = obj_name, position = position} then
|
elseif surface.can_place_entity {name = obj_name, position = position} then
|
||||||
if object.biter then
|
if object.biter then
|
||||||
local e = surface.create_entity({name = obj_name, position = position, force = force})
|
local e = surface.create_entity({name = obj_name, position = position, force = force})
|
||||||
@ -1134,7 +1133,7 @@ local function on_player_used_capsule(event)
|
|||||||
surface.create_entity({name = obj_name, position = position, force = force})
|
surface.create_entity({name = obj_name, position = position, force = force})
|
||||||
end
|
end
|
||||||
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
p(({'rpg_main.object_spawned', obj_name}), Color.success)
|
||||||
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
|
rpg_t.mana = rpg_t.mana - object.mana_cost
|
||||||
else
|
else
|
||||||
p(({'rpg_main.out_of_reach'}), Color.fail)
|
p(({'rpg_main.out_of_reach'}), Color.fail)
|
||||||
return
|
return
|
||||||
@ -1143,7 +1142,7 @@ local function on_player_used_capsule(event)
|
|||||||
|
|
||||||
local msg = player.name .. ' casted ' .. object.obj_to_create .. '. '
|
local msg = player.name .. ' casted ' .. object.obj_to_create .. '. '
|
||||||
|
|
||||||
rpg_t[player.index].last_spawned = game.tick + object.tick
|
rpg_t.last_spawned = game.tick + object.tick
|
||||||
Functions.update_mana(player)
|
Functions.update_mana(player)
|
||||||
|
|
||||||
local reward_xp = object.mana_cost * 0.085
|
local reward_xp = object.mana_cost * 0.085
|
||||||
|
@ -96,16 +96,41 @@ local function spawn_biters(data)
|
|||||||
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position})
|
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position})
|
||||||
end
|
end
|
||||||
|
|
||||||
if random(1, 64) == 1 then
|
if random(1, 45) == 1 then
|
||||||
|
BiterHealthBooster.add_unit(unit, boosted_health)
|
||||||
|
elseif random(1, 64) == 1 then
|
||||||
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38)
|
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spawn_worms(data)
|
local function spawn_worms(data)
|
||||||
|
local wave_number = WD.get('wave_number')
|
||||||
|
local d = Diff.get()
|
||||||
|
local m = 0.0015
|
||||||
|
if d.difficulty_vote_index then
|
||||||
|
if not d.strength_modifier then
|
||||||
|
m = m * 1.05
|
||||||
|
else
|
||||||
|
m = m * d.strength_modifier
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local boosted_health = 1 + (wave_number * (m * 2))
|
||||||
|
|
||||||
|
if wave_number >= 100 then
|
||||||
|
boosted_health = boosted_health * 2
|
||||||
|
end
|
||||||
|
|
||||||
local surface = data.surface
|
local surface = data.surface
|
||||||
local position = data.position
|
local position = data.position
|
||||||
BiterRolls.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
|
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})
|
local unit = surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position})
|
||||||
|
|
||||||
|
if random(1, 45) == 1 then
|
||||||
|
BiterHealthBooster.add_unit(unit, boosted_health)
|
||||||
|
elseif random(1, 64) == 1 then
|
||||||
|
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.buried_biter(surface, position, max)
|
function Public.buried_biter(surface, position, max)
|
||||||
|
@ -966,15 +966,30 @@ Event.add(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
local leave_reason_map = {
|
||||||
|
[defines.disconnect_reason.quit] = '',
|
||||||
|
[defines.disconnect_reason.dropped] = ' (Dropped)',
|
||||||
|
[defines.disconnect_reason.reconnect] = ' (Reconnect)',
|
||||||
|
[defines.disconnect_reason.wrong_input] = ' (Wrong input)',
|
||||||
|
[defines.disconnect_reason.desync_limit_reached] = ' (Desync limit reached)',
|
||||||
|
[defines.disconnect_reason.cannot_keep_up] = ' (Cannot keep up)',
|
||||||
|
[defines.disconnect_reason.afk] = ' (AFK)',
|
||||||
|
[defines.disconnect_reason.kicked] = ' (Kicked)',
|
||||||
|
[defines.disconnect_reason.kicked_and_deleted] = ' (Kicked)',
|
||||||
|
[defines.disconnect_reason.banned] = ' (Banned)',
|
||||||
|
[defines.disconnect_reason.switching_servers] = ' (Switching servers)'
|
||||||
|
}
|
||||||
|
|
||||||
Event.add(
|
Event.add(
|
||||||
defines.events.on_player_left_game,
|
defines.events.on_player_left_game,
|
||||||
function(event)
|
function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
if not player or not player.valid then
|
if not player then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
raw_print(player_leave_tag .. player.name)
|
local reason = leave_reason_map[event.reason] or ''
|
||||||
|
raw_print(player_leave_tag .. player.name .. reason)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user