Skip to content

Commit

Permalink
Some Imps only aggro by sight during the night
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcmorris committed Sep 8, 2024
1 parent 65e64d3 commit f1541b7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions scripts/mixins/families/imp_aggro.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require('scripts/globals/mixins')
-----------------------------------
xi = xi or {}
xi.mix = xi.mix or {}
xi.mix.imp_aggro = xi.mix.imp_aggro or {}

g_mixins = g_mixins or {}
g_mixins.families = g_mixins.families or {}

local function updateAggro(mob, hour)
mob:setLocalVar('hour', hour);

if hour >= 18 or hour < 6 then
mob:setMobMod(xi.mobMod.DETECTION, bit.bor(xi.detects.SIGHT, xi.detects.HEARING))
elseif hour < 18 and hour >= 6 then
mob:setMobMod(xi.mobMod.DETECTION, xi.detects.HEARING)
end
end

g_mixins.families.imp_aggro = function(mob)
mob:addListener('SPAWN', 'IMP_AGGRO_SPAWN', function(imp)
updateAggro(imp, VanadielHour())
end)

mob:addListener('ROAM_TICK', 'IMP_AGGRO_ROAM_TICK', function(imp)
local hour = VanadielHour()
if hour ~= imp:getLocalVar('hour') then
updateAggro(imp, hour)
end
end)
end

return g_mixins.families.imp_aggro
2 changes: 1 addition & 1 deletion scripts/zones/Caedarva_Mire/mobs/Heraldic_Imp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Area: Caedarva Mire
-- Mob: Heraldic Imp
-----------------------------------
mixins = { require('scripts/mixins/families/imp') }
mixins = { require('scripts/mixins/families/imp'), require('scripts/mixins/families/imp_aggro') }
-----------------------------------
---@type TMobEntity
local entity = {}
Expand Down
2 changes: 1 addition & 1 deletion scripts/zones/Caedarva_Mire/mobs/Orderly_Imp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Area: Caedarva Mire
-- Mob: Orderly Imp
-----------------------------------
mixins = { require('scripts/mixins/families/imp') }
mixins = { require('scripts/mixins/families/imp'), require('scripts/mixins/families/imp_aggro') }
-----------------------------------
---@type TMobEntity
local entity = {}
Expand Down

0 comments on commit f1541b7

Please sign in to comment.