2017-05-19 00:47:24 -07:00
|
|
|
local aiPredicates = {}
|
|
|
|
|
|
|
|
-- imports
|
|
|
|
|
|
|
|
local constants = require("Constants")
|
|
|
|
|
|
|
|
-- constants
|
|
|
|
|
|
|
|
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
|
2017-11-20 23:27:03 -08:00
|
|
|
local AI_STATE_NOCTURNAL = constants.AI_STATE_NOCTURNAL
|
2017-05-19 00:47:24 -07:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
|
|
|
function aiPredicates.canAttack(natives, surface)
|
2018-02-02 22:40:01 -08:00
|
|
|
return ((natives.state == AI_STATE_AGGRESSIVE) or aiPredicates.canAttackDark(natives, surface)) and not surface.peaceful_mode
|
2017-05-19 00:47:24 -07:00
|
|
|
end
|
|
|
|
|
2017-11-20 23:27:03 -08:00
|
|
|
function aiPredicates.isDark(surface)
|
|
|
|
return surface.darkness > 0.65
|
|
|
|
end
|
|
|
|
|
|
|
|
function aiPredicates.canAttackDark(natives, surface)
|
|
|
|
return aiPredicates.isDark(surface) and natives.state == AI_STATE_NOCTURNAL
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-05-19 00:47:24 -07:00
|
|
|
return aiPredicates
|