Rules for facilities constructions?

Post Reply
LordYanaek
Posts: 940
Joined: Mon Jan 23, 2017 1:34 pm

Rules for facilities constructions?

Post by LordYanaek »

This is mostly a question for developers or beta testers (unless some good code digger can answer). I'd like to know what rules govern the construction of AVATAR facilities. I know that Aliens can build 3 of those no matter what happens and after that they are limited by vigilance/alert levels and the construction of those facilities are activities that can be detected and attacked but that's about it.
Specifically i'd like to know
  • Are those built in any region or just uncontacted regions?
  • Is there a limit to how soon a facility can be built or is it possible to have this activity start at day 1?
  • How many facilities are allowed to be "under construction" at the same time and is there a cooldown?
  • I see the activity can't start in regions with vigilance>5, does it apply to the first 3 facilities?
  • After 3 facilities how exactly are further construction affected by local vigilance/alert levels? By global levels?
  • This activity have iPriority=10, what does that say of the chances for this mission to be selected rather than say reinforce with iPriority=40?
Any other specifics i didn't consider are also interesting. I'm trying to gather information to add to UFOpedia so hopefully players won't be caught by surprise when AVATAR progress accelerates.

The page is a WIP currently and not linked to the rest of the wiki. If you want to have a look your feedback is welcome.

EDIT : I already made some global search in all inis for "doom" and "avatar" so don't spend time doing it :)
Last edited by LordYanaek on Sun Apr 16, 2017 7:41 pm, edited 1 time in total.
Zyxpsilon
Posts: 274
Joined: Fri Jan 20, 2017 1:26 am

Re: Rules for facilities constructions?

Post by Zyxpsilon »

Just wanna say -- excellent work so far on that Wiki article. :D

I too am always digging through the game files to find specific details to integrate as facts within my LAByrinth mod.. but it still takes time & patience & maybe, some lucky finds (During own gameplay or catching great streamers in the act!) -- so i certainly can relate to your quest for rational truths! :P

PS; Facilities... I found that IF we have more (as many as possible) contacted Regions and sooner, the first would most likely reveal itself & THAT one nearly always has the most PIPs (a whopping SIX in my recent veteran game!) to try working out at the Doom pace. Secondly, RealityMachina's mod "Facility Hunt" Jobs for Rebel is a blessing to help out triggering facility lead missions.. which in turn, can alter a sure defeat status into a relatively good hope for a chance to win -- by more than just luck! 8-)
Tuhalu
Posts: 433
Joined: Wed Feb 01, 2017 9:02 pm

Re: Rules for facilities constructions?

Post by Tuhalu »

Here's some stuff for you.

Code: Select all

[LW_Overhaul.XComGameState_LWAlienActivityManager]
; For every point that global vigiliance (sum of all regional vigilances) exceeds global alert,
; completion of an avatar point project at the Fotress or at a research facility will be delayed
; by this many hours
AVATAR_DELAY_HOURS_PER_NET_GLOBAL_VIG=10
So that's exactly how you slow down avatar progress and how much.

Code: Select all

[LW_Overhaul.X2LWActivityCondition_ResearchFacility]
; These are governors on the construction of facilities, with facilities requiring a safer world (for ADVENT)
; for each new one built
MAX_UNOBSTRUCTED_FACILITIES=3
GLOBAL_ALERT_DELTA_PER_EXTRA_FACILITY=10
Not sure what the GLOBAL_ALERT_DELTA_PER_EXTRA_FACILITY means. Does it change the global alert or do new facilities have some kind of limiter based on how much global alert there is?

Code: Select all

;chance to transfer a point of doom from regional facility to Alien HQ -- triggers when local doom timer triggers
;each chance to transfer is rolled independently (e.g. 3 10% chances is slightly less than 30%)
CHANCE_PER_LOCAL_DOOM_TRANSFER_TO_ALIEN_HQ[0]=10.0
CHANCE_PER_LOCAL_DOOM_TRANSFER_TO_ALIEN_HQ[1]=20.0
CHANCE_PER_LOCAL_DOOM_TRANSFER_TO_ALIEN_HQ[2]=25.0
CHANCE_PER_LOCAL_DOOM_TRANSFER_TO_ALIEN_HQ[3]=30.0
The exact timing of point transfers is unclear in your wiki entry. The comments to this code make it clear that the check is made whenever a Facility generates a new pip.
LordYanaek
Posts: 940
Joined: Mon Jan 23, 2017 1:34 pm

Re: Rules for facilities constructions?

Post by LordYanaek »

Tuhalu wrote:Here's some stuff for you.
Thanks for this but everything in the ini is perfectly known to me (even if i didn't have time to write it all so far) which is why i was specifically asking about the construction of facilities. I really have no clue on this part and like you i don't know what GLOBAL_ALERT_DELTA_PER_EXTRA_FACILITY does. I guess it's related to some limitation to new facilities construction as i think something like this exist but the ini doesn't have enough "intel" on that part.
The exact timing of point transfers is unclear in your wiki entry. The comments to this code make it clear that the check is made whenever a Facility generates a new pip.
I'll try to rephrase that part.

Reading that part again

Code: Select all

[LW_Overhaul.X2LWActivityCondition_ResearchFacility]
; These are governors on the construction of facilities, with facilities requiring a safer world (for ADVENT)
; for each new one built
MAX_UNOBSTRUCTED_FACILITIES=3
GLOBAL_ALERT_DELTA_PER_EXTRA_FACILITY=10
I would think that maybe each facility over 3 requires 10 more Global Alert above some threshold (10 for the 4th, 20 for the 5th) to be constructed but what's that threshold? Is it simply above Global Vigilance or something else?
Zyxpsilon
Posts: 274
Joined: Fri Jan 20, 2017 1:26 am

Re: Rules for facilities constructions?

Post by Zyxpsilon »

GLOBAL_ALERT_DELTA_PER_EXTRA_FACILITY

The main colored DELTA hint is related to the VB/C++ mnemonic that means indirect "FloorMath" calculations. In coding principle at least.. this sort of variable can reach max but only according to feed-through parameters that can't floor it to a MIN under certain conditions. Think of it as Integer rounding from float equations (or slope curves).

Technically speaking.. this; http://en.wikipedia.org/wiki/Symmetric_difference
chrisb
Pavonis Dev
Posts: 364
Joined: Mon Feb 27, 2017 8:43 pm

Re: Rules for facilities constructions?

Post by chrisb »

This has to do with the ResearchFacility ActivityCondition. It's used in various mission types.

From what I can tell in the code, this variable does not even seem to be used. There are two condition functions, one global the other regional. The global one checks if a certain variable (bRequiresHiddenAlienResearchFacilityInWorld) is false, which it is by default, and BuildResearchFacility does not set it to true.

The only activity that sets the value to true is ProtectResearch which rewards Facility Leads.

So I'm not entirely certain that it is even being used. It seems like the logic and the settings that are used for it mean that the code that uses that variable will never be executed.

From the code that is there where it's being used, it is meant to be a throttle to prevent more facilities if vigilance is too high. If the number of facilities is >= 3 then this check is performed.

Code: Select all

GlobalAlert - (ALERT_DELTA * (NumFacilities - MAX_UNOBSTRUCTED + 1)) < GlobalVigilance
With 3 faciliities it would be GlobalAlert + 10 < GlobalVigilance. So 10 or more NetGV would return false.
With 4 facilities it would be GlobalAlert < GlobalVigilance.

But, this code as far as I can tell will never be executed. So not sure if that's a bug or not.

The other function, which checks the condition against a region, simply checks if the region has a facility and if the condition is set to allow the activity to be created if there is one. Build facility sets this to false obviously. So it seems to me like the rule for creating facilities is that it simply spawns in a region that does not have one. There's no other logic to it.
LordYanaek
Posts: 940
Joined: Mon Jan 23, 2017 1:34 pm

Re: Rules for facilities constructions?

Post by LordYanaek »

Zyxpsilon wrote: The main colored DELTA hint is related to the VB/C++ mnemonic that means indirect "FloorMath" calculations. In coding principle at least.. this sort of variable can reach max but only according to feed-through parameters that can't floor it to a MIN under certain conditions. Think of it as Integer rounding from float equations (or slope curves).
Huh, yeah .... whatdyoumean :shock:
I somewhat understood the linked wikipedia article and from this it seems like it's an operation that can only be used on sets of numbers. In common mathematical speaking (when non mathematicians are trying to use mathematical terms ;) ) delta is often used simply to indicate a difference and from that bit of code chrisb unearthed it looks like it's simply a factor to compare two values.
chrisb wrote:

Code: Select all

GlobalAlert - (ALERT_DELTA * (NumFacilities - MAX_UNOBSTRUCTED + 1)) < GlobalVigilance
With 3 faciliities it would be GlobalAlert + 10 < GlobalVigilance. So 10 or more NetGV would return false.
With 4 facilities it would be GlobalAlert < GlobalVigilance.

But, this code as far as I can tell will never be executed. So not sure if that's a bug or not.
That's close to what i guessed but without knowing where it starts so apparently you need 10 GV over GA to prevent the 4th facility construction, GV>GA to prevent the 5th and i guess GV>GA-10 to prevent a 6th facility.

If the code is not executed due to a bug however, it would mean that delaying AVATAR is harder than it should as facilities have a huge impact on AVATAR progress.

It would be good to have a developer's word.

My own code digging have revealed the template for the Build Facility activity which to my understanding holds the condition under which this activity can be started at the line 1273 of X2StrategyElement_DefaultAlienActivities.uc
Of particular interest is this part.

Code: Select all

	//these define the requirements for creating each activity
	Template.ActivityCreation = new class'X2LWActivityCreation_FurthestAway';
	Template.ActivityCreation.Conditions.AddItem(default.SingleActivityInWorld);
	Template.ActivityCreation.Conditions.AddItem(default.AlertAtLeastEqualToVigilance);
	Template.ActivityCreation.Conditions.AddItem(default.AnyAlienRegion);
	Template.ActivityCreation.Conditions.AddItem(new class'X2LWActivityCondition_AlertVigilance');
My understanding of this is that the activity will occur in the non liberated region that's furthest away from any contacted region and where Alert Level is at least equal to Vigilance level. I don't think vigilance can be higher than alert in uncontacted regions but i may be wrong as there is an activity that simulates rebel actions without XCOM control. There can be only one such activity in the world at a given moment and it has an additional condition related to Alert and Vigilance but that condition (defined in X2LWActivityCondition_AlertVigilance.uc) apparently evaluates to false in a number of situations that are not defined in that same file and returns true if it doesn't evaluate to false and i'm a bit lost where to look next :?
chrisb
Pavonis Dev
Posts: 364
Joined: Mon Feb 27, 2017 8:43 pm

Re: Rules for facilities constructions?

Post by chrisb »

Code: Select all

Template.ActivityCreation.Conditions.AddItem(default.AlertAtLeastEqualToVigilance);
This is defined at the bottom of the file, it sets MinAlertVigilanceDiff to 0. This is used in the regional condition check.

Code: Select all

AlertVigilanceDiff = RegionalAI.LocalAlertLevel - RegionalAI.LocalVigilanceLevel;
if(AlertVigilanceDiff < MinAlertVigilanceDiff)
		bMeetsCondition = false;
So If Alert is less than Vigilance it will evaluate to true, setting the var to false and rejecting the region.

As for the general use AlertVigilance, this uses the values from the LW_Activities config to override the defaults. So in this case vigilance can't be more than 5.

It seems like this is mostly being governed by the activity duration. It ranges from 45-48 days. Since there can only be one at a time, your basically getting a facility every 45-48 days. This is only restricted by there being a valid region for the facility to spawn in. Looking at the conditions available, in general it should always be able to find one.

As for the facility research itself, that uses some custom logic which is why the Duration_Hours is -1. It's configured per difficulty.
  • Rookie 35-45 days
  • Veteran 32-40 days
  • Commander 28-36 days
  • Legend 26-34 days
Which is of course modified by 10 hours per positive NetGV. So being a 'Severe' threat is adding at least 8 days to all these numbers. There's also a chance based on difficulty that the doom pip will go to the AI HQ and not the facility itself.
LordYanaek
Posts: 940
Joined: Mon Jan 23, 2017 1:34 pm

Re: Rules for facilities constructions?

Post by LordYanaek »

Thanks chrisb for your help understanding all of this.
I already had the research itself covered.

So to recap it all, facilities are built
  • As far away from any contacted region as possible
  • In a region where Vigilance<5 and <Alert
  • Only one at a time
  • With a cooldown of 45-48 days
    • As a result the first facility should complete somewhere around mid April.
    • New facilities would appear every 1.5 month, with the second coming online early June, 3rd somewhere in July and 4th possibly early September.
  • Faculties after 3 might require that GV<GA+10 if the code for this is actually executed. Is it deprecated? This could make a large difference in XCOM's ability to delay AVATAR progress so it would be nice to have a definitive answer on that last point.
Zyxpsilon
Posts: 274
Joined: Fri Jan 20, 2017 1:26 am

Re: Rules for facilities constructions?

Post by Zyxpsilon »

Don't worry LY, it's the language barrier that i often misuse since i'm of Quebec/French origin.. so sometimes, i really screw up whatever English phrasing i'm trying to convey.
The important thing to know is that those DELTA evaluations are simple math principles that determine which high/low values get priority within various functions.

You can also find some of these into the LW-Toolbox code section that deals with the "STATS_CAPS" (picked from "SWAPS" variations too) randomization process for the NCE & HiddenPotential.

Something else i found about Facilities "Build cycle" is that beyond the Vigilance gap(s) the Aliens tend to hold off a bit when we are highly successful at a global level (indirectly that *IS* Vigilance -duh!). It is extremely unlikely that a Fifth facility would ever be built, btw. The DELTA for it is soooooooo high.. you'd already be very near defeat status with the Doom-Tracker at Maximum & possibly into the trigger period itself.
chrisb
Pavonis Dev
Posts: 364
Joined: Mon Feb 27, 2017 8:43 pm

Re: Rules for facilities constructions?

Post by chrisb »

LordYanaek wrote:Thanks chrisb for your help understanding all of this.
I already had the research itself covered.

So to recap it all, facilities are built
  • As far away from any contacted region as possible
  • In a region where Vigilance<5 and <Alert
  • Only one at a time
  • With a cooldown of 45-48 days
    • As a result the first facility should complete somewhere around mid April.
    • New facilities would appear every 1.5 month, with the second coming online early June, 3rd somewhere in July and 4th possibly early September.
  • Faculties after 3 might require that GV<GA+10 if the code for this is actually executed. Is it deprecated? This could make a large difference in XCOM's ability to delay AVATAR progress so it would be nice to have a definitive answer on that last point.
Sounds right, unless I'm missing something obvious, there is no code path that executes the code using that delta gap variable.
Post Reply