1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00
This commit is contained in:
MewMew 2019-04-19 12:29:06 +02:00
parent e8464f13bf
commit 1b85c9deb9
9 changed files with 134 additions and 42 deletions

View File

@ -43,7 +43,7 @@ local function bounce(surface, position, ammo)
valid_entities = shuffle(valid_entities)
for c = 1, math.random(1,3), 1 do
for c = 1, math.random(2,4), 1 do
if not valid_entities[c] then return end
create_projectile(surface, position, valid_entities[c].position, ammo)
end

View File

@ -0,0 +1,15 @@
local event = require 'utils.event'
local math_random = math.random
local rock_raffle = {"sand-rock-big", "rock-big", "rock-big", "rock-big", "rock-huge"}
local function on_entity_died(event)
if not global.crumbly_walls_unlocked then return end
local entity = event.entity
if not entity.valid then return end
if entity.name ~= "stone-wall" then return end
if math_random(1,3) == 1 then return end
entity.surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = entity.position, force = "player"})
end
event.add(defines.events.on_entity_died, on_entity_died)

View File

@ -8,8 +8,8 @@ local function splash_damage(surface, position, final_damage_amount)
if distance_from_center <= radius then
local damage_distance_modifier = 1 - distance_from_center / radius
if damage > 0 then
e.damage(damage * damage_distance_modifier, "player", "explosion")
if math.random(1, 3) == 1 then surface.create_entity({name = "explosion", position = e.position}) end
e.damage(damage * damage_distance_modifier, "player", "explosion")
end
end
end

View File

@ -8,7 +8,6 @@ require "maps.fish_defender.on_entity_damaged"
require "modules.rocket_launch_always_yields_science"
require "modules.launch_fish_to_win"
require "modules.biters_yield_coins"
require "modules.railgun_enhancer"
require "modules.dynamic_landfill"
require "modules.dangerous_goods"
require "modules.custom_death_messages"

View File

@ -9,14 +9,16 @@ local function on_player_changed_position(event)
if not global.flame_boots[player.index] then global.flame_boots[player.index] = {} end
if not global.flame_boots[player.index].timeout then return end
if not global.flame_boots[player.index].fuel then return end
if global.flame_boots[player.index].timeout - game.tick < 0 then
if global.flame_boots[player.index].fuel < 0 then
player.print("Your flame boots have worn out.", {r = 0.22, g = 0.77, b = 0.44})
global.flame_boots[player.index] = {}
return
end
if global.flame_boots[player.index].fuel % 500 == 0 then player.print("Fuel remaining: " .. global.flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44}) end
if not global.flame_boots[player.index].step_history then global.flame_boots[player.index].step_history = {} end
local elements = #global.flame_boots[player.index].step_history
@ -25,7 +27,9 @@ local function on_player_changed_position(event)
if elements < 50 then return end
player.surface.create_entity({name = "fire-flame", position = global.flame_boots[player.index].step_history[elements - 2]})
player.surface.create_entity({name = "fire-flame", position = global.flame_boots[player.index].step_history[elements - 2]})
global.flame_boots[player.index].fuel = global.flame_boots[player.index].fuel - 1
end
local function on_init()

View File

@ -1,6 +1,8 @@
require 'maps.fish_defender.flame_boots'
require 'maps.fish_defender.trapped_capsules'
require 'maps.fish_defender.ultra_mines'
require 'maps.fish_defender.crumbly_walls'
require 'maps.fish_defender.vehicle_nanobots'
local event = require 'utils.event'
@ -13,11 +15,14 @@ local slot_upgrade_offers = {
}
local special_descriptions = {
["flame-boots"] = "Flame Boots - Get yourself some hot boots for a few minutes.",
["flame-boots"] = "Flame Boots - Get yourself some hot boots.",
["explosive-bullets"] = "Unlock Explosive Bullets - Submachine-Gun and Pistol gains a chance to deal splash damage.",
["bouncy-shells"] = "Unlock Bouncy Shells - Shotgun projectiles may bounce to multiple targets.",
["trapped-capsules"] = "Unlock Trapped Capsules - Combat robots will send a last deadly projectile to a nearby enemy when killed.",
["ultra-mines"] = "Unlock Ultra Mines - Careful with these..."
["ultra-mines"] = "Unlock Ultra Mines - Careful with these...",
["railgun-enhancer"] = "Unlock Railgun Enhancer - Turns the railgun into a powerful forking gun.",
["crumbly-walls"] = "Unlock Crumbly Walls - Fortifications which crumble, may turn into rocks.",
["vehicle-nanobots"] = "Unlock Vehicle Nanobots - Your vehicles repair rapidly while driving.",
}
local function refresh_market_offers()
@ -103,16 +108,25 @@ local function refresh_market_offers()
end
if not global.explosive_bullets_unlocked then
global.market.add_market_item({price = {{"coin", 2500}}, offer = {type = 'nothing', effect_description = special_descriptions["explosive-bullets"]}})
global.market.add_market_item({price = {{"coin", 5000}}, offer = {type = 'nothing', effect_description = special_descriptions["explosive-bullets"]}})
end
if not global.bouncy_shells_unlocked then
global.market.add_market_item({price = {{"coin", 5000}}, offer = {type = 'nothing', effect_description = special_descriptions["bouncy-shells"]}})
global.market.add_market_item({price = {{"coin", 7500}}, offer = {type = 'nothing', effect_description = special_descriptions["bouncy-shells"]}})
end
if not global.trapped_capsules_unlocked then
global.market.add_market_item({price = {{"coin", 2500}}, offer = {type = 'nothing', effect_description = special_descriptions["trapped-capsules"]}})
end
if not global.trapped_capsules_unlocked then
global.market.add_market_item({price = {{"coin", 7500}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
if not global.ultra_mines_unlocked then
global.market.add_market_item({price = {{"coin", 10000}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
end
if not global.railgun_enhancer_unlocked then
global.market.add_market_item({price = {{"coin", 1500}}, offer = {type = 'nothing', effect_description = special_descriptions["railgun-enhancer"]}})
end
if not global.crumbly_walls_unlocked then
global.market.add_market_item({price = {{"coin", 25000}}, offer = {type = 'nothing', effect_description = special_descriptions["crumbly-walls"]}})
end
if not global.vehicle_nanobots_unlocked then
global.market.add_market_item({price = {{"coin", 12500}}, offer = {type = 'nothing', effect_description = special_descriptions["vehicle-nanobots"]}})
end
end
@ -158,6 +172,19 @@ local function on_market_item_purchased(event)
if offer_index < 50 then return end
if bought_offer.effect_description == special_descriptions["flame-boots"] then
game.print(player.name .. " has bought themselves some flame boots.", {r = 0.22, g = 0.77, b = 0.44})
if not global.flame_boots[player.index].fuel then
global.flame_boots[player.index].fuel = math.random(1500, 3000)
else
global.flame_boots[player.index].fuel = global.flame_boots[player.index].fuel + math.random(1500, 3000)
end
player.print("Fuel remaining: " .. global.flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44})
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["explosive-bullets"] then
game.print(player.name .. " has unlocked explosive bullets.", {r = 0.22, g = 0.77, b = 0.44})
global.explosive_bullets_unlocked = true
@ -171,27 +198,41 @@ local function on_market_item_purchased(event)
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["flame-boots"] then
game.print(player.name .. " has bought themselves some flame boots.", {r = 0.22, g = 0.77, b = 0.44})
global.flame_boots[player.index].timeout = game.tick + math.random(7200, 10800)
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["trapped-capsules"] then
game.print(player.name .. " has unlocked trapped capsules.", {r = 0.22, g = 0.77, b = 0.44})
game.print(player.name .. " has unlocked trapped capsules!", {r = 0.22, g = 0.77, b = 0.44})
global.trapped_capsules_unlocked = true
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["ultra-mines"] then
game.print(player.name .. " has unlocked ultra mines. Handle with care.", {r = 0.22, g = 0.77, b = 0.44})
game.print(player.name .. " has unlocked ultra mines!", {r = 0.22, g = 0.77, b = 0.44})
global.ultra_mines_unlocked = true
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["railgun-enhancer"] then
game.print(player.name .. " has unlocked the enhanced railgun!", {r = 0.22, g = 0.77, b = 0.44})
global.railgun_enhancer_unlocked = true
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["crumbly-walls"] then
game.print(player.name .. " has unlocked crumbly walls!", {r = 0.22, g = 0.77, b = 0.44})
global.crumbly_walls_unlocked = true
refresh_market_offers()
return
end
if bought_offer.effect_description == special_descriptions["vehicle-nanobots"] then
game.print(player.name .. " has unlocked vehicle nanobots!", {r = 0.22, g = 0.77, b = 0.44})
global.vehicle_nanobots_unlocked = true
refresh_market_offers()
return
end
end
local function on_gui_opened(event)

View File

@ -5,7 +5,6 @@ local damage_min = 400
local damage_max = 800
local math_random = math.random
local additional_visual_effects = true
local do_splash_damage = true
local biological_target_types = {
["unit"] = true,
@ -15,6 +14,8 @@ local biological_target_types = {
}
local function create_visuals(source_entity, target_entity)
if not source_entity.valid then return end
if not target_entity.valid then return end
if not additional_visual_effects then return end
local surface = target_entity.surface
surface.create_entity({name = "water-splash", position = target_entity.position})
@ -46,7 +47,7 @@ local function create_visuals(source_entity, target_entity)
end
local function do_splash_damage_around_entity(source_entity, player)
if not do_splash_damage then return end
if not source_entity.valid then return end
local research_damage_bonus = player.force.get_ammo_damage_modifier("laser-turret") + 1
local research_splash_radius_bonus = player.force.get_ammo_damage_modifier("laser-turret") * 0.5
local splash_area = {
@ -55,22 +56,25 @@ local function do_splash_damage_around_entity(source_entity, player)
}
local entities = source_entity.surface.find_entities_filtered({area = splash_area})
for _, entity in pairs(entities) do
if entity.health and entity ~= source_entity and entity ~= player then
if additional_visual_effects then
local surface = entity.surface
surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = entity.position})
surface.create_entity({name = "water-splash", position = entity.position})
if biological_target_types[entity.type] then
surface.create_entity({name = "blood-fountain", position = entity.position})
if entity.valid then
if entity.health and entity ~= source_entity and entity ~= player then
if additional_visual_effects then
local surface = entity.surface
surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = entity.position})
surface.create_entity({name = "water-splash", position = entity.position})
if biological_target_types[entity.type] then
surface.create_entity({name = "blood-fountain", position = entity.position})
end
end
local damage = math_random(math.ceil((damage_min * research_damage_bonus) / 16), math.ceil((damage_max * research_damage_bonus) / 16))
entity.damage(damage, player.force, "physical")
end
local damage = math_random(math.ceil((damage_min * research_damage_bonus) / 16), math.ceil((damage_max * research_damage_bonus) / 16))
entity.damage(damage, player.force, "physical")
end
end
end
local function enhance(event)
local function enhance(event)
if not global.railgun_enhancer_unlocked then return end
if event.damage_type.name ~= "physical" then return end
if event.original_damage_amount ~= 100 then return end

View File

@ -1,4 +1,18 @@
local event = require 'utils.event'
local radius = 8
local function damage_entities_around_target(entity, damage)
for _, e in pairs(entity.surface.find_entities_filtered({area = {{entity.position.x - radius, entity.position.y - radius},{entity.position.x + radius, entity.position.y + radius}}})) do
if e.health then
if e.force.name ~= "player" then
local distance_from_center = math.sqrt((e.position.x - entity.position.x) ^ 2 + (e.position.y - entity.position.y) ^ 2)
if distance_from_center <= radius then
e.damage(damage, "player", "explosion")
end
end
end
end
end
local function on_entity_died(event)
if not global.ultra_mines_unlocked then return end
@ -6,14 +20,13 @@ local function on_entity_died(event)
if event.entity.name ~= "land-mine" then return end
event.entity.surface.create_entity({
name = "artillery-projectile",
position = event.entity.position,
force = "player",
source = event.entity.position,
target = event.entity.position,
max_range = 1,
speed = 1
name = "big-artillery-explosion",
position = event.entity.position
})
local damage = (1 + event.entity.force.get_ammo_damage_modifier("grenade")) * 250
damage_entities_around_target(event.entity, damage)
end
event.add(defines.events.on_entity_died, on_entity_died)

View File

@ -0,0 +1,16 @@
local event = require 'utils.event'
local function on_player_changed_position(event)
if not global.vehicle_nanobots_unlocked then return end
local player = game.players[event.player_index]
if not player.character then return end
if not player.character.driving then return end
if not player.vehicle then return end
if not player.vehicle.valid then return end
if player.vehicle.health == player.vehicle.prototype.max_health then return end
player.vehicle.health = player.vehicle.health + player.vehicle.prototype.max_health * 0.005
end
event.add(defines.events.on_player_changed_position, on_player_changed_position)