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
|
|
|
|
|
2018-02-10 09:57:04 +02:00
|
|
|
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
|
2017-05-19 09:47:24 +02:00
|
|
|
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
|
2018-02-14 10:28:42 +02:00
|
|
|
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
|
2018-02-19 06:18:04 +02:00
|
|
|
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
|
2019-02-09 07:48:00 +02:00
|
|
|
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
|
2017-05-19 09:47:24 +02:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
2021-02-20 07:41:30 +02:00
|
|
|
function aiPredicates.canAttack(native, tick)
|
|
|
|
local surface = native.surface
|
|
|
|
local goodAI = (((native.state == AI_STATE_AGGRESSIVE) and (native.canAttackTick > tick)) or
|
|
|
|
(native.state == AI_STATE_RAIDING) or
|
|
|
|
(native.state == AI_STATE_ONSLAUGHT))
|
2020-05-15 22:51:38 +02:00
|
|
|
local notPeaceful = not surface.peaceful_mode
|
2021-02-20 07:41:30 +02:00
|
|
|
local noctural = (not native.aiNocturnalMode) or (native.aiNocturnalMode 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 07:41:30 +02:00
|
|
|
function aiPredicates.canMigrate(native)
|
|
|
|
local surface = native.surface
|
|
|
|
return ((native.state == AI_STATE_MIGRATING) or
|
|
|
|
(native.state == AI_STATE_SIEGE))
|
|
|
|
and native.expansion
|
2019-04-25 08:13:22 +02:00
|
|
|
and not surface.peaceful_mode
|
2021-02-20 07:41:30 +02:00
|
|
|
and ((not native.aiNocturnalMode) or
|
|
|
|
(native.aiNocturnalMode and surface.darkness > 0.65))
|
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
|