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 ... 249 250 [251] 252 253 ... 706

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 1700688 times)

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3750 on: January 15, 2018, 03:32:02 AM »

Apologies if this has already been asked, but the search function isn't helping much;

How does one go about creating a binary star system, or more specifically a binary star system with both stars circling a central point? I have tried using StarSystemAPI.initNonStarCenter and then adding the stars  and running autogenerateHyperspaceJumpPoints(causes crash upon viewing the system, I suspect jump points are behind it), doing the same without running autogenerateHyperspaceJumpPoints (no crash, but the system cannot be entered, not even from manually added jump points), and have also attempted to declare two stars and then move them programmatically (causes only one star to spawn, and makes only the Corona move, but otherwise works).

What would be the correct way to do it?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3751 on: January 15, 2018, 09:26:17 AM »

Can you take a look at the com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator code? The system type you're interested in is BINARY_CLOSE, and the method that adds the stars is addStars(). There may be a bit more to it than just that method but it should be in that file as well.

Taking a very brief look, I *think* the salient part may be that the primary star is created using initStar(), while the secondary uses addPlanet().
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3752 on: January 15, 2018, 09:30:00 AM »

EDIT2: So, so very sorry guys. The absolutely final question I'll ask for the forseeable future: How does one effect the post-battle loot drops? I've taken a gander through the core game and the Templar mod, as well as the forum and it's not really clear to me. Aim is to add a commodity to drop post-battle for a specific faction - not from an event, but in general. Now I've seen something in the SeededRemnantFleetManager about this, but it refers to tags which as far as I can tell, don't actually match with the commodity information. If anyone could put me to rights, I'd appreciate it.

Hmm - looking at RemnantSeededFleetManager, I'm not seeing what you mean about tags. It looks like it's just adding a RemnantFleetInteractionConfigGen to the spawned fleet's memory (in addRemnantInteractionConfig()), which adds AI cores to the salvage based on ship losses, and does a few other optional things.
Logged

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3753 on: January 15, 2018, 01:22:34 PM »

Can you take a look at the com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator code? The system type you're interested in is BINARY_CLOSE, and the method that adds the stars is addStars(). There may be a bit more to it than just that method but it should be in that file as well.

Taking a very brief look, I *think* the salient part may be that the primary star is created using initStar(), while the secondary uses addPlanet().

Thanks, that did it; the first star has to be initialized with initStar() while all other has to be initialized using addPlanet(). Using two initStar() causes wierd teleportation behaviour and invisible stars, while using two addPlanet() prevents hyperspace locations from being properly spawned and causes a nullpointer error when viewing the system.

Actually changing their rotation point was simply a matter of creating a centerpoint and setting the first star's orbit around it manually afterwards (since initStar doesn't take an orbit as an argment).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3754 on: January 15, 2018, 01:37:55 PM »

Cool, glad you got it working!

Actually changing their rotation point was simply a matter of creating a centerpoint and setting the first star's orbit around it manually afterwards (since initStar doesn't take an orbit as an argment).

Btw, if you want them to orbit around (0, 0), you could make system.getCenter() the focus of the orbit - the init-non-star-center method creates a sector entity token in the middle of the system for this purpose. Creating another sector entity token manually to serve as the orbit focus will work no problem, though.
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 679
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3755 on: January 16, 2018, 01:51:25 AM »

Hmm - looking at RemnantSeededFleetManager, I'm not seeing what you mean about tags. It looks like it's just adding a RemnantFleetInteractionConfigGen to the spawned fleet's memory (in addRemnantInteractionConfig()), which adds AI cores to the salvage based on ship losses, and does a few other optional things.

I was refering to the bit underneath the interaction config line in RemnantSeededFleetManager:

Code
	
public static void addRemnantAICoreDrops(Random random, CampaignFleetAPI fleet, float mult) {
if (random == null) random = new Random();
long salvageSeed = random.nextLong();
fleet.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SEED, salvageSeed);

int [] counts = new int[3];
String [] groups = new String [] {Drops.AI_CORES1, Drops.AI_CORES2, Drops.AI_CORES3};
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
if (member.isCapital()) {
counts[2] += 2;
} else if (member.isCruiser()) {
counts[2] += 1;
} else if (member.isDestroyer()) {
counts[1] += 1;
} else if (member.isFrigate()) {
counts[0] += 1;
}
}

if (fleet.isStationMode()) {
counts[2] += 10;
}

for (int i = 0; i < counts.length; i++) {
int count = counts[i];
if (count <= 0) continue;

DropData d = new DropData();
d.group = groups[i];
d.chances = (int) Math.ceil(count * mult);
fleet.addDropRandom(d);
}

}

The drops lines tie in to tags, and I can't figure out where the tags point. I kind of want to figure out how to use this code, but I'm unsure how to add a custom commodity (and for future use, AI core) to this list. Am I looking at the wrong thing to start with?

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3756 on: January 16, 2018, 02:39:52 AM »

Templars mod adds Templar Flux Core drops by adding them to the cargo of the fleets it generates.

The other easy way is to use reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) in a CampaignEventListener. Here's an example.
Logged

NightKev

  • Commander
  • ***
  • Posts: 104
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3757 on: January 16, 2018, 06:15:50 AM »

A couple questions about `BaseHullMod.advanceInCombat(ShipAPI ship, float amount)`:
- How often is this called?
- What is "amount"?
Logged

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3758 on: January 16, 2018, 07:16:22 AM »

A couple questions about `BaseHullMod.advanceInCombat(ShipAPI ship, float amount)`:
- How often is this called?
- What is "amount"?
A - It should call it every frame (so hopefully 60 times per second)

B - How much time has actually passed since the last time it was called (so around 1/60 of a second if no lag is experienced)

King Alfonzo

  • Admiral
  • *****
  • Posts: 679
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3759 on: January 17, 2018, 03:26:49 AM »

Templars mod adds Templar Flux Core drops by adding them to the cargo of the fleets it generates.

The other easy way is to use reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) in a CampaignEventListener. Here's an example.

I thought the Templars did that, but I couldn't figure out where they did that. I checked both the cheat fleet and the fleet factory files and it didn't add them.

Regards, using reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) worked like a charm. Many thanks Histidine!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3760 on: January 17, 2018, 08:35:20 AM »

I was refering to the bit underneath the interaction config line in RemnantSeededFleetManager:

...
The drops lines tie in to tags, and I can't figure out where the tags point. I kind of want to figure out how to use this code, but I'm unsure how to add a custom commodity (and for future use, AI core) to this list. Am I looking at the wrong thing to start with?

Ahh, ok. Take a look at data/campaign/procgen/drop_groups.csv - a lot of the random drops from exploration etc are handled through those.
Logged

bananana

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3761 on: January 17, 2018, 10:56:50 PM »

sup, FS.
is there a way i can get all ships within sertain distance from a beam, i.e. inside a rectangular area, parallel to a beam?
Spoiler
[close]
also how can i prevent getnearestally(ship_sample) from picking ship_sample's modules, and instead pick next nearest ally.
Logged
Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
i do NOT want to see my name appear in the credits section of any published mod and will consider it a personal insult.

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3762 on: January 18, 2018, 12:11:06 AM »

sup, FS.
is there a way i can get all ships within sertain distance from a beam, i.e. inside a rectangular area, parallel to a beam?
Spoiler
[close]
also how can i prevent getnearestally(ship_sample) from picking ship_sample's modules, and instead pick next nearest ally.

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.


As for the beam... it's possible to get the formula for that area mathematically and then check all enemies in range to see if they fit the formula. But i suspect that is far from the easiest solution, and the formula itself would grow fairly complicated.

Another solution would be to iterate a large amount of circular areas along the beam (simply moving the center coordinate from beamStart to beamEnd with sufficiently small steps), though i doubt that would be particularly performance-friendly.

bananana

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3763 on: January 18, 2018, 12:31:21 AM »

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.
Logged
Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
i do NOT want to see my name appear in the credits section of any published mod and will consider it a personal insult.

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3764 on: January 18, 2018, 01:05:30 AM »

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.

Aha. That makes things more difficult.

My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
Pages: 1 ... 249 250 [251] 252 253 ... 706