1
0
mirror of https://github.com/veden/Rampant.git synced 2025-02-07 13:31:36 +02:00
Rampant/libs/AIPredicates.lua

30 lines
668 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)
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