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 ... 27 28 [29] 30 31 ... 706

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

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #420 on: April 15, 2013, 05:18:05 AM »

not sure how the weapon.getId() works

does it return the id, display name, or something else?

so for example, if I get a mining blaster to call that, what's the return gonna be?

The number id on the CSV weapon_data, as a String
Logged

Vinya

  • Captain
  • ****
  • Posts: 379
  • Vulgar at best...
    • View Profile
    • Mykyria Scifi/Zombie writing blog (Old site)
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #421 on: April 15, 2013, 10:36:21 AM »

So I'm working on a system or two for custom ships, not sure how to go about it though.

Essentially the system just allows PD Lasers all over the ship to actually fire while locking other weapon systems.

If possible, the PD matrix should be able to replace shields like phase-tech, but if not it should disable shields.

The other system is an ECM Jamming system that while turned on, any missiles locked onto the ship will lose tracking, and any missiles fired at the ship will lose tracking. Possible by using invisible flares?

Logged
If by "good guys" you mean "elitist regime that suppresses colonial independence and thrives off of an overwhelmingly deep gap in wealth between social classes," then yes.

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #422 on: April 15, 2013, 10:51:10 AM »

So I'm working on a system or two for custom ships, not sure how to go about it though.

Essentially the system just allows PD Lasers all over the ship to actually fire while locking other weapon systems.

If possible, the PD matrix should be able to replace shields like phase-tech, but if not it should disable shields.

The other system is an ECM Jamming system that while turned on, any missiles locked onto the ship will lose tracking, and any missiles fired at the ship will lose tracking. Possible by using invisible flares?



considering some of the ship systems cycerin got into his mod (the nevermore and the kurmaraja especially) i'd say that you just need to find a talented coder to get all those awesome ideas working perfectly
Logged

PCCL

  • Admiral
  • *****
  • Posts: 2016
  • still gunnyfreak
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #423 on: April 15, 2013, 09:02:14 PM »

is there a way of hiding decorative weapons from the grouping bug? Or are we just waiting on a fix at this point?
Logged
mmm.... tartiflette

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #424 on: April 19, 2013, 11:55:33 AM »

Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #425 on: April 19, 2013, 11:57:56 AM »

is there a way of hiding decorative weapons from the grouping bug? Or are we just waiting on a fix at this point?

Waiting for a fix.

Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #426 on: April 19, 2013, 12:03:17 PM »


Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.

Well, maybe if the ships hp are about to reach 0 or lower then 0, trying to find a way to replicate the Fury http://wiki.uqm.stack.nl/Fury special ability
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1363
    • View Profile
    • GitHub Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #427 on: April 19, 2013, 01:43:06 PM »


Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.

Well, maybe if the ships hp are about to reach 0 or lower then 0, trying to find a way to replicate the Fury http://wiki.uqm.stack.nl/Fury special ability

You could try spawning the same ship again, something like the following:
Code
        engine.getFleetManager((ship.getOwner() == 0 ? FleetSide.PLAYER : FleetSide.ENEMY))
                .spawnShipOrWing(ship.getHullSpec().getHullId(),
                ship.getLocation(), ship.getFacing());
        engine.removeEntity(ship);

You would probably want to change ship.getHullSpec().getHullId() to the variant name. I don't think there's a way to get the variant ID through the API yet, so it would have to be hardcoded (you could use ship.getVariant().getDisplayName() to select between the various default variants).

You'd lose anything customized on the old ship - name, hullmods, vents/caps, etc. I've never used spawnShipOrWing before so I don't know if the ship is added to your fleet, so it's possible you'd lose the ship after the battle anyway.

All in all, not a great solution outside of missions, but it's the best I can see as possible right now. :(
« Last Edit: April 19, 2013, 01:44:56 PM by LazyWizard »
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1363
    • View Profile
    • GitHub Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #428 on: April 19, 2013, 01:51:57 PM »

Slightly better solution (not tested):

Code
    public static String getVariantId(ShipAPI ship)
    {
        CampaignFleetAPI tmpFleet;
        FleetMemberAPI tmpShip;
        for (Iterator fleets = ((StarSystemAPI) Global.getSector().getStarSystems().get(0))
                .getFleets().iterator(); fleets.hasNext();)
        {
            tmpFleet = (CampaignFleetAPI) fleets.next();
            for (Iterator ships = tmpFleet.getFleetData().getMembersListCopy().iterator(); ships.hasNext();)
            {
                tmpShip = (FleetMemberAPI) ships.next();
                if (tmpShip.getId().equals(ship.getFleetMemberId()))
                {
                    return tmpShip.getSpecId();
                }
            }
        }

        return ship.getHullSpec().getHullId();
    }

    public static void revive(ShipAPI ship, CombatEngineAPI engine)
    {
        engine.getFleetManager((ship.getOwner() == 0 ? FleetSide.PLAYER : FleetSide.ENEMY))
                .spawnShipOrWing(getVariantId(ship), ship.getLocation(), ship.getFacing());
        engine.removeEntity(ship);
    }
« Last Edit: April 19, 2013, 01:58:57 PM by LazyWizard »
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #429 on: April 19, 2013, 04:09:16 PM »

Hey guys I have a weird report for my mod and I'm not sure what it may be related to, any clue?

Spoiler
51418 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ArrayIndexOutOfBoundsException: 2
java.lang.ArrayIndexOutOfBoundsException: 2
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.OÒ0000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.super(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetView.private.String(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleet.render(Unknown Source)
   at com.fs.starfarer.campaign.BaseCampaignEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.Õ00000(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.render(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.render(Unknown Source)
   at com.fs.starfarer.campaign.A.Óô0000(Unknown Source)
   at com.fs.starfarer.A.ÖÖÒ000(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #430 on: April 21, 2013, 09:42:41 AM »

Alright so, for those who dont know, ive been working on a mod for SC2, that means, creating a few mechanics that arent present in the vanilla.
Right now im stuck with a weapon i cant manage to work, know as the Variable power blaster.
More info: http://wiki.uqm.stack.nl/Trader

So how does it work?
It spawns a projectile infront of the ship, that projectile can be used as a shield and its consumed if used like that, but, the more time you charge the weapon, the stronger that projectile gets. The weapon has 4 stages, a green one that does 2000 dmg, next comes the blue does 4000 dmg, then the purple/magenta, does 8000 damage and last comes the red one doing 16000 damage. While the projectile with stay still as long as you keep "firing", meaning holding the LMB, when you release, it will release the projectile that was currently created. While i cant make the weapon permanently chargeable, ive been trying to at list do the projectile animation infront of the ship and once you released the charge it would reset the animation and would spawn the projectile for the current charge level.
So far the weapon plugin i worked on with Lazy's help has ignored every condition i/he set to avoid spawning projectiles with 0 cd.
Heres the code ive changed and got in so far:

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements EveryFrameWeaponEffectPlugin
{  
    // weapon takes 7 seconds to fully charge
    private int currentCharge = 0;
    private float currentChargelvl = 0;

public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
        {
            ShipAPI ship = weapon.getShip();
            if (ship == null)
            {
                return;
            }
            currentChargelvl = weapon.getChargeLevel();
            AnimationAPI animation = weapon.getAnimation();
            
            if (weapon.isFiring())
            {
                ship.getMutableStats().getFluxDissipation().modifyFlat(ship.getHullSpec().getHullId().toString(), 0); //while chargins the dissipation should be set to 0
                
                if (currentChargelvl <= 0.33f)
                {
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                    if(currentCharge == 0)
                    {
                        engine.addFloatingText(ship.getLocation(), "Power Level 1",25f,Color.GREEN,weapon.getShip(),0f,0f);
                        currentCharge = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if(animation.getFrame() == 5)
                    {
                        animation.setFrame(1);
                        animation.play();
                    }
                }
                
                if (currentChargelvl <= 0.66f && currentChargelvl > 0.33f)
                {
                    if(currentCharge == 1)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",25f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge = 2;
                        animation.setFrame(6);
                        animation.play();
                    }

                    if(animation.getFrame() == 10)
                    {
                        animation.setFrame(6);
                        animation.play();
                    }
                }
                
                if (currentChargelvl <= 0.99f && currentChargelvl > 0.66f)
                {
                    if(currentCharge == 2)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge = 3;
                        animation.setFrame(11);
                        animation.play();
                    }
                    
                    if(animation.getFrame() == 15)
                    {
                        animation.setFrame(11);
                        animation.play();
                    }
                }
                
                if(currentChargelvl > 0.99f)
                {
                    if(currentCharge == 3)
                    {
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",25f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge = 4;
                        animation.setFrame(16);
                        animation.play();
                    }

                    if(animation.getFrame() == 20)
                    {
                        animation.setFrame(16);
                        animation.play();
                    }
                }
            }  
            else
            {
                switch (currentCharge)
                {
                    case 1:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    case 2:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    case 3:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    default:
                    // Whatever happens if it isn't charged
                }
                ship.getMutableStats().getFluxDissipation().unmodify();
                currentCharge = 0;
            }
            
    }//advance
}  

With the code atm, will spawn the lvl 1 projectile without charging anything.

heres a video: http://www.youtube.com/watch?v=FEYfYxM7iVA
« Last Edit: April 21, 2013, 09:49:31 AM by silentstormpt »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #431 on: April 22, 2013, 10:13:36 AM »

Hmm. I don't think you're using the AnimationAPI correctly. play() will loop the animation, so relying on code like this:
if(animation.getFrame() == 15)
{
    animation.setFrame(11);
    animation.play();
}
Is a mistake because you're not guaranteed to actually stop on that frame. It might get missed due to a frame rate hiccup. If the animation is slow enough (<30fps), I suppose it might work, since the engine won't go below that (but will slow time instead)... but still, a bit iffy.

So, if you're going to use setFrame(), you should go all the way and use it to drive the whole animation rather than using play().


Beyond that, I don't see anything glaringly wrong, though it was a rather quick look. I'd suggest adding some messages to the log to help figure out what's going on here (or running with an IDE and hooking a debugger up to the JVM, so you can actually use breakpoints, but that's more involved.)

For logging:
Logger log = Logger.getLogger(this.getClass());
log.info("whatever string you want to print");


Opening up the log file with a text editor capable of updating it on the fly would be helpful if you do that, too. Or using something like "tail" on it (which you could do if you installed cygwin, if you're running Windows).
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #432 on: April 23, 2013, 01:13:37 PM »

no luck so far, would using IntervalUtil help? Also i do not know exactly how it works, if its a interval from X to X
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1363
    • View Profile
    • GitHub Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #433 on: April 23, 2013, 01:32:34 PM »

no luck so far, would using IntervalUtil help? Also i do not know exactly how it works, if its a interval from X to X

It's basically a repeating timer where you can have different intervals each iteration.

The values you pass in are the minimum and maximum intervals. It picks a random number in the range between them as its 'target' (you can just pass in the same number for both for a normal timer behavior). You need to call advance(<amount to advance>) for the IntervalUtil to work; usually you will use the time since the last frame as the amount argument. You can then check intervalElapsed() to see if it hit its target. You need to check intervalElapsed() after each advance(), because it will only return true for one frame. The next frame after time is up, a new random interval in the range you gave is chosen, and the process starts over.

You can change the interval ranges at any time with setInterval(min, max).

IntervalUtil is in the API, by the way, so you can view the source in starfarer.api.zip.
« Last Edit: April 23, 2013, 03:12:08 PM by LazyWizard »
Logged

Thule

  • Admiral
  • *****
  • Posts: 580
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #434 on: April 23, 2013, 04:59:22 PM »

hi there,

i am trying to set up a decorative weapon.
i get an error message i can't figure out. It's looking for filenames that arent specified anywhere. Is there a certain file suffix neccesary`?

Code
java.lang.RuntimeException: Error loading [graphics/TL/weapons/decor/thule_heimdahl_0059_Frame-1.png01.png] resource, not found in [D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\LazyLib,D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\StealThisStuff,D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Thule Legacy,../starfarer.res/res,CLASSPATH]
at com.fs.util.C.Ò00000(Unknown Source)
at com.fs.util.C.Object(Unknown Source)
at com.fs.graphics.K.String(Unknown Source)
at com.fs.graphics.K.Ò00000(Unknown Source)
at com.fs.graphics.K$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Logged

Pages: 1 ... 27 28 [29] 30 31 ... 706