Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 689 690 [691] 692 693 ... 710

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

nathan67003

  • Commander
  • ***
  • Posts: 155
  • Excellent imagination, mediocre implementation.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10350 on: December 02, 2023, 03:53:08 PM »

Is it possible to make it so that when a ship uses its ship system (f-button, not right-click) they become immune to certain usually-unavoidable weaponry (such as Afflictor ship system and Harbinger ship system)?

Another one: how does the Harbinger's system work exactly, does it just set a ship's flux at 100% or does it inject actual flux? Wondering if things with obscenely large buffers would be immune to immediate effects in-universe.
Logged
I have some ideas but can't sprite worth a damn and the ideas imply really involved stuff which I've no clue how to even tackle.

Sorrydough

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10351 on: December 02, 2023, 10:56:44 PM »

I have a capital with a lot of small hybrid slots and some larger synergy slots. I want to discount weapons in the hybrid slots to disincentivize leaving slots empty. I also want to discount energies in the synergy slots, since missiles are really strong. Therefore the hullmod effect would be as follows: "Non-missile weapons mounted in mixed weapon slots cost 1/2/4 fewer ordnance points." However, it seems like the API only allows me to discount *all* weapons of a particular type, not by the specific slot. Am I missing something? Basically what I'd want is like "if weapon.slot != energy && weapon.type != missile then weapon.getDynamic.getmod(Stats.COST_MOD).modifyFlat(discount.get(weaponsize))".
Logged

Lukas04

  • Captain
  • ****
  • Posts: 362
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10352 on: December 03, 2023, 11:17:23 AM »

Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?
Logged
My Mods

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10353 on: December 03, 2023, 11:33:56 AM »

Is it possible to make it so that when a ship uses its ship system (f-button, not right-click) they become immune to certain usually-unavoidable weaponry (such as Afflictor ship system and Harbinger ship system)?

Another one: how does the Harbinger's system work exactly, does it just set a ship's flux at 100% or does it inject actual flux? Wondering if things with obscenely large buffers would be immune to immediate effects in-universe.

1 - as far as I can tell, no - the targeting logic for the system only seems to care about range (and you can check for yourself at com.fs.starfarer.api.impl.combat.AcausalDisruptorStats)
2 - it simply forces the ship into the overloaded state, entirely ignoring flux

<SD's question>

I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.
« Last Edit: December 03, 2023, 12:01:37 PM by Ruddygreat »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24123
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10354 on: December 03, 2023, 03:21:28 PM »

I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.

Yep. Thank you for the answers!

Just one more note here: the HullModEffect.affectsOPCosts() method should also return true for this kind of hullmod - this is a critical step for OP-affecting hullmods and is very easy to forget.


Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?

Ah, I see why there's no setter - that's just a convenience method to get the ship for the wing's source fighter bay. Let me add FighterWingAPI.setSourceBay().

As to working around this, hmm. I don't think so. This would require a new method to pass in a source fighter bay, I think. I realize this is not a helpful answer but I'm inclined to say this is just a straight-up bug in the mods that do this, even if it's one that doesn't manifest too often.

Ugh. The code path from the spawnFleetMember call to where the wing is actually spawned is annoyingly long, too, so passing in any sort of parameter would probably be some sort of "pass it into the initial method, set in a static variable, use it, and unset it" hack. Digging into this, it's actually not super clear exactly how to do this; I'd have to really test it out to make sure I didn't break something. The only reason these kinds of weapons/hullmods work is that vanilla happens to "deploy" a fighter wing with no members, set its source bay afterwards, and then start deploying members from the bay one at a time. This is such an implementation detail; it could totally create the fighters before deployign them and then set the wing's source.
Logged

Lukas04

  • Captain
  • ****
  • Posts: 362
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10355 on: December 04, 2023, 07:30:51 AM »

I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.

Yep. Thank you for the answers!

Just one more note here: the HullModEffect.affectsOPCosts() method should also return true for this kind of hullmod - this is a critical step for OP-affecting hullmods and is very easy to forget.


Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?

Ah, I see why there's no setter - that's just a convenience method to get the ship for the wing's source fighter bay. Let me add FighterWingAPI.setSourceBay().

As to working around this, hmm. I don't think so. This would require a new method to pass in a source fighter bay, I think. I realize this is not a helpful answer but I'm inclined to say this is just a straight-up bug in the mods that do this, even if it's one that doesn't manifest too often.

Ugh. The code path from the spawnFleetMember call to where the wing is actually spawned is annoyingly long, too, so passing in any sort of parameter would probably be some sort of "pass it into the initial method, set in a static variable, use it, and unset it" hack. Digging into this, it's actually not super clear exactly how to do this; I'd have to really test it out to make sure I didn't break something. The only reason these kinds of weapons/hullmods work is that vanilla happens to "deploy" a fighter wing with no members, set its source bay afterwards, and then start deploying members from the bay one at a time. This is such an implementation detail; it could totally create the fighters before deployign them and then set the wing's source.

Fair enough, it probably wont be a major issue and i already asked the mod author that it conflicted with to nullcheck the sourceShip since there didnt seem to be another way. Im not sure if this is a reasonable solution, but in this case having a way to stop the execution of hullmods and weapon advances for the first frame of being spawned, + the addition of a setter, would fix situations like this where they happen. But im going to asume that this hullmod and weapon advance code is also deeply nested in the code.
Logged
My Mods

alaricdragon

  • Commander
  • ***
  • Posts: 162
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10356 on: December 04, 2023, 11:51:41 AM »

hello once again everyone. i have returned with a question:
1) is it possible to run code every X ticks? (on the campaign map and/or everywhere)?
2) is it possible to run code every X time? (in game days/hours)
3) is it possible to run code before/when one opens / views there cargo?
4) is it possible to organize the players cargo bay with code?
thanks again all you people for responding to everyone's questions. it is most kind
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10357 on: December 04, 2023, 02:55:44 PM »

hello once again everyone. i have returned with a question:
1) is it possible to run code every X ticks? (on the campaign map and/or everywhere)?
2) is it possible to run code every X time? (in game days/hours)
3) is it possible to run code before/when one opens / views there cargo?
4) is it possible to organize the players cargo bay with code?
thanks again all you people for responding to everyone's questions. it is most kind

1 & 2 - you can use an intervalUtil to to this kind of thing, it's effectively just a counter that resets when it hits a limit.
you can track real time passage with them by using the "amount" value that gets passed into most "advance"-type methods; that can also be converted into campaign time using Global.getSector().getClock().ConvertToDays;

3 - from a quick look, the CargoScreenListener interface seems to be what you're looking for, though I've never used it myself so I won't really be able to give any implementation help

I'm unsure on 4, though there doesn't seem to be a method for it in cargoAPI

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10358 on: December 06, 2023, 12:13:17 PM »

is there a good (read : not through personalites.csv) way to give a human officer a custom personality name / description?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24123
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10359 on: December 06, 2023, 12:39:22 PM »

Im not sure if this is a reasonable solution, but in this case having a way to stop the execution of hullmods and weapon advances for the first frame of being spawned, + the addition of a setter, would fix situations like this where they happen. But im going to asume that this hullmod and weapon advance code is also deeply nested in the code.

Yeah, this would I think be an even more difficult/potentially troublesome hack, since it'd have to wait a frame to reset whatever flag it set, and who knows what other things might break then that expected hullmods to be applied.


4) is it possible to organize the players cargo bay with code?

I think you'd need to get a copy of the cargo in whatever way you want, then clear the cargo and add things to it in the order you like.


is there a good (read : not through personalites.csv) way to give a human officer a custom personality name / description?

I don't think so, sorry! A lot of that stuff is fairly deeply hardcoded.
Logged

Sorrydough

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10360 on: December 08, 2023, 06:16:39 PM »

How do I force a ship to back off in code? I've run into a really weird behavior and I'm trying to correct it, but the ship AI is seemingly ignoring the flags that I set.

https://youtu.be/d9KsfUOQ7YQ

In a nutshell, the ship is deciding to engage at extremely close range because I set it to aggressive personality.
Then it's deciding to facehug the enemy despite having the BACKING_OFF flag for 30+ seconds, completely ignoring the flag as seen in the debug info on the righthand side.

In my code I tried to do this:

We can see in the video that it does successfully apply the flag, but the ship just keeps driving forwards the moment the BACK_OFF flag expires.
What's the point of BACKING_OFF?
« Last Edit: December 08, 2023, 06:55:28 PM by Sorrydough »
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10361 on: December 09, 2023, 10:34:17 AM »

2 small qs about mines -
is there a purely timed fuse mine behaviour?
and is there a mine that drifts less than the PHASE_MINE type?

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10362 on: December 09, 2023, 03:46:52 PM »

Hi, I have a couple of questions: firstly, is there a way to set a captain for a ship, but the player can't replace it? The idea is to add a ship to the player's fleet with a fixed captain - the concept being a sort of ally ship that they can command in the battle phase.

Secondly, is it possible to make it so that ships generated during the battle phase (like a frigate that gets spawned from another ship) can be a target for the [F] view camera command? At the moment when I generate allied ships during battle, they seem to refuse the view command, so I can't really see what they're doing unless I have a ship of my own nearby. Also, I can't seem to command them either - that one's a lesser priority for me but would also appreciate to know if there was a way to make them accept player commands too.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24123
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10363 on: December 10, 2023, 09:05:19 AM »

We can see in the video that it does successfully apply the flag, but the ship just keeps driving forwards the moment the BACK_OFF flag expires.
What's the point of BACKING_OFF?

You want to set the BACK_OFF flag. BACKING_OFF is just a way it can signal that it's doing that to anything else that might care, such as a ship system AI. BACK_OFF is the actual instruction to do so.


2 small qs about mines -
is there a purely timed fuse mine behaviour?

I think you'd want to set the collision class to something that doesn't hit things, like NONE. Though that might mess with the AI being able to appreciate the danger, in which case: I don't think so, hmm.

and is there a mine that drifts less than the PHASE_MINE type?

If you set the acceleration/deceleration to something low that might do it. Not 100% sure. Or you could set the mine to "primed".


Hi, I have a couple of questions: firstly, is there a way to set a captain for a ship, but the player can't replace it? The idea is to add a ship to the player's fleet with a fixed captain - the concept being a sort of ally ship that they can command in the battle phase.

Misc.setUnremovable(person, true) may work.


Secondly, is it possible to make it so that ships generated during the battle phase (like a frigate that gets spawned from another ship) can be a target for the [F] view camera command? At the moment when I generate allied ships during battle, they seem to refuse the view command, so I can't really see what they're doing unless I have a ship of my own nearby. Also, I can't seem to command them either - that one's a lesser priority for me but would also appreciate to know if there was a way to make them accept player commands too.

I don't know - I think this may depend on how you're spawning them but the answer might just be "no", though this would be at least slightly surprising to me.
Logged

m3rc33

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10364 on: December 10, 2023, 01:22:12 PM »

Hey folks, do you know of a mod that allows you to create "loadouts" of your fleet?

I'm in a situation atm where I have a decent system that is visited by pirates, so I bounce between doing stuff in the core worlds (quests, smuggling, buying new ships etc) and going home to clean up the pirate fleets. So I was wondering if I could make 1 loadout with better smuggling and efficient ships for my core world business and 1 loadout for when I return to wreck the pirates.

Alternatively is there a better solution that does not require me to go back every so often?
Logged
Pages: 1 ... 689 690 [691] 692 693 ... 710