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 ... 517 518 [519] 520 521 ... 706

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

Sutopia

  • Admiral
  • *****
  • Posts: 1005
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7770 on: July 22, 2021, 02:38:16 PM »

They're frigates with fighter hullsize. Changing the hullsize to frigate is so they are disabled normally.
Anyways, you can refer to recall device script to learn how to poof a shipAPI from existing.
Logged


Since all my mods have poor reputation, I deem my efforts unworthy thus no more updates will be made.

theDragn

  • Captain
  • ****
  • Posts: 305
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7771 on: July 22, 2021, 10:35:27 PM »

When do WeaponRangeModifier listeners (applied through a applyEffectsAfterShipCreation call) get evaluated, relative to other hullmods and skill effects?
« Last Edit: July 23, 2021, 12:47:36 AM by theDragn »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7772 on: July 23, 2021, 11:54:18 AM »

*EDIT* Ah screw it I compiled a jar and made the code read the value from settings so it is easily changed. Simple enough. Works now.

Probably needed a cast, like:
picked = (FleetMemberAPI) picker.pick();

But yeah JANINO can get weird where generics are involved.

Hello!

How can I adjust the xp gain from battles? I'm getting a way too high xp bonus because the game thinks a battle is hard for my fleet but in reality it is a piece of cake.
Like 260% xp bonus for a battle no ship of mine got a scratch and I used mediocre stock variants.
Does it have anything to do with the civilian hint and/or hullmod? Because that's on all those ships.
I've tried upping fleet points in ship_data.csv but that did nothing.

Can I somehow fix that?

The civilian ships might have something to do with it. You can change the max multiplier by setting
FleetEncounterContext.MAX_XP_MULT
To a smaller value in your mod's ModPlugin, probably in the onApplicationLoad() method.




Does damageAPI.getDamage() return the base damage including any modifiers?
I'm using this to kill some ships with fighter hullsize in an attempt to get around the 50% chance of them poofing out of existence and not being disabled, and while it seems to work most of the time, there have been instances where it doesn't  seem to  trigger, and I can't figure it out for the life of me.

         if(damage.getDamage() > target.getHitpoints())

Hmm - this seems fundamentally wrong since it doesn't account for armor reduction to damage.

You probably want to look at DamageListener, maybe?

When do WeaponRangeModifier listeners (applied through a applyEffectsAfterShipCreation call) get evaluated, relative to other hullmods and skill effects?

They're dynamic, so they get called every time a weapon on that ship fires.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7773 on: July 23, 2021, 01:56:26 PM »

The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Hmm... how should this be done? Like this?

Code
gun.ensureClonedSpec();
dglaunch = gun.getSpec().getTurretFireOffsets().get(0);

//Manitpulating dglaunch to move fire offsets
dglaunch.set(dglaunchX + (smoothedAnimLast*offsetFY), dglaunchY - (smoothedAnimFirst*offsetFX));

gun.getSpec().getTurretFireOffsets().clear();
gun.getSpec().getTurretFireOffsets().add(new Vector2f());

Also, one more thing - I found that when there are multiple units of the same one that has this offset code, it seems they all share the same offset - so if one activates the code, the offset of other units will adjust...
Hi Alex, can you take a look at this?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7774 on: July 23, 2021, 02:21:56 PM »

The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Hmm... how should this be done? Like this?

Code
gun.ensureClonedSpec();
dglaunch = gun.getSpec().getTurretFireOffsets().get(0);

//Manitpulating dglaunch to move fire offsets
dglaunch.set(dglaunchX + (smoothedAnimLast*offsetFY), dglaunchY - (smoothedAnimFirst*offsetFX));

gun.getSpec().getTurretFireOffsets().clear();
gun.getSpec().getTurretFireOffsets().add(new Vector2f());

Also, one more thing - I found that when there are multiple units of the same one that has this offset code, it seems they all share the same offset - so if one activates the code, the offset of other units will adjust...
Hi Alex, can you take a look at this?

Ah - you're doing things in the wrong order. First you're modifying one of the Vector2f offsets (the one returned by .get(0) ), and then you're clearing out the array and adding a new vector to it. That doesn't make sense - you'll end up changing the shared offset, and then also setting the offset for the current weapon to a new Vector2f (so, 0,0).
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7775 on: July 24, 2021, 05:36:49 AM »

Ah - you're doing things in the wrong order. First you're modifying one of the Vector2f offsets (the one returned by .get(0) ), and then you're clearing out the array and adding a new vector to it. That doesn't make sense - you'll end up changing the shared offset, and then also setting the offset for the current weapon to a new Vector2f (so, 0,0).
Thanks a lot Alex! That did the trick for both issues!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7776 on: July 24, 2021, 08:45:22 AM »

Glad to hear it!
Logged

shoi

  • Admiral
  • *****
  • Posts: 650
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7777 on: July 24, 2021, 06:11:13 PM »

edit: nvm  :-X
« Last Edit: July 24, 2021, 10:21:20 PM by shoi »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7778 on: July 25, 2021, 12:41:03 AM »

How are the arrows in the intel screen's map drawn?

I'm doing a custom UI panel and trying to draw arrows between two points. GL11.GL_LINES without anti-aliasing looks awful, and I'd prefer not to work out the trig needed to draw the arrowhead as a triangle :-X
Logged

MeinGott

  • Ensign
  • *
  • Posts: 35
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7779 on: July 25, 2021, 09:53:01 AM »

Hello
Line of hullmod code
Code
List<String> wings = variant.getWings();
appears to be causing error:
Spoiler
Quote
21163 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:9071)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1845)
   at org.codehaus.janino.UnitCompiler.access$2000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitLocalVariableDeclarationStatement(UnitCompiler.java:945)
   at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:2508)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:993)
   at org.codehaus.janino.UnitCompiler.access$1000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java:935)
   at org.codehaus.janino.Java$Block.accept(Java.java:2012)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1088)
   at org.codehaus.janino.UnitCompiler.access$1300(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitForStatement(UnitCompiler.java:938)
   at org.codehaus.janino.Java$ForStatement.accept(Java.java:2196)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

I dont even know what to ask beside "what do?"

thanks
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7780 on: July 25, 2021, 11:18:18 AM »

How are the arrows in the intel screen's map drawn?

I'm doing a custom UI panel and trying to draw arrows between two points. GL11.GL_LINES without anti-aliasing looks awful, and I'd prefer not to work out the trig needed to draw the arrowhead as a triangle :-X

Oh, funny - was just doing something with these arrows myself. It's... doing the trig! Using two "GL_TRIANGLE_FAN" - one for the body, one for the arrowhead. I've found that to be a pretty easy way to get a reasonable-looking "vagely-line-like-thing that starts out wider and gets narrower", especially with how that gets a texture mapped to it.

Let me just paste some code - you'd have to adapt it a bit to use API things. It's rendering each fan three times with slight offsets to get some, uh, budget anti-aliasing. Same reason for using the line32x32 texture.
Spoiler
Code
	private Texture texture = TextureStore.getTexture("graphics/hud/line32x32.png");
private void renderArrow(Vector2f from, Vector2f to, float startWidth, Color color, float maxAlpha) {
float dist = Utils.getDistance(from, to);
Vector2f dir = Vector2f.sub(from, to, new Vector2f());
if (dir.x != 0 || dir.y != 0) {
dir.normalise();
} else {
return;
}
float arrowHeadLength = Math.min(startWidth * 0.4f * 3f, dist * 0.5f);
dir.scale(arrowHeadLength);
Vector2f arrowEnd = Vector2f.add(to, dir, new Vector2f());

// main body of the arrow
renderFan(from.x, from.y, arrowEnd.x, arrowEnd.y, startWidth, startWidth * 0.4f, color,
//0f, maxAlpha * 0.5f, maxAlpha);
maxAlpha * 0.2f, maxAlpha * 0.67f, maxAlpha);
// arrowhead, tapers to a width of 0
renderFan(arrowEnd.x, arrowEnd.y, to.x, to.y, startWidth * 0.4f * 3f, 0f, color,
maxAlpha, maxAlpha, maxAlpha);
}


private void renderFan(float x1, float y1, float x2, float y2, float startWidth, float endWidth, Color color, float edge1, float mid, float edge2) {
//HudRenderUtils.renderFan(texture, x1, y1, x2, y2, startWidth, endWidth, color, edge1, mid, edge2, false);
edge1 *= 0.4f;
edge2 *= 0.4f;
mid *= 0.4f;
boolean additive = true;
//additive = false;
renderFan(texture, x1, y1, x2, y2, startWidth, endWidth, color, edge1, mid, edge2, additive);
renderFan(texture, x1 + 0.5f, y1 + 0.5f, x2 + 0.5f, y2 + 0.5f, startWidth, endWidth, color, edge1, mid, edge2, additive);
renderFan(texture, x1 - 0.5f, y1 - 0.5f, x2 - 0.5f, y2 - 0.5f, startWidth, endWidth, color, edge1, mid, edge2, additive);
}

public static void renderFan(Texture texture, float x1, float y1, float x2, float y2,
float startWidth, float endWidth, Color color,
float edge1, float mid, float edge2, boolean additive) {

GL11.glPushMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);

texture.bind();

GL11.glEnable(GL11.GL_BLEND);
if (additive) {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}

Vector2f v1 = new Vector2f(x2 - x1, y2 - y1);
Utils.normalise(v1);
v1.set(v1.y, -v1.x);
Vector2f v2 = new Vector2f(v1);
v1.scale(startWidth * 0.5f);
v2.scale(endWidth * 0.5f);

GL11.glBegin(GL11.GL_TRIANGLE_FAN);
{
// center
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * mid));
GL11.glTexCoord2f(0.5f, 0.5f);
GL11.glVertex2f((x2 + x1) * 0.5f, (y2 + y1) * 0.5f);

// start
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge1));
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(x1 - v1.x, y1 - v1.y);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(x1 + v1.x, y1 + v1.y);

// end
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge2));
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(x2 + v2.x, y2 + v2.y);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(x2 - v2.x, y2 - v2.y);

// wrap back around to start
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge1));
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(x1 - v1.x, y1 - v1.y);
}
GL11.glEnd();
GL11.glPopMatrix();
}
[close]

Hello
Line of hullmod code
Code
List<String> wings = variant.getWings();
appears to be causing error:
Quote
21163 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
I dont even know what to ask beside "what do?"

thanks

I think the easiest way to fix this would be to not use generics. So, just:
List wings = variant.getWings()
And then cast to String whenever you're using members of this list.

The long-term better way to go would be to set up an IDE and compile your stuff into jars so that you don't have to bother about exactly what Janino (the 3rd party compiler the game uses for loose scripts) supports or not, and what makes it bug out.
Logged

theDragn

  • Captain
  • ****
  • Posts: 305
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7781 on: July 27, 2021, 12:53:19 AM »

Is there any way to change the number of fighters in a squadron aside from the instant change that Reserve Deployment does? And preferably have it show up in the UI. I feel like I've seen it before, but I'm not sure where.

Figured the extra fighters part out- gotta do it every frame, not just once. Is there any way to get extra fighters to show up in the UI? (Also I'm not a total balance psychopath, it's a builtin hullmod and hopefully balanced for the effect.)
« Last Edit: July 27, 2021, 01:13:09 AM by theDragn »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7782 on: July 27, 2021, 11:57:10 AM »

The number of fighters is capped to 6 for display purposes, if that's what you're asking; there's no way to override that.
Logged

theDragn

  • Captain
  • ****
  • Posts: 305
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7783 on: July 27, 2021, 03:03:03 PM »

What I meant was- the extra fighters deployed by the bay.extraDeployments() and associated methods- can those be made to show up on the UI, as long as I keep it at a max of 6 per squadron? Or are they temporary only?

On a different note, what's the difference between modifyPercentAlways() and modifyPercent()?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7784 on: July 27, 2021, 03:11:49 PM »

What I meant was- the extra fighters deployed by the bay.extraDeployments() and associated methods- can those be made to show up on the UI, as long as I keep it at a max of 6 per squadron? Or are they temporary only?

Ah - I don't think so, no.

On a different note, what's the difference between modifyPercentAlways() and modifyPercent()?

modifyPercent() won't apply a modifier if the value is 0. But sometimes it's useful to apply the modifier anyway - such as when there's also a description, and you're showing the description somewhere and want to indicate that <whatever> could be a factor even if it isn't just then.
Logged
Pages: 1 ... 517 518 [519] 520 521 ... 706