aliens

Author Topic: AI and weapon range/hit chance stats  (Read 7973 times)

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
AI and weapon range/hit chance stats
« on: June 30, 2017, 12:10:40 am »
I don't have any slightest idea about the Xcom AI.. and as i see there is no AI file to edit.

So if there is people who knows how the AI works, please enlighten me. I want to edit the alien weapon stats with ranges and hit chances and even damage dropoffs.. What does AI care when it's shooting? Does it check for a hit chance limit? Does it calculate the possibility of killing the target?

For example, at Xenonauts, the AI got an acceptable hit chance limit before hit fires, like the enemy goes near you to get that chance or run out to safety. So if you give a poor acc weapon to aliens, they do not attack you, or rush you without firing until they hug you (something you don't want to see). Another example is, if the enemy thinks that, his fire power is not enough to kill, it just don't go aggressive too and go hiding or near to his other fellas.

So if i give low acc weapons, will the Xcom aliens stop shooting? What will they react to limited range weapons? Does "dropoff" work to aliens shooting too? Should i avoid some important things when coding alien weapons then?

Thx.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #1 on: June 30, 2017, 04:13:12 pm »
I don't have any slightest idea about the Xcom AI.. and as i see there is no AI file to edit.

So if there is people who knows how the AI works, please enlighten me. I want to edit the alien weapon stats with ranges and hit chances and even damage dropoffs.. What does AI care when it's shooting?

LOTS of things.

Does it check for a hit chance limit?

Yes, indirectly, based on distance.

Additionally, in OXCE+ only, there is a true hit chance limit... but it doesn't influence the "AI decision"... only prevents the AI to waste ammo on hopeless shots if it already decided to shoot and increases the odds for reaction fire later.

Does it calculate the possibility of killing the target?

Yes, it considers "how much" damage it can do, e.g. if it can grenade many people it will go for it instead of shooting.

But it doesn't calculate exact damage, ever.

Weapon's power (not damage to target) is considered on several places too... for example if to use melee or ranged weapon if you have both.

For example, at Xenonauts, the AI got an acceptable hit chance limit before hit fires, like the enemy goes near you to get that chance or run out to safety. So if you give a poor acc weapon to aliens, they do not attack you, or rush you without firing until they hug you (something you don't want to see). Another example is, if the enemy thinks that, his fire power is not enough to kill, it just don't go aggressive too and go hiding or near to his other fellas.

Xenonauts didn't have to be compatible with anything.
OpenXcom tries to mimic the original game AI as much as possible... which cost the devs a CRAP-TON of time and nerves...

Suggestions to "improve it" are, dare I say it, "not welcome"... at least not in vanilla.
Btw. they are also not welcome in OXCE+, because I want to keep "not knowing what AI does"... or at least not knowing what little there is I still don't know.

So if i give low acc weapons, will the Xcom aliens stop shooting?

No, not in vanilla.

In OXCE+, yes, if configured so. But as said before, it won't change their decision making... it just prevents them from firing.

What will they react to limited range weapons?

They will consider them as unlimited range (during decision process)... and (most probably, not sure about vanilla) fail to shoot.

Exception are melee weapons, they know they need to get in melee range.

Does "dropoff" work to aliens shooting too?

Yes.

Should i avoid some important things when coding alien weapons then?

Don't fuck them up. Aliens deserve a chance too!

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #2 on: June 30, 2017, 04:50:46 pm »
Don't get me wrong. I am at aliens side.

I just want to give them powerful weapons, but I don't want them to snipe me from far. So I nerfed badly the player weapons with range mostly. So when you can only shoot 5 tile with a pistol, it would be absurd to get hit by alien pistol from snipe range. It's same for enemies uses human weapons.

I plan to make a real short mid and long  range combat for players and I wanted to know what happens if I do this to aliens for balance.


Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #3 on: June 30, 2017, 04:59:51 pm »
There is no such thing as alien snipers. OpenXcom doesn't have "Squadsight".
They can shoot at 20 tiles max, that's it.

You _could_ increase global vision ranges up to 35 or 40 in OXCE/OXCE+ (but no more, that will kill the game performance, even with the great optimisations Stiansel made for us) and then rebalance everything... but, it's a lot of work, with an unpredictable result (success/failure).

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #4 on: June 30, 2017, 05:03:47 pm »
There is no such thing as alien snipers.
They can shoot at 20 tiles max, that's it.

You _could_ increase global vision ranges up to 35 or 40 in OXCE/OXCE+ (but no more, that will kill the game performance, even with the great optimisations Stiansel made for us) and then rebalance everything... but, it's a lot of work, with an unpredictable result (success/failure).

The problem is not about the snipers, it's short rangers.. think about a heavy plasma with 10 max range and an alien with that gun who saw you from far.. so what will happen? will he rush to shoot? will he try to assault me from shadows? will he wait? or go mad.. and simulate this with 5-6 tile range weapons.. 20 is more then enough for an alien..

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #5 on: June 30, 2017, 05:13:22 pm »
Best is to try it out.

Enable "traceAI" option in options.cfg, turn on debug mode and see what the aliens do exactly (on the screen and in the log file).

To be honest, I don't see any "modern" weapon being limited in range... it's just... unrealistic?
Maybe throwing knives, or some sort of flamethrowers could have limited range, but the rest?

20 tiles corresponds to "a small building", so 20-40 meters? Many people can throw a rock that far....

To answer your specific question: if you set max range 10 on a heavy plasma, the alien 20 tiles away will (mostly) decide to shoot... and fail to shoot (please correct me if I'm wrong on this one).
« Last Edit: June 30, 2017, 05:16:57 pm by Meridian »

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #6 on: June 30, 2017, 05:32:02 pm »
Best is to try it out.

Enable "traceAI" option in options.cfg, turn on debug mode and see what the aliens do exactly (on the screen and in the log file).

To be honest, I don't see any "modern" weapon being limited in range... it's just... unrealistic?
Maybe throwing knives, or some sort of flamethrowers could have limited range, but the rest?

20 tiles corresponds to "a small building", so 20-40 meters? Many people can throw a rock that far....

To answer your specific question: if you set max range 10 on a heavy plasma, the alien 20 tiles away will decide to shoot... and fail to shoot (please correct me if I'm wrong on this one).

Yes as range, the ballistic bullets goes mostly far then you can see. But the problem is the hit chance here. So you can shoot a rifle which got about 500 meter range, but the bullet would go crazy even you shoot it from a stable point. If you add human accuracy, the chance go really bad. As a navy officer, i know it a bit (not gun expert, just we shoot and i got some experience from that)...

So as game wise, we need something tactical for chess play, with simulating some realism. I am against pure realism at this kind of games, but i would like to have own tactical rules.

So as your example, even within the biggest map of XCOM, a SMG or bigger weapon can easily shoot far then map size. But with the hit chance dropoff, even you can have the range, your chance will be zero after a while.. as number example: you got a simple rifle with limitless range but gets "0" hit chance after 20 tile.  So a new player who does not this, could try to fire everywhere with his rifle. You can tell me that "the game shows you the acc per tile, so the player would not shoot if he saw zero.." and yeah.. maybe.. i am still at planning phase.. i can just use maxAimed, maxSnap, maxAuto.. which is possible..

If i use unlimited range for mid to large weapons but acc dropoff then Aliens could start to shoot with 0 percent.. so it's important to code it right for both sides. Most of alien weapons could not be used by XCOM directly so i can code them different.. this was the reason i asked the AI.. and the dropoff in percentage..

My poor english does not allow me to explain myself well enough at complex things. I am a modder who plans and thinks every possiblity probably like PirateZ.. so don't expect something simple from me..


Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #7 on: June 30, 2017, 06:02:02 pm »
I am a modder who plans and thinks every possiblity probably like PirateZ.. so don't expect something simple from me..

As long as real lifetm allows, and I see potential in the modder (i.e. their spirit lasts for more than 3 months :) ), I will gladly help if I can. I can't promise everything, but we did some really cool things with piratez already, no reason to stop now. There are boundaries tho, be prepared for compromises.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #8 on: June 30, 2017, 06:35:33 pm »
We're also having a discussion to add some spotter/sniper tactics the the AI in OXCE+, this might be useful for you.

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #9 on: June 30, 2017, 07:05:00 pm »
As long as real lifetm allows, and I see potential in the modder (i.e. their spirit lasts for more than 3 months :) ), I will gladly help if I can. I can't promise everything, but we did some really cool things with piratez already, no reason to stop now. There are boundaries tho, be prepared for compromises.

Yeah that 3 month life span of the modder.. I done it for 2+ years at xenonauts to make"perfect" game for me, with nearly not playing it at all.. heh.. paradox.. I stopped because i saw that i done more then it should as game wise.. it's like "more is not better" so everything should have a limit, a line where it should stop.. i should do less.. some people can get confused with 1000+ research and it's xpedias.. I finished my part and other people still continue to improve it. So as short, i hope i can go more then 3 month :), at least i know what i want and use to mod this kind of games.

The biggest problem is being alone at making a mod for a game. XCOM modding is still alive, i can ask you something, we can discuss it.. Sadly i was very late to xenonauts modding when there are people who is modding it.. that hype is important. I am an old guy anyway as 35+... i like to create and see it working on a game rather then playing it. But as i said, i overdone it more then enough and i start to not like what i done... i wish i go back and change things, make it more simple, more wise..  It's still something crazy but not for my dream anymore.. but i was too late so i stop it and wanted to give a chance to myself at openxcom..

So back to the topic. I will see what AI can do after i handled the weapon coding.. Thanks for your helping with patience.

We're also having a discussion to add some spotter/sniper tactics the the AI in OXCE+, this might be useful for you.

XCOM map sizes and styles are not so good for sniping.. for both sides.. as vanilla game, every alien with plasma rifle or heavy plasma are simply "snipers" because they can shoot you well enough from far points as the map allows.. so you try to counter it with tons of auto shots with praying hit chance god to kill a single guy.. As a vanilla style lover and FMP player, i saw that maps are already very crowded.. I mean at terror sites, there are tons of buildings, at small ufo sites, there is tons of natural blocks with different highs, at big ufos, there is just ufo.. i try to say that, there is not much maps for range play as i see..

I am not a map maker, never was. I won't create maps in the future too so i stuck with what i can have from others.

As i said, the vanilla AI is already snipers at my eyes.. it could improve of course. BUT the real deal is close combat AI where the AI can ambush you or wait/find best time to attack. And an aggressive AI which will make you stuck where you are with suppression firing non-stop..

another question is.. if i give an alien more then one ranged weapon, like a long range mid damage and short range high damage gun, will it change that weapons? Can AI swap weapons to choose the best as ranged?

Offline Dioxine

  • Commander
  • *****
  • Posts: 5412
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: AI and weapon range/hit chance stats
« Reply #10 on: June 30, 2017, 08:12:58 pm »
1. If an alien has a limited range weapon, and it decides to shoot when the target is beyond that range, it will freeze (skip its turn).
2. If an alien has more than 1 ranged weapon, it will completely ignore the one with the higher Snap Shot TU cost.

Improvements would be welcome :)

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #11 on: June 30, 2017, 09:10:26 pm »
1. If an alien has a limited range weapon, and it decides to shoot when the target is beyond that range, it will freeze (skip its turn).

But will it take a reaction shot if any target moves into the weapon's minimum range?

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: AI and weapon range/hit chance stats
« Reply #12 on: June 30, 2017, 10:05:17 pm »
But will it take a reaction shot if any target moves into the weapon's minimum range?

Yes, and that's the best thing about it.
That's how I made my ninja assassins... They're invisible (except from up close) and often use thrown knives with short range. This makes them perfect deathtraps.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #13 on: June 30, 2017, 10:53:50 pm »
You probably could give them weapons that do not have any form of attack but one for switching between distances; for example, give them a longer ranged gun with only aimed shots or snap shots, and beyond ~4 tiles they will prefer that (I think), then a gun with only auto-attack for closer range, which they will prefer under 4 tiles.  Not great for using the looted guns, but this may be the only way to get what you're thinking about without writing more code.

Also, by sniping, I just mean firing beyond visual range (20 tiles without any of the OXCE stuff), something players do quite often but aliens cannot without psi attacks or blaster launchers.  Letting a few aliens fire when their buddies see a target but they don't would go quite a ways towards leveling the playing field for the AI.

Offline drages

  • Colonel
  • ****
  • Posts: 150
    • View Profile
Re: AI and weapon range/hit chance stats
« Reply #14 on: June 30, 2017, 10:57:38 pm »

Also, by sniping, I just mean firing beyond visual range (20 tiles without any of the OXCE stuff), something players do quite often but aliens cannot without psi attacks or blaster launchers.  Letting a few aliens fire when their buddies see a target but they don't would go quite a ways towards leveling the playing field for the AI.

Hmm this is something new and nice.