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 ... 25 26 [27] 28 29 ... 706

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

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #390 on: April 07, 2013, 07:37:43 AM »

Ive been trying to get the Dreadnought hull hp to go down depending on how many drones are outside, but it seems i cant do this on the shipsystems for some reason, heres the code i got in right now:
~
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

public class DreadnoughtFighters implements ShipSystemStatsScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        ShipAPI ship = (ShipAPI) stats.getEntity();

        if (ship == null) {
                return;
            }

        //int HPAmountPerFighter = (int)ship.getMaxHitpoints() / 42;
        float PercPerFighter = 42 / 100; //Grab current perc

            if(ship.getDeployedDrones().isEmpty()) {
                stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (ship.getDeployedDrones().size() * PercPerFighter));
            }
            else {
                stats.getHullRepairRatePercentPerSecond().modifyFlat(id, -(ship.getDeployedDrones().size() * PercPerFighter));
            }
           
}
public void unapply(MutableShipStatsAPI stats, String id) {
stats.getMaxHullRepairFraction().unmodify(id);
        stats.getHullRepairRatePercentPerSecond().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("Releasing Autonomous Fighters.", false);
}
return null;
}
}
Logged

FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #391 on: April 07, 2013, 09:04:18 PM »

Mmm, As a question on ship system ai priority... say I have a phase ship, with a ship system that is also phase cloak, the ai will activate both, (redundant yes)

now say that I have a modified ship system that uses the phase_cloak ai (because it's what i sorta want, a system to use when it detects projectiles and missiles, unlike flare which is strictly missile, )

Is there any way to create a way to make it use the ship system as a last ditch instead of concurrently?

I can see in the sample ai of the fast missile racks where there's logic deny it from using the system when high on flux ( I want the exact opposite; use when near critical )
As the ai's aren't public I doubt I could recreate the phase cloak ai in any way shape or form :P


Logged

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #392 on: April 07, 2013, 10:30:53 PM »

real quick and easy one.
how do fighters determine when to resupply ?
say a wing of 4 ships equipped with 500 rounds of autocannon and 2 harpoon each.

when will they de-engage for resupply ?
im asking cause im modding very resilient and heavily armed fighters that have a powerful main gun along with a few missiles and i wouldnt want them to prematurely de-engage to resupply theire missiles when they can still aptly fight with theire main gun .
(im worried because in this design, the missiles are only there for powerful opportunity strikes, the fighter's main automatic gun is actually the main weapon and i wouldnt want the AI to act the wrong way)
Logged

ValkyriaL

  • Admiral
  • *****
  • Posts: 2145
  • The Guru of Capital Ships.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #393 on: April 08, 2013, 07:07:02 AM »

They will resupply when all of their ammo is gone depending on what role they have, or when the wing as a whole has taken 50% total damage.
Logged

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #394 on: April 08, 2013, 11:01:04 AM »

They will resupply when all of their ammo is gone depending on what role they have, or when the wing as a whole has taken 50% total damage.

which fighter role should i put in the csv so that it act like i previously described ?
Logged

Uomoz

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

Do anyone knows what an error like this is related to?

Code
455068 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.ai.CampaignFleetAI.private.Object(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleet.advance(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.A.super(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)
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #396 on: April 08, 2013, 04:34:17 PM »

Anyone know if there's a way to have a bullet sprite with multiple frames of animation?
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #397 on: April 09, 2013, 02:42:49 PM »

Alrighty, 'nother question:

I'm in the process of setting up an ai for the Elysiums drive system in the hopes that it will stop crashing into things and if hit a bit of an issue.  I based the ai rather heavily off of the ai example Psiyon put together for his Fire Control system; unfortunately the proximity based nature of it seems to be causing the ai to generate false positives from asteroids and thus leads to the ai repeatedly cycling the system on and off.

I know that the Burn Drive "looks ahead" of itself when deciding whether to activate or not.  Is there, either through the default api or through lazylib, some method by which I could get the ship the check in front of itself when deciding if the system is safe to use or not?  I suspect I could probably use getDirectionalVector from lazylib, but I'm not sure how to implement such a thing.

The actual code trying to imitate a decision making process is as follows:

Spoiler
Quote
//Credit goes to Psiyon for his firecontrol AI script.

package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import data.scripts.plugins.CombatUtils;
import java.util.Iterator;
import org.lazywizard.lazylib.MathUtils;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.util.IntervalUtil;

public class ms_drivechargerai implements ShipSystemAIScript {
    private ShipSystemAPI system;
    private ShipAPI ship;
    private float sinceLast = 0f;   
    private IntervalUtil tracker = new IntervalUtil(1f, 2f);
   
    //This just initializes the script.
    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine)
    {
        this.ship = ship;
        this.system = system;
    }
   
    //So here we will tell the ship how to make use of the system.
    @Override
    public void advance (float amount, Vector2f position, Vector2f collisionDanger, ShipAPI target)
    {
        tracker.advance(amount);
       
        sinceLast += amount;
        //Once the interval has elapsed...
   if (tracker.intervalElapsed()) {
            //First we check if the ship is within closing distance of a target, or imminent danger of colliding with something:
            float check_combat = 1000f;
            float check_close = 750f;
            float check_collide = 100f;
            float cutoff_chance = 0f;
            float impact_alert = 0f;
           
            //Then we set it up so that we can track ships
            int ships = 0;
            ShipAPI ship_tmp;
           
            //Now we iterate through all ships on the map
            for (Iterator iter = CombatUtils.getCombatEngine().getShips().iterator();
                iter.hasNext();)
            {
                ship_tmp = (ShipAPI) iter.next();
               
                //We can't collide with fighters, so ignore 'em
                if (ship_tmp.isFighter()) continue;
                if (ship_tmp.isHulk()) continue;
               
                if (CombatUtils.getDistance(ship_tmp, ship) <= (check_combat)) {
                       
                    ships++;
                   
                    if ((CombatUtils.getDistance(ship_tmp, ship) <= (check_close))) {
                        cutoff_chance += 1f;
                    }
               
                    if ((CombatUtils.getDistance(ship_tmp, ship) <= (check_collide))) {
                        impact_alert += 1f;
                    }
               
                    float fluxLevel = ship.getFluxTracker().getFluxLevel();
               
                    //First, lets make it so if no hostile ships are nearby, and the system isn't active, the vessel will turn on the system:
                    if (cutoff_chance <= 1 && !system.isActive() && (ships <= 3) && fluxLevel <=0.35 && ((float) Math.random() > 0.1f)) {
                        ship.useSystem();
                    }
                    //If the ship is only near a few enemies and the system is active, she has moderate chance of turning the system off:
                    else if  (cutoff_chance >= 2 && system.isActive() && (ships >= 3) && ((float) Math.random() > 0.6f)) {
                        ship.useSystem();
                    }
                    //More hostiles means the ship is more like to use the cutoff:
                    else if  (cutoff_chance >= 3 && system.isActive() && (ships >= 4) && ((float) Math.random() > 0.2f)) {
                        ship.useSystem();
                    }
                    //If there are too many ships in the area the system is too risky to use, so the ship will just shut it down period:
                    else if  (cutoff_chance >= 4 && system.isActive() && (ships >= 5)) {
                        ship.useSystem();
                    }
                    //Also, if the ships flux gets too high and the ships system is active, shut it down:
                    else if  (system.isActive() && fluxLevel >=0.85) {
                        ship.useSystem();
                    }
                    //And, for a bit of fun, if enemy ships are within the combat radius, but not too many, and flux is low enough, the ship might turn the system on:
                    else if  (cutoff_chance <= 3 &&  impact_alert == 0 && !system.isActive() && (ships <= 3) && fluxLevel >=0.35 && ((float) Math.random() > 0.8f)) {
                        ship.useSystem();
                    }
                    //Finally if the ship detects an enemy in the direction she's headed inside the collision radius, and her system is on, we'll turn it off:
                    else if  (impact_alert >= 1  && system.isActive()) {
                        ship.useSystem();
                    }
                } else { return; }
            }
        }
    }
}
[close]

The code above "functions" but is terribly finicky, as already mentioned.  In truth I'd like to cut down on the variables just to seeing if the ship is in a range where it's probably in combat or not and seeing if it's likely to collide with something if it keeps the drive online/turns it on.
Logged

Thule

  • Admiral
  • *****
  • Posts: 580
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #398 on: April 09, 2013, 04:28:51 PM »

Hi guys,

Endercore provided me with a modified version of his wing teleporting system. The system in the original would check if a wing was damaged and teleport it back to the carrier where the system was installed.
The new modified one does simply teleport all deployed ships nearby the ship the system is installed. The big question is how could the system itself made more fancier, visual more pleasing as it it lacking this right now.

endercore's code:
Spoiler
Quote
package data.shipsystems.scripts;

import java.util.List;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import data.scripts.plugins.CombatUtils;
import org.lwjgl.util.vector.Vector2f;
import java.util.Random;


/**
 *
 * @author Ender
 */
public class Fleet_Teleporter implements ShipSystemStatsScript {

    private ShipAPI shipsapi;
    private ShipAPI final_shipsapi;
    private CombatEntityAPI combatEntity;
    private CombatEntityAPI currentShip;
    private CombatEngineAPI engine;
    private MutableShipStatsAPI eachShip;
    private boolean hasRun = false;
   
   
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        CombatUtils combatEngine = new CombatUtils();
        engine = combatEngine.getCombatEngine();
       
        if (engine != null && !hasRun) {           
            if (engine.getShips() != null) {
                       
                        Random randomNum = new Random();
                        List ships = engine.getShips();  //get a list of all active ships
                        List shipList = null;
                        currentShip = stats.getEntity(); //we need our current ship so that we know who owns it
                        Vector2f location = currentShip.getLocation();
                        for (int i = 0; i < ships.size(); i++) { //now we loop through the entire list of ships
                            shipsapi = (ShipAPI) (ships.get(i)); //assign the current ship to the ShipAPI so we can give it bonuses or penalties
                            eachShip = shipsapi.getMutableStats(); //now we need something Mutable
                            combatEntity = eachShip.getEntity(); //we need to assign it as an entity as well so we can see who owns it
                           
                            //in here, we're checking to find friendly ships
                            if ((combatEntity.getOwner() == currentShip.getOwner()) && (eachShip != null) && (combatEntity != stats.getEntity())) {
                                float randomX = (randomNum.nextInt(5) - 2) * 400;
                                float randomY = (randomNum.nextInt(5) - 2) * 400;
                                shipsapi.getLocation().x = (location.x + randomX);
                                shipsapi.getLocation().y = (location.y + randomY);
                            }
                        }
                        hasRun = true;
            }           
        }
    }

   
    public void unapply(MutableShipStatsAPI stats, String id) {
      //there's nothing to unapply here, so we can leave this block of code empty
                hasRun = false;
    }
   
    public StatusData getStatusData(int index, State state, float effectLevel) {
      if (index == 0) {
         return new StatusData("Teleporting fleet to near", false); //display status message to the player
      }
      return null;
   }
}
[close]

The ship i had in mind would be this one:

Kind of a "deep diver" or long range Phase ship which could sneak behind enemy lines unharmed, teleport the deployed fleet and make its tactical retreat.
The electric thingy and the shape of the ship reminded me of some kind of portal and i guess some emp arcs spawning around or over the ship would be quite suitable.
Or would it be possible to have a decorative weapons take the part of an animation?

Maybe someone has a clue if one or all or none of the above would be possible to code?
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #399 on: April 09, 2013, 04:31:40 PM »

I just so happen to have arc emitter weapon codes and scripts :)

LazyWizard created them, and you'd have to wait until tomorrow toget them
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)

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 #400 on: April 09, 2013, 04:37:14 PM »

I think some of Flash's newer weapons for Neutrino have animated projectiles, you could take a look at those.

Thule: The energy-looking things in the middle of the circle portion of the hull look like some kind of field generator, Maybe each bit would fire into the middle and cause some kind of EMP (Like, AoE EMP) to nearby ships? Just speculation, I imagine you already have a use for it.
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.

Thule

  • Admiral
  • *****
  • Posts: 580
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #401 on: April 09, 2013, 04:43:00 PM »

@vinya

yeah the ship above and the energy looking things in the middle where supposed to match the shipsystems teleporting ability by spawning "visual" emp arcs.
I thought i already made that clear in my text, but i guess not. Sorry for that as english is not my first language ;) but thanks for the input anyway, and i had quite the same in mind
as i made the ship some time ago.

@sprog
Thanks buddy. i guess you wouldnt be able to combine your lazy wizard code with the one endercore created? ^^
Logged

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #402 on: April 09, 2013, 05:59:24 PM »

I have a couple of questions that I've been wondering about, but Im not really a programmer.

Is there any way to create a projectile that impacts other projectiles? Or at the very least, a missile that doesnt get targeted by PD?

Also, I'd like to know if there is a way to create a projectile that is able to penetrate multiple targets.

Any answers, even "No", would be greatly appreciated.
Logged

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #403 on: April 09, 2013, 06:10:05 PM »

I have a couple of questions that I've been wondering about, but Im not really a programmer.

Is there any way to create a projectile that impacts other projectiles? Or at the very least, a missile that doesnt get targeted by PD?

Also, I'd like to know if there is a way to create a projectile that is able to penetrate multiple targets.

Any answers, even "No", would be greatly appreciated.

what do you mean "a projectile that impacts other projectile ?"
and im pretty sure PDs are hardwired to shoot at missile, its kindof part of the balance mechanism versus missiles. i mean, your missile will become way too strong if its homing and cant be hit by PDs, and if its not homing and youre worried about PDs, then why even make it a missile ?

also, i recall seeing a mod somewhere on another forum of starsector that had a penetrating mechanism, but that was done with modding illegally so of the code
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #404 on: April 09, 2013, 06:22:57 PM »

I think some of Flash's newer weapons for Neutrino have animated projectiles, you could take a look at those.

Well, I've given it a look-see and it seems like Flash managed to spoof projectile animations by cunningly using MIRV styled missiles for his projectiles; literally spawning the next frame of animation through the projectile mechanics.

Cunning.  Not sure how applicable it'll be, but quite clever.  At the very least it's given me some ideas.
Logged
Pages: 1 ... 25 26 [27] 28 29 ... 706