Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 211 212 [213] 214 215 ... 710

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

Tecrys

  • Admiral
  • *****
  • Posts: 595
  • repair that space elevator!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3180 on: April 26, 2017, 08:55:25 AM »

Does anyone remember how I could check if a ship is in refit screen?
I think its done With a specific ship owner number but I can't remember
Logged
Symbiotic Void Creatures 0.5.0-alpha for 0.97a is out
https://fractalsoftworks.com/forum/index.php?topic=28010.0

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3181 on: April 26, 2017, 10:53:57 AM »

if the owner is -1 it's in refit.
Logged
 

Tecrys

  • Admiral
  • *****
  • Posts: 595
  • repair that space elevator!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3182 on: April 26, 2017, 11:59:52 AM »

Thanks a bunch Tartiflette!
Nope, somehow doesn't do it for me. It's supposed to mirror an installed weapon in refit screen but no matter how I try, it won't work.

I guess I will have to live with the fact that my little monsters will have 2 (actually more than that) right clawas in refit screen. As soon as battle starts everything is mirrored perfectly ...

The Script (Posted it once a long time ago)
Spoiler
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;
import com.fs.starfarer.api.graphics.SpriteAPI;
import java.util.*;

public class BaseAnimateOnFireEffect2 implements EveryFrameWeaponEffectPlugin
{
    // Default to 15 frames per second
    private float timeSinceLastFrame, timeBetweenFrames = 1.0f / 140f;
    private Map pauseFrames = new HashMap();
    private int curFrame = 0, pausedFor = 0;
    private boolean isFiring = false;
   private boolean runOnce = false;
   private boolean runOnce2 = false;
   private boolean runOnce3 = false;

    protected void setFramesPerSecond(float fps)
    {
        timeBetweenFrames = 1.0f / fps;
    }

    protected void pauseOnFrame(int frame, int pauseFor)
    {
        pauseFrames.put(frame, pauseFor);
    }


    private void incFrame(AnimationAPI anim)
    {
   
        if (pauseFrames.containsKey(curFrame))
        {
            if (pausedFor < (Integer) pauseFrames.get(curFrame))
            {
                pausedFor++;
                return;
            }
            else
            {
                pausedFor = 0;
            }
        }

        curFrame = Math.min(curFrame + 1, anim.getNumFrames() - 1);
    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){ 
            if (weapon.getShip().getOwner() == -1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()   ){ 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
            runOnce = true; 
        }
        AnimationAPI anim = weapon.getAnimation();
        anim.setFrame(curFrame);

        if (isFiring)
        {
            timeSinceLastFrame += amount;

            if (timeSinceLastFrame >= timeBetweenFrames)
            {
                timeSinceLastFrame = 0f;
               
                anim.setFrame(curFrame);
                    if(runOnce2 == false){ 
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()   
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){ 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
           
        } 
             incFrame(anim);

                if (curFrame == anim.getNumFrames() - 1)
                {
                    isFiring = false;
               runOnce2 = true; 
                }
            }
        }
        else
        {
            if (weapon.isFiring() && weapon.getChargeLevel() == 1.0f)
            {
                isFiring = true;
                incFrame(anim);
                anim.setFrame(curFrame);
            }
            else
            {
                curFrame = 0;
                anim.setFrame(curFrame);
                    if(runOnce3 == false){ 
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()   
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX())
            { 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
            runOnce3 = true; 
        }
            }
        }
    }
}
[close]
« Last Edit: April 26, 2017, 12:05:40 PM by Tecrys »
Logged
Symbiotic Void Creatures 0.5.0-alpha for 0.97a is out
https://fractalsoftworks.com/forum/index.php?topic=28010.0

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3183 on: April 26, 2017, 12:34:47 PM »

I'm not sure but you might need
Code
.getOriginalOwner()
rather than just
Code
.getOwner()
Logged
 

Tecrys

  • Admiral
  • *****
  • Posts: 595
  • repair that space elevator!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3184 on: April 26, 2017, 01:24:24 PM »

Ha! You're a genius!

Funny thing about the refit screen: the whole X/Y coordinate system is rotated by 90° clockwise, I had to change the code to this:
Spoiler
if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){  
            if (weapon.getShip().getOriginalOwner() == -1 && weapon.getLocation().getY() > weapon.getShip().getLocation().getY()   ){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce = true;  
        }
[close]

See, I had to change getX to getY or it would allways mirror both weapons, not just the one that was supposed to be mirrored

Here the whole script for anybody interrested in mirroring weapons, they're firing animation and they're location in the refit screen:
Spoiler
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;
import com.fs.starfarer.api.graphics.SpriteAPI;
import java.util.*;

public class BaseAnimateOnFireEffect2 implements EveryFrameWeaponEffectPlugin
{
    // Default to 15 frames per second
    private float timeSinceLastFrame, timeBetweenFrames = 1.0f / 140f;
    private Map pauseFrames = new HashMap();
    private int curFrame = 0, pausedFor = 0;
    private boolean isFiring = false;
   private boolean runOnce = false;
   private boolean runOnce2 = false;
   private boolean runOnce3 = false;

    protected void setFramesPerSecond(float fps)
    {
        timeBetweenFrames = 1.0f / fps;
    }

    protected void pauseOnFrame(int frame, int pauseFor)
    {
        pauseFrames.put(frame, pauseFor);
    }


    private void incFrame(AnimationAPI anim)
    {
   
        if (pauseFrames.containsKey(curFrame))
        {
            if (pausedFor < (Integer) pauseFrames.get(curFrame))
            {
                pausedFor++;
                return;
            }
            else
            {
                pausedFor = 0;
            }
        }

        curFrame = Math.min(curFrame + 1, anim.getNumFrames() - 1);
    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){  
            if (weapon.getShip().getOriginalOwner() == -1 && weapon.getLocation().getY() > weapon.getShip().getLocation().getY()   ){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce = true;  
        }
        AnimationAPI anim = weapon.getAnimation();
        anim.setFrame(curFrame);

        if (isFiring)
        {
            timeSinceLastFrame += amount;

            if (timeSinceLastFrame >= timeBetweenFrames)
            {
                timeSinceLastFrame = 0f;
                
                anim.setFrame(curFrame);
                    if(runOnce2 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            
        }  
             incFrame(anim);

                if (curFrame == anim.getNumFrames() - 1)
                {
                    isFiring = false;
               runOnce2 = true;  
                }
            }
        }
        else
        {
            if (weapon.isFiring() && weapon.getChargeLevel() == 1.0f)
            {
                isFiring = true;
                incFrame(anim);
                anim.setFrame(curFrame);
            }
            else
            {
                curFrame = 0;
                anim.setFrame(curFrame);
                    if(runOnce3 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX())
            {  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce3 = true;  
        }
            }
        }
    }
}
[close]

Next problem: script that is supposed to disble the hit ship's shields for a set amount of time doesn't work, no errors simply no effect at all:
Spoiler
Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShieldAPI.ShieldType;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class DissableShieldOnHitEffect implements OnHitEffectPlugin {
    // This is how we store which ships have dissabled shields and how much
    //  longer they'll be dissabled.
    //
    // Key - ShipAPI (the affected ship)
    // Value - float (the remaining duration of shield dissable-ization)
    static Map affectedShips = new HashMap();

    static final float DISSABLE_TIME_PER_HIT = 10f; // In seconds

    @Override
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
        if (!(target instanceof ShipAPI)) return;

        ShipAPI ship = (ShipAPI)target;

        if(!ship.isAlive() || ship.getShield() == null) return;

        if(affectedShips.containsKey(ship)) {
            affectedShips.put(ship, (Float)affectedShips.get(ship) + DISSABLE_TIME_PER_HIT);
        } else {
            affectedShips.put(ship, DISSABLE_TIME_PER_HIT);
        }
}

// This is called once each frame by the ForceShieldDissablePlugin
    public static void forceDissableShields(float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();

        if(engine.isPaused()) return;

        for(Iterator iter = affectedShips.keySet().iterator(); iter.hasNext();) {
            ShipAPI ship = (ShipAPI)iter.next();
            float remainingTime = (Float)affectedShips.get(ship) - amount;

            if(remainingTime < 0) {
                // This removes the current ship from affectedShips
                iter.remove();
            } else {
                affectedShips.put(ship, remainingTime);
                ship.getShield.setActiveArc(0);
            }
        }
    }
}
[close]
« Last Edit: April 26, 2017, 02:42:01 PM by Tecrys »
Logged
Symbiotic Void Creatures 0.5.0-alpha for 0.97a is out
https://fractalsoftworks.com/forum/index.php?topic=28010.0

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3185 on: April 26, 2017, 07:25:38 PM »

Where would one find Fighter wing specs? I'm trying to make a mod for my own use and it keeps throwing this error at me.

Code
7412 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Fighter wing spec [ADF_Interceptor_wing] not found
java.lang.RuntimeException: Fighter wing spec [ADF_Interceptor_wing] not found
at com.fs.starfarer.loading.O0oO.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.U$Oo.<init>(Unknown Source)
at com.fs.starfarer.loading.U.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
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$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3186 on: April 26, 2017, 07:30:16 PM »

Where would one find Fighter wing specs?

In the same place they used to be, "wing_data.csv". The problem is they now have a bunch of new stats which you'll need to add. Check the stock game files for reference.

Also, don't forget that ships also now have a "fighter bays" value which is specified in "ship_data.csv", as well as the launch bays in the "___.ship" file.
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3187 on: April 26, 2017, 07:34:35 PM »

Where would one find Fighter wing specs?

In the same place they used to be, "wing_data.csv". The problem is they now have a bunch of new stats which you'll need to add. Check the stock game files for reference.

Also, don't forget that ships also now have a "fighter bays" value which is specified in "ship_data.csv", as well as the launch bays in the "___.ship" file.
I know that much, i have everything marked where it's supposed to be, it's just throwing out that error.
Could it be because i've got the fighters listed in the .faction file? It worked perfectly fine before
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3188 on: April 26, 2017, 07:36:59 PM »

I know that much, i have everything marked where it's supposed to be, it's just throwing out that error.
Could it be because i've got the fighters listed in the .faction file? It worked perfectly fine before

Ah, yeah that could cause problems. Try removing those and see what happens.

The other option is that you've got a minor spelling or syntax error somewhere that's causing the thing to throw a tantrum.
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3189 on: April 26, 2017, 07:38:53 PM »


Ah, yeah that could cause problems. Try removing those and see what happens.

The other option is that you've got a minor spelling or syntax error somewhere that's causing the thing to throw a tantrum.
Spelling isn't an issue, i've checked that about 600 times by now, I'll try the fighter wings thing.
Will have to remember to add them to the carrier's variants file.
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3190 on: April 26, 2017, 07:40:19 PM »

Strange. If that doesn't work, do you mind if I take a look? Do you have some way to upload a version of the mod?
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3191 on: April 26, 2017, 07:51:56 PM »

Strange. If that doesn't work, do you mind if I take a look? Do you have some way to upload a version of the mod?
Well it's not giving me that error anymore, now it's asking for a , or a } in a line that doesn't need one of those.
I can drop box it if you want me to
Edit: Am Dumb, nevermind
« Last Edit: April 26, 2017, 08:00:45 PM by Tufted Titmouse »
Logged

Calodine

  • Lieutenant
  • **
  • Posts: 50
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3192 on: April 26, 2017, 08:16:19 PM »

Made a ship. No problem, works fine. Custom system, less so.

It's a very slightly modified temporal shell - I've only changed two lines in the actual script, most of it is in the csv.

But it's crashing, and given I downloaded the IDE tonight, I can't figure out why.

Code
19311 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: shipsystems.TemporalRipperStats
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I've got starfarer.api set as a library, and BaseShipSystemScript over too, since temporalshell extends it. I can't figure out what the problem is - searching for it got me an old post from shaderlib, but that's about it.
My best guess is I'm missing some dependency somewhere?
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3193 on: April 26, 2017, 08:18:43 PM »

Spoiler
Made a ship. No problem, works fine. Custom system, less so.

It's a very slightly modified temporal shell - I've only changed two lines in the actual script, most of it is in the csv.

But it's crashing, and given I downloaded the IDE tonight, I can't figure out why.

Code
19311 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: shipsystems.TemporalRipperStats
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I've got starfarer.api set as a library, and BaseShipSystemScript over too, since temporalshell extends it. I can't figure out what the problem is - searching for it got me an old post from shaderlib, but that's about it.
My best guess is I'm missing some dependency somewhere?
[close]
Do you have the latest version Lazylib?
Logged

Calodine

  • Lieutenant
  • **
  • Posts: 50
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3194 on: April 26, 2017, 08:20:35 PM »

Yeah - but this isn't touching that, just base starsector stuff.
Logged
Pages: 1 ... 211 212 [213] 214 215 ... 710