2019-02-15 20:17:30 -08:00
|
|
|
if (aiPredicatesG) then
|
|
|
|
return aiPredicatesG
|
|
|
|
end
|
2017-05-19 00:47:24 -07:00
|
|
|
local aiPredicates = {}
|
|
|
|
|
|
|
|
-- imports
|
|
|
|
|
|
|
|
local constants = require("Constants")
|
|
|
|
|
|
|
|
-- constants
|
|
|
|
|
2018-02-09 23:57:04 -08:00
|
|
|
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
|
2017-05-19 00:47:24 -07:00
|
|
|
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
|
2018-02-14 00:28:42 -08:00
|
|
|
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
|
2018-02-18 20:18:04 -08:00
|
|
|
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
|
2019-02-08 21:48:00 -08:00
|
|
|
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
|
2017-05-19 00:47:24 -07:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
2020-05-19 19:37:16 -07:00
|
|
|
function aiPredicates.canAttack(natives, surface, tick)
|
|
|
|
local goodAI = (((natives.state == AI_STATE_AGGRESSIVE) and (natives.canAttackTick > tick)) or
|
|
|
|
(natives.state == AI_STATE_RAIDING) or
|
|
|
|
(natives.state == AI_STATE_ONSLAUGHT))
|
2020-05-15 13:51:38 -07:00
|
|
|
local notPeaceful = not surface.peaceful_mode
|
|
|
|
local noctural = (not natives.aiNocturnalMode) or (natives.aiNocturnalMode and surface.darkness > 0.65)
|
|
|
|
return goodAI and notPeaceful and noctural
|
2017-05-19 00:47:24 -07:00
|
|
|
end
|
|
|
|
|
2019-02-02 22:01:28 -08:00
|
|
|
function aiPredicates.canMigrate(natives, surface)
|
2018-02-12 23:10:17 -08:00
|
|
|
return ((natives.state == AI_STATE_MIGRATING) or
|
2019-10-19 12:13:48 -07:00
|
|
|
(natives.state == AI_STATE_SIEGE))
|
2019-02-08 20:37:33 -08:00
|
|
|
and natives.expansion
|
2019-04-24 23:13:22 -07:00
|
|
|
and not surface.peaceful_mode
|
2019-02-05 22:25:43 -08:00
|
|
|
and ((not natives.aiNocturnalMode) or
|
|
|
|
(natives.aiNocturnalMode and surface.darkness > 0.65))
|
2017-11-20 23:27:03 -08:00
|
|
|
end
|
|
|
|
|
2019-02-15 20:17:30 -08:00
|
|
|
aiPredicatesG = aiPredicates
|
2017-05-19 00:47:24 -07:00
|
|
|
return aiPredicates
|