aliens

Author Topic: Questions about AI (shot-type use and multiple "fixed" weapons)  (Read 5264 times)

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Question 1

I'm working on a new mod and I wanted to have a different behavior for the autoshot.

The following would be the standard stats configuration for the autoshot-enabled weapons:
(accuracy% and TUs are indicative, juts so you can understand)
    accuracyAuto: 33
    accuracySnap: 66
    accuracyAimed: 99
    tuAuto: 20
    tuSnap: 40
    tuAimed: 60
    ...
    autoShots: 1

This makes the autoshot to behave like it does in Apocalypse: no more triple burst but simply another single,  faster and more inaccurate, shot.
It works (already tested).

I want to know if the AI, with the weapons made like this, will still be able to choose normally between the fire modes, or will just start using the autoshot like there no tomorrow (seeing that now it has the lowest TUs requirement).



Question 2

If I give an unit two natural (built-in) weapons, a bite (melee) and an acid spit (ranged), will it be able to use them properly (i.e. choosing to attack melee  if near enough to the target, instead of just staying still and spitting at it)?


Thanks.
« Last Edit: May 28, 2014, 07:34:56 pm by robin »

Offline Shoes

  • Commander
  • *****
  • Posts: 502
    • View Profile
Re: Questions about AI (shot-type use and multiple "fixed" weapons)
« Reply #1 on: May 28, 2014, 08:33:17 pm »
For Question 1, AlienBAIState.cpp has a function selectFireMethod() at line 1685; that's what I am using to answer you.

If the distance between the alien and the soldier is less than 4, the alien will try to Autoshot first, then Snap, then Aim.

If the distance is greater than 12, it will try to Aim. If it can't Aim shot, and the distance is less than 20, it will Snap.

Otherwise, the alien will try to Snap first, then Aim, then Auto.

Other than distance, the way shots fail is if they lack TUs. Nothing else is considered.

So to answer your question : if you set the TUs low enough, the AI will likely always select Autoshot when distance < 4, or if the distance is between 4 and 12 inclusive and it can't Snap or Aim shot.
« Last Edit: May 28, 2014, 08:36:29 pm by Shoes »

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Questions about AI (shot-type use and multiple "fixed" weapons)
« Reply #2 on: May 28, 2014, 09:30:12 pm »
For Question 1
[...]
Thanks. I feared a

"autoshots, autoshots everywhere"
                                                       \


scenario, but based on your explanation it should work fine enough.
I think I'll go with it.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11702
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Questions about AI (shot-type use and multiple "fixed" weapons)
« Reply #3 on: May 28, 2014, 11:10:56 pm »
Regarding question 2:

If I give an unit two natural (built-in) weapons, a bite (melee) and an acid spit (ranged), will it be able to use them properly (i.e. choosing to attack melee  if near enough to the target, instead of just staying still and spitting at it)?

Sadly, no - only one fixed weapon allowed. Unless it was changed recently (in which case I'd be ecstatic myself).

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Questions about AI (shot-type use and multiple "fixed" weapons)
« Reply #4 on: May 28, 2014, 11:28:15 pm »
I see, thanks.

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Questions about AI (shot-type use and multiple "fixed" weapons)
« Reply #5 on: May 29, 2014, 12:29:12 am »
Anther question:
This is the formula for calculating the blast radius for projectiles:

-- Projectile Explosives       INT(HE/20)+1

So for example the Auto-Cannon HE shell blast radius, with its 44 damage,  should be: (44/20)+1 ==integer==>  3.
And then if I wanted to change the damage but preserve the size of the blast, I 'd have to add the line "blastRadius: 3" to the item.
Everything correct?