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 ... 324 325 [326] 327 328 ... 706

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

Melissia

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4875 on: August 24, 2019, 11:04:56 AM »

Thank you.
Logged

SwissArmyKnife

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4876 on: August 24, 2019, 02:15:54 PM »


@SwissArmyKnife: not actually sure offhand what's going on. Might be another error message somewhere earlier in the log? This sort of thing might happen if your script is doing something Janino (the compiler the game uses for loose scripts) doesn't support, or if the class doesn't have a default constructor, but none of that seems to be the problem in your code.


Thanks for taking a look at it. This may be a dumb question but I couldn't find a good answer anywhere and it's making me think the solution is simpler than it seems.

If I want to add a .java file to an existing mod's .jar file. For instance adding my new guns animation .java file to DiableAvionics  .jar file. How do I do that? Do I need to use something like netbeans to package and compile the whole thing again from src?

Do I even need to do that in the first place?

Update: Figured it out! Not ideally but it works which is good enough for a small personal mod. Ended up putting the java file in Diable's data/scripts/weapons instead of trying to add into into it's jar file.

Now my only issue is getting it to animate properly. Right now it's just cycling through the frames over and over. I need it to pause on frame 5 during firing but I'm not sure how to do that. I have no real idea what I'm doing so I looked at a bunch of different guns and couldn't find one that did the above.

I assumed that  if (!weapon.isFiring()) would dicate what it was doing while firing but adding animeSetFrame(5); in there just locks it to frame 5 in it's resting state. Firing animation still cycles through all 13 on a loop.

Here's the anim code again.
Spoiler
Code
// By Deathfly
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;

public class EldosAnimation implements EveryFrameWeaponEffectPlugin {

    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        AnimationAPI anime = weapon.getAnimation();
       
        if (anime == null){
            return;
        }
        if (!weapon.isFiring()) {
            chargeLevel = 0;
            anime.setFrameRate(-12);
            if (anime.getFrame() == 0) {
                anime.setFrameRate(0);
            }
        } else {
            if (weapon.getChargeLevel() >= chargeLevel) {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() < validFrames) {
                    anime.setFrameRate(12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(13);
                }
            } else {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() > 0) {
                    anime.setFrameRate(-12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(0);
                }
            }
            if (weapon.getShip().getFluxTracker().isOverloadedOrVenting()){
                weapon.setRemainingCooldownTo(weapon.getCooldown());
            }
        }
    }
}
[close]
« Last Edit: August 24, 2019, 03:33:03 PM by SwissArmyKnife »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4877 on: August 24, 2019, 03:06:48 PM »

Do I need to use something like netbeans to package and compile the whole thing again from src?
That would work. An IDE can make your life a lot easier. .jar files don't contain .java files, so no, you can't simply add a .java to a .jar. Jars contain .class files, which are the compiled versions of the java source.

Do I even need to do that in the first place?
I don't think so. A loose script should work unless it contains something Janino doesn't support, which I think is the case here. You might try making sure that all values assigned to floats are followed by an f (e.g. 42f instead of 42). I'm pretty sure Janino has a hard time dealing with int/float value mismatches.
Code
    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

King Alfonzo

  • Admiral
  • *****
  • Posts: 679
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4878 on: August 24, 2019, 08:49:12 PM »

Thanks for the reply Alex!

I did put in a check for that, with Get_Messy being the method to find the entity;

Code
		
SectorEntityToken spawnEntityMess = Get_Messy();
if (spawnEntityMess == null) {
return null;
}

However the problem persists. Am I doing it in the wrong area?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4879 on: August 24, 2019, 08:51:29 PM »

@King Alfonzo: I don't know! Take a look at the exception, and it should give you a line number, that's where you should look in your script. If you post the exception, I (or someone else here) can help you interpret it.
Logged

SwissArmyKnife

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4880 on: August 24, 2019, 10:39:10 PM »

I don't think so. A loose script should work unless it contains something Janino doesn't support, which I think is the case here. You might try making sure that all values assigned to floats are followed by an f (e.g. 42f instead of 42). I'm pretty sure Janino has a hard time dealing with int/float value mismatches.
Code
    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

You were completely right, loose script worked fine and janino compiled fine. Starsector launches etc. I just don't know what I'm doing with java scripting and copying existing scripts has only gotten me so far.

Once again I think I'm overcomplicating this. I want the anim to start, play until it gets to say frame 5 where the barrel is open and "hot" and pause while the beam is firing, then continue playing to the end when the gun charges down.

Here's where it's at now.
Spoiler
[close]

Anyone able to help a complete noob out?
Logged

dgs6686

  • Ensign
  • *
  • Posts: 22
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4881 on: August 25, 2019, 05:35:54 PM »

Hi all, fairly new to the game and forums but I was considering making a mod to adjust / remove some of the skills available in the game... (particularly Electronic Warfare). I know there is a skills overhaul coming soon anyways but I just wanted to try my hand at this and see how modifying some of these affects combat.

I am fairly new to modding overall and only moderately fluent in Java but I figured this shouldn't be TOO difficult. I was wondering if anyone knew where I would start for something like this? I see the skills files under character/skills and I see the api calls that it appears to make but I'm not quite sure where to look after that.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4882 on: August 25, 2019, 06:16:21 PM »

The Skills are in starfarer.api\com\fs\starfarer\api\impl\campaign\skills.  To implement new ones, you'll need to create a directory (preferably in /scripts) and move one of the Skill java files there, change the reference in the .skill file, etc.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4883 on: August 25, 2019, 09:50:44 PM »

OK, here's a weird issue.  What would stop a given Weapon from being stocked / created at a Market?

I have a "weapon" that costs 0 OPs and does some Special Stuff. 

When I force it into a Market's inventory via a restocking-script, all is well.  When I don't, it doesn't generate, even though it's Known to the Faction involved and some Variants require it to be built.  It isn't being stocked and those Variants never show up in the game.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

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 #4884 on: August 26, 2019, 01:42:08 AM »

What's the best way to record FleetMemberAPI in Persistent Data?
And how to check "FleetMemberAPI" is no longer exists and remove it from the hashmap?
Logged
My mods


Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4885 on: August 26, 2019, 03:55:50 AM »

Where could i find the recovery chance for derelicts? Do the cases in pickDerelictCondition from DerelictShipEntityPlugin affect that chance or is it only for loadout, dmods, etc.?
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4886 on: August 26, 2019, 08:58:54 AM »

I made a whole pack of custom images/flags for the player faction (in graphics/factions/custom). How do I make them show up in-game? I don't see the vanilla images referenced in the setting.json
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4887 on: August 26, 2019, 09:59:51 AM »

OK, here's a weird issue.  What would stop a given Weapon from being stocked / created at a Market?

I have a "weapon" that costs 0 OPs and does some Special Stuff. 

When I force it into a Market's inventory via a restocking-script, all is well.  When I don't, it doesn't generate, even though it's Known to the Faction involved and some Variants require it to be built.  It isn't being stocked and those Variants never show up in the game.

Hmm - looking at the code, that might happen if the tier is set too high for what the submarket allows.


What's the best way to record FleetMemberAPI in Persistent Data?
And how to check "FleetMemberAPI" is no longer exists and remove it from the hashmap?

You basically can't - a FleetMemberAPI could be in a fleet, in storage somewhere, or referenced from some other script, either from core or from another mod. So it's impossible to tell if it has "ceased to exist" or not. The best you could do is check the player's fleet and colony storage.

Where could i find the recovery chance for derelicts? Do the cases in pickDerelictCondition from DerelictShipEntityPlugin affect that chance or is it only for loadout, dmods, etc.?

Modifiers go here:
ship.getMutableStats().getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD)

(See ReinforcedBulkheads, for example)

And the base chance is in settings.json, "baseShipRecoveryChance" and "baseOwnShipRecoveryChance"

The number is a probability, i.e. >=1 is 100% chanc to recover.

I made a whole pack of custom images/flags for the player faction (in graphics/factions/custom). How do I make them show up in-game? I don't see the vanilla images referenced in the setting.json

They go into the player.faction file.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4888 on: August 26, 2019, 10:22:38 AM »

@Alex:  the Tier is set to 0.  This is supposed to be a "pretty common item" for the Factions that have it in their KnownWeapons.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4889 on: August 26, 2019, 10:24:19 AM »

Hmm - try setting the OP to not 0, maybe? I'm not seeing anything that would cause that to not add the weapon but I seem to remember "0 op" being special in some way. Also make sure it's not SYSTEM etc.
Logged
Pages: 1 ... 324 325 [326] 327 328 ... 706