Difference between revisions of "XComStrategyGame.UPK (EU2012)"

From UFOpaedia
Jump to navigation Jump to search
m
Line 15: Line 15:
 
* iHours
 
* iHours
 
===GetEvents===
 
===GetEvents===
GetEvents generates the array of events for each month (<THQEvent> arrEvents) and uses AddAIEvent to fill it.  
+
GetEvents generates the array of events for each month (<THQEvent> arrEvents) and uses [[XComStrategyGame.UPK (EU2012)#AddAIEvent|AddAIEvent]] to fill it.  
  
 
It checks for several conditions:
 
It checks for several conditions:
Line 27: Line 27:
 
** If objective is 5 (Abduct), eMission = 2 (Abduction)
 
** If objective is 5 (Abduct), eMission = 2 (Abduction)
 
** If objective is 6 (Terrorize), eMission = 7 (TerrorSite)
 
** If objective is 6 (Terrorize), eMission = 7 (TerrorSite)
* If there's no last mission (for the month it calls function AddAIEvent(eMission, 0, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
+
* If there's no last mission (for the month it calls function [[XComStrategyGame.UPK (EU2012)#AddAIEvent|AddAIEvent]](eMission, 0, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
* Otherwise, it calls AddAIEvent (eMission, (m_arrObjectives[iObjective].m_iNextMissionTimer - m_iCounter) / 2, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
+
* Otherwise, it calls [[XComStrategyGame.UPK (EU2012)#AddAIEvent|AddAIEvent]] (eMission, (m_arrObjectives[iObjective].m_iNextMissionTimer - m_iCounter) / 2, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
 
* Function loops until all objectives have a mission added to the array of events
 
* Function loops until all objectives have a mission added to the array of events
  
Line 37: Line 37:
 
* Sets the array arrUFOsShotDown with 10 entries
 
* Sets the array arrUFOsShotDown with 10 entries
 
* Sets the array TObjectives with 8 entries
 
* Sets the array TObjectives with 8 entries
* Calls BuildObjectives function
+
* Calls [[XComStrategyGame.UPK (EU2012)#BuildObjectives|BuildObjectives]] function
 
* m_kResistance.arrCountries.Add(36);
 
* m_kResistance.arrCountries.Add(36);
 
* m_kResistance.arrNoResistance.Add(36);
 
* m_kResistance.arrNoResistance.Add(36);
Line 44: Line 44:
 
* CreateAlienBase - sets location of Alien Base
 
* CreateAlienBase - sets location of Alien Base
 
* Defines TerrorCounter as 2
 
* Defines TerrorCounter as 2
* If ISCONTROLLED() is negative (no Tutorial active) calls function AIAddNewObjectives
+
* If ISCONTROLLED() is negative (no Tutorial active) calls function [[XComStrategyGame.UPK (EU2012)#AIAddNewObjectives|AIAddNewObjectives]]
 
 
 
===MakeMonthlyPlan===
 
===MakeMonthlyPlan===
Calls functions EndOfMonth and AIAddNewObjectives
+
Calls functions [[XComStrategyGame.UPK (EU2012)#EndOfMonth|EndOfMonth]] and [[XComStrategyGame.UPK (EU2012)#AIAddNewObjectives|AIAddNewObjectives]]
  
 
===Update===
 
===Update===
Calls funcions AIUpdateMission and UpdateObjectives
+
Calls funcions [[XComStrategyGame.UPK (EU2012)#AIUpdateMission|AIUpdateMission]] and [[XComStrategyGame.UPK (EU2012)#UpdateObjectives|UpdateObjectives]]
  
 
===UpdateObjectives===
 
===UpdateObjectives===
 
Function defines iNumUnits = 1 and bPaydayUpdate = false
 
Function defines iNumUnits = 1 and bPaydayUpdate = false
*If each objective (kObjective) on the array arrObjectives hasn't been completed, it calls function Update
+
*If each objective (kObjective) on the array arrObjectives hasn't been completed, it calls function [[XComStrategyGame.UPK (EU2012)#Update|Update]]
*If the array FirstBlitzTargets > 0 (is full)
+
*If the array FirstBlitzTargets > 0 (used to define the targets of Abductions)
 
** FirstBlitzCounter is reduced by 1
 
** FirstBlitzCounter is reduced by 1
** If FirstBlitzCounter <= 0 then LaunchBlitz and remove entry from array FirstBlitzTargets
+
** If FirstBlitzCounter <= 0 then starts [[XComStrategyGame.UPK (EU2012)#LaunchBlitz|LaunchBlitz]] and remove entry from array FirstBlitzTargets
 
*Calls World, FundingCouncil.UpdateSlingshotMission
 
*Calls World, FundingCouncil.UpdateSlingshotMission
 
* If the counter HQAssaultCounter > 0, it is reduced by 1
 
* If the counter HQAssaultCounter > 0, it is reduced by 1
 
* if((m_iHQAssaultCounter < 2) && iNumUnits > 1) then m_iHQAssaultCounter = 2
 
* if((m_iHQAssaultCounter < 2) && iNumUnits > 1) then m_iHQAssaultCounter = 2
* If the HQAssaultCounter is 0, and the Geoscape conditions isBusy and GetFinalMission are none, then AIAddNewMission(7, none)
+
* If the HQAssaultCounter is 0, and the Geoscape conditions isBusy and GetFinalMission are none, then [[XComStrategyGame.UPK (EU2012)#AIAddNewMission|AIAddNewMission]](7, none)
 
** Otherwise defines HQAssaultCounter = 1
 
** Otherwise defines HQAssaultCounter = 1
 
* If PaydayUpdate is false, then calls function EXALT().UpdateObjectives(iNumUnits) and adds 1 to the Counter
 
* If PaydayUpdate is false, then calls function EXALT().UpdateObjectives(iNumUnits) and adds 1 to the Counter
Line 67: Line 66:
 
===CurrentlyHasObjective===
 
===CurrentlyHasObjective===
 
For each kObjective on arrObjectives it sees if (GetType) is equal to the eObjective and if so, returns it as true. Otherwise returns false.
 
For each kObjective on arrObjectives it sees if (GetType) is equal to the eObjective and if so, returns it as true. Otherwise returns false.
 +
 +
===AddCouncilMission===
 +
Defines the Council counter used on [[XComStrategyGame.UPK (EU2012)#GetEvents|GetEvents]], using the values COUNCIL_DAY (20.0) and COUNCIL_RAND_DAYS (7.0) found on XComGame.UPK, XGTacticalGameCore. If the Tutorial isn't activated, the CouncilCounter is defined as:
 +
* CouncilCounter = 20.0 * 48 (converts to half-hours)
 +
* CouncilCounter + random number (7.0 * 48 *2) - random (7.0 *48)
 +
 +
===AddHQAssaultMission===
 +
Sets counter for the Base Defense mission, using the values HQASSAULT_MAX_DAYS (21) and HQASSAULT_MIN_DAYS (14) found on XComGame.UPK, XGTacticalGameCore.
 +
* HQAssaultCounter = random (HQASSAULT_MAX_DAYS - HQASSAULT_MIN_DAYS) + HQASSAULT_MAX_DAYS
 +
* Multiplies final value by 48 to convert to half-hours.
 +
 +
===AddLateMission===
 +
Used after the Alien Base is assaulted to add missions, generating the following integers: iNumCouncil, iNumTerror, iNumUFOs, iNumAbductions. It creates a local array of missions (arrMissions) then populates it according to the following:
 +
* If there's no Terror (iNumTerror == 0) mission present, it creates 1 on the array arrMissions
 +
* If there's no Council iNumCouncil == 0) mission present, it creates 1 on the array arrMissions
 +
* If function [[XComStrategyGame.UPK (EU2012)#DetermineBestAbductionTargets|DetermineBestAbductionTargets]] => 3, it creates 1 on the array arrMissions
 +
* Roll for LATE_UFO_CHANCE is positive (50% odds) it adds 1 to iNumUFOs
 +
* Afterwards it randomly chooses 1 mission type from arrMissions
 +
** If choice is 9 it calls functions [[XComStrategyGame.UPK (EU2012)#AddNewTerrorMission|AddNewTerrorMission]] and [[XComStrategyGame.UPK (EU2012)#DetermineBestTerrorTarget|DetermineBestTerrorTarget]] and adds 1 to iNumTerror
 +
** If choice is 11 it calls functions AddCouncilMission and adds 1 to iNumCouncil
 +
** If choice is 2 it adds 1 to iNumAbductions
 +
 +
===AIAddNewObjectives===
 +
  
  
 
[[Category: Game Files (EU2012)]]
 
[[Category: Game Files (EU2012)]]
 
[[Category: Enemy Unknown (2012)]]
 
[[Category: Enemy Unknown (2012)]]

Revision as of 15:46, 12 April 2014

XComStrategyGame.UPK is a Unreal Engine 3 file used to determine several functions of XCOM: Enemy Unknown related to the strategic layer of the game. XComStrategyGame.UPK is divided into several classes, each related to different aspects of the Geoscape/HQ view and described below.

A complete catalog of the file can be found here: Nexusmods wiki page on XComStrategyGame.UPK.

This page will focus on the practical aspects of the file and how they affect playing the game. For details on how to mod the game, you're advised to check the XCOM section at the Nexusmods wiki.

XGStrategyAI

XGStrategyAI contains most of the functions used to generate UFOs and missions, determine type and composition of alien squads, panic changes and so on. The class is further subdivided into Structures, Variables, Functions and and Default Values. The most important functions will be mentioned below.

AddAIEvent

AddAIEvent is used to add a game event (kEvent) to the array of events generated each month (THQEvent).

Each kEvent added to the array consists a mission, its target (country) and the number of hours it will be available:

  • eMission
  • eTarget
  • iHours

GetEvents

GetEvents generates the array of events for each month (<THQEvent> arrEvents) and uses AddAIEvent to fill it.

It checks for several conditions:

  • If iCouncilCounter > 0, it adds a Council mission to the array (11, m_iCouncilCounter / 2, 0)
  • If the all the entries on the array of objectives (arrObjectives) are marked as completed it does nothing, otherwise for each uncompleted objective it adds a mission (eMission):
    • If objective is 0 (Recon) it doesn't add a mission.
    • If objective is 1 (Scout) then eMission = 3 (Crash)
    • If objective is 3 (Flyby) and HQ doesn't have Facility 18 (Hyperwave Relay) then eMission = 0 (None), otherwise eMission = 12 (DLC)
    • If objective is 4 (Hunt), eMission = 5 (HQAssault)
    • If objective is 2 (Harvest), eMission = 4 (LandedUFO)
    • If objective is 5 (Abduct), eMission = 2 (Abduction)
    • If objective is 6 (Terrorize), eMission = 7 (TerrorSite)
  • If there's no last mission (for the month it calls function AddAIEvent(eMission, 0, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
  • Otherwise, it calls AddAIEvent (eMission, (m_arrObjectives[iObjective].m_iNextMissionTimer - m_iCounter) / 2, byte(m_arrObjectives[iObjective].m_iCountryTarget), arrEvents)
  • Function loops until all objectives have a mission added to the array of events

InitNewGame

Used when a new game is started.

  • Defines the start date based on the value located on XGDateTime as 00:00:00, January 1st, 2015
  • Sets the array arrUFOsShotDown with 10 entries
  • Sets the array TObjectives with 8 entries
  • Calls BuildObjectives function
  • m_kResistance.arrCountries.Add(36);
  • m_kResistance.arrNoResistance.Add(36);
  • m_kResistance.arrHunted.Add(36);
  • LogResistance(HQ().m_arrSatellites[0].iCountry);
  • CreateAlienBase - sets location of Alien Base
  • Defines TerrorCounter as 2
  • If ISCONTROLLED() is negative (no Tutorial active) calls function AIAddNewObjectives

MakeMonthlyPlan

Calls functions EndOfMonth and AIAddNewObjectives

Update

Calls funcions AIUpdateMission and UpdateObjectives

UpdateObjectives

Function defines iNumUnits = 1 and bPaydayUpdate = false

  • If each objective (kObjective) on the array arrObjectives hasn't been completed, it calls function Update
  • If the array FirstBlitzTargets > 0 (used to define the targets of Abductions)
    • FirstBlitzCounter is reduced by 1
    • If FirstBlitzCounter <= 0 then starts LaunchBlitz and remove entry from array FirstBlitzTargets
  • Calls World, FundingCouncil.UpdateSlingshotMission
  • If the counter HQAssaultCounter > 0, it is reduced by 1
  • if((m_iHQAssaultCounter < 2) && iNumUnits > 1) then m_iHQAssaultCounter = 2
  • If the HQAssaultCounter is 0, and the Geoscape conditions isBusy and GetFinalMission are none, then AIAddNewMission(7, none)
    • Otherwise defines HQAssaultCounter = 1
  • If PaydayUpdate is false, then calls function EXALT().UpdateObjectives(iNumUnits) and adds 1 to the Counter

CurrentlyHasObjective

For each kObjective on arrObjectives it sees if (GetType) is equal to the eObjective and if so, returns it as true. Otherwise returns false.

AddCouncilMission

Defines the Council counter used on GetEvents, using the values COUNCIL_DAY (20.0) and COUNCIL_RAND_DAYS (7.0) found on XComGame.UPK, XGTacticalGameCore. If the Tutorial isn't activated, the CouncilCounter is defined as:

  • CouncilCounter = 20.0 * 48 (converts to half-hours)
  • CouncilCounter + random number (7.0 * 48 *2) - random (7.0 *48)

AddHQAssaultMission

Sets counter for the Base Defense mission, using the values HQASSAULT_MAX_DAYS (21) and HQASSAULT_MIN_DAYS (14) found on XComGame.UPK, XGTacticalGameCore.

  • HQAssaultCounter = random (HQASSAULT_MAX_DAYS - HQASSAULT_MIN_DAYS) + HQASSAULT_MAX_DAYS
  • Multiplies final value by 48 to convert to half-hours.

AddLateMission

Used after the Alien Base is assaulted to add missions, generating the following integers: iNumCouncil, iNumTerror, iNumUFOs, iNumAbductions. It creates a local array of missions (arrMissions) then populates it according to the following:

  • If there's no Terror (iNumTerror == 0) mission present, it creates 1 on the array arrMissions
  • If there's no Council iNumCouncil == 0) mission present, it creates 1 on the array arrMissions
  • If function DetermineBestAbductionTargets => 3, it creates 1 on the array arrMissions
  • Roll for LATE_UFO_CHANCE is positive (50% odds) it adds 1 to iNumUFOs
  • Afterwards it randomly chooses 1 mission type from arrMissions
    • If choice is 9 it calls functions AddNewTerrorMission and DetermineBestTerrorTarget and adds 1 to iNumTerror
    • If choice is 11 it calls functions AddCouncilMission and adds 1 to iNumCouncil
    • If choice is 2 it adds 1 to iNumAbductions

AIAddNewObjectives