Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 696 697 [698] 699 700 ... 711

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

NeoLemon

  • Ensign
  • *
  • Posts: 28
  • Y E S
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10455 on: February 06, 2024, 10:58:08 AM »

is it possible for a standard missile to deal soft flux damage at the moment? I wanted to change locust damage to kinetic, but don't want it to just eat ships...

I believe so, using a custom DamageDealtModifier.

Does getShipEngines() return an array of the engines on a ship that I could then iterate thru?

The Starsector javadoc is here:
https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

It should help you find the answers to those kinds of questions, see what methods are available, etc.

Code attempt:  (causes a crash currently)

The actual error message/stack trace is really helpful to see along this sort of question, btw!

Secondly, is this the proper way to implement a custom missile ai script called "SeekerMissileAI"   to missiles of projectile ID "battlefleets_tau_seekermissile"?

That looks right to me, though I didn't try it etc. But at least the general idea looks correct.

Alex sorry to bother you, but it is possible to make ship to be able to shoot while venting? and if it doesnt, do you will add api that will allow it to happen next patch?
Logged

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 135
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10456 on: February 06, 2024, 03:27:55 PM »

Whoops!   here's the crash log for my broken fusion blaster:

Code

12551 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.weapons.FusionBlasterOnFireEffect]
java.lang.RuntimeException: Error loading [data.scripts.weapons.FusionBlasterOnFireEffect]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.weapons.FusionBlasterOnFireEffect'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
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/scripts/weapons/FusionBlasterOnFireEffect.java', Line 44, Column 16: Unexpected selector '(' after "."

So it would appear that my line to cause the flameout:

   shipengine.(weapon.getShip()).forceFlameout();

Is not the proper implementation.


Also I tried tagging in the code for the missileAI and got this:

Code
12127 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.world.BattlefleetsSectorsGen]
java.lang.RuntimeException: Error loading [data.scripts.world.BattlefleetsSectorsGen]
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/scripts/world/BattlefleetsSectorsGen.java', Line 70, Column 44: Cannot determine simple type name "MissileAPI"
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/scripts/world/BattlefleetsSectorsGen.java', Line 70, Column 44: Cannot determine simple type name "MissileAPI"

I think I'm missing an import declaration for missileAI?
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10457 on: February 07, 2024, 06:23:13 AM »

@accuracyThruVolume are you using a proper java IDE? all of these mistakes are minor syntax errors that one would automatically correct for you.
The wiki has a guide for setting up intellij here that should only take a few minutes & will make things so much easier compared to using something like notepad++

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10458 on: February 07, 2024, 02:59:50 PM »

Hi people on the forum,

Here is VladimirVV, a player of starsector since 2015. I'm currently making a mod, and I met a silly question that I can't find answer to, any help would be appreciated!

The question is, I want to implement a weapon like death ray, a super laser that literally kills anything in its way but takes super long time to charge. The implementation is OK, and  I find it fun to play with. The only problem is that the ai does NOT fire it under any circumstances.

For my own efforts regarding this issue,  I tried to google for it and I found something like ai would not fire a weapon set if it costs more than 50% of the flux of the ship. And I made this weapon with purpose that it will fill almost 100% of the flux pool for the ship. I want to let the ai bypass this 50% flux threshold, how can I do it? (I don't want to lower the flux this weapon costs, otherwise the data of the weapon will look bizarre and make the ship quite unbalanced)

Thank you!
Logged
Greetings from the P-Space! --Captain Vladimir

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 135
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10459 on: February 07, 2024, 07:28:37 PM »

Hi people on the forum,

Here is VladimirVV, a player of starsector since 2015. I'm currently making a mod, and I met a silly question that I can't find answer to, any help would be appreciated!

The question is, I want to implement a weapon like death ray, a super laser that literally kills anything in its way but takes super long time to charge. The implementation is OK, and  I find it fun to play with. The only problem is that the ai does NOT fire it under any circumstances.

For my own efforts regarding this issue,  I tried to google for it and I found something like ai would not fire a weapon set if it costs more than 50% of the flux of the ship. And I made this weapon with purpose that it will fill almost 100% of the flux pool for the ship. I want to let the ai bypass this 50% flux threshold, how can I do it? (I don't want to lower the flux this weapon costs, otherwise the data of the weapon will look bizarre and make the ship quite unbalanced)

Thank you!

I've found adding the line:

"autocharge":true,

to your .wpn  file will make the AI fire the weapon more reliably.   Note that I've seen them turn the weapon or even the whole ship away from the target (like the AI thinks the weapon has already fired) before the charging weapon actually fires if the the chargeup time is extensive.    If the AI still seems unable to use your weapon well, try balancing the chargeup and chargedown times.

@accuracyThruVolume are you using a proper java IDE? all of these mistakes are minor syntax errors that one would automatically correct for you.
The wiki has a guide for setting up intellij here that should only take a few minutes & will make things so much easier compared to using something like notepad++

Thanks for the pointer on the IDE Ruddygreat!   8)   I was able to get the missileAI working / not complaining / not crashing the game.   I'm still a little lost on the correct implementation of the forceflameout command.   IntelliJ is useful indeed for the "hey this patch of code is no good"   ;D

Currently my fusion blaster onfire code is:

Code
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;

public class FusionBlasterOnFireEffect implements OnFireEffectPlugin
{

    public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;

private ShipEngineControllerAPI shipengine;

public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);

if (rndChance <= OVERLOADCHANCE)
{
// something here to get each engine, chance to flameout each one individually?

}

if (rndChance <= FLAMEOUTCHANCE)
{
ShipAPI ship = weapon.getShip();
//ship.ShipEngineControllerAPI.forceFlameout();     <--- this doesn't work
//ShipEngineAPI.forceFlameout();                          <--- this doesn't work either
}

}
}

So my current stumbling block is what is the proper command to tell my ship to flameout.

Also the reference for getShipEngines  just shows:

getShipEngines
java.util.List<ShipEngineControllerAPI.ShipEngineAPI> getShipEngines()

So It's unclear what the return value is.   My first guess is an array of the ship's engines?

EDIT:

Ok so I dug around in  ShipEngineControllerAPI.java   and it looks like it returns a list?

List<ShipEngineAPI> getShipEngines();

Is there an example of how to use this function to capture a list of engines?
« Last Edit: February 08, 2024, 03:04:49 AM by AccuracyThruVolume »
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10460 on: February 10, 2024, 09:16:04 PM »

- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

You can't, sorry - these are hardcoded. Not for any design reason, just for "had to get it done quickly at some point" reasons.

Any chance this stuff could get exposed in the near future?

Edit: is there any way we can modify maximum cargo of the campaign fleet? CargoData (class that implements CargoAPI) has setMaxCapacity(float), but I reckon it might be called each time fleet composition changes and fleet members contributing cargo capacity reshuffle.

Basically what I have in mind is some kind of buff/debuff that would modify maximum cargo either flatly or multiplicatively, irrespective of fleet member contributions. Would CargoData usage suffice for my purposes, or are there some non-obvious factors here?
« Last Edit: February 11, 2024, 04:19:53 AM by Ontheheavens »
Logged
   

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10461 on: February 11, 2024, 12:23:56 PM »

this isn't necessarily a modding question, but it is about the game in general - why is all of the rendering manually sorted into layers instead of using the depth buffer?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10462 on: February 11, 2024, 01:36:06 PM »

Alex sorry to bother you, but it is possible to make ship to be able to shoot while venting? and if it doesnt, do you will add api that will allow it to happen next patch?

I don't think so and I don't think so - sorry! There's code pertaining to this in a bunch of places and I wouldn't want to mess with it (and likely break all sorts of things) without a compelling vanilla use case.


- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

You can't, sorry - these are hardcoded. Not for any design reason, just for "had to get it done quickly at some point" reasons.

Any chance this stuff could get exposed in the near future?

Edit: is there any way we can modify maximum cargo of the campaign fleet? CargoData (class that implements CargoAPI) has setMaxCapacity(float), but I reckon it might be called each time fleet composition changes and fleet members contributing cargo capacity reshuffle.

Basically what I have in mind is some kind of buff/debuff that would modify maximum cargo either flatly or multiplicatively, irrespective of fleet member contributions. Would CargoData usage suffice for my purposes, or are there some non-obvious factors here?

See the Bulk Transport skill implementation. IIRC the only way to modify the cargo capacity of the fleet is to modify all the individual ships.

(Re: image/text for loot screen - maybe at some point, but being honest it's an extremely low priority item and there's tons of other things to do.)

this isn't necessarily a modding question, but it is about the game in general - why is all of the rendering manually sorted into layers instead of using the depth buffer?

It's a simpler not having to think about what the z-value needs to be all the time - and, importantly, not needing to pass in an extra z-value *at all* and being able to use glVertex2f etc. And also not needing to worry about z-fighting. And being able to keep the depth test off is nice, too, though that's probably not a big deal performance-wise. Basically using the depth test for this would just be an unnecessary pain. If the layering was difficult for some reason, there'd be some reason for it, but it's ... not.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10463 on: February 11, 2024, 02:40:29 PM »

It's a simpler not having to think about what the z-value needs to be all the time - and, importantly, not needing to pass in an extra z-value *at all* and being able to use glVertex2f etc. And also not needing to worry about z-fighting. And being able to keep the depth test off is nice, too, though that's probably not a big deal performance-wise. Basically using the depth test for this would just be an unnecessary pain. If the layering was difficult for some reason, there'd be some reason for it, but it's ... not.

Ah yeah, that all makes sense. I was mostly thinking of it in the context of rendering stuff between ships & weapons, though manual sorting is way easier to work with for basically everything else.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10464 on: February 11, 2024, 07:49:53 PM »

Gotcha, yeah.
Logged

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 135
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10465 on: February 11, 2024, 11:33:23 PM »

With some discord help I was able to get my code working for my fusion blaster.

Here it is in case anyone else can make use of it:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;
import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;

public class FusionBlasterOnFireEffect implements OnFireEffectPlugin
{

        public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;

private ShipEngineControllerAPI shipengine;

public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
ShipAPI ship = weapon.getShip();
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);

if (rndChance <= OVERLOADCHANCE)
{
if (!ship.getEngineController().getShipEngines().isEmpty())
{
for(ShipEngineControllerAPI.ShipEngineAPI eachengine : ship.getEngineController().getShipEngines())
{
int rndChance2 = (int)Math.round((Math.random() * 99)+ 1);
if (rndChance2 <= 33)
{
eachengine.disable();
}
}
}
}

if (rndChance <= FLAMEOUTCHANCE)
{
ship.getEngineController().forceFlameout();
}
}
}
« Last Edit: February 12, 2024, 03:06:05 AM by AccuracyThruVolume »
Logged

Homete

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10466 on: February 12, 2024, 01:23:34 AM »

Hi i have a question about using updateInteractionDataImpl(). So i was trying to have the data set so when i call the mission, it sets a random planet and gives its distance, star system and calls the map. but it does not call any and acts like nothing happens.

I am at a loss how to resolve this issue. Any help is appreciated.





Code
package data.campaign.missions;

import java.awt.Color;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepRewards;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
import com.fs.starfarer.api.ui.TooltipMakerAPI;

public class eusan_nation_penroseRecovery1 extends HubMissionWithSearch {

    public static enum Stage {
        LOCATE_PENROSE419,
        RETURN_BLACKBOX,
        COMPLETED
    }
   
    protected PersonAPI officer_yeong;
    protected PlanetAPI vineta;
    protected PlanetAPI target_planet;

    @Override
    protected boolean create(MarketAPI arg0, boolean arg1) {
        if(!setGlobalReference("$eusan_nation_penroseRecovery1_ref")){
            return false;
        }

        officer_yeong = getImportantPerson("eusan_nation_officer_yeong");
        vineta = (PlanetAPI) Global.getSector().getEntityById("eusan_nation_vineta");

        resetSearch();
        requirePlanetUnpopulated();
preferPlanetNotFullySurveyed();
preferPlanetInDirectionOfOtherMissions();
        preferPlanetWithoutRuins();
        preferPlanetNonGasGiant();
        preferSystemUnexplored();
        preferSystemNotPulsar();
        preferSystemNotBlackHole();

        target_planet = pickPlanet();

        if(officer_yeong == null){
            return false;
        }
        if (target_planet == null) {
return false;
}
        if(target_planet.isStar()){
            return false;
        }

        setStartingStage(Stage.LOCATE_PENROSE419);
        addSuccessStages(Stage.COMPLETED);

        setStoryMission();

        setStageOnGlobalFlag(Stage.RETURN_BLACKBOX, "$eusan_nation_penroseRecovery1_returnBlackbox");
        setStageOnGlobalFlag(Stage.COMPLETED, "$eusan_nation_penroseRecovery1_completed");

        makeImportant(target_planet, "$eusan_nation_penroseRecovery1_targetPlanet", Stage.LOCATE_PENROSE419);

        beginStageTrigger(Stage.RETURN_BLACKBOX);
        makeImportant(officer_yeong, "$eusan_nation_penroseRecovery1_returnBlackbox", Stage.RETURN_BLACKBOX);
        endTrigger();

        beginStageTrigger(Stage.COMPLETED);
        triggerSetGlobalMemoryValue("$eusan_nation_penroseRecovery1_completed", true);
        endTrigger();

        setCreditReward(100000);
        setRepRewardPerson(RepRewards.HIGH);
setRepRewardFaction(RepRewards.HIGH);

        //return false;
        return true;
    }

    protected void updateInteractionDataImpl(){
        set("$eusan_nation_penroseRecovery1_planetId", target_planet.getId());
        set("$eusan_nation_penroseRecovery1_planetName", target_planet.getName());
        set("$eusan_nation_penroseRecovery1_systemName", target_planet.getStarSystem().getNameWithNoType());
        set("$eusan_nation_penroseRecovery1_distanceLy", getDistanceLY(target_planet));
    }
   
    @Override
    public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height){
        float opad = 10f;
        if(currentStage == Stage.LOCATE_PENROSE419){
            info.addPara("A transponder signal has been detected by the Deep Space Antenna Array on Rotfront. It has been identified as the PENROSE-419. Recover the blackbox and any remains of the crew.", opad);
        }
        else if(currentStage == Stage.RETURN_BLACKBOX){
            info.addPara("Blackbox retrieved. Return the data to " + officer_yeong.getNameString() + ".", opad);
        }
    }

    @Override
    public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad){
        if(currentStage == Stage.LOCATE_PENROSE419){
            info.addPara("A transponder signal has been detected. Locate and recover the Penrose-419's blackbox and any remains of the crew if possible. The location has been determined to be at " + target_planet.getName() + " at the " + target_planet.getStarSystem().getNameWithNoType() + " system.", tc, pad);
            return true;
        }
        else if(currentStage == Stage.RETURN_BLACKBOX){
            info.addPara("Return to " + officer_yeong.getNameString() + ".", tc, pad);
        }
        return false;
    }

    @Override
    public String getBaseName() {
        return "Recover the mission data recorder from the PENROSE-419";
    }

    @Override
    public String getPostfixForState() {
        if (startingStage != null) {
            return "";
        }
        return super.getPostfixForState();
    }
}
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10467 on: February 12, 2024, 07:57:15 AM »

So i was trying to have the data set so when i call the mission, it sets a random planet and gives its distance, star system and calls the map. but it does not call any and acts like nothing happens.
Not sure exactly what you're trying to do, but it sounds like you might want to use the ShowMapMarker command or dialog.getVisualPanel().showMapMarker(). Is there any vanilla mission that does what you're trying to do? If so it might be a good idea to try to copy the relevant parts from that mission.

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10468 on: February 12, 2024, 08:36:41 AM »

Could the exception I reported here ever be caused by returning a HashSet from IntelInfoPlugin.getIntelTags instead of a LinkedHashSet? Or maybe by failing to return a set with "Important" from an intel that returns true from isImportant()? I'm trying to verify that fixing these things prevents the CTD, but I still haven't managed to reproduce it. The stack trace makes it seem like something that would be caused by returning a set that includes null, but I don't see a way any of the mods I was using could've done that.

Lukas04

  • Captain
  • ****
  • Posts: 372
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10469 on: February 12, 2024, 11:03:20 AM »

Used to be able to Extend from the "HyperspaceTerrainPlugin" to create my own terrain with Hyperspace like features, but since 0.97 doing so does no longer causes storms to be appear in the "nebula", any idea on what would cause this?
Logged
My Mods
Pages: 1 ... 696 697 [698] 699 700 ... 711