Author Topic: [DONE] [Suggestion] Geoscape pop-up events  (Read 22908 times)

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
[DONE] [Suggestion] Geoscape pop-up events
« on: July 03, 2019, 04:40:34 pm »
I would like to request a new type of geoscape feature, based on a new type of script.

What it does: displays a custom pop-up message and awards points.

When it happens: same as alien missions, triggered by chance, month, research and other associated parameters.

I don't want to get into actual technicalities, but I imagine it could be done as a missionScript, except no UFO or site is generated (you get the popup instead) and there is no region or race.

Why do I want it?
I want a new tool for the game to affect the player. Right now we have two options: alien missions and arc scripts. Both are partially applicable, but none can do it well; most notably, missions require actual objects on the geoscape, while arc events cannot be repeatable, etc.

What will I do with this?
All sorts of fun stuff.

Example 1) Hurry up. If you haven't accomplished something by a certain time, something bad will happen.
Haven't destroyed a cult, even though you should have done this ages ago? They just assassinated a politician, costing you points.

Example 2) Rewards. Having something researched or being within some timeframe enables you to get something at random, outside the mission system.
So you discovered some alien conspiracy? An anonymous donor sent you a crate of weapons to further your cause. May be influenced by month (the earlier, the better chance).

Example 3) Random events, Microprose-style.
Something explodes, costing you points. You impressed a UN official, giving you points. Your daughter suddenly got married to a Hybrid representative, so they give you some research as a wedding gift. Etc., etc.

Finnik already expressed interest in coding it, but we'd like to hear your opinion first. Would you agree to add something like this? If yes, what are your requirements/advice?

EDIT: The event can also give research, items, etc. If not a problem, chosen randomly from a given list.
« Last Edit: September 12, 2019, 09:44:57 am by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [Suggestion] Pop-up events
« Reply #1 on: July 03, 2019, 04:47:18 pm »
Requirement: "displays a custom pop-up message and awards points"


Example 1: doesn't award points but steals them

Example 2: no points awarded or stolen, and there is something about items which was not in the requirements

Example 3: points stolen again, mixed with items that were not required


None of the examples matches the requirement.


In general, OK with me.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Pop-up events
« Reply #2 on: July 03, 2019, 04:53:06 pm »
Oops, the part with assigning items/research disappeared from my post... Corpo bathroom is not a good place to type long posts :)
As for the points, I thought I could simply give an event a negative value, but if it's not how it works, then whatever should be done.
Thanks for greenlighting the idea!
Do you think it can be done with missionScripts, or we need some new entity?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [Suggestion] Pop-up events
« Reply #3 on: July 03, 2019, 05:25:20 pm »
new, let's say eventScript

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Pop-up events
« Reply #4 on: July 03, 2019, 05:27:48 pm »
OK, thanks.
In this case I propose to keep exactly the same flags/format, since they generally overlap.
I just know I'll mix them up otherwise!

Offline luke83

  • Commander
  • *****
  • Posts: 1559
    • View Profile
    • openxcommods
Re: [Suggestion] Pop-up events
« Reply #5 on: July 05, 2019, 12:56:00 am »
Could be useful for me also... Watching with interest.

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [Suggestion] Pop-up events
« Reply #6 on: July 05, 2019, 06:32:24 am »
Yes indeed, great idea.

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Re: [Suggestion] Pop-up events
« Reply #7 on: July 07, 2019, 01:01:50 am »
I've made some progress with that feature. Thanks to all who helps me to understand how the code works!
I'm sure my code is not perfect, but as a very initial thing it looks working, any advise how to make it better are welcome.
At the moment, I accept such rulset input:
Code: [Select]
eventScripts:
  - type: STR_TEST_EVENT_SCRIPT             # the type/name is used for overwriting or deleting purposes
    eventWeights:                           # list of event names with weights, nothing will happen if omitted
      0:                                    # these are split into monthly chunks, just like in mission scripts do
        STR_TEST_EVENT1: 50         
        STR_TEST_EVENT2: 50
    firstMonth: 0                           # months this command runs on, 0 runs on startup of a new game (default 0)
    lastMonth: 12                           # don't run after this month. -1 denotes no limit (default -1)
    executionOdds: 100                      # % chances of this command executing (default 100)
    minDifficulty: 0                        # this command only applies to difficulty levels of this or above (default 0)
    maxDifficulty: 4                        # this command only applies to difficulty levels of this or below (default 4)
    researchTriggers:                       # a list of research topics that can influence the execution of this command (default empty)
       STR_THE_MARTIAN_SOLUTION: true       # in this case, the command would only run if the player has the Martian Solution
       STR_CYDONIA_OR_BUST: false           # and does NOT have Cydonia or Bust

events:
  - name: STR_TEST_EVENT1                   # name of the event, used for linking to eventScripts
    description: STR_TEST_DESCRIPTION       # text, that describes the event and shows in the popup window. If omitted, no popup window will open, so you can design it as a hidden event or just Ufopedia article (see below).
    background: BACK01.SCR                  # sets the background to the popup window. Defaul is BACK13.SCR
    points: -8000                           # amount of global score points (or research score), that player will have at the end of the month (a positive value means bonus, negative - penalty)
    funds: 1000000                          # amount of money in $ that will receive player as an event outcome (a positive value means bonus, negative - penalty)
    timer: 2100                             # fixed delay timer in minutes for the event to occur after the start of the month (rounded down to the nearest 30, default 0)
    timerRandom: 600                        # additional random part for delay timer, the game chooses a value between 0 and this number to add to event delay timer (default 0)
    bonusResearch: STR_EVENT_RESEARCH       # research project, that will be discovered after an event occurs. can also trigger its getOneFree and getOneFreeProtected and respect its sequentialGetOneFree and spawnItem properties
    abortResearch: STR_TERMINATE_EVENT      # research project, the discovery of which will terminate already spawned event from occurring to the player and delete ongoing event from the game
    spawnedItem: STR_LASER_PISTOL           # this item will be transferred to players first base after event spawned

Here is a small presentation of how it works in-game. Sorry my poor English, I was really nervous about events future while recording it.

I'd like to hear your feedback about events feature and if there could be some code or game design improvement. Also, I would like to discuss these topics:

1) As research discovering processing individually, id like to make possible for bonusResearch to also respect research properties, such as getOneFree, getOneFreeProtected and sequentialGetOneFree. That will make possible for a modder to design more complex events scenarios, making it random and predictable at the same time. You can set up several events with one project as bonusResearch, having a sequence of getOneFrees (let's say, a chain of investigation for XCF). So, your player will come to a single chain of opened Ufopedia articles, that will describe sequentional arc story, but the player will have access to it in different ways in order, that you as a modder can't predict, but it will outcome as a solid story that will be told in the order you specify. I'd guess, we will be closer to it if another bonus researches could trigger getOneFrees, but this is a different topic. Anyway, as a modder and game designer that helps in the development of XCF, I definitely need that one.

2) As for the score, I'm operating with the global score (or researchScore, if you prefer), as there is no specification for the region. It's not hard to add processing of region with what spawned event should be associated. I didn't do it as it was not in initial suggestion and I'd like to know if someone needs that. I think it would be a good upgrade to my logic.

3) Should there be moddable colors as event property and if yes, maybe devs will share their wisdom how to do that.

4) As an outcome for that discussion I'd really would like to know if there any chance for my thing to be integrated to OXCE and if yes, what changes to it I need to do.
« Last Edit: July 14, 2019, 08:36:26 pm by Finnik »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Pop-up events
« Reply #8 on: July 14, 2019, 09:25:19 pm »
Respecting research properties would be neat, as it's a decent tool for modding fuckery and also easily avoided if so desired.
But what's really interesting is the option to run events by region. After all, "A group of Chaos cultists in STR_SOUTH_AMERICA" sounds much more interesting than "A group of Chaos cultists in buggerall on Earth".


To reiterate: in the current code from Finnik, the points from events count against the research pool - the only pool which is global. Which is fine and correct for general events, unrelated to any region. Like for example, "you impressed the Council with your mad juggling skills".
But I would also like a subset which works with regions. For example a terrorist attack which costs you points should be region-based rather than general, because that's how the game works. Also, "Something rotten in Scandinavia" sounds better than ""Something rotten in some unspecified location on Earth."

To expand it even further, it would be cool if the message displayed could optionally also mention a random city in the region. "Political assassination in Irkutsk" just sound way better than "Political assassination in Siberia".
« Last Edit: July 19, 2019, 12:23:26 pm by Solarius Scorch »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #9 on: September 12, 2019, 09:46:03 am »
Test build: https://lxnt.wtf/oxem/builds//Extended/Extended-5.6.3-2eae16abd-2019-09-12-win64.7z

Sample ruleset (also attached as zip):

Code: [Select]
eventScripts:
  - type: STR_TEST_EVENT_SCRIPT
    eventWeights:
      0:
        STR_TEST_EVENT1: 90
        STR_TEST_EVENT2: 10
      6:
        STR_TEST_EVENT1: 100
    firstMonth: 0
    lastMonth: 12
    executionOdds: 100
    minDifficulty: 0
    maxDifficulty: 4
  - type: STR_TEST_EVENT_SCRIPT2
    eventWeights:
      0:
        STR_TEST_EVENT2: 100
    firstMonth: 0
    lastMonth: 12
    executionOdds: 100
    minDifficulty: 0
    maxDifficulty: 4
    researchTriggers:
       STR_THE_MARTIAN_SOLUTION: true
       STR_CYDONIA_OR_BUST: false

events:
  - name: STR_TEST_EVENT1
    description: STR_TEST_DESCRIPTION1
    background: BACK13.SCR
    regionList: [STR_NORTH_AMERICA, STR_EUROPE]
    city: true
    points: 2000
    funds: 100000000
    itemList: [STR_LASER_PISTOL, STR_SOMETHING_ELSE]
    randomItem: false        # false = all items from the list are given, true = only one item is given (randomly)
    researchList: [STR_LASER_PISTOL]
    interruptResearch: STR_LASER_PISTOL
    timer: 1700
    timerRandom: 60
  - name: STR_TEST_EVENT2
    description: STR_TEST_DESCRIPTION2
    background: BACK01.SCR
#    regionList: []
#    city: false
    points: -2000
    funds: -100000000
#    itemList: [YYY]
    researchList: [STR_LASER_RIFLE]
#    interruptResearch: XXX
    timer: 2700
    timerRandom: 150

extraStrings:
   - type: en-US
     strings:
       STR_TEST_EVENT1: "Political assassination in {0}"
       STR_TEST_EVENT2: "Test title"
       STR_TEST_DESCRIPTION1: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
       STR_TEST_DESCRIPTION2: "This one is rather short."
« Last Edit: October 11, 2019, 04:27:20 pm by Meridian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #10 on: September 12, 2019, 01:19:14 pm »
Thank you.

I'm having lots of fun with this!

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #11 on: September 12, 2019, 02:50:15 pm »
Really great. Many ideas hovering in air around my head...
Meridian we praise.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #12 on: September 18, 2019, 08:41:10 pm »
Added more attributes.
First, similar to research triggers, there are item triggers.

Code: [Select]
eventScripts:
  - type: xxx
...
    itemTriggers:
       STR_ITEM1: true
       STR_ITEM2: false

Items considered are ONLY items directly in base stores.

Not considered are:
1. weapons, ammo, vehicles and items in crafts
2. items in transfer
3. weapons, ammo, vehicles and items in crafts in transfer
4. items worn by soldiers (armor)
5. items being researched
6. potential manufacture refunds
7. potential facility dismantle refunds
8. anything else I forgot

Second, there is also a possibility to define minimum and maximum required score (from the previous month), similar to how the difficulty constraint works.
The score constraint is NOT checked at the beginning of the game (before first month).

Code: [Select]
eventScripts:
  - type: xxx
...
    minScore: -1000
    maxScore: 200

Test build: https://lxnt.wtf/oxem/builds//Extended/Extended-5.6.4-4e8202a0f-2019-09-18-win32.7z

EDIT: there is also a possibility to define minimum and maximum required funds (from the current month, i.e. after monthly rating), similar to how the difficulty constraint works.
The funds constraint is NOT checked at the beginning of the game (before first month).

Code: [Select]
eventScripts:
  - type: xxx
...
    minFunds: -1000
    maxFunds: 200
« Last Edit: October 11, 2019, 04:19:50 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #13 on: October 10, 2019, 08:24:23 pm »
More attributes added (oneTimeSequentialEvents and oneTimeRandomEvents) into the eventScript for one-time (non-repeatable) events.

Code: [Select]
eventScripts:
  - type: STR_TEST_EVENT_SCRIPT
    eventWeights:                 # randomly generated repeatable events
      0:
        STR_TEST_EVENT_A: 100
        STR_TEST_EVENT_B: 100
    oneTimeSequentialEvents:      # sequentially generated one-time events (cannot repeat)
      - STR_TEST_EVENT2
      - STR_TEST_EVENT3
      - STR_TEST_EVENT4
      - STR_TEST_EVENT5
    oneTimeRandomEvents:          # randomly generated one-time events (cannot repeat)
      STR_TEST_EVENT1R: 100
      STR_TEST_EVENT2R: 100
      STR_TEST_EVENT3R: 100
      STR_TEST_EVENT4R: 100
      STR_TEST_EVENT5R: 100

Although you can use all 3 types in one script, I suggest using only one type at a time (i.e. split it into multiple scripts)
« Last Edit: October 10, 2019, 08:30:35 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [DONE] [Suggestion] Geoscape pop-up events
« Reply #14 on: October 31, 2019, 12:05:39 pm »
More attributes added for events:

1. music - String ID of the music to play when this event pops up on the Geoscape.
2. everyItemList - A list of item IDs. When this event pops up they are all transferred to the HQ (within 1 hour).
3. randomItemList - A list of item IDs. When this event pops up one of them is selected randomly and transferred to the HQ (within 1 hour).
4. weightedItemList - A weighted list of item IDs. When this event pops up one of them is selected randomly (respecting given weights) and transferred to the HQ (within 1 hour).

Attributes itemList and randomItem have been deprecated (and will be removed in oxce 6.2).

Edit:

5. everyMultiItemList - A list of item IDs and their quantities. When this event pops up they are all transferred to the HQ (within 1 hour).
« Last Edit: December 30, 2019, 04:53:50 pm by Meridian »