Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: [1] 2 3

Author Topic: Stargate Mod  (Read 15277 times)

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Stargate Mod
« on: February 28, 2015, 08:58:24 AM »

Stargatesector.

Made by Joe 'joe130794' Frearson   and  'Doci'

We are collaborating on a Stargate mod using sprites from both of our mods that we are working on. I hope to eventually have a total conversion so that no vanilla ships are left in game and will try to add new features too including replacing the flux bar with a depleting shield bar. If anyone can help with that we would be very grateful.

Ships so far:
X-303
BC-304
F-302 ship system.
Wraith Cruiser
Wraith Hive
Wraith Dart ship system
Replicator ship.
Ori Mothership
Ancient Cruiser
Ancient Aurora Class Battleship
Drone Command Ship
Destiny

To do:
Traveller ship
Ursini Ship
Goa'uld ships
Asgard Ships
Nakai Ships
Maybe City Ship
Drones
Shield bar
Make it a total conversion

No download link just yet.

Short Gameplay video
https://www.youtube.com/watch?v=6xtLy4IN9_U&feature=youtu.be

[attachment deleted by admin]
« Last Edit: November 01, 2015, 01:59:03 PM by joe130794 »
Logged

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Stargate Mod
« Reply #1 on: March 01, 2015, 11:27:57 AM »

My sprited Daedalus. Could use some improvement.

[attachment deleted by admin]
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #2 on: March 01, 2015, 12:43:29 PM »

I have started working on a Stargate mod using some of my own sprites so far but don't have any pictures of the game play yet.
I just had a few questions since I'm new to modding.

1) Is it possible to make a missile penetrate a ship more than once? So I can get realistic Drone Weapons.

2) I have made it so far in a way that the ships weapons do not cause any flux at all and that the ships lose flux slowly to realistically have a representation of shields how they could be slowly depleted or in this case will slowly lose flux so that they can be used again.

3) I'm making most of the ships on a 1:1 scale so 1 metre is 1 pixel to try and minimize lag and to try have it so there can be large scale battles, I have tried to make my own f-302 fighters but haven't had any luck putting them into the game so I planned to use them as a ship system instead but I have no idea how to make this so any help is appreciated. I'm going to add darts as well and will need them to attempt to intercept the BC-304 and X-303 missiles. Otherwise it will be a very short battle with Wraith ships.

4) Also is it possible to make a system that would allow Wraith ships to slowly repair themselves in a similar manor to them being able to heal any light damage in battle.

Thanks in advance.

1) Yes. See my Diable Avionics penetration scripts, recently posted in the Misc. Modding questions
4) Yes. A few mods do this already. Vacuum used to do it, I think ICE has a ship system that does it. Yeah, there are a number of mods that do it already, wouldn't be surprised if you find something in the radioactive code dump with that.
Logged

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Stargate Mod
« Reply #3 on: March 01, 2015, 01:32:14 PM »

Thanks. I'll have a look and see what I can find.
Logged

LB

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Stargate Mod
« Reply #4 on: March 01, 2015, 07:43:12 PM »

2. You're probably better off just reversing the bar and having low flux = high energy in consideration for the AI. If you want something like depleting shields you can make shields cost hard flux, which would be easy.

3. Take a look at the vanilla ship system code for e.g. the Tempest and replace the drone with your fighters.

Off topic, but Debido, why is the code for rotating the penetration plume with the hit ship commented out? Too intensive? Doesn't work properly? It would be super cool.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #5 on: March 01, 2015, 11:56:06 PM »

On the topic of the rotating plume? Not sure? Been a while since I looked at the code, heck the code is for the 0.62 that I have on my machine. I might have been messing with the local diable code for something else related to another project. Whatever code is in the current diable is the final one from that aspect.

On another note, here is a more updated code from something else I was doing
OnHit
Spoiler
Code: java
/*Armour Penetration / Shield Ricochet script by Xangle13, updated by Debido
 * This script allows a missile/projectile to simulate certain behaviors
 * 1. Successfully hitting projectiles will pass through and exit the opposite side of a ship if the armour is low enough
 * 2. The projectile will bounce off the enemies shield if it hits at an oblique enough angle
 */

/*
 This is the instant pass through variant, projectile(s) will only 'pass through' if the exit side has armour that is compromised.
 Dev version, includes pop up text.
 */
package uaf.data.scripts.weapons;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
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.WeaponAPI;
import java.awt.Color;
import java.util.List;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.DefenseUtils;
import org.lwjgl.util.vector.Vector2f;

public class APOnHit implements OnHitEffectPlugin {

    private static final boolean dealsSoftFlux = false;

    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
        float ENTER_FACTOR = 0.1f;
        float EXIT_FACTOR = 0.2f;
        //if the target is a ship, that is to say it will not work on asteroids
        if (target instanceof ShipAPI) {
            ShipAPI sourceShip = projectile.getSource();

            //check the source ship is not a null entity
            if (sourceShip != null) {

                //get the weapon that fired the projectile
                WeaponAPI weaponFrom = projectile.getWeapon();

                //if the weapon that fired the projectile is not null
                if (weaponFrom != null) {

                    //get the projectile location and velocity. Location currently not used
                    Vector2f projectileVelocity = projectile.getVelocity();
                    //get the angle at which the projectile is hitting the ship
                    float fromAngle = projectile.getFacing();
                    //get the damage amount
                    float damageAmount = projectile.getDamageAmount();

                    //get the emp amount
                    float empAmount = projectile.getEmpAmount();

                    //get the damage type
                    DamageType damageType = projectile.getDamageType();

                    if (shieldHit) {

                        //engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 0.25 + 0.25), damageType, empAmount, false, false, null);
                    } else {
                        boolean reinforced = false;
                        List<String> hullmods = ((ShipAPI) target).getVariant().getHullMods();
                        for (String mod : hullmods) {
                            if (mod.contains("reinforcedhull")) {
                                reinforced = true;
                                return;
                            }
                        }
                        // get the targets armor grid
                        ArmorGridAPI targetArmorGrid = ((ShipAPI) target).getArmorGrid();

                        //get the armor rating
                        float targetArmorRating = targetArmorGrid.getArmorRating();

                        //get the armor level of the cell where the projectile is hitting
                        float targetArmorLevel = DefenseUtils.getArmorLevel((ShipAPI) target, point) * (targetArmorRating / 15);

                        //calculate the penetration value against the current armor level at the hit point using 0.1f as a fudge factor.
                        float penetrateValue = (damageAmount * ENTER_FACTOR) - targetArmorLevel;

                        if (targetArmorLevel == 0) {
                            Vector2f penetrateVelocity = new Vector2f(projectileVelocity.getX(), projectileVelocity.getY());
                            penetrateVelocity = penetrateVelocity.normalise(penetrateVelocity);
                            Vector2f penetrateLocation = new Vector2f(point.getX() + penetrateVelocity.getX() * 50f, point.getY() + penetrateVelocity.getY() * 50f);

                            //project the pentration vector through the ship to an imaginary point beyond the ship on the opposite side
                            float projectedLocationX = (float) (1200f * FastTrig.cos(Math.toRadians(projectile.getFacing())) + penetrateLocation.x);
                            float projectedLocationY = (float) (1200f * FastTrig.sin(Math.toRadians(projectile.getFacing())) + penetrateLocation.y);

                            //location as vector2f
                            Vector2f projectedLocation = new Vector2f(projectedLocationX, projectedLocationY);

                            //derive exit location with Lazylib collision utils. This basically uses the imaginary point and the hit point, then checks every segment of the hit boundary segments for an intersect then return the Vector2f value of the closest point where the the two line and the boundary segment meet
                            //using this vector direction it will use the farthest point on the ship for the exit
                            //this method will consistently get the outside boundary
                            //Vector2f exitLocation = CollisionUtils.getCollisionPoint(projectedLocation, penetrateLocation, target);
                            //use this vector direction to determine if it should exit at the nearest point
                            //this method does not consistently get the nearest point due to issues probably with other authors ship boundaries.
                            Vector2f exitLocation = CollisionUtils.getCollisionPoint(penetrateLocation, projectedLocation, target);

                            if (null != exitLocation) {
                                float passThroughShipDistance = MathUtils.getDistance(point, exitLocation);

                                //So let's check IF the imaginary projectile can get 'through' the full distance of internal hull, let's use a value of 1000px, a very very big ship! ie. Zorg
                                if (passThroughShipDistance > 1000f) {
                                    //apply bonus RNG damage to entry point.
                                    engine.applyDamage(target, point, damageAmount / 4f, DamageType.ENERGY, empAmount, true, dealsSoftFlux, projectile.getSource());
                                    //we're done, no exit
                                    return;
                                }
                                //Now let's check how strong the armor is on the exit location, and can we penetrate the otherside
                                float targetArmorExitLevel = DefenseUtils.getArmorLevel((ShipAPI) target, exitLocation) * (targetArmorRating / 15);

                                float penetrateExitValue = (damageAmount * EXIT_FACTOR) - targetArmorExitLevel;

                                if (targetArmorExitLevel == 0) {

                                    //let's do a simple test if the distance through the ship, we have two versions
                                    // if (passThroughShipDistance > projectile.getVelocity().length() || (passThroughShipDistance - projectile.getVelocity().length()) < 100f){
//                                        float newHull = ((ShipAPI)target).getHitpoints() - projectile.getDamageAmount() * 0.5f;
//                                        ((ShipAPI)target).setHitpoints(newHull);
//                                        return;
//                                    }
                                    float passThroughShipTime = passThroughShipDistance / projectile.getVelocity().length();

                                    APDebrisPlugin.startFire(
                                            target,
                                            exitLocation,
                                            projectile.getDamageAmount() * 0.1f,
                                            5f,
                                            projectile.getSource(),
                                            fromAngle,
                                            passThroughShipTime,
                                            projectile
                                    );

                                    APDelayedProjectilePlugin.startFire(
                                            target,
                                            exitLocation,
                                            projectile.getDamageAmount(),
                                            projectile.getSource(),
                                            fromAngle, passThroughShipTime,
                                            projectile.getWeapon().getId(),
                                            projectile.getVelocity().length(),
                                            projectile
                                    );

                                    //engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 1 + 1), damageType, empAmount, true, true, null);
                                    //engine.addFloatingText(penetrateLocation, "Penetrated", 30, new Color(255, 0, 0, 255), target, 1f, 2f);
                                   
                                    engine.applyDamage(target, point, damageAmount / 4f, DamageType.ENERGY, empAmount, true, dealsSoftFlux, projectile.getSource());
                                    if (target.getHitpoints() + damageAmount / 2f < target.getMaxHitpoints()) {
                                        ((ShipAPI) target).setHitpoints(target.getHitpoints() + damageAmount / 2f);
                                       

                                    }

                                } else {
                                    // So if the shaped charge cannot penetrate all the way through, it will start causing damage on the opposite side of the ship.
                                    //
                                    //((ShipAPI) target).setHitpoints(target.getHitpoints() + damageAmount / 2f);
                                    //engine.applyDamage(target, exitLocation, damageAmount / 2f, DamageType.ENERGY, empAmount, true, dealsSoftFlux, projectile.getSource());
                                   
                                    int[] gridCoord = targetArmorGrid.getCellAtLocation(exitLocation);
                                    float armourVal = targetArmorGrid.getArmorValue(gridCoord[0], gridCoord[1]);
                                    if (targetArmorExitLevel - projectile.getDamageAmount() / 4f > 0f){
                                        targetArmorGrid.setArmorValue(gridCoord[0], gridCoord[1], targetArmorExitLevel - projectile.getDamageAmount() / 4f);
                                    } else {
                                        targetArmorGrid.setArmorValue(gridCoord[0], gridCoord[1], 0f);
                                    }
                                   

                                }
                                //There are some strange cases where where the algorithm to find the exit location will not return one, this else statement captures that
                            } else {

                                engine.spawnExplosion(penetrateLocation, new Vector2f(penetrateVelocity.getX() * 250f, penetrateVelocity.getY() * 250f), new Color(225, 200, 50, 200), damageAmount / 70f, 0.5f);

                                //
                                for (int i = 0; i < (int) (damageAmount / 5); i++) {
                                    engine.addHitParticle(penetrateLocation, new Vector2f(penetrateVelocity.getX() * 300f + (float) (Math.random() * 100 - 30), penetrateVelocity.getY() * 500f + (float) (Math.random() * 100 - 30)), damageAmount / 50, 0.5f, 3f, new Color(225, 200, 50, 170));//Color(225,200,50,200)
                                }

                                //spawn exit projectile(s) this will spawn 1 projectiles, there is not need for a loop if you just want to spawn one projectile
                                CombatEntityAPI projectileSpawned = engine.spawnProjectile(null, null, projectile.getWeapon().getId(), penetrateLocation, fromAngle, null);
                                ((DamagingProjectileAPI) projectileSpawned).setSource((ShipAPI) target);

                                //engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 1 + 1), damageType, empAmount, true, true, null);
                                //engine.addFloatingText(penetrateLocation, "Bypass", 30, new Color(255, 0, 0, 255), target, 1f, 2f);
                            }

                        }
                    }
                }
            }
        }
    }
}
[close]

Delayed Projectile
Spoiler
Code: java
package uaf.data.scripts.weapons;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.combat.entities.AnchoredEntity;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import java.awt.Color;
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 java.lang.Math;

// TODO: Check for nearby dprojectiles and merge them for better performance
public class APDelayedProjectilePlugin extends BaseEveryFrameCombatPlugin {

    public Vector2f particleVelocity1;
    public Vector2f particleVelocity2;
    public float damageAmount = 50f; //set this to whatever the damage should be
    public float empAmount = 0f; //set this to whatever the EMP damage should be
    public Color particleColor = new Color(245, 48, 58, 225);
    public float particleSize = 2.5f;
    public float particleBrightness = 1.28f;
    public float particleDuration = 1.45f;
    public float explosionSize = 120f;
    public float explosionSize2 = 60f;
    public float explosionDuration = 0.33f;
    public float explosionDuration2 = 0.9f;
    public float pitch = 1.0f; //sound pitch. Default seems to be 1
    public float volume = 1.0f; //volume, scale from 0-1
    public boolean dealsSoftFlux = false;

    // How long between damage/particle effect ticks
    private static final float TIME_BETWEEN_DAMAGE_TICKS = .2f;
    private static final float TIME_BETWEEN_PARTICLE_TICKS = .1f;
    // Stores the currently DEBRIS_MAP dprojectiles
    // Having the Set backed by a WeakHashMap helps prevent memory leaks
    private static final List<DelayedProjectileData> DEBRIS_MAP = new ArrayList<>();
    private CombatEngineAPI engine;
    private float lastDamage, lastParticle;

    @Override
    public void advance(float amount, List events) {

        if (engine != Global.getCombatEngine()) {
            this.engine = Global.getCombatEngine();
        }

        if (engine.isPaused() || DEBRIS_MAP.isEmpty()) {
            return;
        }

        // Deal dprojectile damage for all actively DEBRIS_MAP projectiles
        for (Iterator iter = DEBRIS_MAP.iterator(); iter.hasNext();) {
            DelayedProjectileData dprojectile = (DelayedProjectileData) iter.next();

            // Check if the dprojectile has gone out
            if (engine.getTotalElapsedTime(false) >= dprojectile.getDelayTime()
                    || !engine.isEntityInPlay(dprojectile.getAnchor())) {

                particleVelocity1 = dprojectile.missile.getVelocity();
                particleVelocity2 = dprojectile.missile.getVelocity();
                particleVelocity1.scale(0.02f);
                particleVelocity2.scale(0.06f);

                //spawn exit projectiles

                   
                    String projID = dprojectile.getWeaponID();
                    projID += "_pen";
                    engine.spawnProjectile(null, null, projID, dprojectile.getLocation(), dprojectile.getExitAngle(), null);

                    /*Optionally the debris can do damage, each projectile does 2dmg in the CSV file.
                     This can cause massive issues in gameplay balance when using the shortest distance vector method for determining the nearest boundary
                     What will happen with ships like the Paragon for example, is the projectile will exit, spewing debris.
                     In a confined inside of a ship this can add up rather quickly in terms of damage, which I think is a bug.
                     */
                    //CombatEntityAPI debrisProj = engine.spawnProjectile(null, null, projID, dprojectile.getLocation(), dprojectile.getExitAngle() + MathUtils.getRandomNumberInRange(-45f, 45f), null);
                    //debrisProj.setCollisionClass(CollisionClass.SHIP);
                    //debrisProj.setAngularVelocity(MathUtils.getRandomNumberInRange(50f, 200f));
                    //void addHitParticle(Vector2f loc, Vector2f vel, float size, float brightness, float duration, Color color);
                    for (int i = 0; i < 5; i++){
                    engine.addHitParticle(
                            dprojectile.getLocation(),
                            new Vector2f(dprojectile.getExitVector().x * 130f + (float) (Math.random() * 100 - 30),
                                    dprojectile.getExitVector().y * 130f + (float) (Math.random() * 100 - 30)),
                            damageAmount / 80,
                            0.5f,
                            3f,
                            new Color(225, 200, 50, 220)
                    );
                }

                iter.remove();

            }

        }
    }

    public static void startFire(CombatEntityAPI target,
            Vector2f hitLoc,
            float totalDamage,
            CombatEntityAPI source,
            float dprojectileAngle,
            float delay,
            String id,
            float speed,
            DamagingProjectileAPI projectile
    ) {
        // TODO: merge with nearby dprojectiles on the same target
        DEBRIS_MAP.add(new DelayedProjectileData(target, hitLoc, totalDamage, source, dprojectileAngle, delay, id, speed, projectile));
    }

    @Override
    public void init(CombatEngineAPI engine) {
    }

    private static class DelayedProjectileData {

        private final AnchoredEntity hitLoc;
        private final CombatEntityAPI source;
        private final float dmg, start, shipStartFacing, deltaAngle, newSpeed;
        private final String weaponID;
        private final DamagingProjectileAPI missile;

        public DelayedProjectileData(CombatEntityAPI target, Vector2f hitLoc,
                float totalDamage,
                CombatEntityAPI source,
                float dprojectileAngle,
                float delay, String id,
                float speed,
                DamagingProjectileAPI projectile
        ) {
            this.hitLoc = new AnchoredEntity(target, hitLoc);
            this.source = source;
            this.deltaAngle = dprojectileAngle;
            this.shipStartFacing = source.getFacing();
            this.dmg = totalDamage;
            this.start = Global.getCombatEngine().getTotalElapsedTime(false)
                    + delay;
            this.weaponID = id;
            this.newSpeed = speed;
            this.missile = projectile;
        }

        public Vector2f getLocation() {
            float radius = source.getCollisionRadius();
            float projectedLocationX = (float) (30f * FastTrig.cos(Math.toRadians(getExitAngle())) + hitLoc.getLocation().x);
            float projectedLocationY = (float) (30f * FastTrig.sin(Math.toRadians(getExitAngle())) + hitLoc.getLocation().y);
            return new Vector2f(projectedLocationX, projectedLocationY);
            //return new Vector2f(0f, 0f);
        }

        public CombatEntityAPI getAnchor() {
            return hitLoc.getAnchor();
        }

        private float getExitAngle() {
            return deltaAngle + (shipStartFacing - source.getFacing());
        }

        private float getDelayTime() {
            return start;
        }

        private float getDamage() {
            return dmg;
        }

        private String getWeaponID() {
            return weaponID;
        }

        //this is actually the unit vector returned
        public Vector2f getExitVector() {
            float x = (float) FastTrig.cos(Math.toRadians(getExitAngle()));
            float y = (float) FastTrig.sin(Math.toRadians(getExitAngle()));
            return new Vector2f(x, y);
        }
    }

}

[close]

Debris/Venting FX
Spoiler
Code: java
package uaf.data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.entities.AnchoredEntity;
import org.lwjgl.util.vector.Vector2f;

// TODO: Check for nearby debriss and merge them for better performance
public class APDebrisPlugin extends BaseEveryFrameCombatPlugin {

    // How long between damage/particle effect ticks
    private static final float TIME_BETWEEN_DAMAGE_TICKS = .2f;
    private static final float TIME_BETWEEN_PARTICLE_TICKS = .33f;
    // Stores the currently DEBRIS_MAP debriss
    // Having the Set backed by a WeakHashMap helps prevent memory leaks
    private static final List<DebrisData> DEBRIS_MAP = new ArrayList<>();
    private CombatEngineAPI engine;
    private float lastDamage, lastParticle;

    @Override
    public void advance(float amount, List events) {

        if (engine != Global.getCombatEngine()) {
            this.engine = Global.getCombatEngine();
        }

        if (engine.isPaused() || DEBRIS_MAP.isEmpty()) {
            return;
        }

        lastDamage += amount;
        lastParticle += amount;

        float damageMod = lastDamage;

        boolean dealDamage = false;
        if (lastDamage >= TIME_BETWEEN_DAMAGE_TICKS) {
            lastDamage -= TIME_BETWEEN_DAMAGE_TICKS;
            dealDamage = true;
        }

        boolean showParticle = false;
        if (lastParticle >= TIME_BETWEEN_PARTICLE_TICKS) {
            lastParticle -= TIME_BETWEEN_PARTICLE_TICKS;
            showParticle = true;
        }

        // Deal debris damage for all actively DEBRIS_MAP projectiles
        for (Iterator iter = DEBRIS_MAP.iterator(); iter.hasNext();) {
            DebrisData debris = (DebrisData) iter.next();

            dealDamage = false;

            // Check if the debris has gone out
            if (engine.getTotalElapsedTime(false) >= debris.expiration
                    || !engine.isEntityInPlay(debris.getAnchor())) {
                iter.remove();
            } else if (engine.getTotalElapsedTime(false) < debris.start) {
                continue;
            } else {
                if (dealDamage) {
                    engine.applyDamage(debris.getAnchor(), debris.getLocation(),
                            debris.dps * damageMod, DamageType.FRAGMENTATION,
                            debris.dps * damageMod, true, true, debris.source);
                }

                // Draw smoke effect to show where the debris is DEBRIS_MAP
                float intensity = debris.getRemainingDuration() / debris.getDuration();
                float intensity2 = debris.getRemainingDuration() / (debris.getDuration() * debris.getDuration());

                if (showParticle) {
                    Vector2f particleVelocity = new Vector2f(intensity2 * (debris.getDebrisVector().x),
                            intensity2 * (debris.getDebrisVector().y)
                    );

                    engine.addSmokeParticle(debris.getLocation(), // Location
                            particleVelocity, // Velocity
                            MathUtils.getRandomNumberInRange(20f, 40f), // Size
                            MathUtils.getRandomNumberInRange(.05f, .15f), // Brightness
                            2.2f, Color.DARK_GRAY); // Duration, color

//                    engine.spawnExplosion(debris.getLocation(), //location
//                            particleVelocity,//velocity
//                            Color.yellow, //colour
//                            MathUtils.getRandomNumberInRange(2f, 5f), //size
//                            MathUtils.getRandomNumberInRange(.01f, .05f)); //duration
                }
                //spawn debris from exit hole
                for (int i = 0; i < 2; i++) {
                    Vector2f debrisVelocity = new Vector2f(1200f * intensity2 * debris.getDebrisVector().x
                            + debris.getAnchor().getVelocity().x,
                            1200f * intensity2 * debris.getDebrisVector().y
                            + debris.getAnchor().getVelocity().y
                    );

                    float tempKelvin = intensity * 4800f;
                    Color debrisColor = KelvinCalc.getRGB(tempKelvin);

                    engine.addHitParticle(
                            debris.getLocation(), //location,
                            debrisVelocity, //velocity
                            MathUtils.getRandomNumberInRange(1f, 4f) * debris.getRemainingDuration(), //size
                            intensity, debris.getRemainingDuration() * 0.11f, //, new Color(225, 200, 50, 200)
                            debrisColor
                    );

                }

            }
        }
    }

    public static void startFire(CombatEntityAPI target,
            Vector2f hitLoc,
            float totalDamage,
            float burnDuration,
            CombatEntityAPI source,
            float debrisAngle,
            float delay,
            DamagingProjectileAPI projectile
    ) {
        // TODO: merge with nearby debriss on the same target
        DEBRIS_MAP.add(new DebrisData(target, hitLoc, totalDamage, burnDuration, source, debrisAngle, delay, projectile));
    }

    @Override
    public void init(CombatEngineAPI engine) {
    }

    private static class DebrisData {

        private final AnchoredEntity hitLoc;
        private final CombatEntityAPI source;
        private final float dps, expiration, duration, start;
        private final float shipStartFacing, deltaAngle;
        private final DamagingProjectileAPI damagingProjectile;

        public DebrisData(CombatEntityAPI target,
                Vector2f hitLoc,
                float totalDamage,
                float burnDuration,
                CombatEntityAPI source,
                float debrisAngle,
                float delay,
                DamagingProjectileAPI projectile
        ) {
            this.hitLoc = new AnchoredEntity(target, hitLoc);
            this.source = source;
            this.deltaAngle = debrisAngle;
            this.duration = burnDuration;
            this.shipStartFacing = source.getFacing();
            dps = totalDamage / burnDuration;
            expiration = Global.getCombatEngine().getTotalElapsedTime(false)
                    + burnDuration;
            start = Global.getCombatEngine().getTotalElapsedTime(false)
                    + delay;
            this.damagingProjectile = projectile;
        }

        public Vector2f getLocation() {
            return hitLoc.getLocation();
        }

        public CombatEntityAPI getAnchor() {
            return hitLoc.getAnchor();
        }

        private float getDebrisAngle() {
            return deltaAngle + (shipStartFacing - source.getFacing());
        }

        public float getRemainingDuration() {
            return expiration - Global.getCombatEngine().getTotalElapsedTime(false);
        }

        public float getDuration() {
            return duration;
        }

        public Vector2f getDebrisVector() {
            Vector2f debVector = new Vector2f();
            damagingProjectile.getVelocity().normalise(debVector);
            return debVector;
        }
    }

    private static class KelvinCalc {

        //Code adapted from http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
        static Color getRGB(float tmpKelvin) {

            double tmpCalc = tmpKelvin; //Temperature must fall between 1000 and 40000 degrees
            double r, g, b = 0f;

            if (tmpKelvin < 1000) {
                tmpKelvin = 1000;
            }
            if (tmpKelvin > 40000) {
                tmpKelvin = 40000;
            } //All calculations require tmpKelvin \ 100, so only do the conversion once
            tmpKelvin /= 100;

            //Calculate each color in turn
            //First: red
            if (tmpKelvin <= 66) {
                r = 255;
            } else {//Note: the R-squared value for this approximation is .988
                tmpCalc = tmpKelvin - 60;
                tmpCalc = 329.698727446d * (Math.pow((double) tmpCalc, -0.1332047592d));
                r = tmpCalc;
                if (r < 0) {
                    r = 0;
                }

                if (r > 255) {
                    r = 255;
                }

            }
            if (tmpKelvin <= 66) {
                tmpCalc = tmpKelvin;
                tmpCalc = 99.4708025861d * Math.log(tmpCalc) - 161.1195681661d;
                g = tmpCalc;

                if (g < 0) {
                    g = 0;
                }

                if (g > 255) {
                    g = 255;
                }

            } else {//Note: the R-squared value for this approximation is .987
                tmpCalc = tmpKelvin - 60;

                tmpCalc = 288.1221695283d * (Math.pow(tmpCalc, -0.0755148492d));
                g = tmpCalc;
                if (g < 0) {
                    g = 0;
                    if (g > 255) {
                        g = 255;
                    }
                }

            }

            //blue
            if (tmpKelvin >= 66) {
                b = 255;
            } else {
                if (tmpKelvin <= 19) {
                    b = 0;
                } else {
                    tmpCalc = tmpKelvin - 10;
                    tmpCalc = 138.5177312231d * Math.log(tmpCalc) - 305.0447927307;

                    b = tmpCalc;
                    if (b < 0) {
                        b = 0;
                    }

                    if (b > 255) {
                        b = 255;
                    }

                }
            }

            return new Color((int) r, (int) g, (int) b, 240);
        }
    }
}
[close]

The reason for it being a 'delayed' projectile is that I imagine it takes 'time' for a projectile to pass through a ship. The bigger the ship the longer the delay, also the angle and distance it has to pass through matters. This script was originally for a normal ballistic projectile, but you can use missiles just as well.
Logged

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Stargate Mod
« Reply #6 on: March 04, 2015, 06:36:44 AM »

So the first code is for armour penetration? could that be adapted for shields too? and the 2nd and 3rd codes are for delays for it to pass through a ship.

Is there any way to make the drones in the ship system launch from the bays of the ship instead of spawning in the centre of the ship.

I'll get round to trying missile penetration once I've sorted out my fighter ship systems.
Thanks for the help.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #7 on: March 04, 2015, 06:59:43 AM »

So the first code is for armour penetration? could that be adapted for shields too? and the 2nd and 3rd codes are for delays for it to pass through a ship.

Is there any way to make the drones in the ship system launch from the bays of the ship instead of spawning in the centre of the ship.

I'll get round to trying missile penetration once I've sorted out my fighter ship systems.
Thanks for the help.

Yes the first one performs the scripting related to calculating the path a projectile takes through a ship, the second script is the queue for spawning another projectile out the otherside of the victim vessel a short time after the first projectile impacted and was despawned. The third script is for displaying debris and gasses on both the entrance and exit holes the projectile creates.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #8 on: March 04, 2015, 07:00:51 AM »

Oh and no, you couldn't use it for penetrating shields. That requires you spawn projectiles without collision detection, then you have an EveryFrame script that does the detection of impacting with ships yourself IIRC to get around the default behaviour of projectiles hitting shields.
Logged

LB

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Stargate Mod
« Reply #9 on: March 04, 2015, 07:04:14 PM »

Perhaps you could use a "collisionClass":"NONE" missile with appropriate guidance behavior and deal damage when it is over a target?
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #10 on: March 04, 2015, 07:12:21 PM »

Perhaps you could use a "collisionClass":"NONE" missile with appropriate guidance behavior and deal damage when it is over a target?

Yeah sure, if you want your missiles passing over, that'll do the trick too. Depends whether you want it to 'go over' or 'through'?
Logged

LB

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Stargate Mod
« Reply #11 on: March 04, 2015, 07:27:50 PM »

Well, it is the same thing, isn't it? :v

I didn't manage to figure out how to layer it under the ship, though.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Stargate Mod
« Reply #12 on: March 04, 2015, 08:18:57 PM »

Yeah, cannot put it in the layer under the ship. There is a way in which the layers are rendered, I can probably pull up the quote from Alex.

A projectile going 'through' would 'hit' the bound box and de-spawn, then for a variable period would 'do FX and dmg etc. etc.' until a new projectiles is spawned at the other side of the ship after the time period is up.

A projectile going over the ship would ignore all bounds and you would need to handle the AI of the missile while it is 'over' the top. The other thing is that it is always visible unless you grab the SpriteAPI of the missile and set it to transparent until it 'exits' according to your rules and you make it 'visible' again.

A couple of ways to skin this cat.
Logged

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Stargate Mod
« Reply #13 on: August 11, 2015, 10:56:33 AM »

I'm going to start working on this again. At the moment it's only on 0.65a. I'm going to remove the ori motherships and wraith cruiser because they are so big compared to the daedalus and prometheus that when they enter a battle they collide with the ones already destroyed.
Going to add Ha'taks instead and gliders, maybe a couple of asgard ships.
Need to alter the balance for weapons and such. and need help with my sprites if anyone has time. Mine aren't very good. If anyone wants to help please PM me
Logged

Doci

  • Ensign
  • *
  • Posts: 14
    • View Profile
Re: Stargate Mod
« Reply #14 on: September 18, 2015, 03:44:46 AM »

Hey Joe :)

If you Need some help i would be glad to help you out :D

I have some experience with modding Starsector.

The only thing i would need is the latest ship Editor (if there is one ? :D )

I could do weapons or/and ships for you ? :)

Would be happy to receave an answer :D
Logged
"Hallowed are the Ori"
Pages: [1] 2 3