Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom statuses from mods for units #322

Closed
RealityMachina opened this issue Oct 31, 2018 · 5 comments · Fixed by #447
Closed

Allow custom statuses from mods for units #322

RealityMachina opened this issue Oct 31, 2018 · 5 comments · Fixed by #447
Labels
enhancement needs-docs Needs documentation

Comments

@RealityMachina
Copy link
Contributor

The specific function to change would be GetStatusStringsSeparate in XComGameState_Unit, which conveniently is the one stop place the game has for knowing what kind of status string to deliver.

By default it just checks projects and covert actions, but an event trigger for a tuple to come back with a string when applicable would allow for mods with unique strategy functions for units to give proper statuses of units interacting with them.

@Xymanek
Copy link
Member

Xymanek commented Oct 31, 2018

Maybe a new ESoldierStatus entirely? Something like eStatus_AwayFromAvenger that strategy mods can then use as they want?

@Xymanek
Copy link
Member

Xymanek commented Oct 31, 2018

The intend of my initial idea was to not confuse other mods and game systems which may attempt to look for the current covert op. However thinking about this more, maybe we should take this a step further? Make something like CHItemSlot but for soldier status. Some idea for callbacks it will have:

  • GetStatusString
  • GetTimeValue
  • CanVisitInArmoury (thinking of LW2 advisors)
  • CanChangeLoadout (thinking of LW2 advisors again but during retals in that region)
  • CanGainXP (for the all soldiers gain XP mod)

Pretty sure there can be other uses. As for how it can be implemented, we can take inspiration from Firaxis:

//@TODO - rmcfall/jbouscher - Refactor these enums? IE. make location a state object reference to something? and make status based on the location?
//*******************************************
enum ESoldierStatus

@Xymanek
Copy link
Member

Xymanek commented Nov 11, 2018

For the record: I spoke to robo on discord and he gave a very good reason to keep using eStatus_CovertAction - existing code/mods uses it to distinguish units that are not on avenger. So I scrap my above suggestions for sake of simplicity

pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Apr 30, 2019
Further to an earlier pull request, this change adds two extra events that
allow mods to customise unit status strings.

The first is 'OverridePersonnelStatus', which can override the status strings
determined by `GetPersonnelStatusSeparate()`. The event takes the form:

   {
      ID: OverridePersonnelStatus,
      Data: [out string Status, out string TimeLabel, out int TimeNum,
             out int State, out bool HideTime],
      Source: Unit
   }

The second event is 'OverridePersonnelStatusTime', which can override the
time parts of the status, for example by converting days to hours or vice
versa. The event takes the form:

   {
      ID: OverridePersonnelStatusTime,
      Data: [out string TimeLabel, out int TimeNum],
      Source: Unit
   }

This commit also introduces a new config variable -
CHHelpers.UseNewPersonnelStatusBehavior - that, when set, makes
GetPersonnelStatus() go through GetPersonnelStatusSeparate(). This is
to help ensure consistency between the two methods.

Finally, GetStatusStringsSeparate() and GetMentalStateStringsSeparate()
in XComGameState_Unit now trigger the 'OverridePersonnelStatusTime' event
so that listeners can override how times are displayed in those cases.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue May 4, 2019
Further to an earlier pull request, this change adds two extra events that
allow mods to customise unit status strings.

The first is 'OverridePersonnelStatus', which can override the status strings
determined by `GetPersonnelStatusSeparate()`. The event takes the form:

   {
      ID: OverridePersonnelStatus,
      Data: [out string Status, out string TimeLabel, out int TimeNum,
             out int State, out bool HideTime],
      Source: Unit
   }

The second event is 'OverridePersonnelStatusTime', which can override the
time parts of the status, for example by converting days to hours or vice
versa. The event takes the form:

   {
      ID: OverridePersonnelStatusTime,
      Data: [out string TimeLabel, out int TimeNum],
      Source: Unit
   }

This commit also introduces a new config variable -
CHHelpers.UseNewPersonnelStatusBehavior - that, when set, makes
GetPersonnelStatus() go through GetPersonnelStatusSeparate(). This is
to help ensure consistency between the two methods.

Finally, GetStatusStringsSeparate() and GetMentalStateStringsSeparate()
in XComGameState_Unit now trigger the 'OverridePersonnelStatusTime' event
so that listeners can override how times are displayed in those cases.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue May 5, 2019
Further to an earlier pull request, this change adds two extra events that
allow mods to customise unit status strings.

The first is 'OverridePersonnelStatus', which can override the status strings
determined by `GetPersonnelStatusSeparate()`. The event takes the form:

   {
      ID: OverridePersonnelStatus,
      Data: [out string Status, out string TimeLabel, out int TimeNum,
             out int State, out bool HideTime],
      Source: Unit
   }

The second event is 'OverridePersonnelStatusTime', which can override the
time parts of the status, for example by converting days to hours or vice
versa. The event takes the form:

   {
      ID: OverridePersonnelStatusTime,
      Data: [out string TimeLabel, out int TimeNum],
      Source: Unit
   }

This commit also introduces a new config variable -
CHHelpers.UseNewPersonnelStatusBehavior - that, when set, makes
GetPersonnelStatus() go through GetPersonnelStatusSeparate(). This is
to help ensure consistency between the two methods.

Finally, GetStatusStringsSeparate() and GetMentalStateStringsSeparate()
in XComGameState_Unit now trigger the 'OverridePersonnelStatusTime' event
so that listeners can override how times are displayed in those cases.
@robojumper
Copy link
Member

Reopening because this needed bit of a redesign and the rewrite PR ended up more intrusive than initially expected.

@robojumper robojumper reopened this May 11, 2019
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue May 23, 2019
Further to an earlier pull request, this change adds two extra events that
allow mods to customise unit status strings.

The first is 'OverridePersonnelStatus', which can override the status strings
determined by `GetPersonnelStatusSeparate()`. The event takes the form:

   {
      ID: OverridePersonnelStatus,
      Data: [out string Status, out string TimeLabel, out int TimeNum,
             out int State, out bool HideTime],
      Source: Unit
   }

The second event is 'OverridePersonnelStatusTime', which can override the
time parts of the status, for example by converting days to hours or vice
versa. The event takes the form:

   {
      ID: OverridePersonnelStatusTime,
      Data: [out string TimeLabel, out int TimeNum],
      Source: Unit
   }

This commit also introduces a new config variable -
CHHelpers.UseNewPersonnelStatusBehavior - that, when set, makes
GetPersonnelStatus() go through GetPersonnelStatusSeparate(). This is
to help ensure consistency between the two methods.

Finally, GetStatusStringsSeparate() and GetMentalStateStringsSeparate()
in XComGameState_Unit now trigger the 'OverridePersonnelStatusTime' event
so that listeners can override how times are displayed in those cases.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jun 4, 2019
This change allows listeners more flexibility in what is displayed for the
time value of a unit's status. For example, a percentage can be used in place
of a time duration.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jun 4, 2019
This change allows listeners more flexibility in what is displayed for the
time value of a unit's status. For example, a percentage can be used in place
of a time duration.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jun 7, 2019
This change allows listeners more flexibility in what is displayed for the
time value of a unit's status. For example, a percentage can be used in place
of a time duration.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jun 13, 2019
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jun 13, 2019
Musashi1584 added a commit that referenced this issue Jun 21, 2019
@Xymanek
Copy link
Member

Xymanek commented Dec 22, 2019

Implemented in 1.19

@Xymanek Xymanek closed this as completed Dec 22, 2019
@robojumper robojumper added the needs-docs Needs documentation label Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs-docs Needs documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants