mirror of
https://github.com/veden/Rampant.git
synced 2025-02-03 13:11:54 +02:00
working ion cannon reaction
This commit is contained in:
parent
d9a9045ada
commit
471c6fe62d
@ -43,6 +43,7 @@ Configure Options not in game menu:
|
|||||||
- No Homing Projectiles - All projectiles are fired at locations and no longer track the player
|
- No Homing Projectiles - All projectiles are fired at locations and no longer track the player
|
||||||
- Pathfinding - Unit groups will use potential fields to perform only single step pathfinding allowing for efficient and dynamic pathing
|
- Pathfinding - Unit groups will use potential fields to perform only single step pathfinding allowing for efficient and dynamic pathing
|
||||||
- Peace mode - If something sets peace mode, Rampant will respect it
|
- Peace mode - If something sets peace mode, Rampant will respect it
|
||||||
|
- Ion Cannon Reaction - When using the Ion Cannon Mod, biters will
|
||||||
|
|
||||||
# Planned Features
|
# Planned Features
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ Configure Options not in game menu:
|
|||||||
# Version History
|
# Version History
|
||||||
|
|
||||||
0.15.11 -
|
0.15.11 -
|
||||||
|
- Feature: Ion cannon mod integration
|
||||||
- Fixed: Player region scan can no longer overlap passive map scan causing double processing
|
- Fixed: Player region scan can no longer overlap passive map scan causing double processing
|
||||||
- Tweak: Increased rally cry chance from 0.02(@100 evo) to 0.08(@100 evo) compensate for the once per logic cycle per chunk
|
- Tweak: Increased rally cry chance from 0.02(@100 evo) to 0.08(@100 evo) compensate for the once per logic cycle per chunk
|
||||||
- Improvement: Changed biter base detection from slow map scan to event
|
- Improvement: Changed biter base detection from slow map scan to event
|
||||||
|
@ -88,7 +88,7 @@ function upgrade.attempt(natives, regionMap)
|
|||||||
|
|
||||||
--[[
|
--[[
|
||||||
For making changes to maps that haven't had Rampant loaded and aren't starting from a brand new map
|
For making changes to maps that haven't had Rampant loaded and aren't starting from a brand new map
|
||||||
Was causing desyncs when client connected before having the below settings saved into the map
|
Was causing desyncs when client connected before having the below settings saved into the map 0.15.15 factorio
|
||||||
--]]
|
--]]
|
||||||
local mapSettings = game.map_settings
|
local mapSettings = game.map_settings
|
||||||
|
|
||||||
@ -124,6 +124,7 @@ function upgrade.attempt(natives, regionMap)
|
|||||||
natives.unitRefundAmount = 0
|
natives.unitRefundAmount = 0
|
||||||
natives.attackWaveThreshold = 0
|
natives.attackWaveThreshold = 0
|
||||||
|
|
||||||
|
-- used for breaking up how many squads are processing per logic cycle
|
||||||
natives.regroupIndex = 1
|
natives.regroupIndex = 1
|
||||||
|
|
||||||
natives.useCustomAI = settings.startup["rampant-useCustomAI"].value
|
natives.useCustomAI = settings.startup["rampant-useCustomAI"].value
|
||||||
|
@ -9,6 +9,11 @@ local mathUtils = require("libs/MathUtils")
|
|||||||
local gaussianRandomRange = mathUtils.gaussianRandomRange
|
local gaussianRandomRange = mathUtils.gaussianRandomRange
|
||||||
local mCeil = math.ceil
|
local mCeil = math.ceil
|
||||||
|
|
||||||
|
|
||||||
|
-- automatic mod detection
|
||||||
|
|
||||||
|
config.ionCannonPresent = settings.startup["ion-cannon-radius"] ~= nil
|
||||||
|
|
||||||
-- configurations
|
-- configurations
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
43
control.lua
43
control.lua
@ -17,6 +17,7 @@ local tests = require("tests")
|
|||||||
local upgrade = require("Upgrade")
|
local upgrade = require("Upgrade")
|
||||||
local baseUtils = require("libs/BaseUtils")
|
local baseUtils = require("libs/BaseUtils")
|
||||||
local mathUtils = require("libs/MathUtils")
|
local mathUtils = require("libs/MathUtils")
|
||||||
|
local config = require("config")
|
||||||
|
|
||||||
-- constants
|
-- constants
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ local INTERVAL_PROCESS = constants.INTERVAL_PROCESS
|
|||||||
|
|
||||||
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
|
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
|
||||||
|
|
||||||
|
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
|
||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
local roundToNearest = mathUtils.roundToNearest
|
local roundToNearest = mathUtils.roundToNearest
|
||||||
@ -192,9 +195,9 @@ local function onTick(event)
|
|||||||
|
|
||||||
processPlayers(players, regionMap, surface, natives, tick)
|
processPlayers(players, regionMap, surface, natives, tick)
|
||||||
|
|
||||||
-- if (natives.useCustomAI) then
|
if natives.useCustomAI then
|
||||||
-- processBases(regionMap, surface, natives, tick)
|
processBases(regionMap, surface, natives, tick)
|
||||||
-- end
|
end
|
||||||
|
|
||||||
squadBeginAttack(natives, players)
|
squadBeginAttack(natives, players)
|
||||||
squadAttack(regionMap, surface, natives)
|
squadAttack(regionMap, surface, natives)
|
||||||
@ -218,6 +221,33 @@ local function onPickUp(event)
|
|||||||
addRemovePlayerEntity(regionMap, event.entity, natives, false, false)
|
addRemovePlayerEntity(regionMap, event.entity, natives, false, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function onIonCannonFired(event)
|
||||||
|
--[[
|
||||||
|
event.force, event.surface, event.player_index, event.position, event.radius
|
||||||
|
--]]
|
||||||
|
local surface = event.surface
|
||||||
|
if (surface.index == 1) then
|
||||||
|
natives.points = natives.points + 3000
|
||||||
|
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
||||||
|
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||||
|
end
|
||||||
|
local chunk = getChunkByPosition(regionMap, event.position.x, event.position.y)
|
||||||
|
if chunk then
|
||||||
|
local tempNeighbors = {false, false, false, false, false, false, false, false}
|
||||||
|
rallyUnits(chunk,
|
||||||
|
regionMap,
|
||||||
|
surface,
|
||||||
|
natives,
|
||||||
|
event.tick,
|
||||||
|
tempNeighbors)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- local function onIonCannonTargeted(event)
|
||||||
|
|
||||||
|
-- end
|
||||||
|
|
||||||
local function onDeath(event)
|
local function onDeath(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
local surface = entity.surface
|
local surface = entity.surface
|
||||||
@ -307,6 +337,13 @@ script.on_event(defines.events.on_runtime_mod_setting_changed,
|
|||||||
onModSettingsChange)
|
onModSettingsChange)
|
||||||
script.on_configuration_changed(onConfigChanged)
|
script.on_configuration_changed(onConfigChanged)
|
||||||
|
|
||||||
|
if config.ionCannonPresent then
|
||||||
|
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
|
||||||
|
onIonCannonFired)
|
||||||
|
-- script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_targeted"),
|
||||||
|
-- onIonCannonTargeted)
|
||||||
|
end
|
||||||
|
|
||||||
script.on_event(defines.events.on_player_built_tile, onSurfaceTileChange)
|
script.on_event(defines.events.on_player_built_tile, onSurfaceTileChange)
|
||||||
|
|
||||||
script.on_event(defines.events.on_biter_base_built,
|
script.on_event(defines.events.on_biter_base_built,
|
||||||
|
@ -4,11 +4,11 @@ local NEUpdates = require("prototypes/enemies/UpdatesNE")
|
|||||||
local constants = require("libs/Constants")
|
local constants = require("libs/Constants")
|
||||||
|
|
||||||
local function bobsDetected()
|
local function bobsDetected()
|
||||||
return data.raw["turret"]["bob-big-explosive-worm-turret"] ~= nil
|
return settings.startup["bobmods-enemies-aliensdropartifacts"] ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function NEDetected()
|
local function NEDetected()
|
||||||
return data.raw["unit"]["medium-spitter-Mk3"] ~= nil
|
return settings.startup["NE_Difficulty"] ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if settings.startup["rampant-useDumbProjectiles"].value then
|
if settings.startup["rampant-useDumbProjectiles"].value then
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"author" : "Veden",
|
"author" : "Veden",
|
||||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||||
"description" : "Improves the enemies tactics by using potential fields/pheromones allowing probing of defenses, retreats, reinforcements, counterattacking, breaching, rallying death cry, and player hunting. Also removes homing biter projectiles. Difficulty setting in mod options menu.",
|
"description" : "Improves the enemies tactics by using potential fields/pheromones allowing probing of defenses, retreats, reinforcements, counterattacking, breaching, rallying death cry, and player hunting. Also removes homing biter projectiles. Difficulty setting in mod options menu.",
|
||||||
"dependencies" : ["base >= 0.13.17", "? bobenemies", "? Natural_Evolution_Enemies", "? DayNightExtender"]
|
"dependencies" : ["base >= 0.13.17", "? bobenemies", "? Natural_Evolution_Enemies", "? DayNightExtender", "? Orbital Ion Cannon"]
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ function aiAttack.squadAttack(regionMap, surface, natives)
|
|||||||
radius = 28,
|
radius = 28,
|
||||||
distraction = DEFINES_DISTRACTION_BY_ENEMY }
|
distraction = DEFINES_DISTRACTION_BY_ENEMY }
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#squads do
|
for i=1,#squads do
|
||||||
local squad = squads[i]
|
local squad = squads[i]
|
||||||
local group = squad.group
|
local group = squad.group
|
||||||
|
@ -55,12 +55,13 @@ constants.AI_TUNNEL_COST = 100
|
|||||||
constants.AI_MAX_POINTS = 10000
|
constants.AI_MAX_POINTS = 10000
|
||||||
constants.AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_POINTS * 3
|
constants.AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_POINTS * 3
|
||||||
|
|
||||||
|
|
||||||
constants.AI_UNIT_REFUND = 3
|
constants.AI_UNIT_REFUND = 3
|
||||||
|
|
||||||
constants.AI_MAX_SQUAD_COUNT = 40
|
constants.AI_MAX_SQUAD_COUNT = 40
|
||||||
constants.AI_MAX_BITER_GROUP_SIZE = 450
|
constants.AI_MAX_BITER_GROUP_SIZE = 450
|
||||||
|
|
||||||
|
constants.AI_SQUAD_MERGE_THRESHOLD = constants.AI_MAX_BITER_GROUP_SIZE * 0.75
|
||||||
|
|
||||||
constants.AI_STATE_PEACEFUL = 1
|
constants.AI_STATE_PEACEFUL = 1
|
||||||
constants.AI_STATE_AGGRESSIVE = 2
|
constants.AI_STATE_AGGRESSIVE = 2
|
||||||
constants.AI_STATE_NOCTURNAL = 3
|
constants.AI_STATE_NOCTURNAL = 3
|
||||||
|
@ -26,6 +26,7 @@ local NO_RETREAT_SQUAD_SIZE_BONUS_MAX = constants.NO_RETREAT_SQUAD_SIZE_BONUS_MA
|
|||||||
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
|
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
|
||||||
|
|
||||||
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
||||||
|
local AI_SQUAD_MERGE_THRESHOLD = constants.AI_SQUAD_MERGE_THRESHOLD
|
||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
@ -152,8 +153,8 @@ function unitGroupUtils.cleanSquads(natives)
|
|||||||
local weight = natives.unitRefundAmount
|
local weight = natives.unitRefundAmount
|
||||||
|
|
||||||
local cleanSquads = {}
|
local cleanSquads = {}
|
||||||
|
|
||||||
for i=1,squadCount do
|
for i=1, squadCount do
|
||||||
local squad = squads[i]
|
local squad = squads[i]
|
||||||
local group = squad.group
|
local group = squad.group
|
||||||
if group.valid then
|
if group.valid then
|
||||||
@ -196,7 +197,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function unitGroupUtils.regroupSquads(natives)
|
function unitGroupUtils.regroupSquads(natives)
|
||||||
local groupThreshold = AI_MAX_BITER_GROUP_SIZE * 0.75
|
local groupThreshold = AI_SQUAD_MERGE_THRESHOLD
|
||||||
|
|
||||||
local squads = natives.squads
|
local squads = natives.squads
|
||||||
local squadCount = #squads
|
local squadCount = #squads
|
||||||
|
@ -42,7 +42,7 @@ function tests.activeSquads()
|
|||||||
for i=1, #global.natives.squads do
|
for i=1, #global.natives.squads do
|
||||||
local squad = global.natives.squads[i]
|
local squad = global.natives.squads[i]
|
||||||
if squad.group.valid then
|
if squad.group.valid then
|
||||||
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state)
|
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members)
|
||||||
print(serpent.dump(squad))
|
print(serpent.dump(squad))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user