Author Topic: Mission Scripting  (Read 27044 times)

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Mission Scripting
« on: July 29, 2015, 09:37:42 am »
Mission scripting is live. Didn't find this anyware (it's from Warboy) so I'm posting it here:

Code: [Select]
#  - type: example                       # the type/name is used for overwriting or deleting purposes.
#    firstMonth: 0                       # months this command runs on, 0 runs on startup of a new game (default 0)
#    lastMonth: 0                        # don't run after this month. in this context we mean "run once". -1 denotes no limit (default -1)
#    label: 1                            # label, used for conditionals (default 0)
#    conditionals: [1, -2]               # conditional list, just like mapscripts (default none)
#    missionWeights:                     # the type of mission to spawn (omit to pick one from the mission table) (default none)
#      0:                                # these are split into monthly chunks, and can contain multiple entries,
#        STR_ALIEN_RESEARCH: 20          # including weighted odds, but there is a caveat here:
#        STR_ALIEN_ABDUCTION: 30         # you cannot mix and match missions with mission site objectives (ie: terror) with regular missions,
#        STR_ALIEN_CROP_CIRCLES: 30      # they are generated too differently. using executionOdds and conditionals instead can achieve
#        STR_CATTLE_MUTILATION: 20       # exactly the same thing. similarly, terror missions should not appear in regional mission weights (regions.rul)
#    executionOdds: 100                  # % chances of this command executing (default 100)
#    targetBaseOdds: 75                  # % chances of this mission targeting a region containing an xcom base instead of random (default 0)
#    startDelay: 120                     # number of minutes to delay the start of the mission (rounded down to the nearest 30, 0 to use the wave timer from the mission itself) (default 0)
#    raceWeights:                        # can override established monthly race weights here if desired (default empty)
#      0:
#        STR_SECTOID: 100                # in this case we want a sectoid mission, so they get 100%
#    regionWeights:                      # again, this can override the defined mission region weights (default empty)
#      0:                                # this won't come into play here unless the mission doesn't target an xcom base, as described above.
#        STR_SAMPLE_REGION1: 20          # IF OMITTED:
#        STR_SAMPLE_REGION2: 30          # for a terror type mission, all regions that meet the criteria will be weighed equally.
#        STR_SAMPLE_REGION3: 50          # for regular missions the normal regional distribution weights will be applied.
#    minDifficulty: 0                    # this command only applies to difficulty levels of this or above (default 0)
#    researchTriggers:                   # a list of research topics that can influence the execution of this mission (default empty)
#      STR_THE_MARTIAN_SOLUTION: true    # in this case, the mission would only run if the player has the martian solution
#      STR_CYDONIA_OR_BUST: false        # and does NOT have Cydonia or bust
#    maxRuns: 12                         # this mission type can only execute this number of times, -1 for infinite (default -1)
#    avoidRepeats: 12                    # this means "store an array of the 12 previous coordinates, and don't use them again" (default 0)
#    varName: researching                # this is an internal variable name, used for tracking maxruns and avoidRepeats (default none)
#    useTable: false                     # check this mission type appears in the mission tables, and remove it if it does? (default true)
« Last Edit: July 29, 2015, 11:50:02 am by Warboy1982 »

Offline liberation

  • Captain
  • ***
  • Posts: 75
    • View Profile
Re: Mission Scripting
« Reply #1 on: July 29, 2015, 09:10:27 pm »
Epic  8) cheers for the post robin!

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Scripting
« Reply #2 on: July 29, 2015, 09:27:54 pm »
Didn't find this anyware (it's from Warboy) so I'm posting it here:

This explanation is included as comments in the missionScript.rul file :)

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Mission Scripting
« Reply #3 on: July 29, 2015, 09:51:21 pm »
@liberation: I'm not responsible for Mission Scripting at all, I merely made the thread when I saw the update nightly.

This explanation is included as comments in the missionScript.rul file :)
Yeah, Warboy edited my post pasting that (an updated version of what I posted initially). I still haven't looked into it.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Scripting
« Reply #4 on: August 01, 2015, 05:15:36 am »
so... any questions? have people been messing about with it at all? any problems? (apart from the loading/deleting issue that's already solved)

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Scripting
« Reply #5 on: August 01, 2015, 06:31:49 am »
so... any questions? have people been messing about with it at all? any problems? (apart from the loading/deleting issue that's already solved)

I've been testing a few things but so far minor stuff, like adding additional missions. I've tried adding the Shipping attacks but that will have to wait until TFTD is fully implemented. The Research triggers are also very interesting but I need first to implement other stuff before I start toying with those.

Offline Zeno

  • Squaddie
  • *
  • Posts: 6
    • View Profile
Re: Mission Scripting
« Reply #6 on: August 01, 2015, 11:14:50 pm »
Research trigger is going to be giving a lot of amazing options; you could research an alien weapon, and then the aliens change to adapt
Being able to force a mission of a type/enemy is wonderful, especially being able to force a mission in a region that has an XCOM base in it. You can actually ensure that you get a UFO in the first week.
maxRuns is dangerous as hell if you're setting up a mod that uses plot-based missions; if the player misses a critical one for whatever reason, the players campaign could be gimped if the mod didn't build the missions with research redundancies in mind.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Scripting
« Reply #7 on: August 02, 2015, 01:27:19 am »
Research trigger is going to be giving a lot of amazing options; you could research an alien weapon, and then the aliens change to adapt
[/quote]
You can now actually trigger the appearance of Mutons to plasma weapon research, which is a bit ironic since many players of the original (myself included) wrongly thought that it was the case.

Quote
Being able to force a mission of a type/enemy is wonderful, especially being able to force a mission in a region that has an XCOM base in it. You can actually ensure that you get a UFO in the first week.

You already get this on vanilla. The first mission is always Alien Research crewed by Sectoids and it takes place on the region of your starting base. But your small radar might not be able to detect the initial UFO.

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Mission Scripting
« Reply #8 on: August 02, 2015, 09:42:35 am »
  - type: researchRetaliation
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    researchTriggers:
      STR_THE_MARTIAN_SOLUTION: true
    startDelay: 150
    targetBaseOdds: 100
    useTable: false
    label: 1

  - type: beginnerRetaliation
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    firstMonth: 14
    targetBaseOdds: 100
    useTable: false
    conditionals: [-1]
    label: 2
    startDelay: 150

Looking at these I understand that "beginnerRetaliation" (conditionals: [-1]) starts if "researchRetaliation" (label: 1) fails.
Is this interpretation correct?
(Also what exactly "fails" means? The player shoots down the UFOs/wipes clean the mission site, or the command itself fails because" executionOdds" missed?)
« Last Edit: August 02, 2015, 10:15:09 am by robin »

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Scripting
« Reply #9 on: August 02, 2015, 02:09:42 pm »
failure in this context literally means "did not run"
causes for a command to fail are:

any of the conditional checks didn't pass
any of the research triggers were not met
the executionOdds check didn't pass
the maxRuns has already been hit
(for terror sites) no suitable location could be found to carry out the attack
the game month is less than the command's firstMonth
the game month is greater than the command's lastMonth
the difficulty is too low

so in this case, researchRetaliation takes priority, as it is listed first.
it processes the list above. if all of the conditions are met, it creates the mission, and post a "success" (1), otherwise it does nothing and posts a "failure" (-1)

then beginnerRetaliation:
process the list above. if all of the conditions are met, create the mission, post a "success" (2), otherwise do nothing and posts a "failure" (-2)

etc.
« Last Edit: August 02, 2015, 02:27:19 pm by Warboy1982 »

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Scripting
« Reply #10 on: August 02, 2015, 02:11:34 pm »
  - type: researchRetaliation
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    researchTriggers:
      STR_THE_MARTIAN_SOLUTION: true
    startDelay: 150
    targetBaseOdds: 100
    useTable: false
    label: 1

  - type: beginnerRetaliation
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    firstMonth: 14
    targetBaseOdds: 100
    useTable: false
    conditionals: [-1]
    label: 2
    startDelay: 150

Looking at these I understand that "beginnerRetaliation" (conditionals: [-1]) starts if "researchRetaliation" (label: 1) fails.
Is this interpretation correct?
(Also what exactly "fails" means? The player shoots down the UFOs/wipes clean the mission site, or the command itself fails because" executionOdds" missed?)

The logic tree of the retaliation sequence is:
1) If Martian Solution is researched then run retaliation mission
2) Otherwise if 1) is false (failed to run) and month >= 14 then run retaliation with 100% of spawning in a region with an XCom base, and don't use the mission table (the list of missions assigned to regions), with a delay of 150
3) Otherwise if 1) and 2) are false and difficulty level = 1 (experienced) and month >= 13, then run retaliation, with the conditions described before
4) Otherwise if 1), 2) and 3) are false and difficulty level = 2 (veteran) and month >= 12, then run retaliation
5) Otherwise if 1), 2), 3) and 4) are false and difficulty level = 3 (genius) and month >= 11, then run retaliation
6) Otherwise if 1), 2), 3), 4) and 5) are false and difficulty level = 4 (superhuman) and month >= 10, then run retaliation
« Last Edit: August 02, 2015, 02:47:01 pm by Hobbes »

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Mission Scripting
« Reply #11 on: August 02, 2015, 02:27:30 pm »
So that whole thing means that, from a certain point in time depending on various factors (research, month, game difficulty), aliens will start retaliating in loop.
This in addition to normal retaliation triggered by soothing down UFOs.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Scripting
« Reply #12 on: August 02, 2015, 02:44:18 pm »
hobbes, check your comparators, you've got = where you should have >=, but otherwise, yes. that.

Correct, thank you and fixed, forgot to add that.

So that whole thing means that, from a certain point in time depending on various factors (research, month, game difficulty), aliens will start retaliating in loop.
This in addition to normal retaliation triggered by soothing down UFOs.

Yup, if by retaliation in loop you mean a monthly retaliation mission.
« Last Edit: August 02, 2015, 02:47:36 pm by Hobbes »

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Mission Scripting
« Reply #13 on: August 02, 2015, 03:05:53 pm »
The check of the conditionals is done after each mission? Monthly?
For example what if want to chain missions:

  - type: doBasicMission1
    firstMonth: 0
    executionOdds: 50
    label: 1
    useTable: false
  - type: ifBasicMission1Fails_DoThisBasicMission2
    firstMonth: 0
    executionOdds: 100
    conditionals: [-1]
    useTable: false
  - type: else_DoBasicMission1FollowUp
    firstMonth: 0
    executionOdds: 100
    conditionals: [1]
    useTable: false

(so each month I'd have 50% BasicMission1+FollowUp or 50% BasicMission2)
?

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Scripting
« Reply #14 on: August 02, 2015, 04:00:15 pm »
precisely.
although it's worth mentioning that you can omit the exectutionOdds if they're 100, and the firstMonth if that's 0 (those are the default values)

to do "normal" mission generation all you _NEED_ to define in the command is the "type"
« Last Edit: August 02, 2015, 04:06:59 pm by Warboy1982 »