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:
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.