Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 478 479 [480] 481 482 ... 710

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

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7185 on: March 31, 2021, 09:42:01 PM »

Right, yeah. If you do this for particle effects it can be helpful. Basically, binding a texture has a performance cost - higher for larger textures, too. So if you *can* bind a texture atlas before doing all your drawing, it can help. It helps more if you do a lot of drawing, like for a particle effect. I wouldn't worry about it too much unless you're really drawing a lot of things.
Well, so when the "binding the texture" will happen? I mean, actually starsector would bind all the textures while loading right?
Logged
My mods


Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7186 on: April 01, 2021, 05:38:39 AM »

How do I actually use a Janino-compiled script from precompiled code? As in, this crashes the game on start:

Spoiler
Code: java
	@Override
public void onApplicationLoad() throws Exception {
try {
String className = "data.scripts.world.systems.Galatia";
Global.getLogger(this.getClass()).info("Class loader loading class");
Global.getLogger(this.getClass()).info("Class name: " + Global.getSettings().getScriptClassLoader().loadClass(className).getName());
Global.getLogger(this.getClass()).info("Trying Class.forName");
Class test = Class.forName(className);
} catch (ClassNotFoundException cex) {
throw new RuntimeException(cex);
}
}
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Class loader loading class
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Class name: data.scripts.world.systems.Galatia
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Trying Class.forName
19481 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
java.lang.RuntimeException: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
   at org.histidine.testmod.plugins.TestModPlugin.onApplicationLoad(TestModPlugin.java:41)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at org.histidine.testmod.plugins.TestModPlugin.onApplicationLoad(TestModPlugin.java:39)
   ... 6 more

[close]
(Context of what I'm trying to do. Not sure if this problem surfaced in Starsector 0.95a, and don't feel like reinstalling to find out)

UPDATE: Applied a hammer to this screw.
Spoiler
Code: java
	public static void generateSystemsJanino() {
List<String> inputList = new ArrayList<>();
String[] sysNames = {"Galatia", "Askonia", "Eos", "Valhalla", "Arcadia",
"Magec", "Aztlan", "Samarra", "Penelope", "Yma", "Hybrasil", "Duzahk",
"TiaTaxet", "Canaan", "AlGebbar", "Isirah", "KumariKandam", "Naraka",
"Thule", "Mayasura", "Zagan", "Westernesse", "Tyle"};

inputList.add("import com.fs.starfarer.api.campaign.SectorAPI;\r\n");
inputList.add("SectorAPI sector = com.fs.starfarer.api.Global.getSector();\r\n");
inputList.add("new data.scripts.world.corvus.Corvus().generate(sector);\r\n");
for (String systemName : sysNames) {
String entry = "new data.scripts.world.systems." + systemName + "().generate(sector);\r\n";
inputList.add(entry);
}

ScriptEvaluator eval = new ScriptEvaluator();
eval.setReturnType(void.class);
eval.setParentClassLoader(Global.getSettings().getScriptClassLoader());

StringBuilder sb = new StringBuilder();
for (String input : inputList) sb.append(input);
Global.getLogger(VanillaSystemsGenerator.class).info("Output: " + sb.toString());
try
{
eval.cook(sb.toString());
eval.evaluate(null);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
[close]
« Last Edit: April 01, 2021, 07:06:43 AM by Histidine »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7187 on: April 01, 2021, 09:43:32 AM »

How do I actually use a Janino-compiled script from precompiled code? As in, this crashes the game on start:

Hmm - I mean, this sounds like a it's probably an IDE configuration issue? I'm not seeing why it wouldn't work if the resulting class file properly refers to the Janino-compiled class (i.e. right package etc). As long as it's not called before that class is compiled. That said, this doesn't happen in vanilla, so maybe there's a larger issue here that I'm just not seeing, perhaps due to how the classloaders are hooked up.
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 #7188 on: April 01, 2021, 03:19:16 PM »

I cannot for the life of me find the thread where it was mentioned and I don't see it in the patch notes, but - did the "Don't ever target fighters" weapon hint make it into the release?

If so, what is the hint?

(Or am I just crazy and dreamed that was going to be a thing?)

*EDIT*

Ah I finally found the thread! Looking at the discussion again I think maybe I was misunderstanding? I was going off of:

Fair enough, yeah.

Edit: added "NO_TURN_RATE_BOOST_WHEN_IDLE" weapon hint.
That plus a ignore fighters tag? Whooooo this is great, thanks a lot. Combined with a smarter autofire decision AI, it should help a LOT when dealing with ships supported by fighters.

So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?
« Last Edit: April 01, 2021, 03:53:48 PM by Morrokain »
Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7189 on: April 01, 2021, 07:22:02 PM »

Is the code that handles integrating an AI core officer obfuscated? I've poked around the api source and haven't managed to stumble into it.

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7190 on: April 01, 2021, 07:40:08 PM »

These seem relevant:

com.fs.starfarer.api.campaign.AICoreOfficerPlugin

CampaignPlugin.pickAICoreOfficerPlugin()
Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7191 on: April 01, 2021, 07:46:56 PM »

These seem relevant:

com.fs.starfarer.api.campaign.AICoreOfficerPlugin

CampaignPlugin.pickAICoreOfficerPlugin()

Those are used to generate the AI core officers- but I'm looking for the stuff that handles integrating an AI core officer into an automated ship (the option that uses a story point). Specifically, integrating an AI officer into a ship blocks command transferring- even if I redo the Automated Ship hullmod to not block command transfer.

ArneHD

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7192 on: April 02, 2021, 09:08:04 AM »

Hi, can I make the character screen wider? I tried adding a skill after tier 5, but it went off screen there, and I don't know where to find the UI files or, for that matter, how the UI works.

Any help would be appreciated, thanks.
Logged

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 231
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7193 on: April 02, 2021, 09:16:38 AM »

Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.
Logged

Warnoise

  • Commander
  • ***
  • Posts: 206
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7194 on: April 02, 2021, 09:23:17 AM »

Hi, is it possible to modify existing ships? For example adding built in mods, modifying op, armor, etc...
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7195 on: April 02, 2021, 11:00:26 AM »

So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?

Yeah, that sounds right - sorry :)

Those are used to generate the AI core officers- but I'm looking for the stuff that handles integrating an AI core officer into an automated ship (the option that uses a story point). Specifically, integrating an AI officer into a ship blocks command transferring- even if I redo the Automated Ship hullmod to not block command transfer.

See: Misc.isUnremovable(); setting that flag is what integrating the AI core does. But the core code that does it is not directly moddable, no.


Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.

There isn't, I don't think. But doesn't it give you a scrollbar? Or does that only work vertically if you add more aptitudes? I don't actually remember.

Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.

I don't believe so, no. Well, if you set its collision class to NONE, that might do it, but that'd have other effects, too.

Hi, is it possible to modify existing ships? For example adding built in mods, modifying op, armor, etc...

Yeah - you can edit the corresponding .ship file (for built-in mods) and the corresponding ship_data.csv row for editing their stats.
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 #7196 on: April 02, 2021, 12:15:59 PM »

So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?

Yeah, that sounds right - sorry :)


No worries thanks for clarifying!
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7197 on: April 02, 2021, 07:07:54 PM »

Given a float representing % bonus XP from story point use (say, 0.5), how do I determine the bonus XP amount I should pass to MutableCharacterStatsAPI.addBonusXP?

(I'm doing a thing where player can spend one SP on an action and get X% bonus XP back, then if they cancel that action they get the other (100-X)% bonus XP as a refund)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7198 on: April 02, 2021, 07:14:19 PM »

Ah - let me add long getBonusXPForSpendingStoryPointBeforeSpendingIt() to MutableCharacterStatsAPI.

It's a bit involved; here's the actual method. It *should* be correct - I did a pretty good amount of testing on it. But it might not handle some edge case like, say, the bonus XP exceeding a single level's total XP.

Code
	public long getBonusXPForSpendingStoryPointBeforeSpendingIt() {
LevelupPlugin plugin = ScriptStore.getPlugin(LevelupPlugin.class);
int per = plugin.getStoryPointsPerLevel();


// what we want to do is figure out exactly how much bonus XP is needed to gain 1 story point
// if the bonus XP crosses over to the next level - so part of the bonus XP is based on the XP
// for the current level, and part for the next.
int levelWithBonusXP = 1;
while (plugin.getXPForLevel(levelWithBonusXP + 1) <= xp + bonusXp * 2L) {
levelWithBonusXP++;
if (levelWithBonusXP >= plugin.getMaxLevel()) break;
}

if (levelWithBonusXP < plugin.getMaxLevel() - 1) {
long currLevelStart = plugin.getXPForLevel(levelWithBonusXP);
long currLevelEnd = plugin.getXPForLevel(levelWithBonusXP + 1);
long nextLevelEnd = plugin.getXPForLevel(levelWithBonusXP + 2);

currLevelEnd -= currLevelStart;
nextLevelEnd -= currLevelStart;

float fraction = (float)(xp + bonusXp * 2L - currLevelStart) / (float) currLevelEnd;
float fractionPerPt = 1f / (float) per;
float fractionAfter = fraction + fractionPerPt * 2f; // * 2 because it'll be gained alongside real XP

float xpForThisLevel = Math.max(0f, Math.min(1f, fractionAfter) - fraction) * currLevelEnd;
float xpForNextLevel = Math.max(0f, fractionAfter - 1f) * (nextLevelEnd - currLevelEnd);

return (long)Math.round((xpForThisLevel + xpForNextLevel) * 0.5f); // * 0.5f to undo the earlier doubling
}

int level = this.level + 1;
level = Math.min(level, plugin.getMaxLevel() + 1);
long neededForPrevLevel = plugin.getXPForLevel(level - 1);
long neededForSPLevel = plugin.getXPForLevel(level);

return ((neededForSPLevel - neededForPrevLevel) / per);
Logged

Warnoise

  • Commander
  • ***
  • Posts: 206
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7199 on: April 02, 2021, 11:27:05 PM »

So what if, for example, I want to modify the XIV variant of the onslaught only (not the regular one), for example I want to add a built in mode for the xiv variant only, how can I do that?

I checked the .ship files and I only found the base versions of said ships, I couldn't find the xiv variants in . ship files.
Logged
Pages: 1 ... 478 479 [480] 481 482 ... 710