From f1541b785a6ffb74222c93941db13889ce7f235e Mon Sep 17 00:00:00 2001 From: Jasson McMorris Date: Sat, 7 Sep 2024 19:58:27 -0700 Subject: [PATCH] Some Imps only aggro by sight during the night --- scripts/mixins/families/imp_aggro.lua | 33 +++++++++++++++++++ .../zones/Caedarva_Mire/mobs/Heraldic_Imp.lua | 2 +- .../zones/Caedarva_Mire/mobs/Orderly_Imp.lua | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/mixins/families/imp_aggro.lua diff --git a/scripts/mixins/families/imp_aggro.lua b/scripts/mixins/families/imp_aggro.lua new file mode 100644 index 00000000000..ca82d225a97 --- /dev/null +++ b/scripts/mixins/families/imp_aggro.lua @@ -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 diff --git a/scripts/zones/Caedarva_Mire/mobs/Heraldic_Imp.lua b/scripts/zones/Caedarva_Mire/mobs/Heraldic_Imp.lua index 69d11f75898..a21515696de 100644 --- a/scripts/zones/Caedarva_Mire/mobs/Heraldic_Imp.lua +++ b/scripts/zones/Caedarva_Mire/mobs/Heraldic_Imp.lua @@ -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 = {} diff --git a/scripts/zones/Caedarva_Mire/mobs/Orderly_Imp.lua b/scripts/zones/Caedarva_Mire/mobs/Orderly_Imp.lua index 4400a71b70e..2f7eebaa4f6 100644 --- a/scripts/zones/Caedarva_Mire/mobs/Orderly_Imp.lua +++ b/scripts/zones/Caedarva_Mire/mobs/Orderly_Imp.lua @@ -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 = {}