mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-11 14:49:24 +02:00
Elite biter changes
Changes: - Elite biters now appear from league 800 in Easy and Normal difficulties (In Hard and Nightmare difficulties, elite biters appear from league 40). Previously, in Easy and Normal difficulties elite biters never appeared at all. - Elite biters now also explode and spawn 4 non-elite biters.
This commit is contained in:
parent
bca9ca16f8
commit
b5e61d577b
@ -905,7 +905,39 @@ function Public.try_boat_biters_attack()
|
||||
end
|
||||
|
||||
|
||||
local function on_entity_destroyed(event)
|
||||
local registration_number = event.registration_number
|
||||
|
||||
local p
|
||||
local biter_name
|
||||
local surface_name
|
||||
local memory
|
||||
for i = 1,3 do
|
||||
Memory.set_working_id(i)
|
||||
memory = Memory.get_crew_memory()
|
||||
if memory.elite_biters_stream_registrations then
|
||||
for j, r in pairs(memory.elite_biters_stream_registrations) do
|
||||
if r.number == registration_number then
|
||||
p = r.position
|
||||
biter_name = r.biter_name
|
||||
surface_name = r.surface_name
|
||||
memory.elite_biters_stream_registrations = Utils.ordered_table_with_index_removed(memory.elite_biters_stream_registrations, j)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if p then break end
|
||||
end
|
||||
if p then
|
||||
local surface = game.surfaces[surface_name]
|
||||
if not (surface and surface.valid) then return end
|
||||
|
||||
local p2 = surface.find_non_colliding_position('medium-biter', p, 10, 0.2)
|
||||
if not p2 then return end
|
||||
|
||||
surface.create_entity{name = biter_name, position = p2, force = memory.enemy_force_name}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- function Public.destroy_inactive_scripted_biters()
|
||||
@ -924,5 +956,8 @@ end
|
||||
--=== Data
|
||||
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_entity_destroyed, on_entity_destroyed)
|
||||
|
||||
|
||||
return Public
|
||||
|
@ -253,6 +253,34 @@ local function damage_to_elite_biters(event)
|
||||
local remaining_health = Common.entity_damage_healthbar(event.entity, damage)
|
||||
|
||||
if remaining_health and remaining_health <= 0 then
|
||||
local surface = event.entity.surface
|
||||
if surface and surface.valid then
|
||||
-- Shoot spit around and spawn biters where spit lands
|
||||
local arc_size = (2 * Math.pi) / Balance.biters_spawned_on_elite_biter_death
|
||||
for i = 1, Balance.biters_spawned_on_elite_biter_death, 1 do
|
||||
local offset = Math.random_vec_in_arc(Math.random(4, 8), arc_size * i, arc_size)
|
||||
local target_pos = Math.vector_sum(event.entity.position, offset)
|
||||
|
||||
local stream = surface.create_entity{
|
||||
name = 'acid-stream-spitter-big',
|
||||
position = event.entity.position,
|
||||
force = memory.enemy_force_name,
|
||||
source = event.entity.position,
|
||||
target = target_pos,
|
||||
max_range = 500,
|
||||
speed = 0.1
|
||||
}
|
||||
|
||||
if not memory.elite_biters_stream_registrations then memory.elite_biters_stream_registrations = {} end
|
||||
memory.elite_biters_stream_registrations[#memory.elite_biters_stream_registrations + 1] = {
|
||||
number = script.register_on_entity_destroyed(stream),
|
||||
position = target_pos,
|
||||
biter_name = event.entity.name,
|
||||
surface_name = surface.name -- surface name is needed to know where biter died
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
memory.elite_biters[event.entity.unit_number] = nil
|
||||
event.entity.die()
|
||||
end
|
||||
|
@ -93,6 +93,8 @@ Public.min_ore_spawn_distance = 10
|
||||
Public.biter_boats_start_arrive_x = 40 * 5
|
||||
Public.need_resources_to_undock_x = 40 * 20
|
||||
|
||||
Public.biters_spawned_on_elite_biter_death = 4
|
||||
|
||||
function Public.starting_boatEEIpower_production_MW()
|
||||
-- return 3 * Math.sloped(Common.capacity_scale(), 1/2) / 2 --/2 as we have 2
|
||||
return 3/2
|
||||
|
@ -1861,7 +1861,7 @@ function Public.try_make_biter_elite(entity)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
local difficulty_index = CoreData.get_difficulty_option_from_value(memory.difficulty)
|
||||
if difficulty_index < 3 then return end
|
||||
if difficulty_index < 3 and Public.overworldx() < 800 then return end
|
||||
|
||||
if Public.overworldx() == 0 then return end
|
||||
|
||||
@ -1870,7 +1870,7 @@ function Public.try_make_biter_elite(entity)
|
||||
|
||||
local health_multiplier
|
||||
|
||||
if difficulty_index == 3 then
|
||||
if difficulty_index <= 3 then
|
||||
health_multiplier = 5
|
||||
else
|
||||
health_multiplier = 10
|
||||
|
@ -789,6 +789,7 @@ function Public.initialise_crew(accepted_proposal)
|
||||
memory.class_auxiliary_data = {}
|
||||
|
||||
memory.elite_biters = {}
|
||||
memory.elite_biters_stream_registrations = {}
|
||||
memory.pet_biters = {}
|
||||
|
||||
memory.hold_surface_count = 1
|
||||
|
@ -105,8 +105,21 @@ function Public.random_vec(scalar)
|
||||
scalar = scalar or 1
|
||||
local random_angle = Public.random_float_in_range(0, 2 * Public.pi)
|
||||
return {
|
||||
x = Public.sin(random_angle) * scalar,
|
||||
y = Public.cos(random_angle) * scalar
|
||||
x = Public.cos(random_angle) * scalar,
|
||||
y = Public.sin(random_angle) * scalar
|
||||
}
|
||||
end
|
||||
|
||||
-- Returns vector in random direction in arc: [arc_offset, arc_offset + arc_size], starting at {x=1, y=1} and going anti-clockwise.
|
||||
-- scalar: returned vector length. If nil, 1 will be chosen.
|
||||
-- arc_offset: offset of arc in radians.
|
||||
-- arc_size: size of arc in radians. Result is undefined with negative arc_size
|
||||
function Public.random_vec_in_arc(scalar, arc_offset, arc_size)
|
||||
scalar = scalar or 1
|
||||
local random_angle = Public.random_float_in_range(arc_offset, arc_offset + arc_size)
|
||||
return {
|
||||
x = Public.cos(random_angle) * scalar,
|
||||
y = Public.sin(random_angle) * scalar
|
||||
}
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user