1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

new module > railgun_enhancer

This commit is contained in:
MewMew 2018-12-19 15:59:31 +01:00
parent 9689f8a687
commit 2d4a57d1c2
5 changed files with 86 additions and 5 deletions

View File

@ -71,6 +71,7 @@ local function on_console_chat(event)
process_bot_answers(event)
end
--share vision of silent-commands with other admins
local function on_console_command(event)
if event.command ~= "silent-command" then return end
if not event.player_index then return end

View File

@ -11,7 +11,7 @@ require "poll"
require "score"
--require "maps.modules.hunger"
--require "maps.tools.cheat_mode"
require "maps.tools.cheat_mode"
---- enable maps here ----
--require "maps.biter_battles"
@ -21,7 +21,7 @@ require "score"
--require "maps.labyrinth"
--require "maps.spaghettorio"
--require "maps.spiral_troopers"
--require "maps.fish_defender"
require "maps.fish_defender"
--require "maps.crossing"
--require "maps.spooky_forest"
--require "maps.atoll"

View File

@ -3,6 +3,7 @@
local event = require 'utils.event'
require "maps.fish_defender_map_intro"
require "maps.fish_defender_kaboomsticks"
require "maps.modules.railgun_enhancer"
local map_functions = require "maps.tools.map_functions"
local math_random = math.random
local insert = table.insert
@ -626,8 +627,8 @@ local function refresh_market_offers()
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'rocket', count = 1}},
{price = {{"coin", 7}}, offer = {type = 'give-item', item = 'explosive-rocket', count = 1}},
{price = {{"coin", 7500}}, offer = {type = 'give-item', item = 'atomic-bomb', count = 1}},
{price = {{"coin", 90}}, offer = {type = 'give-item', item = 'railgun', count = 1}},
{price = {{"coin", 5}}, offer = {type = 'give-item', item = 'railgun-dart', count = 1}},
{price = {{"coin", 260}}, offer = {type = 'give-item', item = 'railgun', count = 1}},
{price = {{"coin", 8}}, offer = {type = 'give-item', item = 'railgun-dart', count = 1}},
{price = {{"coin", 40}}, offer = {type = 'give-item', item = 'poison-capsule', count = 1}},
{price = {{"coin", 4}}, offer = {type = 'give-item', item = 'defender-capsule', count = 1}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'light-armor', count = 1}},

View File

@ -0,0 +1,78 @@
-- improves the damage of the railgun and adds visual effects -- by mewmew
local event = require 'utils.event'
local damage_min = 1000
local damage_max = 2000
local math_random = math.random
local additional_visual_effects = true
local do_splash_damage = true
local biological_target_types = {
["unit"] = true,
["player"] = true,
["turret"] = true,
["unit-spawner"] = true
}
local function create_visuals(source_entity, target_entity)
if additional_visual_effects then
local surface = target_entity.surface
local beams = surface.find_entities_filtered({name = "railgun-beam", area = {{source_entity.position.x - 1, source_entity.position.y - 1}, {source_entity.position.x + 1, source_entity.position.y + 1}}, limit = 1})
if beams[1] then
surface.create_entity({name = "railgun-beam", position = beams[1].position, source = beams[1].position, target = target_entity.position})
else
surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = target_entity.position})
end
surface.create_entity({name = "water-splash", position = target_entity.position})
if biological_target_types[target_entity.type] then
surface.create_entity({name = "blood-explosion-small", position = target_entity.position})
for x = -8, 8, 1 do
for y = -8, 8, 1 do
if math_random(1, 16) == 1 then
surface.create_entity({name = "blood-fountain", position = {target_entity.position.x + (x * 0.1), target_entity.position.y + (y * 0.1)}})
surface.create_entity({name = "blood-fountain-big", position = {target_entity.position.x + (x * 0.1), target_entity.position.y + (y * 0.1)}})
end
end
end
else
for x = -4, 4, 1 do
for y = -4, 4, 1 do
if math_random(1, 3) == 1 then
surface.create_trivial_smoke({name="smoke-fast", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}})
end
end
end
end
end
end
local function do_splash_damage_around_entity(source_entity)
if not do_splash_damage then return end
local entities = source_entity.surface.find_entities_filtered({area = {{source_entity.position.x - 2.5, source_entity.position.y - 2.5}, {source_entity.position.x + 2.5, source_entity.position.y + 2.5}}})
for _, entity in pairs(entities) do
if entity.health and entity ~= source_entity then
create_visuals(source_entity, entity)
entity.damage(math_random(math.ceil(damage_min / 50), math.ceil(damage_max / 50)), source_entity.force, "physical")
end
end
end
local function on_entity_damaged(event)
if not event.cause then return end
if event.cause.name ~= "player" then return end
if event.damage_type.name ~= "physical" then return end
if event.original_damage_amount ~= 100 then return end
local player = event.cause
if player.shooting_state.state == defines.shooting.not_shooting then return end
local selected_weapon = player.get_inventory(defines.inventory.player_guns)[player.selected_gun_index]
if selected_weapon.name ~= "railgun" then return end
create_visuals(event.cause, event.entity)
do_splash_damage_around_entity(event.entity)
event.entity.health = event.entity.health + event.final_damage_amount
event.entity.damage(math_random(damage_min, damage_max), player.force, "physical")
end
event.add(defines.events.on_entity_damaged, on_entity_damaged)

View File

@ -5,7 +5,8 @@ function cheat_mode()
game.players[1].insert({name="fusion-reactor-equipment", count=4})
game.players[1].insert({name="personal-laser-defense-equipment", count=8})
game.players[1].insert({name="rocket-launcher"})
game.players[1].insert({name="explosive-rocket", count=200})
game.players[1].insert({name="railgun", count=1})
game.players[1].insert({name="railgun-dart", count=10})
game.players[1].insert({name="coin", count = 100000})
game.players[1].insert({name="loader"})
game.players[1].insert({name="fast-loader"})