Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 [2]

Author Topic: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change  (Read 10068 times)

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #15 on: July 16, 2017, 01:33:43 PM »

I'm intrigued by your questions Morrokain - would you mind posting your code and what you're trying to do? I'm interested because I have no idea how the token's work! I'm guessing you are making dialogs that address the player by name?
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #16 on: July 16, 2017, 02:31:17 PM »

I'm intrigued by your questions Morrokain - would you mind posting your code and what you're trying to do? I'm interested because I have no idea how the token's work! I'm guessing you are making dialogs that address the player by name?

Certainly.  :)

For now, just basic additions of fleet dialogue for faction patrol interactions of various kinds, and reputation description dialogue for the various reputation levels (friendly, welcoming). For the faction interactions, I am calling the variables mentioned in my post, $local.name and $local.rank to get the commander of the fleet the player is interaction with. The line in the rules.csv file, under the 'text' column after the 'script' column would read like this: (variable examples in bold for readability)

Spoiler
"You have been scanned and identified. The Order bears you no ill-will. Keep your distance."
OR
"Do you long for the phase dimension too?" $local.rank $local.name seems to drift for a moment, then recovers.

"Apologies, I...  lost myself for a second. You have no idea what power you could wield, would you only submit..."
OR
"Greeting traveler! Dark Stars watch over you on your journey. Tell me, have you any intel on those Tachyon dogs?"
OR
"I have spent decades in the phase dimension, young one. Your proximity is of little concern to one such as I." $local.rank $local.name chuckles.

"Ah, I see you don't believe me. Trust me when I assure you my youthful appearance is a carefully fabricated veneer. Vanity? Maybe. But, one all life shares, yes?" $heOrShe smiles pointedly.
OR
"Lord Archeus shall make this sector His own! Those weak charlatans, foul pretenders all! They infest the Core Worlds with their blight and greed, damning those under their sanctuary in a useless struggle for domination."

"The Order must intervene to save what's left of humanity! Surely you must see this as well?"

You get the distinct impression that, despite the phrasing, the last statement was not really a question.
[close]


The other 'variables' you see there are actually tokens. They are defined in a separate file specifically to replace text for different contexts. They aren't used by the game's engine at all for calculation or comparisons (unlike normal variables called above) and are, by Alex's account, a hold-over from a time before you could actually call engine variables in text. That means they will likely be changed or removed later on down the line and should probably be avoided. Examples of tokens below (same line of code):

Spoiler

"You have been scanned and identified. The Order bears you no ill-will. Keep your distance."
OR
"Do you long for the phase dimension too?" $local.rank $local.name seems to drift for a moment, then recovers.

"Apologies, I...  lost myself for a second. You have no idea what power you could wield, would you only submit..."
OR
"Greeting traveler! Dark Stars watch over you on your journey. Tell me, have you any intel on those Tachyon dogs?"
OR
"I have spent decades in the phase dimension, young one. Your proximity is of little concern to one such as I." $local.rank $local.name chuckles.

"Ah, I see you don't believe me. Trust me when I assure you my youthful appearance is a carefully fabricated veneer. Vanity? Maybe. But, one all life shares, yes?" $heOrShe smiles pointedly.
OR
"Lord Archeus shall make this sector His own! Those weak charlatans, foul pretenders all! They infest the Core Worlds with their blight and greed, damning those under their sanctuary in a useless struggle for domination."

"The Order must intervene to save what's left of humanity! Surely you must see this as well?"

You get the distinct impression that, despite the phrasing, the last statement was not really a question.

[close]


and another variable/token example: (variables in bold, tokens struck through)
Spoiler


"Always good to see a friendly face out here!" The $local.post 's smile falters for a second. "We lost another expedition to the Consortium the other day. Things are getting bad, $playerName ."
OR
"Burn bright, friend! The corps is dedicated to getting the gates operational again. We could use all the help we can get."
OR
"The other factions are so intent on destroying each other. Don't they see the toll their constant wars have had on the sector?"

"We are almost an extinct species now, holding a handful of worlds when we used to rule countless galaxies... and of those who remain, how many have lost their humanity fighting over the scraps?"

$local.rank $local.name briefly turns away from the screen for a moment. Then looks back at you. Expectant.

"Don't let this tired captain keep you, $playerName . What would you like to discuss?"
OR
"We must be the shining light in the darkness. The beacon of hope for those who still cling to the ideal of a peaceful future. The last remaining bastion of human collaboration and goodwill.. perhaps in the whole universe."

$local.rank $local.name shakes $hisOrHer head as if to clear way the thought, then smiles sheepishly.

"No pressure, right?"
OR
The $local.post looks up and &hisOrHer face lights up. "By the Domain, $playerName its good to see you!"

[close]

As you can see, tokens don't have a dot notation with a 'memory map reference'(correct terminology?) in front them.

Btw: $local.rank calls the string from the .faction file under "ranks" and $local.name is the interaction entity commander's name, not the entity's name itself. That I think would be $local.fleet but haven't tested that.

$local.post calls the string from the .faction file under "posts" that can also be custom defined.

Overkill probably, but here's a screenshot of the implementation of the examples: Hope this helped  :)

Spoiler
[close]

Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #17 on: July 16, 2017, 02:59:04 PM »

The next item on the list is editing the campaign tutorial to teach the new combat balance and, well lets just say if I'm right I am going to start the action off early for the player with some pretty cool encounters.

Then I am going to heavily expand fleet encounter dialogue options including:

bribery, extortion, cooperative assaults on markets with allies, factional politics, gossip and general location aides on things like derelicts and salvage - both to sell for rep or reward or to gain if the player has chosen that playstyle.

Since I really feel more documentation is needed in the community right now, I think I will post my findings so there is an example of in-depth rules modding that links various conditions, tracks custom defined variables added to the local and global memory maps for use in rule commands and comparisons, and dynamically alters the campaign off those scripts.

Ambitious I know  ;) but all technically possible I believe.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #18 on: July 16, 2017, 04:27:59 PM »

Very cool! Thanks for explaining :). Also, I'm looking forward to your mod as just those little snippets look great.

For those interested, the next tutorial will be about adding custom subfactions - like the Luddic Path Raiders - to the game. It will cover .faction files, setting up relationships between factions, and writing a custom fleet manager that both spawns ships and sets their campaign level behavior. I have a working prototype, but it might be a week or two before I've finished the .faction files and have a written tutorial.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #19 on: July 20, 2017, 02:15:39 PM »

Very cool! Thanks for explaining :). Also, I'm looking forward to your mod as just those little snippets look great.

For those interested, the next tutorial will be about adding custom subfactions - like the Luddic Path Raiders - to the game. It will cover .faction files, setting up relationships between factions, and writing a custom fleet manager that both spawns ships and sets their campaign level behavior. I have a working prototype, but it might be a week or two before I've finished the .faction files and have a written tutorial.

No problem at all and thanks! I'm excited to share it!

I'll check out the next tutorial too. I've been really curious about that actually!


 I may create a 'for beginners' one myself for this stuff:

I have now successfully tested/implemented:
Spoiler
-Custom fleet interactions including:

1. Basic dialogue by faction for friendly, neutral and hostile contexts.

2. Custom dialogue by faction for transponder being off and the proceeding scan for smuggling/contraband if applicable.

3. Suspected smuggling and scan encounters by faction.
[close]

Next up:

More advanced things that involve either more scripting (in some cases) or a more complex way of combining different rules.

Spoiler
- A revival of the "toll" system in (hopefully  ::) ) a unique, flavorful and fun way that doesn't inhibit the player quite so much.

- Player requests for various things based on various contexts with success/failure rate linked to personal/factional reputation and standing and the situation at hand:
      -fuel
      -supplies
      -crew
      -credits
      -commodities
     and even...
      -ships/weapons

- More dialogue based on personality of the contact. I am going to delve into a bit of world-building here. Gossip will be linked to this too, but this is one of the more ambitious things (and therefore lower on the list).
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #20 on: July 20, 2017, 02:31:38 PM »

Some quick notes:

If you omit "local." it just assumes the variable is local (in case that wasn't clear), so you don't need to specify local.

It's fine to *use* tokens - I don't really see removing them - it's more that I wouldn't suggest using them for adding your own custom bits of data/text/etc.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #21 on: July 21, 2017, 02:24:26 PM »

Some quick notes:

If you omit "local." it just assumes the variable is local (in case that wasn't clear), so you don't need to specify local.

It's fine to *use* tokens - I don't really see removing them - it's more that I wouldn't suggest using them for adding your own custom bits of data/text/etc.

Oh, ok thanks for clarifying that! I'll probably keep the syntax the same for my own sanity if nothing else. Just easier to see at a glance where the variable is coming from, especially since I plan on defining my own globals..

For the second part, I guess I am a little confused as to why, or at least what you mean by using them to add custom data. I use them- when necessary- with my custom fleets with custom dialogue and it seems fine, but if you mean like adding a custom entity that's not just a faction fleet with a commander and trying to call a gender context token yeah I wouldn't think that would work. Is that kind of what you are saying? Or do you mean its not a good idea to define your own tokens in that definition file and use them?

I was going to create a $LordOrLady and $lordOrLady, so if so, well darn.  ;)

Sorry if I seem especially thick on this, but trying to nail down proper usage here. My rules spreadsheet is already pretty huge, and I just really, REALLY don't want to have to rewrite a bunch of stuff later.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #22 on: July 21, 2017, 02:36:06 PM »

For the second part, I guess I am a little confused as to why, or at least what you mean by using them to add custom data. I use them- when necessary- with my custom fleets with custom dialogue and it seems fine, but if you mean like adding a custom entity that's not just a faction fleet with a commander and trying to call a gender context token yeah I wouldn't think that would work. Is that kind of what you are saying? Or do you mean its not a good idea to define your own tokens in that definition file and use them?

I was going to create a $LordOrLady and $lordOrLady, so if so, well darn.  ;)

Sorry if I seem especially thick on this, but trying to nail down proper usage here. My rules spreadsheet is already pretty huge, and I just really, REALLY don't want to have to rewrite a bunch of stuff later.

No, fair question, this is confusing :)

Basically, what I'm saying is, if you want your own text-substitution things - e.g. $LordOrLady etc - there are two ways to go there:

1) Provide your own implementation of RuleTokenReplacementGeneratorPlugin, and add it to the Rules via Global.getSector().getRules().addTokenReplacementGenerator() - which you will have to do on every game load, since that's not persistent, or

2) Put them into the local memory, with expiration time 0, using one of the updateXXXFactions methods in your own implementation of CampaignPlugin (see: CoreCampaignPluginImpl for reference of how to do it). You only have to register this plugin once and then it goes in the savefile. (See: SectorGen.java, sector.registerPlugin(new CoreCampaignPluginImpl()); )

What I'm saying is the two are more or less equivalent (at least, I can't think of a way why #1 would be superior) for text replacement, and the second way also allows those values to be used in rule conditions etc, plus it's just one less place to keep track of. So my suggestion would be to use the 2nd way. But, whichever one works for you.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: SS Modding Tutorial: Basic Rules.csv and Market Allegience Change
« Reply #23 on: July 23, 2017, 02:26:48 PM »

No, fair question, this is confusing :)

Basically, what I'm saying is, if you want your own text-substitution things - e.g. $LordOrLady etc - there are two ways to go there:

1) Provide your own implementation of RuleTokenReplacementGeneratorPlugin, and add it to the Rules via Global.getSector().getRules().addTokenReplacementGenerator() - which you will have to do on every game load, since that's not persistent, or

2) Put them into the local memory, with expiration time 0, using one of the updateXXXFactions methods in your own implementation of CampaignPlugin (see: CoreCampaignPluginImpl for reference of how to do it). You only have to register this plugin once and then it goes in the savefile. (See: SectorGen.java, sector.registerPlugin(new CoreCampaignPluginImpl()); )

What I'm saying is the two are more or less equivalent (at least, I can't think of a way why #1 would be superior) for text replacement, and the second way also allows those values to be used in rule conditions etc, plus it's just one less place to keep track of. So my suggestion would be to use the 2nd way. But, whichever one works for you.

Ohh completely understand what you mean, now! Yeah the second way does make more sense to me :) , especially if it opens up use in rule conditions and less load (even if relatively unnoticeable).

On a side note from an earlier response, nice to know I can safely use existing tokens, too.

Thanks for all the help, as always!
Logged
Pages: 1 [2]