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 ... 251 252 [253] 254 255 ... 706

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

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3780 on: January 30, 2018, 08:24:17 AM »

As for weapons, see my function in my AI that gets weapon barrel offsets via JSON query; you can then handle the rotational position easily by using MathUtils.getPointOnCircle() .
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3781 on: January 30, 2018, 08:28:46 AM »

You can get the barrel offsets/angles through the API now, btw.

List<Vector2f> getHardpointFireOffsets();
List<Float> getHardpointAngleOffsets();

List<Vector2f> getTurretFireOffsets();
List<Float> getTurretAngleOffsets();

List<Vector2f> getHiddenFireOffsets();
List<Float> getHiddenAngleOffsets();

(Use the ones for the type of slot it's in...)
Logged

bananana

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3782 on: January 30, 2018, 02:39:11 PM »

Thanks, but that was not exactly what i was asking.
I was asking about modifying vector2f points, how is it done in starsector.
I.e. newpointvector.x =oldpointvector.x + distance*cos(angle);
This kind of thing.
« Last Edit: January 30, 2018, 02:41:36 PM by passwalker »
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.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3783 on: January 30, 2018, 02:49:35 PM »

So, 2D vector rotation? If so, this covers the basic formula:

https://stackoverflow.com/questions/4780119/2d-euclidean-vector-rotations
Logged

NightKev

  • Commander
  • ***
  • Posts: 104
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3784 on: January 30, 2018, 05:34:51 PM »

Ah, in that case check out LazyLib, it has a bunch of functions to simplify that stuff.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 288
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3785 on: February 08, 2018, 05:43:38 PM »

Is there a way to clean hyperspace around an added star system? So far the two systems I added float in a mess of deep hyperspace with raging storm.

I was quite sure someone already asked something similar but cannot find it  :-\
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3786 on: February 10, 2018, 10:34:50 AM »

Hey! There is, yes. Take a look at com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.java, in the api code.


Here's some of the relevant code:

Code: java
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);

float minRadius = plugin.getTileSize() * 2f;
for (StarSystemAPI curr : systems) {
float radius = curr.getMaxRadiusInHyperspace();
editor.clearArc(curr.getLocation().x, curr.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
editor.clearArc(curr.getLocation().x, curr.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
}

The above clears hyperspace around all the star systems; done as part of sector-generation.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 288
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3787 on: February 12, 2018, 07:45:02 AM »

OK, I "think" it works. I was missing the "import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.java" part in the star system files...

Thanks!
Logged

vagrant

  • Ensign
  • *
  • Posts: 29
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3788 on: February 12, 2018, 10:57:55 AM »

So i might be missing something simple here, but is there a way to limit which barrels on a weapon fire in alternating mode / skip over barrels if that's not possible?


I'm designing a weapon with 2 barrels, but the weapon usually only has 1 ammo in the magazine, and I only want it to use the first barrel, unless the user puts extended magazines on the ship, in which case it will have two ammo and use both barrels to fire.
Logged

Midnight Kitsune

  • Admiral
  • *****
  • Posts: 2846
  • Your Friendly Forum Friend
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3789 on: February 12, 2018, 05:45:22 PM »

So i might be missing something simple here, but is there a way to limit which barrels on a weapon fire in alternating mode / skip over barrels if that's not possible?


I'm designing a weapon with 2 barrels, but the weapon usually only has 1 ammo in the magazine, and I only want it to use the first barrel, unless the user puts extended magazines on the ship, in which case it will have two ammo and use both barrels to fire.
I don't think E Mags will give you enough ammo to push you over to two ammo
Logged
Help out MesoTroniK, a modder in need

2021 is 2020 won
2022 is 2020 too

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3790 on: February 19, 2018, 05:26:12 AM »

Question: Why do SectorEntityToken.setContainingLocation(null) and LocationAPI.removeEntity(token) need to be called together?

If I only do the latter the entity remains in the containing location (or at least the CampaignFleetAPI I'm testing does); only the former means entity.getContainingLocation() still returns the original LocationAPI.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3791 on: February 19, 2018, 11:14:52 AM »

Question: Why do SectorEntityToken.setContainingLocation(null) and LocationAPI.removeEntity(token) need to be called together?

If I only do the latter the entity remains in the containing location (or at least the CampaignFleetAPI I'm testing does); only the former means entity.getContainingLocation() still returns the original LocationAPI.

The containing location gets set every frame, IIRC, so if you just null it once, it'll be re-set the next frame. If you removeEntity(), that'll *actually* remove it, but its containingLocation will still be set to the last value it was at, even though it's no longer in that location's list of objects. I'm not sure what you mean by it remaining in the containing location; could you clarify? There's plenty of vanilla code that calls removeEntity() w/o a corresponding setContainingLocation().


In case this is relevant: a fleet's isAlive() method looks like this:

public boolean isAlive() {
   return getContainingLocation() != null && getContainingLocation().getObjects().contains(this);
}
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3792 on: February 19, 2018, 04:35:58 PM »

The containing location gets set every frame, IIRC, so if you just null it once, it'll be re-set the next frame. If you removeEntity(), that'll *actually* remove it, but its containingLocation will still be set to the last value it was at, even though it's no longer in that location's list of objects. I'm not sure what you mean by it remaining in the containing location; could you clarify? There's plenty of vanilla code that calls removeEntity() w/o a corresponding setContainingLocation().
Ah, sorry, miswrote: it's setContainingLocation() that makes the entity remain in the location and removeEntity() that causes containingLocation to persist, like you described.

Anyway, what I meant to ask was:
Shouldn't calling removeEntity() also automatically set the entity's containingLocation to null, and calling setContainingLocation() move/remove the entity? That's what one would naively expect the methods to do.
I'm wondering if there's a reason they're separate (and indeed why an entity's containingLocation has a setter, if the variable doesn't actually affect where the entity is and it just gets reset every frame anyway).
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3793 on: February 19, 2018, 04:45:07 PM »

It's sometimes useful to know the last containingLocation of removed entity. For example, a despawned fleet, when it's no longer in any location.

Basically, in normal usage, you don't need to call get/set containingLocation, and you just use add/removeEntity(). When you need something more specialized (i.e. previous location for a despawned fleet, hard-setting the location for whatever reason), there's a pair of dumb getter/setter methods to do the job that they might be less suited for if they were "smart".

(Edit: I should add, addEntity() also sets the containing location.)
« Last Edit: February 19, 2018, 04:47:20 PM by Alex »
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3794 on: February 23, 2018, 02:10:40 PM »

I have a weird bug where one of my interceptor wings disappears from my inventory after I go to the refit screen.

Two hulls present in my fleet have built in versions of this wing, so could it have something to do with that? Other fighter wings don't appear to act that way as far as I know.

**Edit: Yes, it definitely seems to be because of that. It doesn't disappear from my inventory if that ship is not present.

 Is this a vanilla bug? Or did I mess something up?

**Edit2: Confirmed that this occurs with any wing present in player inventory that is also built-in to a hull in their fleet.
« Last Edit: February 23, 2018, 02:51:25 PM by Morrokain »
Logged
Pages: 1 ... 251 252 [253] 254 255 ... 706