Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Skills and Story Points (07/08/19)

Pages: 1 ... 251 252 [253] 254 255 ... 379

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 15382
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3780 on: January 29, 2018, 08:42:26 AM »

Hmm - as far as I'm aware, nothing about how that works has changed. Can you try actually making a meaningless edit to the file? It might be your OS decided to treat the move/move back differently somehow...
Logged

passwalker

  • Commander
  • ***
  • Posts: 104
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3781 on: January 30, 2018, 01:36:17 AM »

sup, FS!
how can i get shield center coordinates and shield radius of a target ship?
how can i get a point, that is different from weapon.getlocation by known amount. i.e. get weapon barrel end coordinates?
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.

NightKev

  • Commander
  • ***
  • Posts: 104
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3782 on: January 30, 2018, 03:43:22 AM »

For shield information, it looks like you can do `ShipAPI.getShield()` which returns a `ShieldAPI` object with information about the ship's shields, which you can then query for more information (cf: this section of the Starfarer API javadoc).
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4815
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3783 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
Check out my SS projects :)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 15382
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3784 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

passwalker

  • Commander
  • ***
  • Posts: 104
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3785 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: 15382
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3786 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 #3787 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

  • Commander
  • ***
  • Posts: 219
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3788 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: 15382
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3789 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

  • Commander
  • ***
  • Posts: 219
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3790 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
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3791 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: 2643
  • Your Friendly Forum Friend
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3792 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
Stop trying to balance the game around a few minmaxers...
Programming is like sex:
One mistake and you have to support it for the rest of your life.

Tired of having your game crash because of out of date mods? Then click here!
Spoiler
Get Version Checker today! Now with 90% less hassle! Simply toss it into your mod folder, activate the mod like a normal one and BINGO you will now be informed of any and all updates when you start SS campaign up!
[close]

Histidine

  • Admiral
  • *****
  • Posts: 2409
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3793 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: 15382
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3794 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
Pages: 1 ... 251 252 [253] 254 255 ... 379