You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-09-16 09:06:21 +02:00
rpg addition
This commit is contained in:
@@ -14,6 +14,7 @@ require "modules.dangerous_goods"
|
||||
require "modules.custom_death_messages"
|
||||
require "modules.biter_evasion_hp_increaser"
|
||||
require "modules.rocks_yield_ore"
|
||||
require "modules.rpg"
|
||||
|
||||
local event = require 'utils.event'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
|
@@ -34,8 +34,7 @@ end
|
||||
local function accelerate()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
local driver = global.locomotive.get_driver()
|
||||
if driver then return end
|
||||
if global.locomotive.get_driver() then return end
|
||||
global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"})
|
||||
global.locomotive_driver.driving = true
|
||||
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
|
||||
@@ -45,73 +44,29 @@ local function remove_acceleration()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
if global.locomotive_driver then global.locomotive_driver.destroy() end
|
||||
end
|
||||
--[[
|
||||
local function constant_speed()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
if not global.locomotive_cargo.train.locomotives then return end
|
||||
if not global.locomotive_cargo.train.locomotives.front_movers then return end
|
||||
if not global.locomotive_cargo.train.locomotives.front_movers[1] then return end
|
||||
local loco = global.locomotive_cargo.train.locomotives.front_movers[1]
|
||||
local front_rail_connection = global.locomotive_cargo.train.front_rail.
|
||||
defines.rail_direction.front
|
||||
defines.rail_direction.back
|
||||
if loco.speed < 1 and then
|
||||
local driver = loco.get_driver()
|
||||
if driver then return end
|
||||
global.locomotive_driver = loco.surface.create_entity({name = "character", position = loco.position, force = "player"})
|
||||
global.locomotive_driver.driving = true
|
||||
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
|
||||
else
|
||||
if global.locomotive_driver then global.locomotive_driver.destroy() end
|
||||
end
|
||||
end
|
||||
]]
|
||||
local function set_player_spawn()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
local position = global.locomotive_cargo.surface.find_non_colliding_position("stone-furnace", global.locomotive_cargo.position, 16, 2)
|
||||
if not position then return end
|
||||
game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface)
|
||||
global.locomotive_driver = nil
|
||||
end
|
||||
|
||||
local function set_player_spawn_and_refill_fish()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 8})
|
||||
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 4})
|
||||
local position = global.locomotive_cargo.surface.find_non_colliding_position("stone-furnace", global.locomotive_cargo.position, 16, 2)
|
||||
if not position then return end
|
||||
game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface)
|
||||
end
|
||||
|
||||
local function force_nearby_units_to_attack()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
|
||||
global.locomotive_cargo.surface.set_multi_command({
|
||||
command={
|
||||
type = defines.command.attack,
|
||||
target = global.locomotive_cargo,
|
||||
distraction = defines.distraction.none
|
||||
},
|
||||
unit_count = 4,
|
||||
force = "enemy",
|
||||
unit_search_distance = 256
|
||||
})
|
||||
end
|
||||
|
||||
local function tick()
|
||||
if game.tick % 30 == 0 then
|
||||
fish_tag()
|
||||
accelerate()
|
||||
if game.tick % 1800 == 0 then
|
||||
set_player_spawn_and_refill_fish()
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < game.tick then
|
||||
global.game_reset_tick = nil
|
||||
reset_map()
|
||||
end
|
||||
end
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < game.tick then
|
||||
global.game_reset_tick = nil
|
||||
reset_map()
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@@ -580,8 +580,7 @@ local function on_entity_damaged(event)
|
||||
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
|
||||
local damage = event.original_damage_amount + event.original_damage_amount * get_melee_modifier(event.cause.player)
|
||||
|
||||
local damage = event.final_damage_amount + event.final_damage_amount * get_melee_modifier(event.cause.player)
|
||||
|
||||
if math_random(0,999) < get_one_punch_chance(event.cause.player) * 10 then
|
||||
one_punch(event.cause, event.entity, damage)
|
||||
@@ -657,7 +656,7 @@ end
|
||||
local function on_player_crafted_item(event)
|
||||
if not event.recipe.energy then return end
|
||||
local player = game.players[event.player_index]
|
||||
gain_xp(player, event.recipe.energy * 0.25)
|
||||
gain_xp(player, event.recipe.energy * 0.20)
|
||||
end
|
||||
|
||||
local function on_player_respawned(event)
|
||||
|
Reference in New Issue
Block a user