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 ... 420 421 [422] 423 424 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6315 on: April 18, 2020, 08:21:32 AM »

Nice!!!
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6316 on: April 18, 2020, 10:00:32 PM »

I feel like I've missed something fundamental in the usage of the FogOfWarAPI in combat. I'm trying to reveal the area around a battle objective, and while it appears to be doing so, it isn't showing any ships or entities within that area.

The setup is based on a hullmod carried by a ship. I'll brush right over how I'm acquiring the objectives, but this is the meat of the script that should clear the fog of war (in the "advanceInCombat()" method of the hullmod):
Code
int owner = ship.getOriginalOwner();
FogOfWarAPI fog = engine.getFogOfWar(owner);
...
fog.revealAroundPoint(objective,
        objective.getLocation().getX(),
        objective.getLocation().getY(),
        REVEAL_AREA);
That bit works, it reveals the fog in a circle around the objective in question just fine. But for whatever reason, enemy ships are still invisible within that area. (The objective is being invisibly captured by the enemy despite them having to be within the revealed area.)

- I have also tried this setup where I spawn a custom projectile, with the ship in question as the source, on the point of the objective and then reveal fog around that instead, but the result was the same.
- Further, I'm 99% sure I'm using the setup correctly because I've played with a script revealing fog before, and that was also based on a projectile, however that was run through an everyFrameEffectPlugin as opposed to an advance script.

Does anyone know why the fog is lifted in the area specified, but enemy ships within it are still "hidden"? Have I missed something really fundamental?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6317 on: April 19, 2020, 09:40:11 AM »

Hmm - I'd say to take a look at this:
com.fs.starfarer.api.impl.combat.EscapeRevealPlugin

I don't see what you might be doing wrong, though, it seems like it should work. IIRC the reveal radius needs to be >1000 for it to work? I'm not actually 100% sure, this is a very hazy memory. And you need to do it every single frame.
Logged

Kaykat

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6318 on: April 19, 2020, 01:41:49 PM »

(I'm not a scripter no bully plz ._.)

I added a market condition from Unknown Skies to a planet I made, but the game crashes when it's on any planet (US_Bedrock). I tested it and this happens to any US market condition. The error is:

"US_BEDROCK" is neither a method, a field, nor a member class of "com.fs.starfarer.api.impl.campaign.ids.Conditions"

The weird thing is I have another planet with the type US_Auric and that works fine, so it's not US. So so, my lizard brain reading the error makes me think I need to somehow make my files dependent on US, but I don't know how. It doesn't make sense to me when the planet types work just fine without doing that already. Can someone way more knowledgeable than me explain what's going on here and maybe how to fix it? I am super confused about all this >_<
Logged
If all the mod authors weren't so entitled and rude all the time maybe I would've stayed and contributed, au revoir >_>

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6319 on: April 19, 2020, 01:46:51 PM »

Instead of doing Conditions.US_BEDROCK, to "US_Bedrock" (with the quotes). The Conditions class has the ids of the vanilla
conditions in strings - for easier use, changes, and cross-referencing - but conditions added by mods wouldn't be found there. So you need to just specify it as a string literal, with the double quotes and so on.
Logged

Kaykat

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6320 on: April 19, 2020, 01:50:40 PM »

Instead of doing Conditions.US_BEDROCK, to "US_Bedrock" (with the quotes). The Conditions class has the ids of the vanilla
conditions in strings - for easier use, changes, and cross-referencing - but conditions added by mods wouldn't be found there. So you need to just specify it as a string literal, with the double quotes and so on.

Agh, it's ALWAYS simpler than I think it is! Thank you so much!
Logged
If all the mod authors weren't so entitled and rude all the time maybe I would've stayed and contributed, au revoir >_>

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6321 on: April 19, 2020, 01:56:01 PM »

You're welcome, good luck :)
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6322 on: April 19, 2020, 04:23:37 PM »

IIRC the reveal radius needs to be >1000 for it to work? I'm not actually 100% sure, this is a very hazy memory. And you need to do it every single frame.

That would have made me laugh, since I'd tried it with a bunch of different radii but the highest I'd set it to was exactly 1000. ;D Somewhat thankfully, setting it higher didn't fix the issue.

I am definitely calling the function every frame - at least I think I am. The piece of script I shared is running every iteration of the advanceInCombat() method of a hullmod script. That runs every frame, right?

As for the EscapeRevealPlugin, all I can glean differently from that is using "this" for the Object source of the revealAroundPoint() method, and that didn't seem to help either - much like when I tried it with "ship" in its place, it seems only one area of fog can be cleared by a single object, so once it has more than one objective to reveal, it starts flickering and doing odd things.

Once again though I'm thinking this might be a difference between the advanceInCombat hullmod method, and the advance method of an everyFrameEffectPlugin. It just seems odd that there's a difference so I'm naturally apprehensive of trying that instead. I'll give it a whirl as an everyFrame anyway and report back.
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6323 on: April 19, 2020, 06:07:49 PM »

Follow up to the above: Moving the fog reveal code to an everyFrameEffectPlugin worked! ;D And while I'm glad to have this working, I'm really confused as to why that worked! :o What's the fundamental difference between the advance methods here, and why should they act differently with the same code?

Nonetheless, thanks for the help.

I Spy

[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6324 on: April 19, 2020, 06:34:25 PM »

Ah! I bet what's happening is fog of war state is reset every frame and re-calculated. And the method for doing it in the hullmod runs before it's reset, i.e. when it doesn't matter. At least, that'd be my guess. Doesn't quite explain why it *looks* like it works, though, but... well, maybe it runs after checks for ships being visible, but before rendering, or something. Point being, I strongly suspect it's due to the order of operations. In any case, glad you got it working!
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6325 on: April 19, 2020, 07:09:51 PM »

Ah! I bet what's happening is fog of war state is reset every frame and re-calculated. And the method for doing it in the hullmod runs before it's reset, i.e. when it doesn't matter. At least, that'd be my guess. Doesn't quite explain why it *looks* like it works, though, but... well, maybe it runs after checks for ships being visible, but before rendering, or something. Point being, I strongly suspect it's due to the order of operations.

Huh, that would explain the issues I was seeing. Odd, but fair enough.
Logged

Xaiier

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6326 on: April 21, 2020, 02:27:52 AM »

I found a strange issue while spawning emp arcs with the CombatEngineAPI methods spawnEmpArc(...) & spawnEmpArcPierceShields(...)

If you target a combat entity which doesn't have any valid arc targets within the maxRange distance of the source location, the arc will instead target somewhere along the circumference of a circle centered at (0,0) in the combat space. The radius of this circle doesn't appear to have any relationship to shield size or anything that I could find. It appears as though the method is using some default value when finding a target fails and causing these arcs to stretch out towards the origin.

The vanilla implementations of this kind of thing (ex: TachLance) all use arbitrarily large maxRange values which hide the issue. With such large values, finding a valid target always succeeds.

Interestingly, this doesn't hold true for the custom CombatEntityAPI classes defined in LazyLib - the arcs go to their target and ignore any restrictions defined by maxRange.
Logged

_Dividebyzero_

  • Ensign
  • *
  • Posts: 9
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6327 on: April 21, 2020, 06:59:54 PM »

Is there a way to add a recoverable ship to a debris field during system creation?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6328 on: April 21, 2020, 08:32:41 PM »

I found a strange issue while spawning emp arcs with the CombatEngineAPI methods spawnEmpArc(...) & spawnEmpArcPierceShields(...)

If you target a combat entity which doesn't have any valid arc targets within the maxRange distance of the source location, the arc will instead target somewhere along the circumference of a circle centered at (0,0) in the combat space. The radius of this circle doesn't appear to have any relationship to shield size or anything that I could find. It appears as though the method is using some default value when finding a target fails and causing these arcs to stretch out towards the origin.

The vanilla implementations of this kind of thing (ex: TachLance) all use arbitrarily large maxRange values which hide the issue. With such large values, finding a valid target always succeeds.

Interestingly, this doesn't hold true for the custom CombatEntityAPI classes defined in LazyLib - the arcs go to their target and ignore any restrictions defined by maxRange.

Hmm, alright, I'll keep this in mind. In general, I would recommend always passing in a very high value for max range, I'm not sure that's ever been used anywhere in vanilla with small values and the fact that this is a parameter at all is probably an oversight.


Is there a way to add a recoverable ship to a debris field during system creation?

Yeah - something like this:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
data.addShip("centurion_Assault", ShipCondition.PRISTINE);
Misc.setSalvageSpecial(debrisField, data);
Logged

_Dividebyzero_

  • Ensign
  • *
  • Posts: 9
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6329 on: April 21, 2020, 08:45:23 PM »

Is there a way to add a recoverable ship to a debris field during system creation?

Yeah - something like this:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
data.addShip("centurion_Assault", ShipCondition.PRISTINE);
Misc.setSalvageSpecial(debrisField, data);

Will try that out, thanks a lot!
Logged
Pages: 1 ... 420 421 [422] 423 424 ... 706