Alien Aggression - how it works

Ryoga

King
Joined
Oct 12, 2010
Messages
993
The fact that you can eradicate all aliens from the map and never see them going into red is quite odd in my opinion, so I made of few tests to try and understand how that works and why it is so hard to get the aliens angry.

Eventually I plan to make my own mod to fix that, but right now I thought I could share my findings for other modders and you might as well contribute to that if you have other data.


The relevant rows in the XML database are under "GlobalDefines.xml"

Code:
		<Row Name="ALIEN_REPRISAL_AGGRO_HIGH">
			<Value>5</Value>
		</Row>
		<Row Name="ALIEN_REPRISAL_AGGRO_MEDIUM">
			<Value>3</Value>
		</Row>
		<Row Name="ALIEN_REPRISAL_AGGRO_LOW">
			<Value>1</Value>
		</Row>
		<Row Name="ALIEN_NEST_FRIENDLY_WEIGHT">
		      <Value>0.25</Value>
		</Row>
		<Row Name="ALIEN_OPINION_FRIENDLY_THRESHOLD">
			<Value>15</Value>
		</Row>
		<Row Name="ALIEN_OPINION_HOSTILE_THRESHOLD">
			<Value>-15</Value>
		</Row>
		<Row Name="ALIEN_OPINION_VERY_HOSTILE_THRESHOLD">
			<Value>-45</Value>
		</Row>

What do they mean?

ALIEN_REPRISAL_AGGRO_LOW This is the amount of "hate" you get for a low tier hostile action against aliens. Attacking an alien is confirmed to be one of such actions (not clear if there are others). By default it is set on "1" and it is subtracted from the "alien opinion" value.

ALIEN_REPRISAL_AGGRO_MEDIUM This is the "hate" value you get for a medium tier hostile action against aliens. I have yet to determine which action is considered "medium tier". By default it is set on "3" and it is subtracted from the "alien opinion" value.

ALIEN_REPRISAL_AGGRO_HIGH This is the "hate" value you get for a high tier hostile action against aliens. Razing a nest is confirmed to be one of such actions (not clear if there are others). By default it is set on "5" and it is subtracted from the "alien opinion" value.

ALIEN_NEST_FRIENDLY_WEIGHT This is the amount of positive points you get each turn per every alien nests in your borders (the more nests you have in your borders, the more points you get each turn). By default it is set on "0.25".

ALIEN_OPINION_FRIENDLY_THRESHOLD This is the amount of points the "alien opinion" must reach before aliens become friendly (blue) to you. By default it is set on "15".

ALIEN_OPINION_HOSTILE_THRESHOLD This is the amount of points the "alien opinion" must reach before aliens become hostile (orange) to you. By default it is set on "-15".

ALIEN_OPINION_VERY_HOSTILE_THRESHOLD This is the amount of points the "alien opinion" must reach before aliens become very hostile (red) to you. By default it is set on "-45".


NEGATIVE OPINION DECAY I wasn't able to find where this value is set in the XML, but my tests prove that a decay value definitely exists.
This value is not affected by Gamespeed. Tests on Marathon and on Quick both show that the decay value of negative "alien opinion" is exactly 0.25 per turn (it used to be 1 before the December 2014 patch).
Further testing on Sputnik difficulty, Apollo difficulty and frenzied aliens option did not show any difference in the "hate" decay or "hate" gain.

All the tests were done on early turns. But this game isn't supposed to use the "era" system of Civ V, so there shouldn't be any difference.

-Since only "attacking" is considered an hostile action and not "killing", passive killing does not cause any change in the "alien opinion". For example aliens that are killed by your units defending near a nest, do not cause any change in the "alien opinion".
-City attacks are not considered hostile actions at all, even when they kill aliens.
-Same as above, aerial attacks are not considered hostile actions.
-Any ranged attack that is launched from any hexes that aren't directly adjacent to the target do not affect the "alien opinion" (this is most likely a bug).
-The above is true for naval units, whether they attack surface aliens or sea aliens they only increase hostility if they attack from an adjacent tile.


NEW - LUA API

I have found the lua API that are related to the alien opinion.

Aliens.GetOpinionForPlayer( playerID )
Aliens.SetOpinionForPlayer( playerID, opinionID )


Examples:

Code:
print ( Aliens.GetOpinionForPlayer( Players[0] ) )
This prints the alien opinion level for player 0 (the human player in single player games)

Code:
Aliens.SetOpinionForPlayer( Players[0], 1 )
This sets the alien opinion level for player 0 to "1".

There are four existing level of opinions each corresponding to a precise ID.

- 0 = Neutral level (green)
- 1 = Friendly level (blue)
- 2 = Hostile level (orange)
- 3 = Very Hostile level (red)

These four levels can also be called from a specific table:

AIAlienOpinionTypes.ALIEN_OPINION_NEUTRAL is equal to "0"
AIAlienOpinionTypes.ALIEN_OPINION_FRIENDLY is equal to "1"
AIAlienOpinionTypes.ALIEN_OPINION_HOSTILE is equal to "2"
AIAlienOpinionTypes.ALIEN_OPINION_VERY_HOSTILE is equal to "3"


Aliens.SetOpinionValueForPlayer( playerID, opinionvalue )

This allows to set the precise value of the alien opinion for the specified player.

Example:

Code:
Aliens.SetOpinionValueForPlayer(Players[0], -50 )

This sets the alien opinion value for player 0 to "-50".
On the default settings this means that the alien opinion will turn "very hostile" and it will remain so for quite a few turns until hate decays.

Regretfully there doesn't seem to be a GetOpinionValueForPlayer function.


Aliens.DoCityWormStrike(city, numWorms, strikeRange, strikeDuration)

This is the function used in the Worm Strike Covert Ops script.
Example:

Code:
Aliens.DoCityWormStrike(Players[0]:GetCapitalCity(), 4, 1, 5)

This spawns 4 worms near the capital of player 0.

"strikeRange" seems to determine how closer to the city the worms will spawn. It seems however that they cannot spawn closer than 2 hexes away and they do not necessarily spawn at the specified distance.

It is unclear what "strikeDuration" exactly does. What is certain is that i does not determine how long the summoned worms will stay.
Rather it seems to determine how many turns the worms will stay still before moving after the summoning, but I'm not 100% positive about that.

Worms spawned this way are immune to the ultrasonic fence of the designated city, but not to ultrasonic fences from other cities.


Other API

Aliens.GetTotalSeaDamageDealt()
Aliens.GetTotalLandDamageDealt()
Aliens.GetTotalLandUnitsLost()
Aliens.GetTotalSeaDamageReceived()
Aliens.GetTotalPlayerUnitsKilled()
Aliens.GetTotalSeaUnitsLost()
Aliens.GetTotalLandDamageReceived()


These are all global values and do not require arguments. They are pretty straightforward as to what they do, but "Aliens.GetTotalSeaDamageDealt()" doesn't seem to work as it always reports "0".
 
Thanks for this! Is attacking an alien a hostile action, or only the kill?

Question -- theoretically, if we change these values manually, do we need a mod? I ask because I play MP with a friend and it'd be good to play a game with more hostile aliens.

Also, how hard would it be to edit it so that alien strength is related to their hostility level? :)

Unfortunately, it looks like the location one of the key values that need to be changed -- the decay -- is still a mystery ...
 
I almost think they should remove the decay entirely. That'd really mess with things. Return it at its current value for Harmony characters that have it.
 
Thanks for this! Is attacking an alien a hostile action, or only the kill?

After testing it appears that I was wrong. The low tier hostile action is "attacking an alien" and not "killing an alien" so you get 1 negative point for each attack you make.

Question -- theoretically, if we change these values manually, do we need a mod? I ask because I play MP with a friend and it'd be good to play a game with more hostile aliens.

I'm not sure how multiplayer would handle that, but yes you don't actually need a mod for these changes, you can modify directly the xml.

Also, how hard would it be to edit it so that alien strength is related to their hostility level? :)

That would almost certainly require a lua program at the very least. It should be possible to make it, probably by adding a promotion to aliens. However it would probably require a check every turn, it might slow down the turn progress depending on how the code is made.

Note that this would probably cause the AI to be raped by aliens early on, thus likely giving you a victory before you can do anything. The AI attitude toward aliens in spite of what they say seems to be a fixed "kill on sight".

Actually now that I think about that, to make aliens strength different for each faction depending on their relationship with aliens might be a real issue.

Unfortunately, it looks like the location one of the key values that need to be changed -- the decay -- is still a mystery ...

It would be very cool if the decay value could be found somewhere in the xml, however it's not a very huge problem.
For example if you multiply by 4 every single value of the rows I listed above you should be getting the very same result as you'd get by reducing the decay value to 0.25.
 
Correct me if I'm wrong but using city defenses to bombard aliens in range is not considered an attack, right? It is only when units attack aliens that the alien aggression level is affected, yes?
 
Correct me if I'm wrong but using city defenses to bombard aliens in range is not considered an attack, right? It is only when units attack aliens that the alien aggression level is affected, yes?

EDIT: Tested. You are right. City attacks do not affect "alien opinion" at all whether from distance or from an adjacent hex.

Spoiler No longer relevant :
Moreover further testing suggests that the actual formula is a lot more complicated.

It appears that what I initially wrote is only true in case your attack deal full damage (in other words one-shots the alien). In the case your attack deals just a few damages to the alien, only a fraction of the total amount of the "hate" for attacking the alien is considered.
I've yet to understand how that actually works, I'm getting very erratic results.

Right now I'm testing with ranged attacks with ranged combat strength = 1 (it deals only 1 damage to the aliens) "ALIEN_REPRISAL_AGGRO_LOW" is set to "10" and "ALIEN_OPINION_HOSTILE_THRESHOLD" is set to "-10"

This means that killing one alien in one attack automatically brings them to "hostile" status.
However using the weak ranged attacks requires from 2 to 10 attacks to cause the same result.

this is quite puzzling...


EDIT:

Nevermind, the attack power and damage dealt is irrelevant. It's the distance. But it might be because I messed up the unit stats, hang on for further testing.

EDIT2:

Well I found out the issue. As long as you attack an alien from afar (i.e. as long as you are not attacking them from an adjacent hex) your attack will not be considered an hostile action for the purpose of the "alien_opinion" (this still works properly for the individual hate of the unit which is processed separately). That means you can safely slaughter them all with ranged attacks and they'll never get angry.

I doubt that this is how it was intended to work so this is most likely a bug...
 
I just tried a game where all the aliens were set to Hostile and it was a *blast*-- settlements are just tough enough to take out a Mind Worm before dying, but TWO of them, yeah, not so much. Have fun taking Prosperity first, that should work out great for you .... :cool:

I see something in the .xml that might be useful:

</Row>
<Row Name="ALIEN_CITY_WORM_STRIKE_DEFAULT_RANGE">
<Value>4</Value>
</Row>
<Row Name="ALIEN_CITY_WORM_STRIKE_DEFAULT_NUM_WORMS">
<Value>4</Value>
</Row>

Guessing that if the first was set to '2', the worms wouldn't come up and visit unless they stumbled into a spot that was 2 away.

Any idea what the second is? It isn't the max number of worms that can attack a city, is it?
 
Don't both of those have to with Covert Ops mission for Purity?
 
This is wonderful information!

I wasn't aware we could change the rate of aggression gains so easily.
 
Will a player with multiple nests gain standing with the aliens faster?
 
thanks for the info! now we know friendly aliens take 60 turns, not 50. In my last game with blue aliens they remained friendly after I (accidentally) removed the nest in my borders, which makes sense if I had more than 20 opinion :)
 
Great info! While you're poking around at the alien code, can you figure out what the formula is for nests respawning?
 
I just tried a game where all the aliens were set to Hostile and it was a *blast*-- settlements are just tough enough to take out a Mind Worm before dying, but TWO of them, yeah, not so much. Have fun taking Prosperity first, that should work out great for you .... :cool:

I see something in the .xml that might be useful:

</Row>
<Row Name="ALIEN_CITY_WORM_STRIKE_DEFAULT_RANGE">
<Value>4</Value>
</Row>
<Row Name="ALIEN_CITY_WORM_STRIKE_DEFAULT_NUM_WORMS">
<Value>4</Value>
</Row>

Guessing that if the first was set to '2', the worms wouldn't come up and visit unless they stumbled into a spot that was 2 away.

Any idea what the second is? It isn't the max number of worms that can attack a city, is it?

I haven't tested that but since "worm strike" is the name of the harmony covert op that summons siege worms to the targeted city I am fairly certain that those rows refer to that. The second value is probably the number of worms that get summoned.


Will a player with multiple nests gain standing with the aliens faster?

Interesting question, that's something worth of testing.

EDIT: Tested! The bonus for having a nest in your border is additive. Multiple nests make the "alien opinion" raise faster.

Great info! While you're poking around at the alien code, can you figure out what the formula is for nests respawning?

That's easy, it's not really a formula. What you are looking for is this row:

Code:
		<Row Name="ALIEN_NEST_RECOVERY_RATE">
			<Value>25</Value>
		</Row>

In my tests I set it to "1" and nests did in fact respawn the very next turn each time.


EDIT:

I'm having a doubt now, could it be that "ALIEN_REPRISAL_AGGRO_MEDIUM" is supposed to be the penalty for killing an alien, but it's not working at all?
It would make a lot of sense if it was so.
 
I have been playing games with frenzied/hostile aliens and -- damn, let me tell you, the last thing on your mind in the first 50-100 turns is trade routes. The AI gets mauled something awful, but this is a ton of fun. Pop 3/4 settlements are *just* strong enough to handle a siege worm plus a couple other weaker aliens. Two worms ... probably not.

Need to think about also making the nest respawn be <25 ...

Of course, you have to be on the honor system and not build the ultrasonic fences. That'd be cheating. Might make sense for an ultra-alien-death mod to increase the cost of the fences by a lot, and/or decrease the protective range by 1.

And maybe make, if possible, the AI outposts get a little stronger at baseline.
 
Have you found where the starting alien stance is defined? For example, when you first meet them the aliens are green... is there a way to set starting value to, say, orange?
 
Have you found where the starting alien stance is defined? For example, when you first meet them the aliens are green... is there a way to set starting value to, say, orange?

The starting opinion value is 0.

if you change the value on this row:

Code:
		<Row Name="ALIEN_OPINION_HOSTILE_THRESHOLD">
			<Value>-15</Value>
		</Row>

from -15 to 0, the aliens will start as hostile.

Note that they will immediately become green if you get an alien nest in your borders, provided the relationship is 0 when you do.

If you want the relationship to take always a few turn before becoming green, set it to 1 or 2.
 
There is a Tag AlienOpinionRecoveryMod within the CivBEPlayerPerks.xml that you could potentially use if you are trying to adjust the opinion decay
 
There is a Tag AlienOpinionRecoveryMod within the CivBEPlayerPerks.xml that you could potentially use if you are trying to adjust the opinion decay

I see, that's what used for the perk you get with level1 harmony affinity.

It's set on 100, which means the value is added as a percentage of the normal amount.

It should accept negative values as well, so "-50" should halve the recovery rate.
 
Top Bottom