1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-11 14:49:24 +02:00
This commit is contained in:
Gerkiz 2020-11-15 19:23:54 +01:00
parent 520b097e26
commit 1b2c7f6cd8
20 changed files with 453 additions and 399 deletions

View File

@ -1,3 +1,2 @@
require 'commands.misc'
require 'commands.jail'
require 'commands.where'

View File

@ -1,36 +0,0 @@
local Server = require 'utils.server'
local Event = require 'utils.event'
local function on_console_command(event)
local cmd = event.command
if not event.player_index then
return
end
local player = game.players[event.player_index]
local reason = event.parameters
if not reason then
return
end
if not player.admin then
return
end
if cmd == 'ban' then
if player then
Server.to_banned_embed(table.concat {player.name .. ' banned ' .. reason})
return
else
Server.to_banned_embed(table.concat {'Server banned ' .. reason})
return
end
elseif cmd == 'unban' then
if player then
Server.to_banned_embed(table.concat {player.name .. ' unbanned ' .. reason})
return
else
Server.to_banned_embed(table.concat {'Server unbanned ' .. reason})
return
end
end
end
Event.add(defines.events.on_console_command, on_console_command)

View File

@ -1243,7 +1243,7 @@ function Public.reset_game()
Difficulty.reset_difficulty_poll()
local wave_grace_period = FDT.get('wave_grace_period')
if not wave_grace_period then
wave_grace_period = game.tick + 3600 * 20
wave_grace_period = game.tick + 72000
end
Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = wave_grace_period})

View File

@ -46,7 +46,7 @@ function Public.reset_table()
this.last_reset = game.tick
global.biter_health_boost = 4
this.wave_interval = 3600
this.wave_grace_period = game.tick + 3600 * 20
this.wave_grace_period = game.tick + 72000
this.biter_health_boost = 1
-- this.wave_grace_period = game.tick + 3600
this.boss_biters = {}

View File

@ -25,9 +25,7 @@ local function floaty_hearts(entity, c)
(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}}
)
entity.surface.create_entity({name = 'flying-text', position = p, text = '', color = {random(150, 255), 0, 255}})
end
end
@ -88,9 +86,9 @@ local function is_valid_player(player, unit)
end
function Public.biter_pets_tame_unit(player, unit, forced)
local this = WPT.get()
local biter_pets = WPT.get('biter_pets')
if this.biter_pets[player.index] then
if biter_pets[player.index] then
return false
end
@ -107,7 +105,7 @@ function Public.biter_pets_tame_unit(player, unit, forced)
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})
this.biter_pets[player.index] = {last_command = 0, entity = unit}
biter_pets[player.index] = {last_command = 0, entity = unit}
tame_unit_effects(player, unit)
return true
end
@ -150,31 +148,31 @@ local function command_unit(entity, player)
end
local function on_player_changed_position(event)
local this = WPT.get()
local biter_pets = WPT.get('biter_pets')
if random(1, 100) ~= 1 then
return
end
local player = game.players[event.player_index]
if not this.biter_pets[player.index] then
if not biter_pets[player.index] then
return
end
if not this.biter_pets[player.index].entity then
this.biter_pets[player.index] = nil
if not biter_pets[player.index].entity then
biter_pets[player.index] = nil
return
end
if not this.biter_pets[player.index].entity.valid then
this.biter_pets[player.index] = nil
if not biter_pets[player.index].entity.valid then
biter_pets[player.index] = nil
return
end
if not player.character then
return
end
if this.biter_pets[player.index].last_command + 600 > game.tick then
if biter_pets[player.index].last_command + 600 > game.tick then
return
end
this.biter_pets[player.index].last_command = game.tick
command_unit(this.biter_pets[player.index].entity, player)
biter_pets[player.index].last_command = game.tick
command_unit(biter_pets[player.index].entity, player)
end
local function on_player_dropped_item(event)

View File

@ -125,12 +125,11 @@ end
local function on_entity_removed(data)
local entity = data.entity
local this = data.this
local upg = this.upgrades
local upgrades = WPT.get('upgrades')
local built = {
['land-mine'] = upg.landmine.built,
['flamethrower-turret'] = upg.flame_turret.built
['land-mine'] = upgrades.landmine.built,
['flamethrower-turret'] = upgrades.flame_turret.built
}
local validator = {
@ -141,18 +140,21 @@ local function on_entity_removed(data)
local name = validator[entity.name]
if built[entity.name] and entity.force.index == 1 then
this.upgrades[name].built = this.upgrades[name].built - 1
if this.upgrades[name].built <= 0 then
this.upgrades[name].built = 0
upgrades[name].built = upgrades[name].built - 1
if upgrades[name].built <= 0 then
upgrades[name].built = 0
end
end
end
local function check_health(this)
local m = this.locomotive_health / this.locomotive_max_health
if this.carriages then
for i = 1, #this.carriages do
local entity = this.carriages[i]
local function check_health()
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local carriages = WPT.get('carriages')
local m = locomotive_health / locomotive_max_health
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
if not (entity and entity.valid) then
return
end
@ -165,10 +167,11 @@ local function check_health(this)
end
end
local function check_health_final_damage(this, final_damage_amount)
if this.carriages then
for i = 1, #this.carriages do
local entity = this.carriages[i]
local function check_health_final_damage(final_damage_amount)
local carriages = WPT.get('carriages')
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
if not (entity and entity.valid) then
return
end
@ -178,52 +181,57 @@ local function check_health_final_damage(this, final_damage_amount)
end
local function set_objective_health(final_damage_amount)
local this = WPT.get()
if final_damage_amount == 0 then
return
end
if not (this.locomotive and this.locomotive.valid) then
local locomotive = WPT.get('locomotive')
if not (locomotive and locomotive.valid) then
return
end
if this.locomotive_health <= 5000 then
if not this.poison_deployed then
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local poison_deployed = WPT.get('poison_deployed')
if locomotive_health <= 5000 then
if not poison_deployed then
for i = 1, 2, 1 do
Locomotive.enable_poison_defense()
end
local p = {
position = this.locomotive.position
position = locomotive.position
}
local msg = ({'entity.train_taking_damage'})
Alert.alert_all_players_location(p, msg)
this.poison_deployed = true
WPT.set().poison_deployed = true
end
elseif this.locomotive_health >= this.locomotive_max_health then
this.poison_deployed = false
elseif locomotive_health >= locomotive_max_health then
WPT.set().poison_deployed = false
end
if this.locomotive_health <= 0 then
check_health_final_damage(this, final_damage_amount)
if locomotive_health <= 0 then
check_health_final_damage(final_damage_amount)
return
end
this.locomotive_health = floor(this.locomotive_health - final_damage_amount)
if this.locomotive_health > this.locomotive_max_health then
this.locomotive_health = this.locomotive_max_health
locomotive_health = floor(locomotive_health - final_damage_amount)
if locomotive_health > locomotive_max_health then
locomotive_health = locomotive_max_health
end
if this.locomotive_health <= 0 then
if locomotive_health <= 0 then
Public.loco_died()
end
check_health(this)
check_health()
rendering.set_text(this.health_text, 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health)
local health_text = WPT.get('health_text')
rendering.set_text(health_text, 'HP: ' .. locomotive_health .. ' / ' .. locomotive_max_health)
end
local function protect_entities(event)
local this = WPT.get()
local entity = event.entity
if entity.force.index ~= 1 then
@ -243,9 +251,10 @@ local function protect_entities(event)
end
local function exists()
local carriages = WPT.get('carriages')
local t = {}
for i = 1, #this.carriages do
local e = this.carriages[i]
for i = 1, #carriages do
local e = carriages[i]
if not (e and e.valid) then
return
end
@ -586,7 +595,6 @@ local mining_events = {
}
local function on_player_mined_entity(event)
local this = WPT.get()
local entity = event.entity
local player = game.players[event.player_index]
if not player.valid then
@ -605,8 +613,7 @@ local function on_player_mined_entity(event)
end
local d = {
entity = entity,
this = this
entity = entity
}
on_entity_removed(d)
@ -615,8 +622,10 @@ local function on_player_mined_entity(event)
return
end
local mined_scrap = WPT.get('mined_scrap')
if entity.type == 'simple-entity' or entity.type == 'tree' then
this.mined_scrap = this.mined_scrap + 1
WPT.set().mined_scrap = mined_scrap + 1
Mining.on_player_mined_entity(event)
if entity.type == 'tree' then
if random(1, 3) == 1 then
@ -635,7 +644,6 @@ local function on_player_mined_entity(event)
end
local function on_robot_mined_entity(event)
local this = WPT.get()
local entity = event.entity
if not entity.valid then
@ -649,8 +657,7 @@ local function on_robot_mined_entity(event)
end
local d = {
entity = entity,
this = this
entity = entity
}
on_entity_removed(d)
@ -799,7 +806,6 @@ local function on_entity_damaged(event)
end
local function on_player_repaired_entity(event)
local this = WPT.get()
if not event.entity then
return
end
@ -810,7 +816,8 @@ local function on_player_repaired_entity(event)
return
end
local entity = event.entity
if entity == this.locomotive then
local locomotive = WPT.get('locomotive')
if entity == locomotive then
local player = game.players[event.player_index]
local repair_speed = Functions.get_magicka(player)
if repair_speed <= 0 then
@ -824,8 +831,6 @@ local function on_player_repaired_entity(event)
end
local function on_entity_died(event)
local this = WPT.get()
local entity = event.entity
if not entity.valid then
return
@ -838,8 +843,7 @@ local function on_entity_died(event)
end
local d = {
entity = entity,
this = this
entity = entity
}
on_entity_removed(d)
@ -857,11 +861,14 @@ local function on_entity_died(event)
return
end
local biters_killed = WPT.get('biters_killed')
local biters = WPT.get('biters')
if entity.type == 'unit' or entity.type == 'unit-spawner' then
this.biters_killed = this.biters_killed + 1
this.biters.amount = this.biters.amount - 1
if this.biters.amount <= 0 then
this.biters.amount = 0
WPT.set().biters_killed = biters_killed + 1
biters.amount = biters.amount - 1
if biters.amount <= 0 then
biters.amount = 0
end
if Locomotive.is_around_train(entity) then
entity.destroy()
@ -932,15 +939,11 @@ local function on_entity_died(event)
end
function Public.set_scores()
local this = WPT.get()
local loco = this.locomotive
if not loco then
local locomotive = WPT.get('locomotive')
if not (locomotive and locomotive.valid) then
return
end
if not loco.valid then
return
end
local score = floor(loco.position.y * -1)
local score = floor(locomotive.position.y * -1)
for _, player in pairs(game.connected_players) do
if score > Map_score.get_score(player) then
Map_score.set_score(player, score)
@ -959,14 +962,16 @@ function Public.unstuck_player(index)
end
function Public.loco_died()
local this = WPT.get()
local surface = game.surfaces[this.active_surface_index]
local active_surface_index = WPT.get('active_surface_index')
local locomotive = WPT.get('locomotive')
local surface = game.surfaces[active_surface_index]
local wave_defense_table = WD.get_table()
if wave_defense_table.game_lost then
return
end
Public.set_scores()
if not this.locomotive.valid then
if not locomotive.valid then
local this = WPT.get()
if this.announced_message then
return
end
@ -1015,6 +1020,8 @@ function Public.loco_died()
return
end
local this = WPT.get()
this.locomotive_health = 0
this.locomotive.color = {0.49, 0, 255, 1}
rendering.set_text(this.health_text, 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health)
@ -1051,7 +1058,6 @@ function Public.loco_died()
end
local function on_built_entity(event)
local this = WPT.get()
local entity = event.created_entity
if not entity.valid then
return
@ -1063,7 +1069,9 @@ local function on_built_entity(event)
return
end
local upg = this.upgrades
local upgrades = WPT.get('upgrades')
local upg = upgrades
local surface = entity.surface
local built = {
@ -1085,20 +1093,20 @@ local function on_built_entity(event)
if built[entity.name] and entity.force.index == 1 then
if built[entity.name] < limit[entity.name] then
this.upgrades[name].built = built[entity.name] + 1
this.upgrades.unit_number[name][entity] = entity
this.upgrades.showed_text = false
upgrades[name].built = built[entity.name] + 1
upgrades.unit_number[name][entity] = entity
upgrades.showed_text = false
surface.create_entity(
{
name = 'flying-text',
position = entity.position,
text = this.upgrades[name].built .. ' / ' .. limit[entity.name] .. ' ' .. entity.name,
text = upgrades[name].built .. ' / ' .. limit[entity.name] .. ' ' .. entity.name,
color = {r = 0.82, g = 0.11, b = 0.11}
}
)
else
if not this.upgrades.showed_text then
if not upgrades.showed_text then
surface.create_entity(
{
name = 'flying-text',
@ -1108,7 +1116,7 @@ local function on_built_entity(event)
}
)
this.upgrades.showed_text = true
upgrades.showed_text = true
end
local player = game.players[event.player_index]
player.insert({name = entity.name, count = 1})
@ -1118,7 +1126,6 @@ local function on_built_entity(event)
end
local function on_robot_built_entity(event)
local this = WPT.get()
local entity = event.created_entity
if not entity.valid then
return
@ -1130,7 +1137,9 @@ local function on_robot_built_entity(event)
return
end
local upg = this.upgrades
local upgrades = WPT.get('upgrades')
local upg = upgrades
local surface = entity.surface
local built = {
@ -1152,20 +1161,20 @@ local function on_robot_built_entity(event)
if built[entity.name] and entity.force.index == 1 then
if built[entity.name] < limit[entity.name] then
this.upgrades[name].built = built[entity.name] + 1
this.upgrades.unit_number[name][entity] = entity
this.upgrades.showed_text = false
upgrades[name].built = built[entity.name] + 1
upgrades.unit_number[name][entity] = entity
upgrades.showed_text = false
surface.create_entity(
{
name = 'flying-text',
position = entity.position,
text = this.upgrades[name].built .. ' / ' .. limit[entity.name] .. ' ' .. entity.name,
text = upgrades[name].built .. ' / ' .. limit[entity.name] .. ' ' .. entity.name,
color = {r = 0.82, g = 0.11, b = 0.11}
}
)
else
if not this.upgrades.showed_text then
if not upgrades.showed_text then
surface.create_entity(
{
name = 'flying-text',
@ -1175,7 +1184,7 @@ local function on_robot_built_entity(event)
}
)
this.upgrades.showed_text = true
upgrades.showed_text = true
end
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
inventory.insert({name = entity.name, count = 1})

View File

@ -223,6 +223,7 @@ local artillery_target_callback =
name = 'artillery-projectile',
position = position,
target = entity,
force = 'enemy',
speed = 1.5
}
end

View File

@ -313,9 +313,6 @@ local function on_player_changed_surface(event)
end
function Public.update_gui(player)
local rpg_extra = RPG_Settings.get('rpg_extra')
local this = WPT.get()
if not validate_player(player) then
return
end
@ -329,6 +326,13 @@ function Public.update_gui(player)
end
local gui = player.gui.top[main_frame_name]
local rpg_extra = RPG_Settings.get('rpg_extra')
local mined_scrap = WPT.get('mined_scrap')
local biters_killed = WPT.get('biters_killed')
local upgrades = WPT.get('upgrades')
local train_upgrades = WPT.get('train_upgrades')
local chest_limit_outside_upgrades = WPT.get('chest_limit_outside_upgrades')
if rpg_extra.global_pool == 0 then
gui.global_pool.caption = 'XP: 0'
gui.global_pool.tooltip = ({'gui.global_pool_tooltip'})
@ -337,36 +341,33 @@ function Public.update_gui(player)
gui.global_pool.tooltip = ({'gui.global_pool_amount', floor(rpg_extra.global_pool)})
end
gui.scrap_mined.caption = ' [img=entity.tree-01][img=entity.rock-huge]: ' .. format_number(this.mined_scrap, true)
gui.scrap_mined.caption = ' [img=entity.tree-01][img=entity.rock-huge]: ' .. format_number(mined_scrap, true)
gui.scrap_mined.tooltip = ({'gui.amount_harvested'})
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = WPT.get('pickaxe_tier')
local pick_tier = pickaxe_tiers[tier]
local speed =
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100)
local speed = math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100)
gui.pickaxe_tier.caption = ' [img=item.dummy-steel-axe]: ' .. pick_tier .. ' (' .. tier .. ')'
gui.pickaxe_tier.tooltip = ({'gui.current_pickaxe_tier', pick_tier, speed})
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(this.biters_killed, true)
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(biters_killed, true)
gui.biters_killed.tooltip = ({'gui.biters_killed'})
gui.landmine.caption =
' [img=entity.land-mine]: ' ..
format_number(this.upgrades.landmine.built, true) .. ' / ' .. format_number(this.upgrades.landmine.limit, true)
' [img=entity.land-mine]: ' .. format_number(upgrades.landmine.built, true) .. ' / ' .. format_number(upgrades.landmine.limit, true)
gui.landmine.tooltip = ({'gui.land_mine_placed'})
gui.flame_turret.caption =
' [img=entity.flamethrower-turret]: ' ..
format_number(this.upgrades.flame_turret.built, true) ..
' / ' .. format_number(this.upgrades.flame_turret.limit, true)
format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
gui.flame_turret.tooltip = ({'gui.flamethrowers_placed'})
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(this.train_upgrades, true)
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(train_upgrades, true)
gui.train_upgrades.tooltip = ({'gui.train_upgrades'})
gui.chest_upgrades.caption = ' [img=entity.steel-chest]: ' .. format_number(this.chest_limit_outside_upgrades, true)
gui.chest_upgrades.caption = ' [img=entity.steel-chest]: ' .. format_number(chest_limit_outside_upgrades, true)
gui.chest_upgrades.tooltip = ({'gui.chest_placed'})
end

View File

@ -26,13 +26,13 @@ local function decrement(t, k)
end
local function create_player_table(player)
local this = ICT.get()
if not this.trust_system[player.index] then
this.trust_system[player.index] = {
local trust_system = ICT.get('trust_system')
if not trust_system[player.index] then
trust_system[player.index] = {
[player.name] = true
}
end
return this.trust_system[player.index]
return trust_system[player.index]
end
local function remove_main_frame(main_frame)

View File

@ -304,11 +304,13 @@ end
local function property_boost(data)
local xp_floating_text_color = {r = 188, g = 201, b = 63}
local visuals_delay = 1800
local this = data.this
local locomotive_surface = data.locomotive_surface
local aura = this.locomotive_xp_aura
local locomotive_surface = WPT.get('locomotive_surface')
local locomotive_xp_aura = WPT.get('locomotive_xp_aura')
local locomotive = WPT.get('locomotive')
local xp_points = WPT.get('xp_points')
local aura = locomotive_xp_aura
local rpg = data.rpg
local loco = this.locomotive.position
local loco = locomotive.position
local area = {
left_top = {x = loco.x - aura, y = loco.y - aura},
right_bottom = {x = loco.x + aura, y = loco.y + aura}
@ -322,7 +324,7 @@ local function property_boost(data)
if Math2D.bounding_box.contains_point(area, player.position) or player.surface.index == locomotive_surface.index then
Public.add_player_to_permission_group(player, 'locomotive')
local pos = player.position
Functions.gain_xp(player, 0.5 * (rpg[player.index].bonus + this.xp_points))
Functions.gain_xp(player, 0.5 * (rpg[player.index].bonus + xp_points))
player.create_local_flying_text {
text = '+' .. '',
@ -364,36 +366,30 @@ local function is_around_train(data)
end
local function fish_tag()
local this = WPT.get()
if not this.locomotive_cargo then
local locomotive_cargo = WPT.get('locomotive_cargo')
if not (locomotive_cargo and locomotive_cargo.valid) then
return
end
if not this.locomotive_cargo.valid then
if not (locomotive_cargo.surface and locomotive_cargo.surface.valid) then
return
end
if not this.locomotive_cargo.surface then
return
end
if not this.locomotive_cargo.surface.valid then
return
end
if this.locomotive_tag then
if this.locomotive_tag.valid then
if
this.locomotive_tag.position.x == this.locomotive_cargo.position.x and
this.locomotive_tag.position.y == this.locomotive_cargo.position.y
then
local locomotive_tag = WPT.get('locomotive_tag')
if locomotive_tag then
if locomotive_tag.valid then
if locomotive_tag.position.x == locomotive_cargo.position.x and locomotive_tag.position.y == locomotive_cargo.position.y then
return
end
this.locomotive_tag.destroy()
locomotive_tag.destroy()
end
end
this.locomotive_tag =
this.locomotive_cargo.force.add_chart_tag(
this.locomotive_cargo.surface,
WPT.set().locomotive_tag =
locomotive_cargo.force.add_chart_tag(
locomotive_cargo.surface,
{
icon = {type = 'item', name = 'raw-fish'},
position = this.locomotive_cargo.position,
position = locomotive_cargo.position,
text = ' '
}
)
@ -427,14 +423,17 @@ local function refill_fish()
end
local function set_locomotive_health()
local this = WPT.get()
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local locomotive = WPT.get('locomotive')
local function check_health()
local m = this.locomotive_health / this.locomotive_max_health
this.carriages = this.locomotive.train.carriages
if this.carriages then
for i = 1, #this.carriages do
local entity = this.carriages[i]
local m = locomotive_health / locomotive_max_health
WPT.set().carriages = locomotive.train.carriages
local carriages = WPT.get('carriages')
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
if not (entity and entity.valid) then
return
end
@ -447,7 +446,7 @@ local function set_locomotive_health()
end
end
if not (this.locomotive and this.locomotive.valid) then
if not (locomotive and locomotive.valid) then
return
end
@ -701,10 +700,10 @@ end
local function slider_changed(event)
local player = game.players[event.player_index]
local this = WPT.get()
local players = WPT.get('players')
local slider_value
slider_value = this.players
slider_value = players
if not slider_value then
return
end
@ -721,8 +720,8 @@ local function slider_changed(event)
return
end
slider_value = ceil(slider_value)
this.players[player.index].data.text_input.text = slider_value
redraw_market_items(this.players[player.index].data.item_frame, player, this.players[player.index].data.search_text)
players[player.index].data.text_input.text = slider_value
redraw_market_items(players[player.index].data.item_frame, player, players[player.index].data.search_text)
end
local function text_changed(event)
@ -734,10 +733,10 @@ local function text_changed(event)
return
end
local this = WPT.get()
local players = WPT.get('players')
local player = game.players[event.player_index]
local data = this.players[player.index].data
local data = players[player.index].data
if not data then
return
end
@ -770,7 +769,7 @@ local function text_changed(event)
end
local function gui_opened(event)
local this = WPT.get()
local market = WPT.get('market')
if not event.gui_type == defines.gui_type.entity then
return
@ -781,7 +780,7 @@ local function gui_opened(event)
return
end
if entity ~= this.market then
if entity ~= market then
return
end
@ -794,11 +793,13 @@ local function gui_opened(event)
local inventory = player.get_main_inventory()
local player_item_count = inventory.get_item_count('coin')
if not this.players[player.index].data then
this.players[player.index].data = {}
local players = WPT.get('players')
if not players[player.index].data then
players[player.index].data = {}
end
local data = this.players[player.index].data
local data = players[player.index].data
if data.frame then
data.frame = nil
@ -878,18 +879,18 @@ local function gui_opened(event)
}
)
this.players[player.index].data.search_text = search_text
this.players[player.index].data.text_input = text_input
this.players[player.index].data.slider = slider
this.players[player.index].data.frame = frame
this.players[player.index].data.item_frame = pane
this.players[player.index].data.coins_left = coinsleft
players[player.index].data.search_text = search_text
players[player.index].data.text_input = text_input
players[player.index].data.slider = slider
players[player.index].data.frame = frame
players[player.index].data.item_frame = pane
players[player.index].data.coins_left = coinsleft
redraw_market_items(pane, player, search_text)
end
local function gui_click(event)
local this = WPT.get()
local players = WPT.get('players')
local element = event.element
local player = game.players[event.player_index]
@ -897,11 +898,11 @@ local function gui_click(event)
return
end
if not this.players[player.index] then
if not players[player.index] then
return
end
local data = this.players[player.index].data
local data = players[player.index].data
if not data then
return
end
@ -953,6 +954,8 @@ local function gui_click(event)
return
end
local this = WPT.get()
if name == 'upgrade_pickaxe' then
player.remove_item({name = item.value, count = item.price})
@ -1240,12 +1243,12 @@ end
local function gui_closed(event)
local player = game.players[event.player_index]
local this = WPT.get()
local players = WPT.get('players')
local type = event.gui_type
if type == defines.gui_type.custom then
local data = this.players[player.index].data
local data = players[player.index].data
if not data then
return
end
@ -1254,19 +1257,21 @@ local function gui_closed(event)
end
local function on_player_changed_position(event)
local this = WPT.get()
local players = WPT.get('players')
local player = game.players[event.player_index]
if not this.players[player.index] then
if not players[player.index] then
return
end
local data = this.players[player.index].data
local data = players[player.index].data
if not this.market or not this.market.valid then
local market = WPT.get('market')
if not (market and market.valid) then
return
end
if data and data.frame and data.frame.valid then
local position = this.market.position
local position = market.position
local area = {
left_top = {x = position.x - 10, y = position.y - 10},
right_bottom = {x = position.x + 10, y = position.y + 10}
@ -1724,23 +1729,20 @@ end
function Public.boost_players_around_train()
local rpg = RPG_Settings.get('rpg_t')
local this = WPT.get()
if not this.active_surface_index then
local active_surface_index = WPT.get('active_surface_index')
if not active_surface_index then
return
end
if not this.locomotive then
local locomotive = WPT.get('locomotive')
if not (locomotive and locomotive.valid) then
return
end
if not this.locomotive.valid then
return
end
local surface = game.surfaces[this.active_surface_index]
local surface = game.surfaces[active_surface_index]
local icw_table = ICW.get_table()
local unit_surface = this.locomotive.unit_number
local unit_surface = locomotive.unit_number
local locomotive_surface = game.surfaces[icw_table.wagons[unit_surface].surface.index]
local data = {
this = this,
surface = surface,
locomotive_surface = locomotive_surface,
rpg = rpg
@ -1781,49 +1783,54 @@ function Public.is_around_train(entity)
end
function Public.render_train_hp()
local this = WPT.get()
local surface = game.surfaces[this.active_surface_index]
local active_surface_index = WPT.get('active_surface_index')
local surface = game.surfaces[active_surface_index]
this.health_text =
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local locomotive = WPT.get('locomotive')
local locomotive_xp_aura = WPT.get('locomotive_xp_aura')
WPT.set().health_text =
rendering.draw_text {
text = 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health,
text = 'HP: ' .. locomotive_health .. ' / ' .. locomotive_max_health,
surface = surface,
target = this.locomotive,
target = locomotive,
target_offset = {0, -4.5},
color = this.locomotive.color,
color = locomotive.color,
scale = 1.40,
font = 'default-game',
alignment = 'center',
scale_with_zoom = false
}
this.caption =
WPT.set().caption =
rendering.draw_text {
text = 'Comfy Choo Choo',
surface = surface,
target = this.locomotive,
target = locomotive,
target_offset = {0, -6.25},
color = this.locomotive.color,
color = locomotive.color,
scale = 1.80,
font = 'default-game',
alignment = 'center',
scale_with_zoom = false
}
this.circle =
WPT.set().circle =
rendering.draw_circle {
surface = surface,
target = this.locomotive,
color = this.locomotive.color,
target = locomotive,
color = locomotive.color,
filled = false,
radius = this.locomotive_xp_aura,
radius = locomotive_xp_aura,
only_in_alt_mode = true
}
end
function Public.locomotive_spawn(surface, position)
local this = WPT.get()
for y = -6, 14, 2 do
for y = -6, 6, 2 do
surface.create_entity({name = 'straight-rail', position = {position.x, position.y + y}, force = 'player', direction = 0})
end
this.locomotive = surface.create_entity({name = 'locomotive', position = {position.x, position.y + -3}, force = 'player'})

View File

@ -70,16 +70,16 @@ local collapse_kill = {
}
local function get_player_data(player, remove_user_data)
local this = WPT.get()
local players = WPT.get('players')
if remove_user_data then
if this.players[player.index] then
this.players[player.index] = nil
if players[player.index] then
players[player.index] = nil
end
end
if not this.players[player.index] then
this.players[player.index] = {}
if not players[player.index] then
players[player.index] = {}
end
return this.players[player.index]
return players[player.index]
end
local disable_recipes = function()
@ -400,7 +400,10 @@ function Public.reset_map()
end
local on_player_changed_position = function(event)
local this = WPT.get()
local active_surface_index = WPT.get('active_surface_index')
if not active_surface_index then
return
end
local player = game.players[event.player_index]
local map_name = 'mountain_fortress_v3'
@ -409,7 +412,7 @@ local on_player_changed_position = function(event)
end
local position = player.position
local surface = game.surfaces[this.active_surface_index]
local surface = game.surfaces[active_surface_index]
local p = {x = player.position.x, y = player.position.y}
local get_tile = surface.get_tile(p)
@ -445,9 +448,9 @@ local on_player_changed_position = function(event)
end
local on_player_joined_game = function(event)
local this = WPT.get()
local active_surface_index = WPT.get('active_surface_index')
local player = game.players[event.player_index]
local surface = game.surfaces[this.active_surface_index]
local surface = game.surfaces[active_surface_index]
set_difficulty()
@ -464,7 +467,7 @@ local on_player_joined_game = function(event)
player_data.first_join = true
end
if player.surface.index ~= this.active_surface_index then
if player.surface.index ~= active_surface_index then
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
else
local p = {x = player.position.x, y = player.position.y}
@ -477,10 +480,12 @@ local on_player_joined_game = function(event)
end
end
if not this.locomotive or not this.locomotive.valid then
local locomotive = WPT.get('locomotive')
if not locomotive or not locomotive.valid then
return
end
if player.position.y > this.locomotive.position.y then
if player.position.y > locomotive.position.y then
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
end
end
@ -512,7 +517,6 @@ end
local on_research_finished = function(event)
disable_tech()
local research = event.research
local this = WPT.get()
research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots /
@ -526,16 +530,17 @@ local on_research_finished = function(event)
if not force_name then
return
end
this.flamethrower_damage[force_name] = -0.85
local flamethrower_damage = WPT.get('flamethrower_damage')
flamethrower_damage[force_name] = -0.85
if research.name == 'military' then
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', this.flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier('flamethrower', this.flamethrower_damage[force_name])
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
end
if string.sub(research.name, 0, 18) == 'refined-flammables' then
this.flamethrower_damage[force_name] = this.flamethrower_damage[force_name] + 0.10
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', this.flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier('flamethrower', this.flamethrower_damage[force_name])
flamethrower_damage[force_name] = flamethrower_damage[force_name] + 0.10
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
end
end
@ -563,12 +568,14 @@ local is_player_valid = function()
end
local has_the_game_ended = function()
local this = WPT.get()
if this.game_reset_tick then
if this.game_reset_tick < 0 then
local game_reset_tick = WPT.get('game_reset_tick')
if game_reset_tick then
if game_reset_tick < 0 then
return
end
local this = WPT.get('this')
this.game_reset_tick = this.game_reset_tick - 30
if this.game_reset_tick % 1800 == 0 then
if this.game_reset_tick > 0 then
@ -618,15 +625,17 @@ local boost_difficulty = function()
return
end
local breached_wall = WPT.get('breached_wall')
local difficulty = Difficulty.get()
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
if game.tick < difficulty.difficulty_poll_closing_timeout then
if game.tick < difficulty.difficulty_poll_closing_timeout and breached_wall <= 1 then
return
end
local rpg_extra = RPG_Settings.get('rpg_extra')
Difficulty.get().name = name
Difficulty.get().difficulty_poll_closing_timeout = game.tick
Difficulty.get().button_tooltip = difficulty.tooltip[difficulty.difficulty_vote_index]
Difficulty.difficulty_gui()
@ -640,37 +649,37 @@ local boost_difficulty = function()
local force = game.forces.player
if name == "I'm too young to die" then
rpg_extra.difficulty = 1
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 1
force.character_running_speed_modifier = 0.2
force.manual_crafting_speed_modifier = 0.3
WPT.set().coin_amount = 2
WPT.set('upgrades').flame_turret.limit = 25
WPT.set('upgrades').landmine.limit = 100
WPT.set().locomotive_health = 15000
WPT.set().locomotive_max_health = 15000
WPT.set().bonus_xp_on_join = 700
WD.set().next_wave = game.tick + 3600 * 20
WPT.set().spidertron_unlocked_at_wave = 11
WPT.set().difficulty_set = true
WD.set_biter_health_boost(1.35)
elseif name == 'Hurt me plenty' then
rpg_extra.difficulty = 0.5
-- rpg_extra.difficulty = 1
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
force.character_running_speed_modifier = 0.15
force.manual_crafting_speed_modifier = 0.15
WPT.set().coin_amount = 1
WPT.set('upgrades').flame_turret.limit = 12
WPT.set('upgrades').landmine.limit = 50
WPT.set().locomotive_health = 10000
WPT.set().locomotive_max_health = 10000
WPT.set().bonus_xp_on_join = 500
WD.set().next_wave = game.tick + 3600 * 15
WPT.set().spidertron_unlocked_at_wave = 14
WPT.set().difficulty_set = true
WD.set_biter_health_boost(1.50)
elseif name == 'Hurt me plenty' then
-- rpg_extra.difficulty = 0.5
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
force.character_running_speed_modifier = 0.1
force.manual_crafting_speed_modifier = 0.1
WPT.set().coin_amount = 1
WPT.set('upgrades').flame_turret.limit = 10
WPT.set('upgrades').landmine.limit = 50
WPT.set().locomotive_health = 10000
WPT.set().locomotive_max_health = 10000
WPT.set().locomotive_health = 7000
WPT.set().locomotive_max_health = 7000
WPT.set().bonus_xp_on_join = 300
WD.set().next_wave = game.tick + 3600 * 15
WD.set().next_wave = game.tick + 3600 * 10
WPT.set().spidertron_unlocked_at_wave = 16
WPT.set().difficulty_set = true
WD.set_biter_health_boost(1.75)
WD.set_biter_health_boost(2)
elseif name == 'Ultra-violence' then
rpg_extra.difficulty = 0
-- rpg_extra.difficulty = 0
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
WPT.set().coin_amount = 1
@ -679,12 +688,12 @@ local boost_difficulty = function()
WPT.set().locomotive_health = 5000
WPT.set().locomotive_max_health = 5000
WPT.set().bonus_xp_on_join = 50
WD.set().next_wave = game.tick + 3600 * 10
WPT.set().spidertron_unlocked_at_wave = 21
WD.set().next_wave = game.tick + 3600 * 5
WPT.set().spidertron_unlocked_at_wave = 18
WPT.set().difficulty_set = true
WD.set_biter_health_boost(2.25)
WD.set_biter_health_boost(3)
elseif name == 'Nightmare' then
rpg_extra.difficulty = 0
-- rpg_extra.difficulty = 0
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
WPT.set().coin_amount = 1
@ -693,10 +702,10 @@ local boost_difficulty = function()
WPT.set().locomotive_health = 1000
WPT.set().locomotive_max_health = 1000
WPT.set().bonus_xp_on_join = 0
WD.set().next_wave = game.tick + 3600 * 5
WPT.set().spidertron_unlocked_at_wave = 26
WD.set().next_wave = game.tick + 3600 * 2
WPT.set().spidertron_unlocked_at_wave = 22
WPT.set().difficulty_set = true
WD.set_biter_health_boost(3.5)
WD.set_biter_health_boost(4)
end
end
@ -790,7 +799,6 @@ local on_tick = function()
for _, player in pairs(game.connected_players) do
update_gui(player)
end
is_player_valid()
is_locomotive_valid()
has_the_game_ended()
@ -799,10 +807,10 @@ local on_tick = function()
if tick % 250 == 0 then
compare_collapse_and_train()
boost_difficulty()
end
if tick % 1200 == 0 then
boost_difficulty()
if tick % 1000 == 0 then
collapse_after_wave_100()
Entities.set_scores()
set_difficulty()
@ -811,7 +819,7 @@ local on_tick = function()
local collapse_pos = Collapse.get_position()
local position = surface.find_non_colliding_position('rocket-silo', collapse_pos, 128, 1)
if position then
WD.set_spawn_position(position)
WD.set_spawn_position({position.x, position.y - 50})
end
end
end
@ -822,10 +830,10 @@ local on_init = function()
Public.reset_map()
local tooltip = {
[1] = ({'main.diff_tooltip', '1', '1.5', '0.2', '0.4', '2', '25', '100', '15000', '100%', '20', '10'}),
[2] = ({'main.diff_tooltip', '0.5', '1', '0.1', '0.2', '1', '10', '50', '10000', '75%', '15', '15'}),
[3] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '3', '10', '5000', '50%', '10', '20'}),
[4] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '0', '0', '1000', '25%', '5', '25'})
[1] = ({'main.diff_tooltip', '0', '0.5', '0.2', '0.4', '1', '12', '50', '10000', '100%', '15', '14'}),
[2] = ({'main.diff_tooltip', '0', '0.25', '0.1', '0.1', '1', '10', '50', '7000', '75%', '10', '16'}),
[3] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '3', '10', '5000', '50%', '10', '18'}),
[4] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '0', '0', '1000', '25%', '5', '22'})
}
Difficulty.set_tooltip(tooltip)

View File

@ -217,7 +217,10 @@ local size_of_scrap_raffle = #scrap_raffle
local function get_amount(data)
local entity = data.entity
local this = data.this
local t_modifier = WPT.get('type_modifier')
local rocks_yield_ore_distance_modifier = WPT.get('rocks_yield_ore_distance_modifier')
local rocks_yield_ore_base_amount = WPT.get('rocks_yield_ore_base_amount')
local rocks_yield_ore_maximum_amount = WPT.get('rocks_yield_ore_maximum_amount')
local distance_to_center = floor(sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
local type_modifier = 1
local amount
@ -227,18 +230,18 @@ local function get_amount(data)
local base_amount = 25
local second_base_amount = 10
local maximum_amount = 100
if this.type_modifier then
type_modifier = this.type_modifier
if t_modifier then
type_modifier = t_modifier
end
if this.rocks_yield_ore_distance_modifier then
distance_modifier = this.rocks_yield_ore_distance_modifier
if rocks_yield_ore_distance_modifier then
distance_modifier = rocks_yield_ore_distance_modifier
end
if this.rocks_yield_ore_base_amount then
base_amount = this.rocks_yield_ore_base_amount
if rocks_yield_ore_base_amount then
base_amount = rocks_yield_ore_base_amount
end
if this.rocks_yield_ore_maximum_amount then
maximum_amount = this.rocks_yield_ore_maximum_amount
if rocks_yield_ore_maximum_amount then
maximum_amount = rocks_yield_ore_maximum_amount
end
type_modifier = rock_yield[entity.name] or type_modifier
@ -280,7 +283,7 @@ end
local function randomness(data)
local entity = data.entity
local player = data.player
local this = data.this
local spill_items_to_surface = WPT.get('spill_items_to_surface')
local harvest
local harvest_amount
@ -316,7 +319,7 @@ local function randomness(data)
)
if harvest_amount > max_spill then
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true)
else
player.insert({name = harvest, count = max_spill})
@ -325,14 +328,14 @@ local function randomness(data)
local inserted_count = player.insert({name = harvest, count = harvest_amount})
harvest_amount = harvest_amount - inserted_count
if harvest_amount > 0 then
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
else
player.insert({name = harvest, count = harvest_amount})
end
end
else
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
else
player.insert({name = harvest, count = harvest_amount})
@ -345,11 +348,10 @@ end
local function randomness_scrap(data)
local entity = data.entity
local player = data.player
local this = data.this
local spill_items_to_surface = WPT.get('spill_items_to_surface')
local harvest = scrap_raffle[random(1, size_of_scrap_raffle)]
local amount_bonus =
(game.forces.enemy.evolution_factor * 2) + (game.forces.player.mining_drill_productivity_bonus * 2)
local amount_bonus = (game.forces.enemy.evolution_factor * 2) + (game.forces.player.mining_drill_productivity_bonus * 2)
local r1 = math.ceil(scrap_yield_amounts[harvest] * (0.3 + (amount_bonus * 0.3)))
local r2 = math.ceil(scrap_yield_amounts[harvest] * (1.7 + (amount_bonus * 1.7)))
local harvest_amount = math.random(r1, r2)
@ -366,7 +368,7 @@ local function randomness_scrap(data)
)
if harvest_amount > max_spill then
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true)
else
player.insert({name = harvest, count = max_spill})
@ -375,14 +377,14 @@ local function randomness_scrap(data)
local inserted_count = player.insert({name = harvest, count = harvest_amount})
harvest_amount = harvest_amount - inserted_count
if harvest_amount > 0 then
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
else
player.insert({name = harvest, count = harvest_amount})
end
end
else
if this.spill_items_to_surface then
if spill_items_to_surface then
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
else
player.insert({name = harvest, count = harvest_amount})
@ -403,22 +405,19 @@ function Public.on_player_mined_entity(event)
return
end
local this = WPT.get()
if valid_rocks[entity.name] or valid_trees[entity.name] then
event.buffer.clear()
local data = {
this = this,
entity = entity,
player = player
}
if this.breached_wall == 6 then
randomness_scrap(data)
else
randomness(data)
end
-- if this.breached_wall == 6 then
-- randomness_scrap(data)
-- else
randomness(data)
-- end
end
end

View File

@ -154,7 +154,7 @@ function Public.reset_table()
this.placed_trains_in_zone = {
placed = 0,
positions = {},
limit = 3,
limit = 2,
randomized = false
}
this.marked_fixed_prices = {

View File

@ -139,7 +139,7 @@ end
local function place_wagon(data)
local placed_trains_in_zone = WPT.get('placed_trains_in_zone')
if not placed_trains_in_zone.randomized then
placed_trains_in_zone.limit = random(1, 3)
placed_trains_in_zone.limit = random(1, 2)
placed_trains_in_zone.randomized = true
placed_trains_in_zone = WPT.get('placed_trains_in_zone')
end
@ -178,12 +178,10 @@ local function place_wagon(data)
local r2 = random(2, 4) * 2
if random(1, 2) == 1 then
location =
surface.find_tiles_filtered({area = {{position.x, position.y - r1}, {position.x + 2, position.y + r2}}})
location = surface.find_tiles_filtered({area = {{position.x, position.y - r1}, {position.x + 2, position.y + r2}}})
direction = 0
else
location =
surface.find_tiles_filtered({area = {{position.x - r1, position.y}, {position.x + r2, position.y + 2}}})
location = surface.find_tiles_filtered({area = {{position.x - r1, position.y}, {position.x + r2, position.y + 2}}})
direction = 2
end
@ -1155,10 +1153,20 @@ local function process_level_6_position(x, y, data, void_or_lab)
end
--Resource Spots
if smol_areas < -0.72 then
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
local noise_forest_location = get_perlin('forest_location', p, seed)
if cave_rivers > -0.1 and cave_rivers < 0.1 then
@ -1272,10 +1280,20 @@ local function process_level_5_position(x, y, data, void_or_lab)
end
--Resource Spots
if smol_areas < -0.72 then
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
if small_caves > -0.40 and small_caves < 0.40 then
@ -1390,10 +1408,20 @@ local function process_level_4_position(x, y, data, void_or_lab)
end
--Resource Spots
if smol_areas < -0.72 then
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
if noise_large_caves > -0.2 and noise_large_caves < 0.2 then
@ -1436,10 +1464,20 @@ local function process_level_3_position(x, y, data, void_or_lab)
local smol_areas = get_perlin('smol_areas', p, seed + 60000)
--Resource Spots
if smol_areas < -0.72 then
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
--Market Spots
@ -1581,10 +1619,20 @@ local function process_level_2_position(x, y, data, void_or_lab)
local smol_areas = get_perlin('smol_areas', p, seed + 15000)
--Resource Spots
if smol_areas < -0.72 then
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
if noise_large_caves > -0.75 and noise_large_caves < 0.75 then
@ -1711,10 +1759,20 @@ local function process_level_1_2_position(x, y, data, void_or_lab)
local smol_areas = get_perlin('smol_areas', p, seed + 33333)
--Resource Spots
if smol_areas < -0.71 then
-- if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
-- end
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'enemy'
}
end
return
end
--Chasms
@ -2260,8 +2318,7 @@ local function biter_chunk(data)
}
if random(1, 128) == 1 then
local position =
surface.find_non_colliding_position('biter-spawner', tile_positions[random(1, #tile_positions)], 16, 2)
local position = surface.find_non_colliding_position('biter-spawner', tile_positions[random(1, #tile_positions)], 16, 2)
if position then
entities[#entities + 1] = {
name = spawner_raffle[random(1, #spawner_raffle)],
@ -2273,8 +2330,7 @@ local function biter_chunk(data)
end
if random(1, 128) == 1 then
local position =
surface.find_non_colliding_position('big-worm-turret', tile_positions[random(1, #tile_positions)], 16, 2)
local position = surface.find_non_colliding_position('big-worm-turret', tile_positions[random(1, #tile_positions)], 16, 2)
if position then
entities[#entities + 1] = {
name = 'big-worm-turret',
@ -2363,9 +2419,7 @@ Event.add(
if left_top.y == -128 and left_top.x == -128 then
local pl = WPT.get().locomotive.position
for _, entity in pairs(
surface.find_entities_filtered(
{area = {{pl.x - 5, pl.y - 6}, {pl.x + 5, pl.y + 10}}, type = 'simple-entity'}
)
surface.find_entities_filtered({area = {{pl.x - 5, pl.y - 6}, {pl.x + 5, pl.y + 10}}, type = 'simple-entity'})
) do
entity.destroy()
end

View File

@ -495,8 +495,7 @@ local function on_entity_damaged(event)
event.cause.health = event.cause.health + Functions.get_life_on_hit(event.cause.player)
--Calculate modified damage.
local damage =
event.original_damage_amount + event.original_damage_amount * Functions.get_melee_modifier(event.cause.player)
local damage = event.original_damage_amount + event.original_damage_amount * Functions.get_melee_modifier(event.cause.player)
if event.entity.prototype.resistances then
if event.entity.prototype.resistances.physical then
damage = damage - event.entity.prototype.resistances.physical.decrease
@ -746,18 +745,18 @@ local function on_player_crafted_item(event)
end
local rpg_extra = RPG.get('rpg_extra')
local is_blacklisted = rpg_extra.blacklisted_crafting_items
local is_blacklisted = rpg_extra.tweaked_crafting_items
local item = event.item_stack
local amount = 0.30 * math.random(1, 2)
if item and item.valid then
if is_blacklisted[item.name] then
return
amount = 0.2
end
end
local amount = 0.30 * math.random(1, 2)
Functions.gain_xp(player, event.recipe.energy * amount)
Functions.reward_mana(player, amount)
end
@ -867,9 +866,7 @@ local function floaty_hearts(entity, c)
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
}
entity.surface.create_entity(
{name = 'flying-text', position = p, text = '', color = {math.random(150, 255), 0, 255}}
)
entity.surface.create_entity({name = 'flying-text', position = p, text = '', color = {math.random(150, 255), 0, 255}})
end
end
@ -1007,10 +1004,7 @@ local function on_player_used_capsule(event)
p(({'rpg_main.suicidal_comfylatron', object_name}), Color.success)
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost
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
player.character.health = 10
player.character.surface.create_entity({name = 'water-splash', position = player.position})

View File

@ -158,7 +158,7 @@ function Public.conjure_items()
level = 100,
biter = true,
type = 'entity',
mana_cost = 600,
mana_cost = 800,
tick = 1420,
enabled = true
}
@ -171,7 +171,7 @@ function Public.conjure_items()
force = 'player',
level = 30,
type = 'special',
mana_cost = 100,
mana_cost = 110,
tick = 150,
enabled = true
}
@ -226,7 +226,7 @@ function Public.conjure_items()
force = 'player',
level = 50,
type = 'special',
mana_cost = 66,
mana_cost = 75,
tick = 200,
enabled = true
}
@ -240,7 +240,7 @@ function Public.conjure_items()
force = 'player',
level = 50,
type = 'special',
mana_cost = 120,
mana_cost = 140,
tick = 320,
enabled = true
}
@ -268,7 +268,7 @@ function Public.conjure_items()
force = 'player',
level = 50,
type = 'special',
mana_cost = 300,
mana_cost = 340,
tick = 320,
enabled = true
}
@ -279,7 +279,7 @@ function Public.conjure_items()
force = 'player',
level = 60,
type = 'special',
mana_cost = 300,
mana_cost = 340,
tick = 2000,
enabled = true
}

View File

@ -31,8 +31,7 @@ Public.points_per_level = 5
Public.experience_levels = {0}
for a = 1, 9999, 1 do
Public.experience_levels[#Public.experience_levels + 1] =
Public.experience_levels[#Public.experience_levels] + a * 8
Public.experience_levels[#Public.experience_levels + 1] = Public.experience_levels[#Public.experience_levels] + a * 8
end
Public.die_cause = {
@ -89,7 +88,7 @@ function Public.reset_table()
this.rpg_extra.enable_auto_allocate = false
this.rpg_extra.enable_one_punch = true
this.rpg_extra.enable_one_punch_globally = false
this.rpg_extra.blacklisted_crafting_items = {
this.rpg_extra.tweaked_crafting_items = {
['red-wire'] = true,
['green-wire'] = true,
['stone-furnace'] = true,
@ -395,8 +394,7 @@ function Public.disable_cooldowns_on_spells()
return new_spells
end
--- This will disable the cooldown of all spells.
function Public.blacklisted_crafting_items(tbl)
function Public.tweaked_crafting_items(tbl)
if not tbl then
return
end
@ -405,9 +403,9 @@ function Public.blacklisted_crafting_items(tbl)
return
end
this.blacklisted_crafting_items = tbl
this.tweaked_crafting_items = tbl
return this.blacklisted_crafting_items
return this.tweaked_crafting_items
end
Public.get_projectiles = Spells.projectile_types

View File

@ -76,9 +76,12 @@ function Public.get(key)
end
end
function Public.set(key)
function Public.set(key, value)
if key then
return this[key]
elseif key and value then
this[key] = value
return this[key]
else
return this
end

View File

@ -96,21 +96,15 @@ local get_player_data = function(player, remove)
end
local get_gulag_permission_group = function()
if not game.permissions.get_group('gulag') then
local gulag = game.permissions.create_group('gulag')
gulag.set_allows_action(defines.input_action.cancel_craft, false)
gulag.set_allows_action(defines.input_action.edit_permission_group, false)
gulag.set_allows_action(defines.input_action.import_permissions_string, false)
gulag.set_allows_action(defines.input_action.delete_permission_group, false)
gulag.set_allows_action(defines.input_action.add_permission_group, false)
gulag.set_allows_action(defines.input_action.admin_action, false)
gulag.set_allows_action(defines.input_action.gui_click, false)
gulag.set_allows_action(defines.input_action.drop_item, false)
gulag.set_allows_action(defines.input_action.place_equipment, false)
gulag.set_allows_action(defines.input_action.take_equipment, false)
gulag.set_allows_action(defines.input_action.open_technology_gui, false)
end
local gulag = game.permissions.get_group('gulag')
if not gulag then
gulag = game.permissions.create_group('gulag')
for action_name, _ in pairs(defines.input_action) do
gulag.set_allows_action(defines.input_action[action_name], false)
end
gulag.set_allows_action(defines.input_action.write_to_console, true)
end
return gulag
end
@ -315,8 +309,7 @@ local vote_to_jail = function(player, griefer, msg)
Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.')
if
votejail[griefer].index >= settings.votejail_count or
(votejail[griefer].index == #game.connected_players - 1 and
#game.connected_players > votejail[griefer].index)
(votejail[griefer].index == #game.connected_players - 1 and #game.connected_players > votejail[griefer].index)
then
Public.try_ul_data(griefer, true, votejail[griefer].actor, msg)
end
@ -338,8 +331,7 @@ local vote_to_free = function(player, griefer)
Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.')
if
votefree[griefer].index >= settings.votejail_count or
(votefree[griefer].index == #game.connected_players - 1 and
#game.connected_players > votefree[griefer].index)
(votefree[griefer].index == #game.connected_players - 1 and #game.connected_players > votefree[griefer].index)
then
Public.try_ul_data(griefer, false, votefree[griefer].actor)
votejail[griefer] = nil
@ -374,10 +366,7 @@ local jail = function(player, griefer, msg)
end
local message = griefer .. ' has been jailed by ' .. player .. '. Cause: ' .. msg
if
game.players[griefer].character and game.players[griefer].character.valid and
game.players[griefer].character.driving
then
if game.players[griefer].character and game.players[griefer].character.valid and game.players[griefer].character.driving then
game.players[griefer].character.driving = false
end
@ -571,10 +560,7 @@ Event.add(
griefer = game.players[griefer].name
end
if
trusted and playtime >= settings.playtime_for_vote and playtime < settings.playtime_for_instant_jail and
not player.admin
then
if trusted and playtime >= settings.playtime_for_vote and playtime < settings.playtime_for_instant_jail and not player.admin then
if cmd == 'jail' then
vote_to_jail(player, griefer, message)
return
@ -649,4 +635,6 @@ function Public.required_playtime_for_vote(value)
return settings.playtime_for_vote
end
Event.on_init(get_gulag_permission_group)
return Public

View File

@ -437,11 +437,7 @@ function Public.try_get_data_timeout(data_set, key, callback_token, timeout_tick
try_get_data_cancelable(data_set, key, callback_token)
Task.set_timeout_in_ticks(
timeout_ticks,
timeout_token,
{data_set = data_set, key = key, callback_token = callback_token}
)
Task.set_timeout_in_ticks(timeout_ticks, timeout_token, {data_set = data_set, key = key, callback_token = callback_token})
end
--- Gets all the data for the data_set from the web server's persistent data storage.
@ -817,6 +813,41 @@ Event.add(
end
)
Event.add(
defines.events.on_console_command,
function(event)
local cmd = event.command
if not event.player_index then
return
end
local player = game.players[event.player_index]
local reason = event.parameters
if not reason then
return
end
if not player.admin then
return
end
if cmd == 'ban' then
if player then
Public.to_banned_embed(table.concat {player.name .. ' banned ' .. reason})
return
else
Public.to_banned_embed(table.concat {'Server banned ' .. reason})
return
end
elseif cmd == 'unban' then
if player then
Public.to_banned_embed(table.concat {player.name .. ' unbanned ' .. reason})
return
else
Public.to_banned_embed(table.concat {'Server unbanned ' .. reason})
return
end
end
end
)
Event.add(
defines.events.on_player_died,
function(event)