reenable NPCs even if option to disable is off

This commit is contained in:
Lilian Jónsdóttir 2020-08-25 00:32:54 -07:00
parent 51760a27f6
commit 3215de5c01

View file

@ -117,8 +117,6 @@ this.putNPCsBack = function()
end end
this.processNPCs = function(cell) this.processNPCs = function(cell)
-- todo: move this check somewhere else, so that disabled NPCs will be re-enabled even if the option is off
if not config.disableNPCs then return end
log(common.logLevels.small, "Looking for NPCs to process in cell:%s", cell.id) log(common.logLevels.small, "Looking for NPCs to process in cell:%s", cell.id)
@ -140,26 +138,24 @@ this.processNPCs = function(cell)
-- disable or move NPCs -- disable or move NPCs
if (checks.checkTime() or (checks.checkWeather(cell) and if (checks.checkTime() or (checks.checkWeather(cell) and
(not checks.isBadWeatherNPC(npc) or (checks.isBadWeatherNPC(npc) and not config.keepBadWeatherNPCs)))) then (not checks.isBadWeatherNPC(npc) or (checks.isBadWeatherNPC(npc) and not config.keepBadWeatherNPCs)))) then
if npcHome then if config.disableNPCs then -- this way, even if the option is off, disabled NPCs will get reenabled
this.moveNPC(npcHome) if npcHome then
-- elseif not npc.data.NPCsGoHome.modified then this.moveNPC(npcHome)
elseif not npc.disabled then elseif not npc.disabled then
log(common.logLevels.medium, "Disabling homeless %s", npc.object.name) log(common.logLevels.medium, "Disabling homeless %s", npc.object.name)
-- npc:disable() -- ! this one sometimes causes crashes -- npc:disable() -- ! this one sometimes causes crashes
mwscript.disable({reference = npc}) -- ! this one is deprecated mwscript.disable({reference = npc}) -- ! this one is deprecated
-- tes3.setEnabled({reference = npc, enabled = false}) -- ! but this one causes crashes too -- tes3.setEnabled({reference = npc, enabled = false}) -- ! but this one causes crashes too
-- npc.data.NPCsGoHome.modified = true else
else log(common.logLevels.medium, "Didn't do anything with %s", npc.object.name)
log(common.logLevels.medium, "Didn't do anything with %s", npc.object.name) end
end end
else else
-- if not npcHome and npc.data.modified then
if not npcHome and npc.disabled then if not npcHome and npc.disabled then
log(common.logLevels.medium, "Enabling homeless %s", npc.object.name) log(common.logLevels.medium, "Enabling homeless %s", npc.object.name)
-- npc:enable() -- npc:enable()
mwscript.enable({reference = npc}) mwscript.enable({reference = npc})
-- tes3.setEnabled({reference = npc, enabled = true}) -- tes3.setEnabled({reference = npc, enabled = true})
-- npc.data.NPCsGoHome.modified = false
end end
end end
end end