OpenXcom Forum

OpenXcom => Troubleshooting => Topic started by: tkzv on December 10, 2017, 06:33:20 pm

Title: Sound of hidden movement
Post by: tkzv on December 10, 2017, 06:33:20 pm
How does it work? Currently doors and gunshots are heard, but footsteps are not. I noticed that I can't hear enemy tanks in "The X-COM Files" mod, tried to experiment and concluded that tank engines are only heard if the tank starts moving where an operative can see it.

Is there any way to make loud units always audible? Or maybe this should apply to all units?

P.S. Same for vanilla nightly and OXCE+.
Title: Re: Sound of hidden movement
Post by: Hobbes on December 10, 2017, 08:44:12 pm
How does it work? Currently doors and gunshots are heard, but footsteps are not. I noticed that I can't hear enemy tanks in "The X-COM Files" mod, tried to experiment and concluded that tank engines are only heard if the tank starts moving where an operative can see it.

If you hear the footsteps before you see the unit then on the first turn you'll be able to recognize which types of aliens are present on the mission, without even seeing them. Which increases the drama and suspense.
Title: Re: Sound of hidden movement
Post by: tkzv on December 10, 2017, 10:27:18 pm
If you hear the footsteps before you see the unit then on the first turn you'll be able to recognize which types of aliens are present on the mission, without even seeing them. Which increases the drama and suspense.
Yes, that's how it should work. But it doesn't.
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 11, 2017, 02:08:59 am
not really, we don't animate what you can't see. those aliens are moving at supersonic speeds when not in view. sounds would overlap each other, and it would be a terrifying cacophony.
Title: Re: Sound of hidden movement
Post by: 7Saturn on December 11, 2017, 10:54:31 am
Except of course certain attack sounds, that slip through the fog of war.
Title: Re: Sound of hidden movement
Post by: tkzv on December 11, 2017, 10:56:37 am
not really, we don't animate what you can't see. those aliens are moving at supersonic speeds when not in view. sounds would overlap each other, and it would be a terrifying cacophony.
Then why does hidden movement take so long?

I liked how the sound was done in Apocalypse, by the way.
Title: Re: Sound of hidden movement
Post by: The Reaver of Darkness on December 11, 2017, 12:22:30 pm
sounds would overlap each other, and it would be a terrifying cacophony.
I wish I could toggle this on, just to see what it sounds like.
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 11, 2017, 12:26:59 pm
Then why does hidden movement take so long?

I liked how the sound was done in Apocalypse, by the way.

the majority of the time taken during the alien turn is used calculating courses of action
Title: Re: Sound of hidden movement
Post by: Solarius Scorch on December 11, 2017, 02:15:05 pm
the majority of the time taken during the alien turn is used calculating courses of action

I'd imagine most of it is updating/recalculating vision as AI units move?
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 12, 2017, 01:23:00 am
I'd imagine most of it is updating/recalculating vision as AI units move?
that too, pathfinding happens between actions, FoV calculations take place during movement, there are a hell of a lot of CPU cycles used on the alien turn between the two.
when the AI calculates paths, it calculates ALL of the paths using Dijkstra's algorithm (https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) before using A* (https://en.wikipedia.org/wiki/A*_search_algorithm) to define specific paths to various "points of interest".

i could go into a lot more detail, so i will:
every time the AI plans an action, it tries to create four possible scenarios: patrolling to a node, attacking an enemy, escaping from an enemy, or setting up an ambush, and then picks the one it prefers based on the situation.

The first option is fairly straightforward, if you have a defined node you want to go towards, simply find a path towards it, if you DON'T have a node defined, check through the list of nodes connected to the last node you visited and pick one based on preference, then check it can be pathed to, if not, pick again. if no options are valid, or if you're a scout, start picking nodes at random and pathing to them until you pick one you can reach. at this point, if all has gone well, patrol becomes a valid option.

the second option is less straightforward: first, take stock of the weapons you have available. if you have a melee weapon, pick the closest enemy you know about and try to path to any tile that's within melee range of them. if you have a firearm, we start to get into bat country: based on where your target is, we calculate a bunch of tiles from which a unit of your height could potentially get a shot off using a hypothetical unit to perform LoF calculations, checking to make sure you can actually path to said locations. at this point, if all has gone well, attacking is a viable option.

if you're escaping, you do something similar, only you're tracing the LoF from your enemy to a bunch of tiles that hypothetically contain a unit of your height, that you are capable of pathing to in order to find somewhere that you can move and they can't hit. if this works out escape is an option.

if you're setting up an ambush... both you and your enemy become hypothetical. you start by calculating a path from your enemy to your current position, and calculate LoF from a bunch of tiles from which a hypothetical unit of your height could shoot a hypothetical unit of your enemy's height hypothetically walking along said path, and then calculate paths to those positions that leave you enough TUs to make a reaction shot. if you find a match, ambush is on the table.

after calculating all this, you take your situation into consideration (desperation, morale, injury level, etc.) and choose a preferred option. do this all around 6 times per turn (sometimes more, sometimes less)

when you see an alien moving, the pathfinding is already done, and we can calculate the FoV between frame updates (i believe between frames 4 and 5) but when you don't see it, we simply update the unit's position and calculate the FoV every frame. you can observe this same effect by moving one of your own units that is offscreen, you'd expect him to take 10-15 seconds to appear on screen if he were walking at a normal pace, but instead they'll pop into frame after only 1 or 2.
Title: Re: Sound of hidden movement
Post by: Solarius Scorch on December 12, 2017, 04:50:17 pm
It's an awesome explanation, Warboy. Should be put somewhere visible. :)
Title: Re: Sound of hidden movement
Post by: 7Saturn on December 12, 2017, 04:57:28 pm
How about the ufopedia wiki?
Title: Re: Sound of hidden movement
Post by: The Reaver of Darkness on December 15, 2017, 12:09:30 am
It should go in the UFOPaedia wiki under Enemy Unknown (1994) > Technical Information > Game Mechanics > AI Unit Scripting (or a better name)
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 15, 2017, 07:59:59 am
hah, and to think i deliberately omitted a whole bunch of details i deemed "a bit too spoilery"
Title: Re: Sound of hidden movement
Post by: The Reaver of Darkness on December 15, 2017, 11:26:17 am
I don't see these details as spoilers at all. Anyone taking the time to read and actually understand this is way past the spoiler stage. It's not like you can post a detailed explanation of how aliens seek targets and have someone feel like their game is ruined because they can suddenly predict the aliens' movements. More likely they won't really truly understand it and the aliens will continue to surprise them about as much as before.

It's interesting for modders because it can help us understand what effects our changes will have. When we're denied information about the way the game works, it can make it hard to figure out what actual changes our mods make.
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 16, 2017, 06:26:18 am
there's no denial of information, it was a matter of brevity and staying on topic. i mean, in a thread named "Sound of hidden movement" you wouldn't expect a full write up of the complete alien behavioural routines.
Title: Re: Sound of hidden movement
Post by: The Reaver of Darkness on December 16, 2017, 08:51:16 pm
I meant in the game as a whole. The information you gave was very welcome for some of us, and most of us just won't read it. I think if you feel up to writing it, it should be publicly available in the wiki or elsewhere where we can find it.
Title: Re: Sound of hidden movement
Post by: Yankes on December 16, 2017, 09:20:47 pm
I meant in the game as a whole. The information you gave was very welcome for some of us, and most of us just won't read it. I think if you feel up to writing it, it should be publicly available in the wiki or elsewhere where we can find it.
Its available on github in "plain" text :>
Title: Re: Sound of hidden movement
Post by: tkzv on December 16, 2017, 11:31:41 pm
there's no denial of information, it was a matter of brevity and staying on topic. i mean, in a thread named "Sound of hidden movement" you wouldn't expect a full write up of the complete alien behavioural routines.
Actually, the full run-down of what unseen aliens do and how that should sound — or why that can't sound right — fits the topic perfectly.
Its available on github in "plain" text :>
Most of us have only a rudimentary understanding of the language :) And constantly need to ask to clarify something.
Title: Re: Sound of hidden movement
Post by: The_Funktasm on December 17, 2017, 07:03:39 am
Not to mention that everyone has their own tactics whether they know the logic they should work counter to or not. That's a fun and frustrating thing in game development.
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 17, 2017, 07:35:05 am
Most of us have only a rudimentary understanding of the language :) And constantly need to ask to clarify something.

i actually went out of my way to add a lot of comments and use variable names that made contextual sense in the interests of clarity and full disclosure in the AI Module, so that if a casual observer WERE to look into it, they shouldn't have a great deal of difficulty understanding it, at least on a very basic level. Meridian and Yankes can probably attest to this - there's nothing "hidden" in the code.

all that said though, i'm always willing to answer questions. (as long as they're not about reapers)
Title: Re: Sound of hidden movement
Post by: The_Funktasm on December 17, 2017, 07:46:46 am
i actually went out of my way to add a lot of comments and use variable names that made contextual sense in the interests of clarity and full disclosure in the AI Module, so that if a casual observer WERE to look into it, they shouldn't have a great deal of difficulty understanding it, at least on a very basic level. Meridian and Yankes can probably attest to this - there's nothing "hidden" in the code.

all that said though, i'm always willing to answer questions. (as long as they're not about reapers)

If a reaper falls over, how does it stand up again? (totally kidding.)
Title: Re: Sound of hidden movement
Post by: Warboy1982 on December 17, 2017, 07:57:23 am
it doesn't.
Title: Re: Sound of hidden movement
Post by: Hyper2Snyper on December 17, 2017, 08:30:47 am
I love these kinds of intelligent talks. :)
Title: Re: Sound of hidden movement
Post by: tkzv on December 19, 2017, 10:53:14 am
all that said though, i'm always willing to answer questions.
Thanks. I'll keep that in mind.

But I meant not knowing enough C++. Last time I went digging OXC code, I had to learn what an "iterator" is :)

(as long as they're not about reapers)
I'll bite. Is this sone kind of an in-joke?
Title: Re: Sound of hidden movement
Post by: Meridian on December 21, 2017, 12:18:01 pm
It would be possible to implement xcom2012-like sound cues... but it would be useful only for the player, not for the AI... and thus my interest in it is not very high.
Title: Re: Sound of hidden movement
Post by: Solarius Scorch on December 21, 2017, 12:28:13 pm
I know I've mentioned it a few times already, but UNIMOD (a huge mod for UFO: Extraterrestrials) had a very nice system of sound environment. I can outline it here if you are interested.
Title: Re: Sound of hidden movement
Post by: tkzv on December 22, 2017, 07:42:15 pm
It would be possible to implement xcom2012-like sound cues... but it would be useful only for the player, not for the AI... and thus my interest in it is not very high.
I haven't played 2012 much and don't remember what exactly was there. When I started this thread, I mistakenly expected behaviour similar to Apocalypse. In it sounds allowed to determine the species of aliens, distance travelled and rough direction. Will AI side benefit from rough target positions for area of effect weapons? I'd expect the opposite problem -- the game becoming too hard for human player, as consealment is no longer as effective. Maybe walking, running and different weapons should have different audibility ranges.