Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 487 488 [489] 490 491 ... 710

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

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 135
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7320 on: April 23, 2021, 11:24:11 PM »

Are visible, turret weapons supported for fighters?  All of the examples I have checked of vanilla fighters have them all hidden.  I was attempting to make a specific fighter turret weapon (extra small) but would like to know if it is possible to put this type of weapon on a fighter class ship.  Thx.
Logged

MesoTroniK

  • Admiral
  • *****
  • Posts: 1731
  • I am going to destroy your ships
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7321 on: April 24, 2021, 12:24:29 AM »

Are visible, turret weapons supported for fighters?  All of the examples I have checked of vanilla fighters have them all hidden.  I was attempting to make a specific fighter turret weapon (extra small) but would like to know if it is possible to put this type of weapon on a fighter class ship.  Thx.
Yes they are and done on some vanilla fighters even. A notable low hanging fruit example is the Gladius.

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7322 on: April 24, 2021, 01:08:40 AM »

Is there a way to render below all weapons(like decorative weapons)...
Logged
My mods


DesperatePeter

  • Commander
  • ***
  • Posts: 167
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7323 on: April 24, 2021, 06:09:52 AM »

I am trying to use the WeaponGroupAPI.removeWeapon(Int: index)-method.
However, when I supply an index smaller than the number of weapons in the group, the method always returns null and the number of elements in the weapon group doesn't change.
Just for fun I tried to supply an index larger than the number of weapons, which produces an OutOfBounds (or so) Exception.
I assume this is not the correct behavior?
Or am I doind something wrong?

Update:
I was also wondering: I want my mod to do stuff when ALT+WeaponGroupKey (e.g. ALT+3) gets pressed. But when the Event for 3 "arrives" in my mod, it has already been consumed (presumably by the base game). Is there any other way I can get the information that 3 has been pressed?
« Last Edit: April 24, 2021, 10:40:11 AM by DesperatePeter »
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 #7324 on: April 25, 2021, 01:37:37 PM »

My advice to you and the above poster - Log log log! It will save you a lot of time. ;D
You mean using starsector.log or having an editing/development log, logging progress, changes, etc. or something else?
I've definitely got a few notebooks with sketches and notes in them, but nothing as in-depth as a coder's log. I have previously kept logs for modding but so far I haven't for Starsector or for scripting.

I was talking about setting up a logger in your code to send information to starsector.log so you can track the information in the AI while it is running. Example:

Spoiler
    // Logger.
    private static final Logger LOG = Global.getLogger(AO_FluxConverterAI.class);
    private static final boolean LOG_INFO = false;

             if (LOG_INFO ) {
                 if (system.getAmmo() == system.getMaxAmmo() && nearbyThreats) {
                        LOG.info("Ship was at maximum charges and nearby threats were significant.");
                    }
                    if (hullDamageActivatesSystem) {
                        LOG.info("System was activated from hull damage.");
                    }
                }
[close]
- Stuff like this is important to track data, code logic workflow, etc. For context from the example, my system was designed so that the first charge can be used offensively and the remaining charges are used defensively. The log lets me know that this is working correctly because I should ideally see the statement about max charges in the start of a simulation battle - and then I shouldn't see it afterwards unless enough time passes that the system gets back to full charges. If I do, something has gone awry that I need to investigate. This gets more important as the complexity of the code increases.

Logging each component of when the system activates lets me know why the system activated so I can analyze the battle context to ensure that the AI is working as intended. I set up tracking so that if the ship is taking continuous damage it activates the system. If I see the ship take a bunch of hits to hull and the system doesn't activate, I can look at the log to see details of why. Is it not reaching that part of the code? Is the counter not being increased? Stuff like that.

Final note:
The if (LOG_INFO) is important because logging messages every few frames will fill up the logs very, very quickly. So its a good idea to set up the logging to only log things when you, yourself are testing everything out. After you know its working well, you can just change the boolean to no longer log all the details. That is a good courtesy for other modders. What you do and do not log consistently is something of a judgement call. I generally try and only log errors that ideally shouldn't happen in a release.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7325 on: April 26, 2021, 02:04:50 AM »

If I want a person mission to not show up again for some time after being accepted, I should increase the min timeout and max timeout columns in the CSV, right?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7326 on: April 26, 2021, 09:21:00 AM »

I am trying to use the WeaponGroupAPI.removeWeapon(Int: index)-method.
However, when I supply an index smaller than the number of weapons in the group, the method always returns null and the number of elements in the weapon group doesn't change.
Just for fun I tried to supply an index larger than the number of weapons, which produces an OutOfBounds (or so) Exception.
I assume this is not the correct behavior?
Or am I doind something wrong?

Update:
I was also wondering: I want my mod to do stuff when ALT+WeaponGroupKey (e.g. ALT+3) gets pressed. But when the Event for 3 "arrives" in my mod, it has already been consumed (presumably by the base game). Is there any other way I can get the information that 3 has been pressed?

Ahh! Looks like that method was bugged; fixed it up. Basically it was doing the index check backwards and only trying to remove the weapon if the index was out of bounds.

Re: ALT + etc - you could use:
Keyboard.isKeyDown(Keyboard.KEY_LMENU)

Though that's looking at keyboard state not events. But if the e.g. "3" is consumed by the base game, that means it's already acted on it (in this case, probably by selecting a weapon group) and you couldn't undo that.

If I want a person mission to not show up again for some time after being accepted, I should increase the min timeout and max timeout columns in the CSV, right?

That should do it, yeah.
Logged

Nick XR

  • Admiral
  • *****
  • Posts: 713
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7327 on: April 26, 2021, 10:45:25 AM »

What's the best way to check if a campaign simulation has ended?  I don't see any events to tap into (Like the reportPlayerEngagement method), and the game would be paused so I don't think there's an advance I could check either.  There are state variables I could check, but I would need the checking function to be called on the refit screen.

DesperatePeter

  • Commander
  • ***
  • Posts: 167
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7328 on: April 26, 2021, 01:41:28 PM »

Ahh! Looks like that method was bugged; fixed it up. Basically it was doing the index check backwards and only trying to remove the weapon if the index was out of bounds.

Re: ALT + etc - you could use:
Keyboard.isKeyDown(Keyboard.KEY_LMENU)

Though that's looking at keyboard state not events. But if the e.g. "3" is consumed by the base game, that means it's already acted on it (in this case, probably by selecting a weapon group) and you couldn't undo that.

Awesome, thanks a lot for the reply!
Then I'll wait till the next RC comes out to implement weapon group merging =)

About the keyboard controls: I think I found an alternative solution (use the NUMPAD instead) for this. But that info might still proove valuable later, so thanks!

Two more short questions, if anyone happens to know:

For some reason, when I run Starsector on my virtual Linux machine and press e.g. ALT+NUMPAD3, I get an unconsumed event (with getEventChar=='3' and isAltKeyDown()==true). However, when I run it on my Windows machine, I don't get an unconsumed event (both with 0.95a-RC14 and no other mods except mine and LazyLib). Any idea why that could be?

When calculating the target for Vector2f AutofireAIPlugin.getTarget() (in advance()), how can I access the current target leading accuracy? And how should I factor that into my calculations?

Update: Is my assumption that the values acceleration and deceleration (CombatEntityAPI/ShipAPI) refer to maximum possible rather than current acceleration and deceleration correct?
« Last Edit: April 27, 2021, 06:26:12 AM by DesperatePeter »
Logged

Sodyaler

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7329 on: April 26, 2021, 10:04:04 PM »

Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of
Logged

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7330 on: April 27, 2021, 12:18:22 PM »

Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?
Logged

DesperatePeter

  • Commander
  • ***
  • Posts: 167
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7331 on: April 27, 2021, 01:24:55 PM »

Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7332 on: April 27, 2021, 01:25:41 PM »

For some reason, when I run Starsector on my virtual Linux machine and press e.g. ALT+NUMPAD3, I get an unconsumed event (with getEventChar=='3' and isAltKeyDown()==true). However, when I run it on my Windows machine, I don't get an unconsumed event (both with 0.95a-RC14 and no other mods except mine and LazyLib). Any idea why that could be?

Not sure, sorry!

When calculating the target for Vector2f AutofireAIPlugin.getTarget() (in advance()), how can I access the current target leading accuracy? And how should I factor that into my calculations?

ship.getMutableStats().getAutofireAimAccuracy().getModifiedValue()

Range is something like -0.5 to 1.

1f means aim at the correct predicted point. 0 means assume shots are twice as fast as they actually are, so, lag behind the target a bit.

Of note: the vanilla autofire AI will improve its aim with time spent firing on the same target.

Update: Is my assumption that the values acceleration and deceleration (CombatEntityAPI/ShipAPI) refer to maximum possible rather than current acceleration and deceleration correct?

Hmm - are you mixing up acceleration and speed, maybe? The acceleration is a fixed value. The speed has a current and maximum value. Well, the speed doesn't really have a current value, the velocity does...


Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I don't think so, afaikr this isn't tracked.

Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of

I don't know. It *might* have been one of Sundog's mods, though? I seem to remember him doing stuff with the deployment dialog, though it might have been something else.

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.

Haha, that'd actually do it, especially for dumbfire missiles!
Logged

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7333 on: April 27, 2021, 03:56:59 PM »

Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.

lol, this is brilliant. well, it works well enough, and checking if angular velocity is like 5 is enough to trigger reliably. Thanks!
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7334 on: April 28, 2021, 12:52:38 AM »

Is there a way to add XP to marines in storage, that don't already have XP?

Like, when I have 200 marines with zero XP in cargo, I toss them in Jangala's storage, then call the following:
Code: java
runcode MarketAPI market = Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket();
com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker.getInstance().getDroppedOffAt("marines", market.getPrimaryEntity(), market.getSubmarket("storage"), true).data.addXP(10000);
the stored marines still have no rank icons, and they dilute the XP of any marines I have in my own fleet.
But if it works if I earn some XP for those marines before storing them, they become elite after running that code.

Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of
Pretty sure that's Ruthless Sector by Sundog.
Logged
Pages: 1 ... 487 488 [489] 490 491 ... 710