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 ... 455 456 [457] 458 459 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6840 on: October 12, 2020, 04:37:39 PM »

EDIT: Got it, the ships also needed to have the same ship name.

(Nice!)
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6841 on: October 12, 2020, 10:40:13 PM »

It seems that MissionDefinitionAPI.initMap can only make battlespaces with heights and widths that are multiples of 1000 pixels - do I have that right?

For instance, if I try to create a battlespace with 9000 height and width via api.initMap(-4500f, 4500f, -4500f, 4500f), it will only create a battlespace with 8000 pixels in height and width.

I guess the followup would be whether or not that is intended behavior. It certainly makes the tactical map prettier, but it seems like it's less intuitive than, say, the positive part rounding up and the negative part rounding down, or something to that effect.

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6842 on: October 13, 2020, 09:03:07 AM »

I have an BaseIntelPlugin that uses large description, and can grow in size. It simply uses panel given by the callee and adds many UI elements (panel.createUIElement, add something in resulting TooltipMakerAPI like one button or paragraph, finally addUIElement). It all works nicely until I reach defined height, at which point next "rows" spill over: https://i.imgur.com/XTa1Fyb.png
Pseudocode:
Code
public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
  TooltipMakerAPI tooltip = panel.createUIElement(...);
  tooltip.addButton(...);
  panel.addUIElement(tooltip).inTL(0, height+10);
}

I tried adding an outer element, that would have custom panel, and then use that custom panel to add elements, which works fine: https://i.imgur.com/7QcelBd.png
Pseudo code:
Code
    public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
        TooltipMakerAPI outer = panel.createUIElement(width, height, true);
        CustomPanelAPI inner = panel.createCustomPanel(width, height, new ButtonHandlerFactory());
        TooltipMakerAPI tooltip = panel.createUIElement(...);
        tooltip.addButton(...);
        inner.addUIElement(tooltip).inTL(0, height+10);
        inner.getPosition().setSize(width, height+10);
        outer.addCustom(inner, 0);
        panel.addUIElement(outer).inTL(0, 0);
}
Unfortunately, now no Button callbacks are handled now. I looked into CustomUIPanelPlugin, but processEvents events are low level, and from what I see I'd have to be looking at mouse clicks and comparing it with the location the actual buttons are rendered on intel screen... Or I could make a class for each button and implement CustomUIPanelPlugin, thus letting it handle own callbacks. Which means rewriting most of my row-col rendering logic, which by itself is fine unless there is something easier.
Is there an easier way to get a scroll on panel or am I forced to use customPanel and redoing part of my render logic?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6843 on: October 13, 2020, 09:42:32 AM »

It seems that MissionDefinitionAPI.initMap can only make battlespaces with heights and widths that are multiples of 1000 pixels - do I have that right?

For instance, if I try to create a battlespace with 9000 height and width via api.initMap(-4500f, 4500f, -4500f, 4500f), it will only create a battlespace with 8000 pixels in height and width.

I guess the followup would be whether or not that is intended behavior. It certainly makes the tactical map prettier, but it seems like it's less intuitive than, say, the positive part rounding up and the negative part rounding down, or something to that effect.

Honestly, this is one of those where I'll go with "whichever way it works is what's intended". I'm not sure if -4500 etc actually results in a battlefield being that size and just the visible map grid being smaller, or if it gets rounded, but regardless, I'd say it looks like only multiples of 1000 are supported.

@Jaghaimo: ahh, that's a bug! It came up a bit back, and is fixed for the next release. I mean, the part about button callbacks not getting called if it's added to an outer element - which would indeed be the "right" way to handle this, if it worked. My apologies!
Logged

shoi

  • Admiral
  • *****
  • Posts: 649
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6844 on: October 14, 2020, 07:27:27 PM »

Basically, I wanted to create a more aggressive type of support wing that doesn't hide behind carrier and also doesn't fly directly on top of enemy because they won't survive. On top of that, ships don't seem to use fighter ability like targeting feed on support fighter if all wings consist of them ( intentional?)

So I set the support wing to bomber type, so they will immediately try to reload when ammo runs out instead of loitering like fighters do, and set engagement range to very low value (<1000)

It seems that AI recognizes that they have to get close to use the wings, so no problems there, but is there anything i'd be breaking doing this otherwise?
Would this cause any issue with a ship that has different bombers/fighters with different engage distance, and if I leave the support tag will autofit still assign the wing as if it were a support-type one despite having BOMBER role ?
« Last Edit: October 14, 2020, 10:08:41 PM by shoi »
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 #6845 on: October 14, 2020, 08:32:07 PM »

Basically, I wanted to create a more aggressive type of support wing that doesn't hide behind carrier and also doesn't fly directly on top of enemy because they won't survive. On top of that, ships don't seem to use fighter ability like targeting feed on support fighter( intentional?)

So I set the support wing to bomber type, so they will immediately try to reload when ammo runs out instead of loitering like fighters do, and set engagement range to very low value (<1000)

It seems that AI recognizes that they have to get close to use the wings, so no problems there, but is there anything i'd be breaking doing this otherwise?
Would this cause any issue with a ship that has different bombers/fighters with different engage distance, and if I leave the support tag will autofit still assign the wing as if it were a support-type one despite having BOMBER role ?

Anyone chime in and correct me if this is inaccurate, but I seem to remember that the low range will will likely cause other wings to not be sent out even if they have higher range - though this could have been fixed since I last encountered it. The carrier will wait until all wings can attack unless it is being threatened while REGROUP is active.

Autofit should consider it a support wing, yes, the role only affects how hullmods/skills/ship systems affect it and how the AI uses the wing during a strike.
Logged

Alex

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

On top of that, ships don't seem to use fighter ability like targeting feed on support fighter if all wings consist of them ( intentional?)

That sounds like a bug, made a note - thanks!

I'm unsure about whether low range will make other wings not get sent out - that may indeed be the case if it's not SUPPORT.
Logged

shoi

  • Admiral
  • *****
  • Posts: 649
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6847 on: October 15, 2020, 01:23:10 PM »

Thanks guys  :)

I tested with disparate engagement ranges, and it seems to work fine. It seemed like the fighters with shorter range actually move further out when paired with another wing that has higher engagement range, but im not 100% sure thats what I actually was seeing.

Last question for now - is there a way to dynamically assign a fighter wing to an arbitrary ship? I was looking at the FighterWing API, and there is an option to set an owner, but it accepts an int. Is owner in this context the side, like player/enemy/ally ?
« Last Edit: October 15, 2020, 05:53:34 PM by shoi »
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6848 on: October 15, 2020, 03:44:10 PM »

i'm trying to prohibit building specific Vanilla Structures/Industries on a planet.
I'll take super dodgy solutions at this point, since I'm kinda running out of options :/
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 #6849 on: October 15, 2020, 03:56:37 PM »

i'm trying to prohibit building specific Vanilla Structures/Industries on a planet.
I'll take super dodgy solutions at this point, since I'm kinda running out of options :/

Iirc I don't think this is possible as industry hardcap/structure hardcap mechanics (not the amount in the case of industries, just the build prevention mechanics) is hardcoded and not exposed. I've never tried before, though, so I very well could be wrong.

You could try procedurally removing the structure if it exists, refunding the player, and giving them an intel alert explaining what happened, but preventing building specifically from the structure interface is currently impossible, I believe.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6850 on: October 16, 2020, 04:19:16 AM »

My take on that would be for your mod to extend the base industry you want to prohibit, then replace base industry with your extended class (data/campaign/industry.csv). Then override isAvailableToBuild() with your logic.
Example: com.fs.starfarer.api.impl.campaign.econ.impl.Farming
Code
package i.hate.farms;

import com.fs.starfarer.api.impl.campaign.econ.impl.Farming;

public class MyFarming extends Farming {
   @Override
   public boolean isAvailableToBuild() {
      return false;
   }
}
And in your data/campaing/industries.csv:
Code
farming,Farming,15,60,,1,,,"farming, industry, rural",,graphics/icons/industry/farming.png,i.hate.farms.MyFarming,"Agriculture is a trade and technology as old as civilization itself; for thousands of cycles Humanity has harnessed the power of natural, modified, and artificial biological machines for sustenance. So it has always been, so it shall be so long as humans are human.",200

This is all theoretical code...
« Last Edit: October 16, 2020, 04:21:27 AM by Jaghaimo »
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6851 on: October 16, 2020, 04:41:14 AM »

That would directly override Vanilla .csv values, which is not something I want to do due to compatibility issues - but I thank you for the pointers!
Logged

Alex

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

(That's the only way that comes to mind, yeah. Hmm...)
Logged

shoi

  • Admiral
  • *****
  • Posts: 649
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6853 on: October 16, 2020, 12:13:29 PM »

Trying to change a fighter's variant to another version in combat.

It works...but it also overwrites that variant for every other wing in the game.

Any ideas? I've tried cloning the variant and assigning it to the wing using fleetmember, which doesn't seem to do anything either =/
Code
			if(parent != null)
{
CombatEngineAPI engine = Global.getCombatEngine();
List<FighterWingAPI> wings = parent.getAllWings();

for(FighterWingAPI wing : wings)
{
if(!wing.getWingId().equals("armaa_bit_wing"))
{
continue;
}
//wing.setVariantId("custom");
//List<ShipAPI> fighters = wing.getWingMembers();
ShipAPI fighter = wing.getLeader();
//for(ShipAPI fighter : fighters)
//{
//fighter.getMutableStats().getVariant().setHullVariantId("variant"+ship.getName());
MutableShipStatsAPI stats = fighter.getMutableStats();
ShipVariantAPI newVariant = stats.getVariant().clone();
stats.getVariant().setOriginalVariant(null);
fighter.getFleetMember().setVariant(newVariant,false,true);


stats.getVariant().clearSlot("WS0001");
stats.getVariant().addWeapon("WS0001",ship.getVariant().getWeaponId("WS0001"));
fighter.setHitpoints(0f);
ship.setHitpoints(0f);

//}


}
}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6854 on: October 16, 2020, 12:17:37 PM »

Ah - that's basically just never going to work. The ship is created from the variant once, and if you change the variant's weapons, that's not going to re-create the ship. You'd need to spawn another ship and replace this one with it, though that might have implications e.g. for things already targeting the "old" version etc, though in theory that should work.
Logged
Pages: 1 ... 455 456 [457] 458 459 ... 706