1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-30 04:30:52 +02:00
Rampant/libs/AIPredicates.lua

42 lines
1.3 KiB
Lua
Raw Normal View History

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
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
2017-05-19 00:47:24 -07:00
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
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))
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