Thanks for the information. I can't tell because i don't use Dynamic Music. Perhaps you should ask to Dynamic Music authors. There isn't music in my mod. Perhaps Dynamic Music didn't expect combat without the PC.
New bug found in code line 193: if distToNPC < (fightV - 80) * 200 then Error:[11:52:23.534 E] L0x16d000003[scripts/wildlife_npc/wildlife.lua] callTimer failed: Lua error: [string "scripts/wildlife_npc/wildlife.lua"]:193: attempt to compare nil with number [11:52:23.534 E] stack traceback: [11:52:23.534 E] [string "scripts/wildlife_npc/wildlife.lua"]:193: in function <[string "scripts/wildlife_npc/wildlife.lua"]:148>
I suppose because distToNPC is nil which is possible because aux_util.findMinScore can return nil.
I'll try the following fix: if distToNPC and distToNPC < (fightV - 80) * 200 then
Alright. I started a new game, I did all the Seyda Neen area and quests, plus a few quests in Balmora, and the only NPC vs creature fight I noticed so far was in Addamasartus, the last bandit losing against a rat, and running for his life 😂 Maybe because I use BTB game improvements Necro Edit which increases NPC flee setting and boosts creatures, including rats
I have Lua errors when I create a new game and get out of the census office: [18:13:23.601 E] L@0x188[scripts/wildlife_npc/wildlife.lua] callTimer failed: Lua error: [string "scripts/wildlife_npc/wildlife.lua"]:157: attempt to index a nil value [18:13:23.601 E] stack traceback: [18:13:23.601 E] [string "scripts/wildlife_npc/wildlife.lua"]:157: in function <[string "scripts/wildlife_npc/wildlife.lua"]:149> The code: if types.Actor.stats.dynamic.health(self).current < 1 or ai.getActivePackage().type ~= "Wander" and ai.getActivePackage().type then return end
I printed "ai.getActivePackage()" and it sometimes equals to nil.
Thanks for the report. I can't test it because i'm out of home for 3 weeks. I thought i can test "ai.getActivePackage().type" even if it is nil. I imagine i have to test "if ai.getActivePackage()" before, for example...
Edit: i think you can come back to the 1.4 version (not 1.4.1) for the moment...
Can I change the code to: if types.Actor.stats.dynamic.health(self).current < 1 or ai.getActivePackage() ~= nil and ai.getActivePackage().type and ai.getActivePackage().type ~= "Wander" then return end
Of course, you can change as you want. But won't you get the same error with this new code? And if no, can't you do simpler?: ai.getActivePackage() ~= nil and ai.getActivePackage().type and ai.getActivePackage().type ~= "Wander"
Can you tell me? (remember, i can't test for the moment) If you confirm me a working solution i will upload a new version in place of this bugged one.
Edit: and don't you need "( )" to separate the "or" from the "and' in the test? (just to be sure)
I'm not sure what are the best conditions as I don't really understand your requirements for returning from the function:
Return if - there is an AI package and it's not Wander? - there is an AI package and it has a type and it's not Wander? - there is no AI package or there is one which is not Wander?
In my knowledge, if there is an active package, it _has_ one these 6 types: Combat or Follow or Pursue or Escort or Wander or Travel. https://openmw.readthedocs.io/en/latest/reference/lua-scripting/aipackages.html
In special cases i prefer "return" to be sure to have compatibility. But for me, an active package with type == nil is impossible. So ai.getActivePackage() ~= nil and ai.getActivePackage().type ~= "Wander" is enough for me.
I quickly looked at your code, and I think you could optimize a bit the multiple "self.recordId == "alit" or"... code by using a Lua table defined in the script root (global scope) like:
Wow, you're reactive ☺️ Your code is now more efficient and easier to read.
And just for the info, you can replace: if newAPIcreatures_fightV[self.recordId] ~= nil With if newAPIcreatures_fightV[self.recordId] As if it's different than nil it will be true.
Good question. With or without Protective Guards, guards naturally attack creatures in combat. So we can say they "protect" NPCs against creatures. But Protective Guards doesn't protect NPCs against NPC attacks... But it just so happens that I made a Protective Guards addition that does it! and another important thing!... See my march 20/27th post in the Protective Guards POSTS tab...
Are you confident because of the 2 passive creatures mods you're using and recommending? I use Vanilla friendly creatures and undeads expansion which does: "apart from predators and cliff racers, most creatures are passive unless you get too close".
Passive mods can help, but even without them, i'm confident: - "special" wildlife (unique ones, pets, etc...) isn't in my mod. - i'm not aware of a "normal" aggressive wildlife near a NPC - wildlife isn't very strong in general - even if a NPC were to die because of the starting conditions with my mod (that remains to be seen), it's unlikely to be an essential one.
Hi! Thank you for the great mod. Is there any workaround for music? It started to change rapidly while you are travelling near possible wildlife encounters.
For music i always recommend to remove all "battle" music (edit the files to silence sound), because music in combat is a little bit dumb, and because combat music unrealistically alerts you when an actor, that you don't notice, start to attack. Furthermore, i recommend to add silent files to "explore" music. Personally i modified to have, on average, one "time" of music for 10 "time" of silence. With that, when the music come it's a sort of gift... £:^) See this mod for example: silence.mp3
You could still use the recent openmw function for those who use a recent build if you condition the code on the Lua API version number, like we do in NCGD:
local isLuaApiRecentEnough = core.API_REVISION >= 56 If isLuaApiRecentEnough then ....
Thank you for your suggestion. But i just tried this recent openmw function (types.AIStats.fight(self)) (with a recent build) in my lua file, and i get a lua error: it can't index AIStats. I don't understand. So, for the moment, i can't add this.
And the recent builds work with my tricky mod as it is. £:^)
EDIT: Ok i understand: the right syntax is types.Actor.stats.ai.fight(self).modified. I will see that...
The Sei's Dynamic Wildlife creatures are not taken into account by my mod because they have other IDs (it's like new creatures). So, for my mod, they aren't the Morrowind wildlife creatures.
Yes, but as Sei's mod adds nearly 40 wildlife creatures (with attached mwscript), you must add those nearly 40 animals to the wildlife.lua with preset variables; it's a lot of code lines.
Yes and no: if you use the newer versions of OpenMW, you still have to add the new ID for each new creature, but you don't need to add the "preset" part. So there is less code "lines" to add (1 by creature - 'self.recordId == "<ID>" or'...). EDIT: write IDs in lowercase!
44 comments
There isn't music in my mod. Perhaps Dynamic Music didn't expect combat without the PC.
if distToNPC < (fightV - 80) * 200 then
Error:
[11:52:23.534 E] L0x16d000003[scripts/wildlife_npc/wildlife.lua] callTimer failed: Lua error: [string "scripts/wildlife_npc/wildlife.lua"]:193: attempt to compare nil with number
[11:52:23.534 E] stack traceback:
[11:52:23.534 E] [string "scripts/wildlife_npc/wildlife.lua"]:193: in function <[string "scripts/wildlife_npc/wildlife.lua"]:148>
I suppose because distToNPC is nil which is possible because aux_util.findMinScore can return nil.
I'll try the following fix:
if distToNPC and distToNPC < (fightV - 80) * 200 then
I think your fix is good.
If you can confirm me, i will publish the new version.
I started a new game, I did all the Seyda Neen area and quests, plus a few quests in Balmora, and the only NPC vs creature fight I noticed so far was in Addamasartus, the last bandit losing against a rat, and running for his life 😂
Maybe because I use BTB game improvements Necro Edit which increases NPC flee setting and boosts creatures, including rats
[18:13:23.601 E] L@0x188[scripts/wildlife_npc/wildlife.lua] callTimer failed: Lua error: [string "scripts/wildlife_npc/wildlife.lua"]:157: attempt to index a nil value
[18:13:23.601 E] stack traceback:
[18:13:23.601 E] [string "scripts/wildlife_npc/wildlife.lua"]:157: in function <[string "scripts/wildlife_npc/wildlife.lua"]:149>
The code:
if types.Actor.stats.dynamic.health(self).current < 1
or ai.getActivePackage().type ~= "Wander" and ai.getActivePackage().type then
return
end
I printed "ai.getActivePackage()" and it sometimes equals to nil.
I thought i can test "ai.getActivePackage().type" even if it is nil. I imagine i have to test "if ai.getActivePackage()" before, for example...
Edit: i think you can come back to the 1.4 version (not 1.4.1) for the moment...
if types.Actor.stats.dynamic.health(self).current < 1
or ai.getActivePackage() ~= nil and ai.getActivePackage().type and ai.getActivePackage().type ~= "Wander" then
return
end
But won't you get the same error with this new code? And if no, can't you do simpler?: ai.getActivePackage() ~= nil and
ai.getActivePackage().type andai.getActivePackage().type ~= "Wander"Can you tell me? (remember, i can't test for the moment) If you confirm me a working solution i will upload a new version in place of this bugged one.
Edit: and don't you need "( )" to separate the "or" from the "and' in the test? (just to be sure)
I'm not sure what are the best conditions as I don't really understand your requirements for returning from the function:
Return if
- there is an AI package and it's not Wander?
- there is an AI package and it has a type and it's not Wander?
- there is no AI package or there is one which is not Wander?
Yes, this one.
So i imagine it's: ai.getActivePackage() ~= nil and ai.getActivePackage().type ~= "Wander". It's enough, no?
I don't think we could have a package with a nil type? But if it happened, we would not return, is it ok?
In my knowledge, if there is an active package, it _has_ one these 6 types: Combat or Follow or Pursue or Escort or Wander or Travel.
https://openmw.readthedocs.io/en/latest/reference/lua-scripting/aipackages.html
In special cases i prefer "return" to be sure to have compatibility. But for me, an active package with type == nil is impossible. So
ai.getActivePackage() ~= nil and ai.getActivePackage().type ~= "Wander"
is enough for me.local creatureIds = {
["alit"] = true,
["other"] = true,
...
}
And then just test:
if creatureIds[self.recordId] then...
elseif self.recordId == "alit_blighted" then
fightV = fight_alitBlg
wildlife = "preset"
...
With another Lua table like:
local fightValues = {
["alit_blighted"] = 90,
["alit_diseased"] = 90,
...
}
And then:
local fightV = fightValues[self.recordId]
if fightV ~= nil then
wildLife = "preset"
end
Lua tables allow to do only one check instead of multiple "or" checks.
Your code is now more efficient and easier to read.
And just for the info, you can replace:
if newAPIcreatures_fightV[self.recordId] ~= nil
With
if newAPIcreatures_fightV[self.recordId]
As if it's different than nil it will be true.
With or without Protective Guards, guards naturally attack creatures in combat. So we can say they "protect" NPCs against creatures.
But Protective Guards doesn't protect NPCs against NPC attacks...
But it just so happens that I made a Protective Guards addition that does it! and another important thing!... See my march 20/27th post in the Protective Guards POSTS tab...
But I'm pretty confident.
I use Vanilla friendly creatures and undeads expansion which does: "apart from predators and cliff racers, most creatures are passive unless you get too close".
Passive mods can help, but even without them, i'm confident:
- "special" wildlife (unique ones, pets, etc...) isn't in my mod.
- i'm not aware of a "normal" aggressive wildlife near a NPC
- wildlife isn't very strong in general
- even if a NPC were to die because of the starting conditions with my mod (that remains to be seen), it's unlikely to be an essential one.
Furthermore, i recommend to add silent files to "explore" music. Personally i modified to have, on average, one "time" of music for 10 "time" of silence. With that, when the music come it's a sort of gift... £:^) See this mod for example: silence.mp3
I love your idea 😍
You could still use the recent openmw function for those who use a recent build if you condition the code on the Lua API version number, like we do in NCGD:
local isLuaApiRecentEnough = core.API_REVISION >= 56
If isLuaApiRecentEnough then ....
But i just tried this recent openmw function (types.AIStats.fight(self)) (with a recent build) in my lua file, and i get a lua error: it can't index AIStats. I don't understand. So, for the moment, i can't add this.
And the recent builds work with my tricky mod as it is. £:^)
EDIT: Ok i understand: the right syntax is types.Actor.stats.ai.fight(self).modified. I will see that...