aliens

Author Topic: Scripted event missions  (Read 15473 times)

Offline skymarshall

  • Sergeant
  • **
  • Posts: 22
    • View Profile
Scripted event missions
« on: August 19, 2014, 09:40:34 pm »
One change that I'd like to make for my own modding benefit is the ability to have scripted event missions similar to cydonia that the player could choose to attack when ready, or similar to the TFTD cruise ships and synomium missions that pop up on a timer rather than being tied to the procedural alien missions.

I'd also want to be able to define specific rewards for scripted missions (for example, unlock parts of the tech tree, unlock new alien ufos/races, or handout specific items)

A framework like this would allow a modder to structure access to some of the tech in the game until the player has completed set objectives.  Whether or not you also tie in the aliens progression too would be a matter of preference.  I would only consider myself to have coded it properly if cydonia (and tftd terror sites) could be tied into the config entirely rather than being hardcoded.

One possible use of this might be (eg) add a ton of extra tech and races to the game that become available after cydonia, and a new set of endgame missions to complete after that dependent on the new content (eg unlock TFTD races and the Tleth mission).  Or, one could add a series of missions that you need to complete to advance up the normal tech tree similar to xcom2012.  Or, you could script in a 2 part bastard to serve up to the player on the first of every month just like TFTD :)

Off the top of my head, I was thinking of expanding the ruleset on my local build to script missions that appear on one of the following triggers:

- A timer, one off or recurring
- Once a particular technology has been researched
- Once a particular manufacturing project has been finished
- Once a particular base facility has been built
- Once another scripted mission is finished

The scripted mission itself might look like:

- A special UFO on the geoscape, following set trajectory
- A special alien base or terror site on the geoscape, at set or random location/city
- A new button on the select destination screen (like cydonia)

The first one would need care not to let the player break the game (eg shoot down a critical UFO over water, or fusion ball it to pieces).  Ditto a plot critical terror site would not expire, or would be an auto game loss if expired.

Once accepted, the scripted mission would need config for the terrain, Alien race and tech level to use - ie exactly what's hardcoded for cydonia.  Ideally, multi part missions would be supported in config.

The rewards and penalties for failing the mission (or letting its timer expire, if it has one) might be

- win/lose the game
- lose support of a specific country
- unlock part of the tech tree
- specific items
- unlock alien races / ufos / tech levels (ie they only start appearing after the scripted mission)

Any thoughts on whether anyone else might find this useful or desirable? 
« Last Edit: August 19, 2014, 09:44:35 pm by skymarshall »

Offline Ran

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: Scripted event missions
« Reply #1 on: August 19, 2014, 11:42:52 pm »
I'd love to see this, but I guess it will be rather hard to implement.
Please try it if you find the time, the possibilities would be really stunning. :)

Offline Avalanche

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: Scripted event missions
« Reply #2 on: August 20, 2014, 12:11:46 am »
I think this would be a wonderful idea, if it's actually possible. It'll open up a whole new frontier for mods, create the possibility for tutorials, and add some new excitement to the game.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Scripted event missions
« Reply #3 on: August 22, 2014, 08:28:19 am »
So much yes for this.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Scripted event missions
« Reply #4 on: August 22, 2014, 07:25:17 pm »
Might be too much at once, but yeah, some version of this (perhaps simpler yet even more powerful) is certainly what I expect of the future of the OXCom project...

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Scripted event missions
« Reply #5 on: August 22, 2014, 07:44:19 pm »
many good ideas but i can imagine if someone starts that is (s)he will be pestered with extension and "oh i have also this idea" and "i would like that condition/result added" posts as long as oxc exists :)

Offline skymarshall

  • Sergeant
  • **
  • Posts: 22
    • View Profile
Re: Scripted event missions
« Reply #6 on: August 22, 2014, 10:15:12 pm »
Haha, I've already started implementing it.  If/When I have something loosely working I'll post up some details of what I've done for feedback

At the very least, I'm planning to:

 - externalize configuration for the Cydonia mission (.. and in doing so allow multiple such missions with different setups)
 - externalize configuration for terrain building on alien bases, cydonia and terror sites so that other missions can use those terrains without issue (right now there's too much hardcoded to the mission type)

Once I've done that, I'll start looking at the more ambitious step of having scripted events start putting special UFOs and bases on the map.

EDIT:

Does anyone know if there is a schema document for the OpenXCom YAML rules files?  Similarly, is any part of the Xcom code for encoding/decoding the YAML files autogenerated, or can I safely go hacking around in there to make changes?
« Last Edit: August 22, 2014, 10:46:33 pm by skymarshall »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Scripted event missions
« Reply #7 on: August 22, 2014, 10:40:34 pm »
i would suggest you talk with warboy or supsuper on irc
since tftd needs 2 step mission for alien base attacks perhaps you could help out or avoid coding the same stuff twice

Offline skymarshall

  • Sergeant
  • **
  • Posts: 22
    • View Profile
Re: Scripted event missions
« Reply #8 on: August 22, 2014, 10:54:35 pm »
Good idea, but premature for now.  Right now, I'm just playing around and learning - if I do get to a point where I'd be confident contributing to the TFTD dev, I'll offer my services

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Scripted event missions
« Reply #9 on: August 22, 2014, 11:03:30 pm »
Does anyone know if there is a schema document for the OpenXCom YAML rules files?  Similarly, is any part of the Xcom code for encoding/decoding the YAML files autogenerated, or can I safely go hacking around in there to make changes?
there is no schema all yaml import is done in the ruleset folder
i wrote a python script that parses most of the cpp code into a schema like description .. but its not finished

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Scripted event missions
« Reply #10 on: September 01, 2014, 12:39:34 am »
now its more or less finished
the structure is based mostly on json-schema see https://spacetelescope.github.io/understanding-json-schema/index.html for examples
i convert the yaml file to json and use this to test/format the document (no its not in the modtester at the moment)
its a bit restrictive in what data is allowed
i added some properties but the only difference to json schema is that instead of
Code: [Select]
type: object
  properties
    number: ... 
i use
Code: [Select]
type: object
  oxcT_properties:
    - number: ... 
this way i have a order in my properties that i can use for formatting exported rulfiles in a predefined way

for now one can use the cleaned up json schema i provide here with json.txt
use
https://yamltojson.com/ to convert your ruleset to json
copy the text from there to here https://json-schema-validator.herokuapp.com/
in the first textarea comes the content of json.txt
in the second the converted ruleset
->validate

unfortunately this site seems to only show the first 4 errors


Offline skymarshall

  • Sergeant
  • **
  • Posts: 22
    • View Profile
Re: Scripted event missions
« Reply #11 on: September 05, 2014, 12:19:06 am »
@falko - thanks for that, I will check it out!  I was asking about the YAML schema as I have some ideas for changes and wondered about how best to put them forward.  I suspect anyone reading will find example YAML easier to follow than a JSON schema, so I will stick to that for now. 

I've created a github fork from the current code (4/9/14) and Scripted Events branch for myself here: https://github.com/skymarshall/OpenXcom/tree/Scripted-Event-Framework

This has the first draft of the scripted event framework I described in the first post, so anyone is welcome to download it and take a look. 


The main part of what I've done is to externalize the Cydonia mission.  Cydonia is now expressed in the rules as follows:


scriptedEvents:
  - type: STR_MARS_CYDONIA_EVENT
    scriptedEventType: 1
    engagementRestrictions:
      research: STR_CYDONIA_OR_BUST
      craft:
      - STR_AVENGER
    destinationEvent:
      buttonText: STR_CYDONIA
    winOnSuccess: true
    loseOnFail: true   
    confirmScreen:
      background: "BACK12.SCR"
      mainText: STR_ARE_YOU_SURE_CYDONIA
      palette: 5       
missionSequences:
  - type: STR_MARS_CYDONIA_EVENT
    missionSequence:
    - deployment: STR_MARS_CYDONIA_LANDING
      race: STR_SECTOID
      briefingScreen:
          background: "BACK01.SCR"
          music: "GMNEWMAR"
          title: STR_MARS_CYDONIA_LANDING
          mainText: STR_MARS_CYDONIA_LANDING_BRIEFING 
          palette: 6     
    - deployment: STR_MARS_THE_FINAL_ASSAULT   
      race: STR_MIXED
      briefingScreen:
          background: "BACK01.SCR"
          music: "GMNEWMAR"
          title: STR_MARS_THE_FINAL_ASSAULT
          mainText: STR_MARS_THE_FINAL_ASSAULT_BRIEFING
          palette: 7                                               


The data on what aliens are present is still held in AlienDeployments.

I've removed hardcoding around the mars and alien base terrains so that they can be used by new mission types.  This means that in my build, you should be able to set up any number of cydonia type missions, with full (well, some) control over the screens shown to the user and with the ability to hand out specific rewards (e.g. technology, items).


I've also created one-off events that show up on the geoscape as either static locations or UFOs.  There's another rule file (example_events.rul) where I've created 2 example events to demonstrate the framework. Here is a sample event:


  - type: STR_SUPER_UFO
    scriptedEventType: 3
    engagementRestrictions:
      facility: STR_LARGE_RADAR_SYSTEM
    ufoEvent:
      name: STR_SUPER_UFO
      ufoType: STR_SUPPLY_SHIP
      locations:
        - lon: 65
          lat: -59
        - lon: 111
          lat: -42
        - lon: 89
          lat: -67                   
    winOnSuccess: false
    loseOnDefeat: false   
    detectedScreen:
      background: "BACK04.SCR"
      music: "GMMARS"
      title: STR_SUPER_UFO
      mainText: STR_SUPER_UFO_MAIN
      palette: 3
    failedToEngageScreen:
      background: "BACK03.SCR"
      music: "GMMARS"
      title: STR_SUPER_UFO_NOENGAGE
      mainText: STR_SUPER_UFO_NOENGAGE_MAIN
      palette: 3 
    successDebriefingScreen:
      background: "BACK01.SCR"
      music: "GMMARS"
      title: STR_SUPER_UFO_SUCCESS
      mainText: STR_SUPER_UFO_SUCCESS_MAIN       
      palette: 0
    failureDebriefingScreen:
      background: "BACK01.SCR"
      music: "GMMARS" 
      title: STR_SUPER_UFO_FAIL
      palette: 0     
    successScoreText: STR_SUPER_UFO_SUCCESS
    successScore: 1000 
    rewardItems:
      STR_ALIEN_ALLOYS: 1000
      STR_ELERIUM_115: 250
      STR_PLASMA_RIFLE: 100               
missionSequences:       
  - type: STR_SUPER_UFO
    missionSequence:
    - deployment: STR_SUPER_UFO
      race: STR_ETHEREAL
      briefingScreen:
          background: "BACK01.SCR"
          music: "GMNEWMAR"
          title: STR_SUPER_UFO
          mainText: STR_SUPER_UFO_BRIEFING
          palette: 6


This example mission spawns a unique UFO (a supply ship) that can only be engaged once a large radar has been built.  It uses a unique AlienDeployment that puts the player against an unreasonable quantity of sectopods, and once beaten, gives a huge stack of equipment. 



Any feedback or ideas welcome!  Having done this as a proof of concept, it would be great if I could polish (or more likely, strip down) some of this into a form suitable for inclusion!

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Scripted event missions
« Reply #12 on: September 05, 2014, 01:00:26 am »
I don't see "script" part here, its closer to simply mission definition.
But this is interesting idea, it will allow many new things form modders.

Offline skymarshall

  • Sergeant
  • **
  • Posts: 22
    • View Profile
Re: Scripted event missions
« Reply #13 on: September 05, 2014, 01:12:40 am »
Yeah, "script" here was meant in the sense of the script of a story (ie. missions are scripted out rather than procedurally generated).  I'm certainly not about to implement a scripting language for events!

<sigh> whatever, your reaction has pretty much convinced me that I need to think up a different name for this feature :/
« Last Edit: September 05, 2014, 01:32:43 am by skymarshall »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: Scripted event missions
« Reply #14 on: September 05, 2014, 10:36:18 am »
I am very interesting about these customization improvements and I like very much your proposal

Diuring my little free time, I am working on improve battlescape generations to allow maps of any rectangular size with positional contraints.

It could be a complent to your job.

If your improvements will allow a new class of scripted event missions such as "Detect aliens activity"-"Alien artifact" of TFTD,
we could reuse already existing terrains of Ufo2000 named Normandy, Storm Mountain and Siberia.
https://area51.xcomufo.com/depot2.htm

Those map dataset are not well suitable for standard terror mission or ufo crash/landing mission.