Cracking Open Combat

Discuss modding questions and implementation details.
Post Reply
User avatar
mikeprichard
Posts: 871
Joined: Sun Feb 19, 2017 6:49 pm

Re: Cracking Open Combat

Post by mikeprichard » Wed Dec 11, 2019 11:47 pm

l3lessed wrote:
Wed Dec 11, 2019 9:45 pm
I made a mistake on understanding the stealth code flow, and it led me to misunderstand how this is working some. (...)
Wow, great work! Again, trying to keep things very simple for both my understanding and purposes of the wiki (while still linking to this discussion for those who want more detail), is the below proposed revised wiki text accurate as far as it goes? One area I'm still unsure about is how exactly the "half base speed/playerMotor.IsMovingLessThanHalfSpeed" etc. language translates to the in-game controls of crouching/sneaking/walking/running, as well as whether crouching (assuming crouching is also considered less than or equal to "base sneak speed", which I believe is in turn equivalent to "half base speed"?)/sneaking is advantageous in terms of maintaining stealth over walking/running in the situation where the enemy has yet to "see"/"hear"/"encounter" you - so the final two sentences in the below proposed language may or may not be accurate. It also appears "ambient light" isn't actually a direct factor, so I've tentatively removed that prior language. Finally, I'm a bit confused about the terms used and the order of the enemy "seeing"/"hearing" vs. "detecting"/"finding"/"encountering" you in your description. However, without complicating this even further, I'll just let you critique the proposed text if you'd be so kind, suggesting any specific corrections you think necessary:

Whenever you approach a creature and enter its detection range, your Stealth skill is automatically checked to determine whether the creature successfully detects you and (if hostile) engages you in active combat. In addition to your Stealth skill value, other factors affect your chance of successfully avoiding the creature's detection, including the creature's Stealth skill, your distance from and location in relation to the creature, and your movement speed. If the creature has initially seen and/or heard you, leaving the creature's sight and hearing range and then moving more slowly - i.e. by crouching or sneaking instead of walking or running - will enable you to continue to attempt to avoid detection, while walking or running will result in detection by the creature. On the other hand, if the creature has not yet seen or heard you, you may continue to attempt to avoid detection while moving at any speed.
l3lessed wrote:
Wed Dec 11, 2019 10:24 pm
As for the shield (...)
Thanks for digging into this other issue as well! My layman's read of the code you copied indicates shields are also subject to the same display discrepancy as other armor pieces, such that their armor rating values shown in the player paper doll as applied to the various body parts must be multiplied by 5 to determine the actual values used in the game's armor calculations, but you would know better here.

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

Re: Cracking Open Combat

Post by l3lessed » Thu Dec 12, 2019 8:01 pm

Seeing & Hearing are sense routines. Think of these as your olfactory and the visual cortex of the human brian, but a super simple code version of it. Anytime a thing wants to see or hear something, it activates these routines, just as a human brains visual cortex or olfactory network will activate when it needs to see or hear something. We just do it continuously and at an unfathomable data processing rate compared to computers, even the most advanced AI (but, the AI is catching up very quickly now with how much it can process all at once through your brain).

Detecting and finding are merely two other separate routines. They would be the equivalent of humans neural network for survival responses/flight or fight. Once the thing, using the above routines, sees/hears something, then the response routines kick in, which are to begin moving towards the place of the last known threat (AKA fight response). This is the equivalent of you carefully checking out a loud bang you heard coming from your backyard. You heard something that is a possible unknown threat, your brains subconscious survival mechanics respond with either preparing for a engagement/fight or preparing for protection/flight. Enemies just default automatically to the fight response and head to find and confront the threat.

the encountered trigger seems confusing, but it really isn't once you understand the code flow. It merely stays false, until an enemy sees or hears you, and then it flips to true for 8 hours. At that point, no more running around and remaining unfound, got to keep it under half base speed. So, you better use the walk and crouch movements wisely at this point, as someone knows there is something in the area.

So, to me, that description works wonderfully to articulate that in a clear way.
Last edited by l3lessed on Thu Dec 12, 2019 9:52 pm, edited 2 times in total.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

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

User avatar
jayhova
Posts: 718
Joined: Wed Jul 19, 2017 7:54 pm
Contact:

Re: Cracking Open Combat

Post by jayhova » Thu Dec 12, 2019 8:22 pm

Here is a stupid question: At what point is there a check to see if the PC's language skills pacify the enemy? Is there a pacification check before the MOB actually detects your presence or does it come afterward?
Remember always 'What would Julian Do?'.
Windows 10 Pro 64 bit. DFU Ver. Alpha 0.10.7

User avatar
mikeprichard
Posts: 871
Joined: Sun Feb 19, 2017 6:49 pm

Re: Cracking Open Combat

Post by mikeprichard » Thu Dec 12, 2019 8:28 pm

(edited original post)
Last edited by mikeprichard on Thu Dec 12, 2019 10:25 pm, edited 2 times in total.

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

Re: Cracking Open Combat

Post by l3lessed » Thu Dec 12, 2019 9:48 pm

Here is a stupid question: At what point is there a check to see if the PC's language skills pacify the enemy? Is there a pacification check before the MOB actually detects your presence or does it come afterward?
Not dumb at all, it happens as the very last check. After everything else has failed, and before the target decides to go into fight mode and start trying to track down the thing it saw or heard, it will try a pacify check.

Makes realistic sense to me. Say you're sneaking around, not knowing what's in the area, you wouldn't begin shouting or speaking to see what friends are in the area and draw tons of attention to you. Instead, you sneak around gathering information until all of a sudden a enemy wanders in and sees you. At first, he thinks your a threat and would begin tracking and trying to kill you, like any normal creature would do to an apparent threat to its life or hard earned property. However, you start shouting out in orc, "I'm a friend, I know so and so in so and sos tribe, it's all good brother." And, back to normal the person goes, knowing you now.

So, once everything else that could stop the enemy from coming after you fails, it then has you try the pacify skill.

I'll double check this in the code flow, but that is what my mind tells me from memory of the code I read on it.
Last edited by l3lessed on Thu Dec 12, 2019 9:55 pm, edited 1 time in total.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

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

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

Re: Cracking Open Combat

Post by l3lessed » Thu Dec 12, 2019 9:55 pm

Talking about all this makes it apparent, over time, we need to add more feedback ques for this hidden mechanics that are actually critical to players success and play styles.

We need some sound or grunt for enemies who have confronted you already and are in a heightened state.
We need maybe some sort of murmur or subtle, but not actually hearble, whispering sounds that come from enemies relaxed and not hostile.
We need player movement sounds that increase and decrease based on your speed and how much sound the engine says your emitting. And so on.

Or could you make the weapon sprites go transparent while you're successfully in stealth and fade back when you're found? stuff like that would help with all the hidden mechanics that cause understandable confusion and frustrations at times.
Last edited by l3lessed on Fri Dec 13, 2019 12:36 am, edited 1 time in total.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

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

Ommamar
Posts: 503
Joined: Thu Jul 18, 2019 3:08 am

Re: Cracking Open Combat

Post by Ommamar » Thu Dec 12, 2019 10:14 pm

This is the equivalent of you carefully checking out a loud bang you heard coming from your backyard. You heard something that is a possible unknown threat, your brains subconscious survival mechanics respond with either preparing for a engagement/fight or preparing for protection/flight. Enemies just default automatically to the fight response and head to find and confront the threat.-l3lessed

I wonder if after a certain point this shouldn't be adjusted, logically it would make sense for things like rats and bats to move away from you unless cornered. For reasoning opponents maybe a simple decision flag based of what equipment they see, so if you have full Adamantium equipment that glows with magic compared to their leather or chain armor and steel weapon. It would make sense for them to avoid a fight with someone obviously skilled and well equipped, instead of rushing to attack that person. This might be a far future implementation but it would add to the I am powerful feel and would make sense for it to work that way.

User avatar
mikeprichard
Posts: 871
Joined: Sun Feb 19, 2017 6:49 pm

Re: Cracking Open Combat

Post by mikeprichard » Thu Dec 12, 2019 10:25 pm

l3lessed wrote:
Thu Dec 12, 2019 8:01 pm
(...)
At that point, no more running around and remaining unfound, got to keep it under half base speed. So, you better use the walk and crouch movements wisely at this point, as someone knows there is something in the area.
Thanks for taking the time to explain - that's very clear now! Although it sounds like you're OK with my final above proposed underlined text, the only remaining point I'd like to ensure is correct actually relates to my initial question re: walking vs. running. Specifically, will you please confirm which of the following (if either) bits is accurate? Differences between the two versions are underlined. After your confirmation, I'll finally post to the wiki the above text with any further tweaks as needed per the below, with credit/link to you here in the page update notes. (EDIT: I now think after rereading your above quote that version 2) below is correct - i.e. walking is still considered "under half base speed" and will still allow stealth checks after the enemy initially detected you, but only running won't (you also say "you better use the walk and crouch movements wisely at this point") - but please let me know!)

1)...If the creature has initially seen and/or heard you, leaving the creature's sight and hearing range and then moving more slowly - i.e. by crouching or sneaking instead of walking or running - will enable you to continue to attempt to avoid detection, while walking or running will result in detection by the creature.

2)...If the creature has initially seen and/or heard you, leaving the creature's sight and hearing range and then moving more slowly - i.e. by walking, crouching, or sneaking instead of running - will enable you to continue to attempt to avoid detection, while running will result in detection by the creature.

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

Re: Cracking Open Combat

Post by l3lessed » Fri Dec 13, 2019 12:26 am

dammit, every time I look at this block of code, I get all confused again and second guess myself. But, I think got it down. :lol:

Your language is confusing me with the sneaking or crouching because I thought you always had to be in sneak/stealth mode; stealth mode is a seperate mode you activate from movement mode, correct? All that matters is if you are in stealth mode or not. Before being detected, you can move at whatever speed you wish, and it will do normal stealth checks. Running, talking, crouching, it doesn't matter, just be in stealth mode.

I would play more with stealth myself in game, but at work, and apparently I broke my DFunity build without realizing how or when.

Once seen, you can only move half speed, and if you do, the enemy will keep trying to hear or see you (AkA doing continual stealth checks, until they do see or hear you) . If they don't it will keep doing normal stealth checks. You can stay like this as long as you want, just don't fail a stealth check.

The moment you begin moving faster than half base speed, you are automatically found/unstealthed, and there is no way of stopping it.

Simple way of thinking about it is, you can do stealth checks at any movement speed before being detected.

After being detected, you can only do stealth checks if you stay below half base speed. (I just don't know what speed walking and crouching are compared to base speed)

Sorry if I'm not making it clear for the wiki description. Think we are on the same page at this point and are getting more confused by our language choices.

simplest phrasing I can think of is, you can sneak at any speed before being detected(Seen or Heard). After, you must stay below 50% movement speed or you are automatically revealed.

Also, one small thing I didn't point out before, at the beginning of every update, the enemy will try to see if it can sense a target or if your within a certain classic range of them and will mark you as detected. Enemies, based on classic mechanics in the code, automatically detect you within a small range, and if they can't, then they go for line of site. I imagine this is to stop you from being able to hide when a enemy bumps right into or next to you. Think of this as peripheral vision; humans detect allot of things from senses around them and don't know it; consider how many times you sensed something via just being in its vicinity and using peripheral senses.

This is a little different than everything up to this point. This is the very first trigger to ensure, if the enemy is right next to you or can see you, he automatically kicks you out of stealth. If not, then everything else we have been covering kicks into gear.

Code to detect if you are within classic spawn range:

Code: Select all

 if (distanceToPlayer < 1094 * MeshReader.GlobalScale)
                {
                    float upperXZ;
                    float upperY = 0;
                    float lowerY = 0;
                    bool playerInside = GameManager.Instance.PlayerGPS.GetComponent<PlayerEnterExit>().IsPlayerInside;

                    if (!playerInside)
                    {
                        upperXZ = classicSpawnDespawnExterior;
                    }
                    else
                    {
                        if (!wouldBeSpawnedInClassic)
                        {
                            upperXZ = classicSpawnXZDist;
                            upperY = classicSpawnYDistUpper;
                            lowerY = classicSpawnYDistLower;
                        }
                        else
                        {
                            upperXZ = classicDespawnXZDist;
                            upperY = classicDespawnYDist;
                        }
                    }

                    float YDiffToPlayer = transform.position.y - player.transform.position.y;
                    float YDiffToPlayerAbs = Mathf.Abs(YDiffToPlayer);
                    float distanceToPlayerXZ = Mathf.Sqrt(distanceToPlayer * distanceToPlayer - YDiffToPlayerAbs * YDiffToPlayerAbs);

                    wouldBeSpawnedInClassic = true;

                    if (distanceToPlayerXZ > upperXZ)
                        wouldBeSpawnedInClassic = false;

                    if (playerInside)
                    {
                        if (lowerY == 0)
                        {
                            if (YDiffToPlayerAbs > upperY)
                                wouldBeSpawnedInClassic = false;
                        }
                        else if (YDiffToPlayer < lowerY || YDiffToPlayer > upperY)
                            wouldBeSpawnedInClassic = false;
                    }
                }
                else
                    wouldBeSpawnedInClassic = false;
            }     
            
Code to mark you as detected if within a small spawn area or within line of site. If not, no target is found.

Code: Select all

// If out of classic spawn range, still check for direct LOS to player so that enemies who see player will
                // try to attack.
                if (!wouldBeSpawnedInClassic)
                {
                    distanceToTarget = distanceToPlayer;
                    directionToTarget = toPlayer.normalized;
                    playerInSight = CanSeeTarget(player);
                }
                
                                if (classicTargetUpdateTimer > 5)
                {
                    classicTargetUpdateTimer = 0f;

                    // Is enemy in area around player or can see player?
                    if (wouldBeSpawnedInClassic || playerInSight)
                    {
                        GetTargets();

                        if (target != null && target != player)
                            targetSenses = target.GetComponent<EnemySenses>();
                        else
                            targetSenses = null;
                    }
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

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

User avatar
mikeprichard
Posts: 871
Joined: Sun Feb 19, 2017 6:49 pm

Re: Cracking Open Combat

Post by mikeprichard » Fri Dec 13, 2019 2:48 am

l3lessed wrote:
Fri Dec 13, 2019 12:26 am
dammit, every time I look at this block of code, I get all confused again and second guess myself. But, I think got it down. :lol:
Believe me, if anyone is causing the confusion here, it's me - as again proven with some of my other recent posts, it's probably the thing I do best. (https://www.youtube.com/watch?v=WcYG-5b7448) That said, allow me to take advantage of your monumental patience and take one more stab at this now that I think I see where we're both coming from.

As far as I'm aware/remember from other discussions on the forum long ago, and unless some code is found to prove otherwise, there is no "stealth mode" in the sense I think you're referring to. The "Steal (interaction) Mode" is entirely separate from this discussion, while the "sneak" control (to be revisited in a minute), again as far as I'm aware and have read elsewhere, has no proven direct relationship - as a prerequisite, etc. - to actual "Stealth" skill/detection checks of the kind we care about.

What I'm focusing on, and what earlier discussions have touched upon - e.g. viewtopic.php?f=4&t=260&start=50#p29226 - is the player's "movement speed", which does seem to be the operative factor in the discussion we're having here. The player's movement at any time may have one of four speeds: running (through the "run" control), walking (default), crouch-walking (through the "crouch" control, which in Daggerfall is also practically used to move under things), and sneaking (through the "sneak" control, which again, is not proven to actually be directly related to Stealth checks per se - although it is indirectly related in the sense that both crouch-walking and sneaking appear to be the same reduced level of speed). So what I think everything comes down to in the code you've shown is which of these four movement speeds equate to "half base speed". I'm confident that both crouch-walking and sneaking are under the threshold of "half base speed", and running certainly is faster than "half base speed", but although the equally patient and legendary forum user Jay_H in the topic I just linked above implied that default walking speed would also pass under this "half base speed" threshold and therefore could be done without automatically kicking you out of Stealth when the enemy is in heightened detection mode, I can't find proof of this. So, I find myself back at my original question (although I've learned a lot from you on the way!), as it seems nobody has been able to find in the code the proven relationship showing where the default walking speed falls in relation to "half base speed" for this purpose.

I'd understand if you just want to move on with your life at this point. Please do comment on the above if you feel like it, but otherwise, I may just make some more limited edits to the wiki page leaving out the above stuff we may not know for sure, and leave it at that. I really do appreciate your time and detailed explanations here regardless!

Post Reply