Author Topic: [DONE] [Suggestion] Arc Script  (Read 6443 times)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
[DONE] [Suggestion] Arc Script
« on: April 27, 2019, 12:37:58 pm »
--requested by Hobbes

Hello everyone,

here's a new script that should allow you to orchestrate your arcs and missions a bit better (if you want).

The idea is that you can script when should certain events occur and in which order and use those events to affect mission scripts.
Or, you can just use it to display "a tip of the month", I don't judge :)

The arc script runs just before the mission script, i.e. February arc script does already affect February mission script.

Here's the syntax:

Code: [Select]
arcScripts:
  - type: earlyGame                     # the type/name is used for overwriting or deleting purposes
    sequentialArcs:                     # the type of research topics to be "discovered", each month 0 or 1, processed sequentially
      - STR_EARLY_ARC_1_START
      - STR_EARLY_ARC_2_START
      - STR_EARLY_ARC_3_START
    randomArcs:                         # the type of research topics to be "discovered", each month 0 or 1, chosen randomly considering weights
      STR_SIDE_STORY_1_START: 50
      STR_SIDE_STORY_2_START: 30
      STR_SIDE_STORY_3_START: 20
    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: 75                   # % chances of this command executing (default 100)
    maxArcs: 4                          # maximum number of arcs this command can generate (together during the whole game), -1 for infinite (default -1)
    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

firstMonth, lastMonth, minDifficulty, maxDifficulty and researchTriggers should be self-explanatory.

sequentialArcs and randomArcs are meant to be either-or, but it is possible to use both at the same time if you really want.
If you use both:
 - executionOdds are done only once, same result is used for both types
 - sequential arc is generated first, random arc second
 - maxArcs always applies, e.g. if maxArcs=1 and sequential arc was generated, random arc will not be generated even if everything else was satisfied

maxArcs counts any discovered topics, even from other arc scripts or normal game; and if you have any duplicate topics within a command it will count all duplicates as separate topics too

The "discovered" research topics behave almost identically to normal research:
+ lookups, unlocking, disabling and other features affecting normal research will apply (as if this research was finished in your HQ)
+ score will be awarded
+ ufopedia article will pop up (if available)
- getOneFree DOES NOT work (intentionally, no need to report as bug)

Test download: https://lxnt.wtf/oxem/builds//Extended/Extended-5.4-41f8647ec-2019-04-27-win64.7z

Feedback welcome...
« Last Edit: April 28, 2019, 01:11:40 am by Meridian »

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: [DONE] [Suggestion] Arc Script
« Reply #1 on: April 27, 2019, 04:05:33 pm »
Since I requested it, here's are more details on how to use this new feature.

The logic behind it is that can use research topics to trigger specific events, here are a couple examples how it can be used:
* Randomly give the player research A, B or C at the beginning - each research then unlocks specific tech at game start, giving the player different starting items/research for each campaign
* Randomly give each month one research topic D, E, F... - each research then unlocks a specific mission(s) for that month
* Give tech G on month 0, tech H on month 1 and tech I on month 2 - for multimission story arcs spawning in sequence across several months
* Give tech J and spawn corresponding mission, if mission is victory receive tech K, which then unlocks additional mission next month - for making missions dependent on the previous one
* If research L is completed or if month X is achieved, give tech M at beginning of next month with the UFOPedia notification - this can be used to provide tips, tutorials, ingame message, whatever relevant info you want to give the player.

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Re: [DONE] [Suggestion] Arc Script
« Reply #2 on: April 28, 2019, 12:56:00 am »
OMG! That is very promising!

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
Re: [DONE] [Suggestion] Arc Script
« Reply #3 on: September 18, 2019, 08:40:16 pm »
Added more attributes.
First, similar to research triggers, there are item triggers.

Code: [Select]
arcScripts:
  - 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]
arcScripts:
  - 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]
arcScripts:
  - type: xxx
...
    minFunds: -1000
    maxFunds: 200
« Last Edit: October 11, 2019, 04:19:08 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
Re: [DONE] [Suggestion] Arc Script
« Reply #4 on: May 14, 2020, 08:05:22 pm »
Added one more attribute (in OXCE v6.5).
Similar to research and item triggers, there are base facility triggers.

Code: [Select]
arcScripts:
  - type: xxx
...
    facilityTriggers:
       STR_FACILITY1: true
       STR_FACILITY2: false

Facilities from all bases are considered.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
Re: [DONE] [Suggestion] Arc Script
« Reply #5 on: October 24, 2021, 06:30:52 pm »
OXCE 7.1.4 added triggers based on existence and non-existence of xcom bases in regions and countries, see https://openxcom.org/forum/index.php/topic,7215.msg141846.html#msg141846