Ground of Aces Modding
Loading...
Searching...
No Matches
MissionScriptApi Class Referencesealed

This class is available under a global missions_api variable. More...

Public Member Functions

bool SetOutcome (uint missionEntityId, int outcomeIndex, bool isSuccess)
 Declares one of the four outcomes of a mission that ships no JSON. Index is mandatory and follows the same rule as "_missionOutcomes": 0 gone wrong and skill failed, 1 gone wrong but skill passed, 2 as planned but skill failed, 3 as planned and skill passed. Effects are attached with AddOutcomeEffect.
 
bool AddOutcomeEffect (uint missionEntityId, int outcomeIndex, string effectType, string effectValue)
 Adds one effect to an outcome of a mission that ships no JSON - what the crew, the base or the squadron gains or loses when the mission ends that way.
 
bool CreateMission (string flightMissionId)
 Creates a mission and puts it on the war map now, bypassing the weekly draw and the mission's own requirements. This is how a script hands out a follow-up in reaction to what just happened - a chain that JSON requirements cannot express, because the decision depends on more than the previous mission's outcome.
 
bool AddMissionRequirement (uint missionEntityId, string requirementType, string value)
 Adds one appearance gate to a mission that ships no JSON, the way "_missionRequirements" does for a mission that has a file. Without at least one of these a script-authored mission has no gates at all, which means the weekly draw may hand it out on any map and on any date once it has been created for the first time.
 
bool SetTags (uint missionEntityId, params string[] tags)
 Declares which maps a mission that ships no JSON belongs to, the way "_tags" does for a mission that has a file. A map declares the tags it supports in its own "_tags" and the mission declares the tags it is written for; the mission may appear only where the two share a tag.
 
bool SetMissionStat (uint missionEntityId, string skillType, int minValue, int maxValue)
 Sets the min/max range for one skill of a mission, the way "_missionStats" does for a mission that has JSON. Call it from initialize_mission; a mission needs the two skills its script rolls on, and the first one set is the one rolled when all goes to plan.
 
bool SetAsPlannedChance (uint missionEntityId, int chance)
 Sets the chance, 0 to 100, that the mission goes as planned - the "_asPlannedChance" of a JSON mission. Without it the mission always counts as having gone wrong.
 
bool SetMissionLocation (uint missionEntityId, string locationName)
 Places the mission at a named war map location and derives its distance and fuel level from it, exactly as a JSON mission's "_potentialLocations" does. Without a location the mission still flies, but sits at the map origin.
 
bool SetMaxAirplaneSlots (uint missionEntityId, int slots)
 Sets how many airplanes the player may assign - the "_maxPlaneSlots" of a JSON mission.
 
bool SetDifficulty (uint missionEntityId, int difficultyRating)
 Sets the star rating shown to the player, 1 to 3 - the "_difficultyRating" of a JSON mission.
 
uint[] GetMissionAirplaneFormation (uint missionEntityId)
 Get airplane formation assigned to a mission.
 
int GetEnemyCount (uint missionEntityId)
 Get the number of enemy planes reported.
 
bool IsMissionSuccessful (uint missionEntityId)
 Get mission result.
 
string GetMissionId (uint missionEntityId)
 Get the id of the mission definition (the JSON file name) an entity was created from. The shared default mission script uses this instead of a hard-coded id per script.
 
int GetNumberOfEventsSent (uint missionEntityId)
 Get the amount of events sent during a mission.
 

Detailed Description

This class is available under a global missions_api variable.

Member Function Documentation

◆ AddMissionRequirement()

bool AddMissionRequirement ( uint missionEntityId,
string requirementType,
string value )
inline

Adds one appearance gate to a mission that ships no JSON, the way "_missionRequirements" does for a mission that has a file. Without at least one of these a script-authored mission has no gates at all, which means the weekly draw may hand it out on any map and on any date once it has been created for the first time.

Call it from initialize_mission. Gates are combined with AND - every one you add has to pass.

Parameters
missionEntityIdEntity id of mission
requirementTypeOne of RunwayTier, EarliestAppearanceDay, LatestAppearanceDay, CompletedMission
valueRunwayTier: the tier as a number ("2"). EarliestAppearanceDay / LatestAppearanceDay: the day number counted from the campaign start. CompletedMission: "<missionId>", or "<missionId>,success" / "<missionId>,failure" / "<missionId>,cancelled" to require a particular outcome.
Returns
False when the mission or the requirement type is unknown

◆ AddOutcomeEffect()

bool AddOutcomeEffect ( uint missionEntityId,
int outcomeIndex,
string effectType,
string effectValue )
inline

Adds one effect to an outcome of a mission that ships no JSON - what the crew, the base or the squadron gains or loses when the mission ends that way.

Parameters
missionEntityIdEntity id of mission
outcomeIndex0 to 3, see SetOutcome
effectTypeOne of CrewMood, CrewConfidence, CrewEnergy, Damage, BaseMood, BaseConfidence, BaseEnergy, VictoryPoints
effectValueA number ("-40"), or a range ("70-140") which is rolled per flight
Returns
False when the mission, the index or the effect type is unknown

◆ CreateMission()

bool CreateMission ( string flightMissionId)
inline

Creates a mission and puts it on the war map now, bypassing the weekly draw and the mission's own requirements. This is how a script hands out a follow-up in reaction to what just happened - a chain that JSON requirements cannot express, because the decision depends on more than the previous mission's outcome.

Prefer the JSON route where it fits: "_requirementType": 3 with "<id>,success" or "<id>,failure" already covers "unlock B when A succeeded". Reach for this when the condition is something only a script knows - who flew, what the base looks like, how many times this has happened before.

Parameters
flightMissionIdId of the mission to create
Returns
False when the id is unknown, or when called while a mission is being created

◆ GetEnemyCount()

int GetEnemyCount ( uint missionEntityId)
inline

Get the number of enemy planes reported.

Parameters
missionEntityIdEntity id of mission
Returns
The number of enemy planes reported

◆ GetMissionAirplaneFormation()

uint[] GetMissionAirplaneFormation ( uint missionEntityId)
inline

Get airplane formation assigned to a mission.

Parameters
missionEntityIdEntity id of mission
Returns
Return array of ids of airplanes assigned to mission

◆ GetMissionId()

string GetMissionId ( uint missionEntityId)
inline

Get the id of the mission definition (the JSON file name) an entity was created from. The shared default mission script uses this instead of a hard-coded id per script.

Parameters
missionEntityIdEntity id of mission
Returns
The mission id, or null if the entity does not exist

◆ GetNumberOfEventsSent()

int GetNumberOfEventsSent ( uint missionEntityId)
inline

Get the amount of events sent during a mission.

Parameters
missionEntityIdEntity id of mission
Returns
Returns the amount of mission events already sent

◆ IsMissionSuccessful()

bool IsMissionSuccessful ( uint missionEntityId)
inline

Get mission result.

Parameters
missionEntityIdEntity id of mission
Returns
Return whether a mission is successful or not

◆ SetAsPlannedChance()

bool SetAsPlannedChance ( uint missionEntityId,
int chance )
inline

Sets the chance, 0 to 100, that the mission goes as planned - the "_asPlannedChance" of a JSON mission. Without it the mission always counts as having gone wrong.

Returns
False when the mission is unknown

◆ SetDifficulty()

bool SetDifficulty ( uint missionEntityId,
int difficultyRating )
inline

Sets the star rating shown to the player, 1 to 3 - the "_difficultyRating" of a JSON mission.

Returns
False when the mission is unknown

◆ SetMaxAirplaneSlots()

bool SetMaxAirplaneSlots ( uint missionEntityId,
int slots )
inline

Sets how many airplanes the player may assign - the "_maxPlaneSlots" of a JSON mission.

Returns
False when the mission is unknown

◆ SetMissionLocation()

bool SetMissionLocation ( uint missionEntityId,
string locationName )
inline

Places the mission at a named war map location and derives its distance and fuel level from it, exactly as a JSON mission's "_potentialLocations" does. Without a location the mission still flies, but sits at the map origin.

Parameters
missionEntityIdEntity id of mission
locationNameName of the location, see the location list in the modding docs
Returns
False when the mission or the location name is unknown

◆ SetMissionStat()

bool SetMissionStat ( uint missionEntityId,
string skillType,
int minValue,
int maxValue )
inline

Sets the min/max range for one skill of a mission, the way "_missionStats" does for a mission that has JSON. Call it from initialize_mission; a mission needs the two skills its script rolls on, and the first one set is the one rolled when all goes to plan.

Parameters
missionEntityIdEntity id of mission
skillTypeOne of Fight, Bomb, Recon, Transport, Maneuverability, Stealthiness
minValueLower bound of the target the squadron has to beat
maxValueUpper bound of that target
Returns
False when the mission or the skill name is unknown

◆ SetOutcome()

bool SetOutcome ( uint missionEntityId,
int outcomeIndex,
bool isSuccess )
inline

Declares one of the four outcomes of a mission that ships no JSON. Index is mandatory and follows the same rule as "_missionOutcomes": 0 gone wrong and skill failed, 1 gone wrong but skill passed, 2 as planned but skill failed, 3 as planned and skill passed. Effects are attached with AddOutcomeEffect.

Parameters
missionEntityIdEntity id of mission
outcomeIndex0 to 3, see above
isSuccessWhether this outcome counts as the mission having succeeded
Returns
False when the mission is unknown or the index is out of range

◆ SetTags()

bool SetTags ( uint missionEntityId,
params string[] tags )
inline

Declares which maps a mission that ships no JSON belongs to, the way "_tags" does for a mission that has a file. A map declares the tags it supports in its own "_tags" and the mission declares the tags it is written for; the mission may appear only where the two share a tag.

Leaving this unset reads as "default", which every shipped map declares - so an untagged mission is available everywhere. Set it when a mission belongs to one campaign or one map and would make no sense elsewhere.

Parameters
missionEntityIdEntity id of mission
tagsTags this mission is written for, e.g. ("campaign_debden", "default")
Returns
False when the mission is unknown