1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-11-06 09:09:26 +02:00

Merge pull request #424 from iltar/biter-mining-particles

Added particles when a biter mines a rock upon spawning
This commit is contained in:
Matthew
2018-11-22 22:53:50 -05:00
committed by GitHub
3 changed files with 45 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ local Config = {
-- enable debug mode, shows extra messages
debug = false,
-- allow cheats. Example: by default the player will have X mining speed
-- allow cheats, primarily configured under SetupPlayer
cheats = false,
-- a list of features to register and enable
@@ -31,14 +31,31 @@ local Config = {
{name = 'iron-axe', count = 1},
{name = 'stone-wall', count = 10},
},
-- applied when cheat_mode is set to true. It's recommended to tweak this to your needs
-- when playing with cheats on (recommended for single player or LAN with limited players)
cheats = {
-- Sets the manual mining speed for the player force. A value of 1 = 100% faster. Setting it
-- to 0.5 would make it 50% faster than the base speed.
manual_mining_speed_modifier = 1000,
-- increase the amount of inventory slots for the player force
character_inventory_slots_bonus = 1000,
-- increases the run speed of all characters for the player force
character_running_speed_modifier = 2,
-- a flat health bonus to the player force
character_health_bonus = 1000000,
-- unlock all research by default, only useful when testing
unlock_all_research = true,
-- adds additional items to the player force when starting in addition to defined in start_items above
starting_items = {
{name = 'power-armor-mk2', count = 1},
{name = 'submachine-gun', count = 1},
{name = 'uranium-rounds-magazine', count = 200},
{name = 'uranium-rounds-magazine', count = 1000},
},
},
},
@@ -308,7 +325,6 @@ local Config = {
['medium-biter'] = {['small-biter'] = 1.7},
['big-biter'] = {['medium-biter'] = 1.7},
['behemoth-biter'] = {['big-biter'] = 1.7},
['behemoth-biter'] = {['big-biter'] = 1.7},
-- worms
['small-worm-turret'] = {['small-biter'] = 2.5},

View File

@@ -50,8 +50,20 @@ local do_alien_mining = Token.register(function(params)
break
end
-- with multiple rocks opening at once, it will spawn less particles in total per rock
local particle_count = 16 - ((#rocks - 1) * 5)
for _, rock in pairs(rocks) do
raise_event(defines.events.on_entity_died, {entity = rock})
for _ = particle_count, 1, -1 do
create_entity({
position = rock.position,
name = 'stone-particle',
movement = {random(-5, 5) * 0.01, random(-5, 5) * 0.01},
frame_speed = 1,
vertical_speed = random(12, 14) * 0.01,
height = random(9, 11) * 0.1,
})
end
rock.destroy()
end
end

View File

@@ -20,30 +20,37 @@ global.SetupPlayer = {
function SetupPlayer.register(config)
Event.add(defines.events.on_player_created, function (event)
local player = Game.get_player_by_index(event.player_index)
local force = player.force
local player_insert = player.insert
local position = {0, 0}
local surface = player.surface
for _, item in pairs(config.starting_items) do
for _, item in ipairs(config.starting_items) do
player_insert(item)
end
if (global.SetupPlayer.first_player_spawned) then
if global.SetupPlayer.first_player_spawned then
position = surface.find_non_colliding_position('player', position, 3, 0.1)
else
global.SetupPlayer.first_player_spawned = true
end
player.force.set_spawn_position(position, surface)
force.set_spawn_position(position, surface)
player.teleport(position)
Debug.cheat(function()
local cheats = config.cheats
player.force.manual_mining_speed_modifier = cheats.manual_mining_speed_modifier
player.force.character_inventory_slots_bonus = cheats.character_inventory_slots_bonus
player.force.character_running_speed_modifier = cheats.character_running_speed_modifier
force.manual_mining_speed_modifier = cheats.manual_mining_speed_modifier
force.character_inventory_slots_bonus = cheats.character_inventory_slots_bonus
force.character_running_speed_modifier = cheats.character_running_speed_modifier
force.character_running_speed_modifier = cheats.character_running_speed_modifier
force.character_health_bonus = cheats.character_health_bonus
force.character_health_bonus = cheats.character_health_bonus
if cheats.unlock_all_research then
force.research_all_technologies()
end
for _, item in pairs(cheats.starting_items) do
for _, item in ipairs(cheats.starting_items) do
player_insert(item)
end
end)