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: Anubis-class Cruiser (12/20/24)

Pages: 1 ... 234 235 [236] 237 238 ... 753

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

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3525 on: August 26, 2017, 09:08:09 AM »

If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25044
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3526 on: August 26, 2017, 10:15:40 AM »

If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

Near as I can tell, .jar is just compressed, complied files.
.class are complied .java files, but java files by themselves work by being processed at run-time.

So making a .jar is not strictly necessary, right?
A mod should work with just .java file in proper directories.

The game will compile certain .java files on startup. Generally speaking those have to be somewhere under the data/scripts/ folder.

However, it uses a special compiler - called Janino - to do this. It doesn't support a number of language features and in general isn't the most reliable thing in the world. In addition, compiling on every game start makes it take longer to load.

So, basically, a jar file is all around the preferred option - the game will start faster and you're less likely to run into problems with whatever you're trying to do. Loose .java files are ok for some minor assorted things but I wouldn't recommend it for something larger. Personally, I'm moving away from using them entirely.


Ok, another (maybe dumb) question: what, exactly, is the .GetFleetMemberId function used for? After searching through most fleet-based code, I have yet to find any function that actually takes the "Fleet Member ID" as an argument.

I don't think it's currently used for anything. It's just there to keep track of a specific fleet member if that was ever needed. To "use" it, you'd just iterate over the fleet members in a fleet and check to see if one of those is the one you're looking for.

Follow-up to that question, how would I go about finding a specific ship's related FleetMemberAPI? Casting does not work (obviously), and all functions in FleetAPI seems to use a sorting method that cannot be returned from the ShipAPI. I'm running tests to try and circumvent the process altogether, but if there is a way to get a FleetMemberAPI from a ShipAPI, it would streamline the process immensely.

DeployedFleetMemberAPI CombatFleetManagerAPI.getDeployedFleetMember(ShipAPI ship);

Then that has a method that gets you a FleetMemberAPI.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3527 on: August 26, 2017, 10:23:19 AM »

If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

You mean in the tag section?

AI_fighter_wing,AI-fighter_variant,"fighter2, fighter, low, no_sell",1,,6,8,BOX,5000,500,4,FIGHTER,Fighter,10,10000,,,,,,,,2004
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3528 on: August 26, 2017, 03:25:58 PM »

If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

You mean in the tag section?


Yep. "no_sell" in the tags for fighter wings. You can also add "no_drop" to stop the LPC dropping as loot, if it's a built-in wing you don't want to be modular (see: Shepherd's Borer Drones and Tempest's Terminator Drone).

Also, for weapons marked as "SYSTEM" in the hints, take note that by default system weapons also won't appear in the codex - though there is a "SHOW_IN_CODEX" flag you can also add to override that (which is how you can see things like the Onslaught's TPCs in the codex).
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3529 on: August 27, 2017, 05:43:20 AM »

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipAPI;

public class AmplifiedSensors3 extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 75f);
mag.put(HullSize.FRIGATE, 100f);
mag.put(HullSize.DESTROYER, 125f);
mag.put(HullSize.CRUISER, 150f);
mag.put(HullSize.CAPITAL_SHIP, 200f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getSightRadiusMod().modifyPercent(id, (Float) mag.get(hullSize));
stats.getAutofireAimAccuracy().modifyPercent(id, 25f);

}


public boolean isApplicableToShip(ShipAPI ship) {
return
!ship.getVariant().getHullMods().contains("comp_hull");
}

}

I made a sensor enhancement hullmod, but it does not work. Why?
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3530 on: August 27, 2017, 07:57:12 AM »

"Does not work" is pretty vague.  Did you make sure that the id of the "comp_hull" Hull Mod you're looking for is installed on that Variant?

That would be the simplest explanation.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3531 on: August 27, 2017, 08:43:48 AM »

"Does not work" is pretty vague.  Did you make sure that the id of the "comp_hull" Hull Mod you're looking for is installed on that Variant?

That would be the simplest explanation.

comp_hull is compromised hull. No, it's not on the ship.

The hullmod doesn't seem to have any effect, as the ships sill has 20 sensor range, and it should have the highest sensor range in the fleet.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3532 on: August 27, 2017, 06:03:40 PM »

SightRadiusMod is for the combat sight radius, not Sensors in the Strategic view. 

So use stats.getSensorStrength() instead.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3533 on: August 28, 2017, 12:01:43 AM »

SightRadiusMod is for the combat sight radius, not Sensors in the Strategic view. 

So use stats.getSensorStrength() instead.

thank you!
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3534 on: August 29, 2017, 10:49:56 AM »

*sigh*

So I have this:
   "modPlugin":"data.scripts.SCModPlugin"


in my mod_info.json, and in my data\scripts I have this SCModPlugin.java file:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAIPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.procgen.ConditionGenDataSpec;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import java.io.IOException;
import org.json.JSONException;

public class SCModPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        updateConditionSpecs();
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("ISA");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("RSF");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UIN");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("XLE");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("FFS");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("VNS");
    }

}


I get this error:
Code
34014 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.SCModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.SCModPlugin]
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.SCModPlugin'
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: Compilation unit 'data.scripts.SCModPlugin' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more

Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3535 on: August 30, 2017, 03:11:06 AM »

Anyone?
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7695
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3536 on: August 30, 2017, 04:34:50 AM »

The error seems to imply that something is wrong with either the path or the file name. It looks correct, but check your filenames and folder names.

Also you may want to clean up those imports.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3537 on: August 30, 2017, 06:05:25 AM »

I looked at how Interstellar Imperium did it and copied, removing unnecessary code.
I did check my paths and filenames, which is why it's puzzling me.

SCModPlugin is used everywhere in proper case.

And those imports are all standard Starfarer functions and I removed all II ones, so there shouldn't be problems. I suppose I don't really need anything other than BaseModPlugin.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3538 on: August 30, 2017, 07:24:57 AM »

Changing 
"modPlugin":"data.scripts.SCModPlugin"     <---- this seems to only work if it's in a .jar
into 
"modPlugin":"data\scripts\SCModPlugin.java"

stops the crash, but it does so because the game doesn't see my mod anymore. Cant select it.

WTF is going on?
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3539 on: August 30, 2017, 08:23:15 AM »

Probably the code can't be compiled by Janino.  Which is weird, because I don't see anything very obvious there, but basically, you need to compile to a JAR.
Logged
Please check out my SS projects :)
Xeno's Mod Pack
Pages: 1 ... 234 235 [236] 237 238 ... 753