resting and consequences

Talk about the mods you'd like to see in Daggerfall Unity. Give mod creators some ideas!
User avatar
Blue Footed Booby
Posts: 17
Joined: Wed Jun 14, 2017 4:32 pm

Re: resting and consequences

Post by Blue Footed Booby »

l3lessed wrote: Wed Aug 04, 2021 7:56 pm
another thing, is it possible to make the magical door lock (fenrik's door jam / wizard lock) override enemies being nearby, if you lock a door in a dungeon? so you can rest nicely, if you have a good door lock ability :)
Finding the door wouldn't be hard; It could be done using the built in block data that contains all the doors properties within it or you could do a ray/spherecast from player center out a certain range and have it return upon successfully hitting the door object.

However, the hard part is, how will you know if the player is in the room or in the hallway outside the room? You would have to do more calculations to figure out the area around the player and then assume the bigger area would be the room. However, that assumption isn't even safe.

Or, because all doors start closed, you could create a list/array to store the location the player opens the door at, set that as the location of the hall, and then use that to figure out if the player is on the other side of the door/hall by just calculating the players position from the position of where they opened the door. However, what happens if a monster/npc opens a door? Now it won't work.

Maybe if all doors have a properly places front and back, that could be used. The front would face towards the hall area and the back would face the room. If that is the case, then you could use this as the easiest possible solution. Detect if the player is facing the back of the door (aka is in the room) using the object's and player's rotation/yaw/position properties, and if so, and the door is closed, we get safe sleep.

It can be done, but as said, you would need to be creative and really consider all the issues of code trying to figure out the subjectivity of an area being considered a room or not.
I think maybe you're solving the wrong problem. The goal isn't to determine if the player is in a locked room, it's to figure out if enemies have a way of getting to them. All it would take is a way to query the pathfinding code to figure out if there's a route from the player to any enemy (and potentially to any exit) that doesn't pass through a player-locked door. This approach would nicely handle being in an unlocked room in a locked wing of a dungeon, or resting in a hidey hole a hundred feet off the ground or something else that's unreachable despite not having a door at all.

If we want it to simulate magic-using enemies figuring out what's up it can just do a skill check on all player-locked doors and treat the door as unlocked if the check succeeds.

l3lessed
Posts: 1132
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: resting and consequences

Post by l3lessed »

I think maybe you're solving the wrong problem. The goal isn't to determine if the player is in a locked room, it's to figure out if enemies have a way of getting to them. All it would take is a way to query the pathfinding code to figure out if there's a route from the player to any enemy (and potentially to any exit) that doesn't pass through a player-locked door. This approach would nicely handle being in an unlocked room in a locked wing of a dungeon, or resting in a hidey hole a hundred feet off the ground or something else that's unreachable despite not having a door at all.
What pathfinding code? The pathfinding is extremely simple and pretty much an advanced basic roaming AI. It has no awareness of the level layout itself in anyway past its raycast checks. All it knows is the players/enemies last position, where it is (stops falling over cliffs), and if there is something in the way or not(is the target in LOS or object needs moved around if player is in LOS). It uses these basic things to roam until it finds a path to the player. You ever noticed how easy it is to run from and get enemies stuck by merely turning a corner fast enough with enough distance between you and the enemy chasing you?

What you're asking for, unless I am missing something, requires writing a whole new pathfinding code to figure out a whole dungeon and then have the monster figure out every path to the player available and then have the monster figure out if that path is reachable once in the same room. Also, this is going to be pretty CPU cycle heavy because of the number and amount of calculations this would take without a built in unity pathfinding code object.

I do know unity has a built in pathfinding object that can be built at runtime, but I don't imagine it is as easy as grabbing that object and slapping it on to the dungeon blocks or terrain blocks and it will figure out all the translations between DFU base and unity engine itself. I spent a day researching it, but decided I didn't want to try and solve the issues between the built in pathfinding object and setting it up at runtime in Unity. It would need to be attached to every single interior and exterior block in the game, and that alone would be a time and labor intensive task.

Again, if you know of some method I'm unaware of for building pathfinding without having to create it from scratch, I would love to know. I just spent a week sorting out and building a basic roaming code for 3d animals using a character controller and mesh collider, and this would be much easier if I could just slap a pathfinding object on to these things and not have to code it myself. Also, I would love to have an easy pathfinding object/script/code to grab and connect, so I don't have to rebuild it for a follower framework.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply