Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Hacky way of setting relations with all factions - and a working example  (Read 3502 times)

Darloth

  • Admiral
  • *****
  • Posts: 592
    • View Profile

If for example I add a new faction, can I tell them to be hostile to everyone (including new mod factions in the future that I currently know nothing about) by setting some sort of default standings?

Edit: Okay, I poked around a bit more with the actual definition of the FactionAPI, and it looks like the answer is no.
Alex - if you read this and don't mind answering, how difficult would it be to add this, or alternatively a function that gets all of the relationships for a given faction in a big list please?

Edit2: Hmm... I wonder if doing a single getFleets() call shortly after the system startup, then iterating through and doing getFaction() on every fleet would be a workaround to get all factions... It's not that elegant, but it might work.  I'll have a go at making a faction that -everyone- in Uomoz's mod hates, without them having to be specifically told :)
« Last Edit: August 13, 2012, 11:01:15 AM by Darloth »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #1 on: August 13, 2012, 08:41:45 AM »

Great idea, that :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Trylobot

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1170
    • View Profile
    • Github profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #2 on: August 13, 2012, 08:59:33 AM »

@Darloth I second your request for a "getFactions()" API method; using the existing fleets to get this is less than ideal because you won't get relationships for factions that don't have any fleets spawned at the time you make the call (obviously). I'll put up a formal suggestion if one doesn't already exist.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #3 on: August 13, 2012, 09:21:48 AM »

If I may answer in general terms: the current faction system isn't robust or full featured, and I don't think building on top of incrementally is a good idea. It'll probably be gutted and replaced wholesale with a better system in a future build.
Logged

Darloth

  • Admiral
  • *****
  • Posts: 592
    • View Profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #4 on: August 13, 2012, 09:23:26 AM »

Okay, that sounds fair enough :)

In the meantime I'm making progress with scraping the fleet list, and I would be done by now except JANINO doesn't like foreach loops or generics.

I'm having it check every time a new fleet is spawned - it remains to be seen whether this will cause hilarious performance problems, but if not that should over time get every faction, since it will remember the relations for previous ones.
Logged

Darloth

  • Admiral
  • *****
  • Posts: 592
    • View Profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #5 on: August 13, 2012, 11:00:26 AM »

Finally got it working - had a moment there when I thought I'd found something odd with JANINO but (as is usually the case) it turned out it was me being stupid.  The scary bytecode level error message didn't help though! (For anyone that saw my previous post before I deleted it, it's up to you if you want to reveal to the world just how much of an idiot I was being)

Attached to this is the zip of the mod - it contains no new toys, so it's really only useful for anyone else trying to make mods.  Given what Alex has stated about the faction system, I doubt it will prove reliable in the future either, but here you go! It was fun!

(PS: I meant to make them orange, but apparently I can't do RGB codes off the top of my head, and so they're salmon pink!)

[attachment deleted by admin]
Logged

arcibalde

  • Admiral
  • *****
  • Posts: 1730
    • View Profile

Nice, this i got to see :)

Damn don't understand a bit :)  Back to JAVA tutorials :)
« Last Edit: August 13, 2012, 11:11:22 AM by arcibalde »
Logged
Creator of:
Relics MOD - vanilla balanced - Campaign integrated
Vanilla addon MOD - vanilla balanced - Campaign integrated
Project ONI MOD - mission only

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile

Nice, thanks for sharing the code :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: Is there a way to set the 'default' standings for a faction?
« Reply #8 on: August 13, 2012, 11:45:06 AM »

In the meantime I'm making progress with scraping the fleet list, and I would be done by now except JANINO doesn't like foreach loops or generics.

Yeah, I wish it supported that, but it's just not in the cards since it's pretty much not actively developed anymore.

I'm seriously considering hacking in a regex (or rudimentary parser) to "support" generics by preprocessing them away, though - if I can come up with at least a relatively foolproof one. It gets messy when you start looking at a List of Maps (of Maps, etc) and such.

Btw - it doesn't support annotations either, but @Override and @SuppressWarnings are actually parsed out by the game before it tries to compile...
Logged

Verrius

  • Captain
  • ****
  • Posts: 369
    • View Profile

Darloth, my current version of Fleet Control makes use of this code and it works like a bloody charm.