Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Skills and Story Points (07/08/19)

Pages: 1 ... 211 212 [213] 214 215 ... 361

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

Drokkath

  • Captain
  • ****
  • Posts: 281
  • Xenophilic Mutant Commando
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3180 on: April 26, 2017, 06:32:45 AM »

Well, at least I tried to understand it and get it working, though in vain. As far as coding goes, I am just too impatient for that and the more I fail the more I get furious to a point of doing irrational actions and outcomes.

Increasing the OP points for all ships already did the alternate easy-route trick I needed.
« Last Edit: April 26, 2017, 06:39:23 AM by Drokkath »
Logged
For I dipt in to the future, far as my gazer eye could see; Saw the vision of the world, and all the wonder that would be.

coyote.j.p.m

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3181 on: April 26, 2017, 08:15:23 AM »

So has anyone been able to figure out what determines salvageable ship spawning (as in, which ships can be derelicts to potentially recover)? Do they only spawn as a result of battles or is there some plugin spawning them at random as well? I see in salvage_entity_gen_data.csv there's an entry for "wreck" but I'm not sure if that's the right thing or how it's used anyway.
Logged

coyote.j.p.m

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3182 on: April 26, 2017, 08:40:34 AM »

Ah, I think I figured it out actually. It's in the NearbyEventsEvent class, there's a chance every so often to spawn a derelict ship, which is a random variant of a random faction within 15LY (weighted based on faction-owned market size, where Pirates and Independents always get an extra size 5 market for the picker). So to increase the probability of random ship from my modded factions showing up, i just need more (and bigger) markets...
Logged

Tecrys

  • Captain
  • ****
  • Posts: 478
  • Creator of Biomancy Genetic Engineering
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3183 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
Bringing biological warfare to Stasector since 2014.
Let's say I'm the cave man type of a modder, I put the square through the triangle in kindergarten and even succeed.
Such a stupid thing to quote myself, oh well

Tartiflette

  • Admiral
  • *****
  • Posts: 2751
  • Kickstarter is NOT a magic spring of free money!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3184 on: April 26, 2017, 10:53:57 AM »

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

Tecrys

  • Captain
  • ****
  • Posts: 478
  • Creator of Biomancy Genetic Engineering
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3185 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
Bringing biological warfare to Stasector since 2014.
Let's say I'm the cave man type of a modder, I put the square through the triangle in kindergarten and even succeed.
Such a stupid thing to quote myself, oh well

Tartiflette

  • Admiral
  • *****
  • Posts: 2751
  • Kickstarter is NOT a magic spring of free money!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3186 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

  • Captain
  • ****
  • Posts: 478
  • Creator of Biomancy Genetic Engineering
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3187 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
Bringing biological warfare to Stasector since 2014.
Let's say I'm the cave man type of a modder, I put the square through the triangle in kindergarten and even succeed.
Such a stupid thing to quote myself, oh well

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 65
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3188 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: 1456
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3189 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: 65
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3190 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: 1456
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3191 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: 65
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3192 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: 1456
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3193 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: 65
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3194 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
Pages: 1 ... 211 212 [213] 214 215 ... 361