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 ... 31 32 [33] 34 35 ... 706

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

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #480 on: April 29, 2013, 11:45:21 PM »

D they have a shield generator on their ship?
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #481 on: April 30, 2013, 02:36:29 AM »

Yeah I did put it in.....
unless.... I removed it by accident when I was re-workign all the stats. Now I'll have to check.
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #482 on: April 30, 2013, 04:36:12 AM »

It's Happened to me loads of times man dw about it
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #483 on: April 30, 2013, 08:26:52 AM »

I need to somehow make a projectile move as long as you keep "firing" the weapon, once it stops (!weapon.IsFiring()) the projectile will fade/despawn and spawn several projectiles clockwise (in this case 6 so its 60,120,180,240,300 and 360) around it with a high velocity.

if i do manage to get the first part running ill be able to replicate the Marauder Spin-blade and the Broodhome Crystal Shard

I'd suggest a beam weapon that fires a short-range, invisible, 0-damage, minimal charge up/down time beam, just so that isFiring() behaves the way you'd want it to here. Then you could handle all projectile spawning exclusively via scripts, similarly to how the Tachyon Lance handles adding the EMP arc effect.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #484 on: April 30, 2013, 12:44:32 PM »

WEll, I checked hte shadow order mod and I followed hte logical steps..still n oworky...

What I did:


Added this to the hullmods folder:

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

import java.util.HashMap;
import java.util.Map;

public class InfusedHull extends BaseHullMod {

public static final float REPAIR_FRACTION = 1f;
public static final float REPAIR_BONUS = .99f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 3f);
mag.put(HullSize.FRIGATE, 1f);
mag.put(HullSize.DESTROYER, .75f);
mag.put(HullSize.CRUISER, .5f);
mag.put(HullSize.CAPITAL_SHIP, .25f);
}

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (Float) mag.get(hullSize));
stats.getMaxHullRepairFraction().unmodify(id);
stats.getMaxHullRepairFraction().modifyFlat(id, REPAIR_FRACTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "1";// + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return ".75";// + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return ".5";// + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return ".25";// + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}
}



Added this line to hullmods.csv

"Nano-Infused Hull","infusedhull",,0,0,0,0,"data.hullmods.InfusedHull","Repairs %s/%s/%s/%s percent of the ships hull per second."



And this is how my fighter variant looks:
Code
{
"displayName":"Advanced Fighter",
"hullId":"PhnH",
"hullMods": [infusedhull]
"variantId":"PhnH_standard",
"fluxVents":0,
"fluxCapacitors":0,
"mods":[], # array of strings

# mode is either LINKED or ALTERNATING
# slot ids (WS ***) must match what's in the .ship file
"weaponGroups":[
{"mode":"LINKED",
"weapons":{
"WS01":"20mm_rc",
"WS02":"20mm_rc",
   },
},

{"mode":"LINKED",
"weapons":{
"WS03":"stingerx2",
   },
},
],
}
Logged

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #485 on: May 01, 2013, 03:14:38 PM »

Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.
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 #486 on: May 01, 2013, 05:46:35 PM »

Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.

They won't deal damage when they explode (it's basically the same as if they got shot down), but here's a very simple plugin that should do what you asked:

data/scripts/plugins/MissilesExplodeOnFizzlePlugin.java:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling())
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}

If you want a version that does cause damage to nearby targets when a missile explodes, I can make that for you but it would be far more complicated.
Logged

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #487 on: May 01, 2013, 07:28:28 PM »

Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.

They won't deal damage when they explode (it's basically the same as if they got shot down), but here's a very simple plugin that should do what you asked:

data/scripts/plugins/MissilesExplodeOnFizzlePlugin.java:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling())
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}

If you want a version that does cause damage to nearby targets when a missile explodes, I can make that for you but it would be far more complicated.

Now here's the thing, how would I implement that? Will I have to designate it per missile? Or would it do that for every missile fired? I'm not a programmer by any means.

Also, while the extra damage would be nice, I can make due without it, as the exploding missiles in question are actually used to eat projectiles.

And thanks for your help and time, I honestly do appreciate it.
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 #488 on: May 01, 2013, 07:49:26 PM »

All you would need to do is place the code in a file named MissilesExplodeOnFizzlePlugin.java in data/scripts/plugins, as Starsector automatically loads any plugin placed in that folder.

It should work for all missiles fired, even vanilla. If you want it to only work for certain missiles, that would be an easy change:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static final Set MISSILES_TO_EXPLODE = new HashSet();
    private static CombatEngineAPI engine;

    static
    {
        // Add the projectile IDs of all missiles that should explode here
        // Example: MISSILES_TO_EXPLODE.add("annihilator_rocket");
        MISSILES_TO_EXPLODE.add("proj id goes here");
        MISSILES_TO_EXPLODE.add("any other missiles go in their own line like this");
    }

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling() && MISSILES_TO_EXPLODE.contains(missile.getProjectileSpecId()))
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #489 on: May 02, 2013, 04:41:35 AM »

Silly question:do comments (// texthere ) in .ship and .variant files work?


I would really help with turret groups, especially since I'm working with similar ships with different weapon setups
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 #490 on: May 02, 2013, 04:50:50 AM »

Silly question:do comments (// texthere ) in .ship and .variant files work?


I would really help with turret groups, especially since I'm working with similar ships with different weapon setups

Yes, except you use # instead of //.
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #491 on: May 02, 2013, 07:58:58 AM »

Oh thanks for the missile script lazy, i had something very close to what u got here for the podship plasmoid, i didnt know about the .isFizzling() existing so i based of with a timer.

Heres an example if you want to "despawn" the old missile and spawn a new one in its place:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class PodshipHomingPlasmoid implements EveryFrameCombatPlugin
{

    private String SHELL_ID_1 = "podship_plasmoid";
    private String SHELL_ID_2 = "podship_plasmoid_2";
    private String SHELL_ID_3 = "podship_plasmoid_3";
    private String SHELL_ID_4 = "podship_plasmoid_4";
    private CombatEngineAPI engine;
    
    public void init(CombatEngineAPI engine) {
        this.engine = engine;
    }
    
    public void advance(float amount, List events)
    {
        if (engine.isPaused()) {
            return;
        }    

        for (Iterator allMissiles = engine.getMissiles().iterator();
                allMissiles.hasNext();)
        {
            MissileAPI plasmoid = (MissileAPI) allMissiles.next();
                
            if(plasmoid.isFizzling())
            {
                if(SHELL_ID_1.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_2, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_2.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_3, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_3.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_4, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else {
                    return;
                }
            }  
        }
    }//advance
}//class
« Last Edit: May 02, 2013, 01:14:08 PM by silentstormpt »
Logged

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #492 on: May 02, 2013, 01:04:19 PM »

Lazy you're a gentleman and a scholar. Thank you soo much for your help!
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 #493 on: May 02, 2013, 01:19:10 PM »

No problem, glad to help. :)
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #494 on: May 02, 2013, 02:12:43 PM »

I'm experiencing the wierdest bug ever.

I made my own faction, addied it to the game (using Ironclad mod) and it's ships (3 fighters, 1 frigate, 2 de's, 1 battleship)

Thing is, the 2 DE's down show up graphics-wise. They are in the System Defene Fleet, but they are invisible. The other ship show up normally.

I checked, double-checked and tripple-checked everything. Cant' find anything wrong or off. When I load the ship file in the editor, it opens the ship image normally.
Logged
Pages: 1 ... 31 32 [33] 34 35 ... 706