aliens

Author Topic: Does attraction work?  (Read 5995 times)

Offline CanadianBeaver

  • Colonel
  • ****
  • Posts: 184
    • View Profile
    • AwesomeGuns
Does attraction work?
« on: December 17, 2016, 02:21:34 am »
... and what values are correct?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: Does attraction work?
« Reply #1 on: December 17, 2016, 02:49:27 am »
... and what values are correct?

Yes, it works... unless you mess up default inventory slots really badly (which I think is not the case in your mod).

I've sadly seen it in action with my own eyes :)

0 means disabled, any other (positive) value means enabled. Higher value means "more attractive".

There are pretty hard-to-explain-in-detail algorithms how it works, but you can give it a try:
- https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/BattlescapeGame.cpp#L1835
- https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/BattlescapeGame.cpp#L1872

Offline CanadianBeaver

  • Colonel
  • ****
  • Posts: 184
    • View Profile
    • AwesomeGuns
Re: Does attraction work?
« Reply #2 on: December 17, 2016, 03:59:12 am »
Meridian, what is the possible maximum value?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: Does attraction work?
« Reply #3 on: December 17, 2016, 10:32:26 am »
There is no upper limit, bigger means more attractive.
Minimum effective value is 6 though... 5 or less will not trigger anything.

Some notes:
- aliens will not pick up a weapon, if they already have a working weapon
- aliens will NOT pick up weapons you throw them... they consider them traps... so only weapons they have dropped, or you have lost when dying during their turn
- aliens will NOT pick up weapons if they currently see any xcom operatives.... don't ask me why
- aliens will NOT pick up a weapon, which they don't have ammo for (except blaster launcher or other waypoint-based weapon)

Example:

a/ first a survey is made for the most worthy weapon from all weapons on the ground (which are not considered traps)

Worthiness = attraction / (distance(unit, item) * 2 + 1);

e.g. for attraction = 10, distance between unit and item = 2 tiles... the worthiness = 10 / 3 * 2 + 1 = 10 / 7 = 1

b/ second, once the most worthy weapon is picked, aliens check if they have ammo for it and if they dont see anyone. After that they will make a move for it if the following formula returns true:

attraction - distance(unit, item) * 2 > 5

e.g. for attraction 5 or less, this always returns false
e.g. for attraction = 6, distance must be 0, otherwise returns false
e.g. for attraction 50, distance can be between 0 and 22 tiles, otherwise returns false
« Last Edit: December 17, 2016, 10:35:10 am by Meridian »

Offline Eddie

  • Commander
  • *****
  • Posts: 560
    • View Profile
Re: Does attraction work?
« Reply #4 on: December 17, 2016, 02:09:00 pm »
Does that mean that if an alien has no ammo in his inventory, he will never pick up a weapon (excluding blaster launcher)? Or does "have ammo" also include ammo in the weapon or on the ground?

If the ammo needs to be in his inventory, that would be pretty restricting. It would make the attraction parameter worthless as the alien is restricted to one weapon type anyway (the one he has ammo for).

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: Does attraction work?
« Reply #5 on: December 17, 2016, 02:13:46 pm »
Does that mean that if an alien has no ammo in his inventory, he will never pick up a weapon (excluding blaster launcher)?

No.

Or does "have ammo" also include ammo in the weapon or on the ground?

Yes.

If the ammo needs to be in his inventory, that would be pretty restricting. It would make the attraction parameter worthless as the alien is restricted to one weapon type anyway (the one he has ammo for).

They anyway carry only Heavy Plasmas since month 4 or so.

Offline CanadianBeaver

  • Colonel
  • ****
  • Posts: 184
    • View Profile
    • AwesomeGuns
Re: Does attraction work?
« Reply #6 on: December 17, 2016, 04:11:03 pm »
thank you for answering

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: Does attraction work?
« Reply #7 on: January 24, 2018, 12:52:36 am »
Thanks for this post. I have found it rather difficult to test attraction as any test I run seems to confirm only that it doesn't work. Here's why:
- aliens will NOT pick up weapons you throw them... they consider them traps... so only weapons they have dropped, or you have lost when dying during their turn
- aliens will NOT pick up weapons if they currently see any xcom operatives.... don't ask me why

This makes it nearly impossible to test the effect. Since none of the default items have an attraction value that works, I have never seen it in action. But I guess since you posted the algorithm I have enough info to go on.

Distance works like this: (attraction / 2) - 3. If the resulting value >= 0 then attraction by distance works and the value is the distance.
« Last Edit: January 24, 2018, 12:59:31 am by The Reaver of Darkness »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: Does attraction work?
« Reply #8 on: September 05, 2018, 03:33:42 am »
I don't feel like attraction is working. I have had all of the aliens' weapons set to 20 attraction, yet once they start panicking, I routinely find weapons laying around and aliens walking around with nothing in their hands. Is 20 not high enough? They are frequently leaving their weapons behind whether or not my soldiers are watching.

Couldn't you change it to allow them to pick up weapons while the soldier is watching? It seems like a stupid move to avoid picking up your weapon when doing so may be your only chance at survival. It would also just be so much easier to test the effect.