1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

Merge pull request #128 from ComfyFactory/mtn_v3

Mtn v3 - tweaks
This commit is contained in:
Gerkiz 2021-10-10 22:37:44 +02:00 committed by GitHub
commit 0a0721400b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 61 deletions

View File

@ -288,9 +288,12 @@ local function set_train_final_health(final_damage_amount, repair)
rendering.set_text(health_text, 'HP: ' .. round(locomotive_health) .. ' / ' .. round(locomotive_max_health))
end
local function protect_entities(event)
local entity = event.entity
local dmg = event.final_damage_amount
local function protect_entities(data)
local cause = data.cause
local entity = data.entity
local force = data.force
local dmg = data.final_damage_amount
if not dmg then
return
end
@ -321,8 +324,8 @@ local function protect_entities(event)
local carriages_numbers = WPT.get('carriages_numbers')
if is_protected(entity) then
if (event.cause and event.cause.valid) then
if event.cause.force.index == 2 then
if (cause and cause.valid) then
if cause.force.index == 2 then
if carriages_numbers and carriages_numbers[entity.unit_number] then
set_train_final_health(dmg, false)
return
@ -331,8 +334,8 @@ local function protect_entities(event)
return
end
end
elseif not (event.cause and event.cause.valid) then
if event.force and event.force.index == 2 then
elseif not (cause and cause.valid) then
if force and force.index == 2 then
if carriages_numbers and carriages_numbers[entity.unit_number] then
set_train_final_health(dmg, false)
return
@ -362,21 +365,25 @@ local function hidden_treasure(player, entity)
Loot.add(entity.surface, entity.position, chests[random(1, size_chests)])
end
local function biters_chew_rocks_faster(event)
if event.entity.force.index ~= 3 then
local function biters_chew_rocks_faster(data)
local cause = data.cause
local entity = data.entity
local final_damage_amount = data.final_damage_amount
if entity.force.index ~= 3 then
return
end --Neutral Force
if not event.cause then
if not cause then
return
end
if not event.cause.valid then
if not cause.valid then
return
end
if event.cause.force.index ~= 2 then
if cause.force.index ~= 2 then
return
end --Enemy Force
event.entity.health = event.entity.health - event.final_damage_amount * 7
entity.health = entity.health - final_damage_amount * 7
end
local projectiles = {'grenade', 'explosive-rocket', 'grenade', 'explosive-rocket', 'explosive-cannon-projectile'}
@ -760,9 +767,11 @@ local function on_robot_mined_entity(event)
on_entity_removed(d)
end
local function get_damage(event)
local entity = event.entity
local damage = event.original_damage_amount + event.original_damage_amount * random(1, 100)
local function get_damage(data)
local entity = data.entity
local original_damage_amount = data.original_damage_amount
local damage = original_damage_amount + original_damage_amount * random(1, 100)
if entity.prototype.resistances then
if entity.prototype.resistances.physical then
damage = damage - entity.prototype.resistances.physical.decrease
@ -841,8 +850,10 @@ local function kaboom(entity, target, damage)
end
end
local function boss_puncher(event)
local cause = event.cause
local function boss_puncher(data)
local cause = data.cause
local entity = data.entity
if not cause then
return
end
@ -854,8 +865,6 @@ local function boss_puncher(event)
return
end
local entity = event.entity
if entity.force.index ~= 1 then
return
end
@ -867,7 +876,7 @@ local function boss_puncher(event)
end
if random(1, 10) == 1 then
kaboom(cause, entity, get_damage(event))
kaboom(cause, entity, get_damage(data))
end
end
@ -878,17 +887,30 @@ local function on_entity_damaged(event)
return
end
local cause = event.cause
local force = event.force
local final_damage_amount = event.final_damage_amount
local original_damage_amount = event.original_damage_amount
local wave_number = WD.get_wave()
local boss_wave_warning = WD.get_alert_boss_wave()
local munch_time = WPT.get('munch_time')
protect_entities(event)
biters_chew_rocks_faster(event)
local data = {
cause = cause,
entity = entity,
final_damage_amount = final_damage_amount,
original_damage_amount = original_damage_amount,
force = force
}
protect_entities(data)
biters_chew_rocks_faster(data)
if munch_time then
if boss_wave_warning or wave_number >= 1000 then
if random(0, 512) == 1 then
boss_puncher(event)
boss_puncher(data)
end
end
end
@ -1157,15 +1179,30 @@ local function show_mvps(player)
local date = Server.get_start_time()
game.server_save('Final_' .. name .. '_' .. tostring(date))
--ignore
local text = '**Statistics!**\\n\\n' ..
'Time played: ' .. time_played ..
'\\n' .. 'Game Difficulty: ' .. diff.name ..
'\\n' .. 'Highest wave: ' .. format_number(wave, true) ..
'\\n' .. 'Total connected players: ' .. total_players ..
'\\n' .. 'Threat: ' .. format_number(threat, true) ..
'\\n' .. 'Pickaxe Upgrade: ' .. pick_tier .. ' (' .. tier ..
')\\n' .. 'Collapse Speed: ' .. collapse_speed ..
'\\n' .. 'Collapse Amount: ' .. collapse_amount .. '\\n'
local text =
'**Statistics!**\\n\\n' ..
'Time played: ' ..
time_played ..
'\\n' ..
'Game Difficulty: ' ..
diff.name ..
'\\n' ..
'Highest wave: ' ..
format_number(wave, true) ..
'\\n' ..
'Total connected players: ' ..
total_players ..
'\\n' ..
'Threat: ' ..
format_number(threat, true) ..
'\\n' ..
'Pickaxe Upgrade: ' ..
pick_tier ..
' (' ..
tier ..
')\\n' ..
'Collapse Speed: ' ..
collapse_speed .. '\\n' .. 'Collapse Amount: ' .. collapse_amount .. '\\n'
--ignore
Server.to_discord_named_embed(send_ping_to_channel, text)
WPT.set('sent_to_discord', true)

View File

@ -856,7 +856,6 @@ function Public.set_difficulty()
local difficulty = WPT.get('difficulty')
local mining_bonus = WPT.get('mining_bonus')
local mining_bonus_till_wave = WPT.get('mining_bonus_till_wave')
local player_balance = WPT.get('player_balance')
local wave_number = WD.get_wave()
local player_count = calc_players()
@ -911,17 +910,21 @@ function Public.set_difficulty()
local force = game.forces.player
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier - mining_bonus
if wave_number < mining_bonus_till_wave then
if player_count < player_balance then
mining_bonus = (((player_balance * 100) / player_count) - 100) / 100
-- the mining speed of the players will increase drastically since RPG is also loaded.
if player_count <= 5 then
mining_bonus = 4 -- set a static 400% bonus if there are <= 5 players.
mining_bonus = round(mining_bonus, 2)
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + mining_bonus
else
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + mining_bonus -- we're at 500% bonus!
elseif player_count >= 6 and player_count <= 10 then
mining_bonus = 1 -- set a static 100% bonus if there are <= 10 players.
mining_bonus = round(mining_bonus, 2)
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + mining_bonus -- we're at 200% bonus!
mining_bonus = 0
end
else
mining_bonus = 0
end
WPT.set('mining_bonus', mining_bonus)
WPT.set('mining_bonus', mining_bonus)
end
end

View File

@ -215,17 +215,12 @@ function Public.add_player_to_permission_group(player, group, forced)
local allow_decon = WPT.get('allow_decon')
local default_group = game.permissions.get_group('Default')
default_group.set_allows_action(defines.input_action.deconstruct, true)
default_group.set_allows_action(defines.input_action.deconstruct, false)
default_group.set_allows_action(defines.input_action.activate_cut, false)
if not game.permissions.get_group('limited') then
local limited_group = game.permissions.create_group('limited')
limited_group.set_allows_action(defines.input_action.cancel_craft, false)
limited_group.set_allows_action(defines.input_action.edit_permission_group, false)
limited_group.set_allows_action(defines.input_action.import_permissions_string, false)
limited_group.set_allows_action(defines.input_action.delete_permission_group, false)
limited_group.set_allows_action(defines.input_action.add_permission_group, false)
limited_group.set_allows_action(defines.input_action.admin_action, false)
limited_group.set_allows_action(defines.input_action.drop_item, false)
if allow_decon then
limited_group.set_allows_action(defines.input_action.deconstruct, true)
@ -238,11 +233,6 @@ function Public.add_player_to_permission_group(player, group, forced)
if not game.permissions.get_group('near_locomotive') then
local near_locomotive_group = game.permissions.create_group('near_locomotive')
near_locomotive_group.set_allows_action(defines.input_action.cancel_craft, false)
near_locomotive_group.set_allows_action(defines.input_action.edit_permission_group, false)
near_locomotive_group.set_allows_action(defines.input_action.import_permissions_string, false)
near_locomotive_group.set_allows_action(defines.input_action.delete_permission_group, false)
near_locomotive_group.set_allows_action(defines.input_action.add_permission_group, false)
near_locomotive_group.set_allows_action(defines.input_action.admin_action, false)
near_locomotive_group.set_allows_action(defines.input_action.drop_item, false)
near_locomotive_group.set_allows_action(defines.input_action.deconstruct, false)
near_locomotive_group.set_allows_action(defines.input_action.activate_cut, false)
@ -250,11 +240,6 @@ function Public.add_player_to_permission_group(player, group, forced)
if not game.permissions.get_group('main_surface') then
local main_surface_group = game.permissions.create_group('main_surface')
main_surface_group.set_allows_action(defines.input_action.edit_permission_group, false)
main_surface_group.set_allows_action(defines.input_action.import_permissions_string, false)
main_surface_group.set_allows_action(defines.input_action.delete_permission_group, false)
main_surface_group.set_allows_action(defines.input_action.add_permission_group, false)
main_surface_group.set_allows_action(defines.input_action.admin_action, false)
main_surface_group.set_allows_action(defines.input_action.deconstruct, false)
main_surface_group.set_allows_action(defines.input_action.activate_cut, false)
end
@ -299,10 +284,6 @@ function Public.add_player_to_permission_group(player, group, forced)
end
end
if player.admin then
return
end
if forced then
default_group.add_player(player)
return
@ -353,7 +334,9 @@ function Public.add_player_to_permission_group(player, group, forced)
if playtime < 5184000 then -- 24 hours
local not_trusted = game.permissions.get_group('not_trusted')
not_trusted.add_player(player)
if not player.admin then
not_trusted.add_player(player)
end
else
if group == 'limited' then
local limited_group = game.permissions.get_group('limited')

View File

@ -203,7 +203,6 @@ function Public.reset_table()
highest = 10,
lowest = 4
}
this.player_balance = 20 -- game balance based on X players
this.mining_bonus = 0
this.mining_bonus_till_wave = 300
this.market_announce = game.tick + 1200