1
0
mirror of https://github.com/veden/Rampant.git synced 2025-02-11 13:39:05 +02:00
Rampant/libs/AIPredicates.lua

32 lines
725 B
Lua
Raw Normal View History

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)
2017-11-20 23:27:03 -08:00
return (((natives.state == AI_STATE_AGGRESSIVE) or aiPredicates.canAttackDark(natives, surface))
2018-01-13 21:48:21 -08:00
and not surface.peaceful_mode -- and (#natives.squads < natives.maxSquads)
)
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