1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-16 02:33:53 +02:00
Rampant/libs/AIPredicates.lua

44 lines
1.4 KiB
Lua
Raw Normal View History

2019-02-16 06:17:30 +02:00
if (aiPredicatesG) then
return aiPredicatesG
end
2017-05-19 09:47:24 +02:00
local aiPredicates = {}
-- imports
local constants = require("Constants")
-- constants
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
2017-05-19 09:47:24 +02:00
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
2017-05-19 09:47:24 +02:00
-- imported functions
-- module code
function aiPredicates.canAttack(map)
2021-02-20 09:31:36 +02:00
local surface = map.surface
local goodAI = (((map.state == AI_STATE_AGGRESSIVE) and (map.sentAggressiveGroups < map.maxAggressiveGroups)) or
2021-02-20 09:31:36 +02:00
(map.state == AI_STATE_RAIDING) or
(map.state == AI_STATE_ONSLAUGHT))
2020-05-15 22:51:38 +02:00
local notPeaceful = not surface.peaceful_mode
2021-02-20 09:31:36 +02:00
local nocturalMode = map.universe.aiNocturnalMode
local noctural = (not nocturalMode) or (nocturalMode and surface.darkness > 0.65)
2020-05-15 22:51:38 +02:00
return goodAI and notPeaceful and noctural
2017-05-19 09:47:24 +02:00
end
2021-02-20 09:31:36 +02:00
function aiPredicates.canMigrate(map)
local surface = map.surface
local universe = map.universe
local nocturalMode = universe.aiNocturnalMode
local goodAI = (map.state == AI_STATE_MIGRATING) or (map.state == AI_STATE_SIEGE)
local noctural = (not nocturalMode) or (nocturalMode and surface.darkness > 0.65)
return goodAI and universe.expansion and not surface.peaceful_mode and noctural
2017-11-21 09:27:03 +02:00
end
2019-02-16 06:17:30 +02:00
aiPredicatesG = aiPredicates
2017-05-19 09:47:24 +02:00
return aiPredicates