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 ... 67 68 [69] 70 71 ... 706

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

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1020 on: October 18, 2013, 05:07:06 PM »

now, as many of you may have seen i have created quite an abomidable piece of code due to my unsatisfaction with curent MIRV behaviour...

now what do i do with it?

this is how far i have gotten (help me im stupid and dont actualy know how to get it to work!!!)
Spoiler
Code: java
package data.scripts.EveryFrameCombatPlugin;


import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.List;

import static org.lazywizard.lazylib.combat.CombatUtils.getShipsWithinRange;

public class Scatterb implements EveryFrameCombatPlugin {

    private IntervalUtil tracker = new IntervalUtil(0.35f, 0.4f);
    private static CombatEngineAPI activeEngine;

    public void advance(float amount, MissileAPI missile, CombatEntityAPI target, CombatEngineAPI engine, java.lang.String SBKR1, List events) {

        if (getShipsWithinRange(missile.getLocation(), 400f, true).get(0).isAlive())
        {
            target = getShipsWithinRange(missile.getLocation(), 400f, true).get(0);
            {
                //create variables
                //capitalized can be changed

                //insert targeter code here (anything goes, you may need to change it so T gives tx/ty a float value
                //see at bottom for possible code
                CombatEntityAPI T = target;//end point of " " (enemy api/point in space/ect) for targeter
                MissileAPI P = missile;    //start point of " " for weapon
                float px = P.getLocation().getX();   //get location og p (for center of dakakakaka)
                float py = P.getLocation().getY();
                //float mvx = missile.getVelocity().getX();
                //float mvy = missile.getVelocity().getY();
                float tx = T.getLocation().getX();   //get location of t (for center of pew pew)
                float ty = T.getLocation().getY();
                double rxd = .5 - Math.random(); //generate a random double with -vs component, range -.5 to +.5
                float rx = (float)rxd*2;          // convert to float
                double ryd = .5 - Math.random();
                float ry = (float)ryd*2;
                double rpd = Math.random(); //+ve random
                float rp = (float)rpd;
                float Tvar = 50f; //radius of t (sets mirv spread (angular))
                float Pvar = 1f;   //variable for vectors can use random float
                double prany = py/Math.abs(py)*Pvar;
                double pranx = px/Math.abs(px)*Pvar;
                float prx = (float)pranx;
                float pry = (float)prany;
                float Rvar = 5f; //how much the velocities of projectiles can vary
                double rvd = .5 - Math.random(); //generate random velocity multiplier for smooth function (to arr roughness back in
                float rv = (float)rvd*Rvar;



                //math

                float Fx = (tx * rx * Tvar);  //create randomized point field to shoot at
                float Fy = (ty * ry * Tvar);
                float Vx = (Fx * px * prx);         //create vectors for pewpews to follow
                float Vy = (Fy * py * pry);
                double Smoothv = (Math.sqrt(((tx-px)*(tx-px))+((ty-py)*(ty-py)))/Math.sqrt((Vx*Vx)+(Vy*Vy)))*rv;   //smoothes out ragged shot
                float Sv = (float) Smoothv;
                Vector2f Pjv = new Vector2f(Vx*Sv, Vy*Sv);   //make the actual vector

                engine.spawnProjectile(null, null,
                        SBKR1,
                        missile.getLocation(), 0,Pjv);

                engine.removeEntity(missile); //make missile go poof
            }

    }
    }



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




    }

    @Override
    public void init(CombatEngineAPI engine) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
[close]

i am trying to attach it to missiles so it will run as an every frame script and check for a ship in range (and when ship is in range trigger my special MIRV behaviour)

i would love even the most basic example of how to implement this(so i can run it ingame), i can probably work out how to customize it to do what i want after that. (i already have the script up, but how to stick it onto a missile?)
« Last Edit: October 18, 2013, 08:10:04 PM by dmaiski »
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

Magician

  • Commander
  • ***
  • Posts: 156
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1021 on: October 19, 2013, 01:01:55 PM »

Didn't want to create thread, so I will ask here. Though questions not really about modding, I'm sorry. Hope Alex or someone else will know the answer.

1) Why in vmparams used "-server"?
2) Why used "-XX:CompilerThreadPriority=1" and what exactly will happen if I remove it?
Now here is a short backstory. I switched native jre folder to JRockit jre. Launcher doesn't even start if -XX:CompilerThreadPriority=1 is present in vmparams, but without it game works. And iirc, JRockit by default uses "-server" mode, and when I tested game without "-server"(but in case of JRockit this parameter looks like this "-jrockit") and with it, game was running with almost twice lower FPS and also game speed was almost twice slower. Though cpu usage was lower. But after I added "-client" parameter, and run Starsector with JRockit jre(-XX:CompilerThreadPriority=1 still removed), game was running perfectly normal with 55-60FPS and average cpu load.

As you may notice, I tried to solve Out of memory problem/problem of 1.5Gb limit for java on 32-bit system. I found that JRockit manages memory differently and may give additional memory to Starsector.

3) I noticed that most of Out of memory errors are associated with game trying to load system or hyperspace background. Out of 6 errors about 5 are same: game trying to load background4.jpg or similiar texture. Can this information be usefull?
I for quite some time thought if it is possible to turn off or enable simplified backgrounds/textures for some things in game to remove some load.

4) And finally I'd like to know if there is some reliable and fast way to recreate Out of memory error. I spent couple of hours flying around whole sector, warping in systems and back, engaging multiple battles, using save loading, just to recreate error with different vmparams settings. I know for a fact that with default installation and few mods enabled (to increase memory usage) game also starts to stutter at some point, if you use hyperspace often. I'd like to test few things, but it will take quite some time if I will just play and wait if errors/stuttering will kick in.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1022 on: October 19, 2013, 01:28:39 PM »

@dmaiksi: I think that's a bit too involved for this thread.

1) Why in vmparams used "-server"?
2) Why used "-XX:CompilerThreadPriority=1" and what exactly will happen if I remove it?

The -server parameter allows the JVM to compile frequently-used code segments into optimized native code, making the game run faster overall. This compilation can take a little time (not a lot, but enough for a slight stutter); the thread priority parameter makes it low priority to minimize that effect. The -server parameter isn't necessary for the game to work.

3) I noticed that most of Out of memory errors are associated with game trying to load system or hyperspace background. Out of 6 errors about 5 are same: game trying to load background4.jpg or similiar texture. Can this information be usefull?

That's just because loading a new background needs a bunch of new memory, and if there's not enough left, it's likely to trigger the OOM. That doesn't mean the background is the underlying cause, though - it's just the most likely thing to trigger it. If it wasn't there, something else would.

4) And finally I'd like to know if there is some reliable and fast way to recreate Out of memory error. I spent couple of hours flying around whole sector, warping in systems and back, engaging multiple battles, using save loading, just to recreate error with different vmparams settings. I know for a fact that with default installation and few mods enabled (to increase memory usage) game also starts to stutter at some point, if you use hyperspace often. I'd like to test few things, but it will take quite some time if I will just play and wait if errors/stuttering will kick in.

Probably not, unless there's an actual memory leak, in which case doing whatever triggers the leak would do it. Stuttering... that depends. I know Exerelin stutters a bit just because of the scripts its running; I'd imagine the load those generate goes up as there are more fleets, so that could explain some instances of it. Other mods could have similar behavior. It could also happen if it's really close to maxing out memory usage and struggles to free enough.

Using hyperspace often really shouldn't factor into this, though. Hmm.
Logged

NikolaiLev

  • Captain
  • ****
  • Posts: 325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1023 on: October 19, 2013, 03:01:30 PM »

Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.

It's possible, but not simple. It involves providing a different version of the fleet interaction dialog plugin.


I don't suppose you could elaborate on this?

Also, is it just me or is it not feasible to have a fighter wing with only one member in it?  It seems like if you attempt it, the fighter wing will run out of combat-capable craft if it dies, despite available CR and replacement chassis.  This could be a bug, or it could be a consequence of how the system works; i.e. does the system "queue" wings up for replacement, or does the wing become combat-incapable if all its members die and a replacement isn't being prepared on a carrier?
Logged


FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1024 on: October 19, 2013, 03:18:29 PM »

Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.

It's possible, but not simple. It involves providing a different version of the fleet interaction dialog plugin.


I don't suppose you could elaborate on this?

Also, is it just me or is it not feasible to have a fighter wing with only one member in it?  It seems like if you attempt it, the fighter wing will run out of combat-capable craft if it dies, despite available CR and replacement chassis.  This could be a bug, or it could be a consequence of how the system works; i.e. does the system "queue" wings up for replacement, or does the wing become combat-incapable if all its members die and a replacement isn't being prepared on a carrier?

For the 2nd bug, I've reported it - http://fractalsoftworks.com/forum/index.php?topic=6796.0
So two crafts are the minimum, lone craft won't resupply, and also will be killed off if they die.
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1025 on: October 19, 2013, 03:52:25 PM »

http://fractalsoftworks.com/forum/index.php?topic=7260.0
i made topic, somone please come help me!!!

on a related note how do i create a java.lang.String for:
Code: java
engine.spawnProjectile(null, null,
                        java.lang.String,
                        missile.getLocation(), 0, Pjv);
and

how do i get an engine.spawnProjectile to work in MissileAIPlugin for:
Code: java
 @Override
    public void advance(float amount)
    {

        if (MathUtils.getDistance(target, missile.getLocation()) < 400)
        {
            engine.spawnProjectile(null, null,
                    java.lang.String,
                    missile.getLocation(), 0, Pjv);
            engine.removeEntity(missile);
        }

????
help plz
« Last Edit: October 20, 2013, 05:04:30 PM by dmaiski »
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1026 on: October 21, 2013, 08:18:37 AM »


the BISO heavy weapons reaserch department presents THOR missiles!

god that took longet then it whould have... but now i have a custom missile AI and custom mirv script that can shoot any weapon i want from a missile!!!
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

maximilianyuen

  • Captain
  • ****
  • Posts: 358
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1027 on: October 22, 2013, 03:08:10 AM »

Spoiler
[close]
the BISO heavy weapons reaserch department presents THOR missiles!

god that took longet then it whould have... but now i have a custom missile AI and custom mirv script that can shoot any weapon i want from a missile!!!

can you mount a turret on a missile?
Logged
Fleet construction in progress.

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1028 on: October 22, 2013, 03:45:04 AM »

:P i can, see the code dump for mun code that dose stuff
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

sirboomalot

  • Admiral
  • *****
  • Posts: 596
  • Boom
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1029 on: October 22, 2013, 11:00:39 AM »

:P i can, see the code dump for mun code that dose stuff

You can!? I know nothing of coding, or what I am looking at when I look at code, but I would love to see a "missile" that is designed to circle an enemy ship whilst shooting at it.
Logged

TimeDiver

  • Captain
  • ****
  • Posts: 345
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1030 on: October 26, 2013, 01:13:01 PM »

Is there a fixed limit on how many 'hidden'-mount weapon slots that a single custom .ship file can have?

'cause I've been getting the following crash and error message repeatedly (.ship in question has 16 'hidden' type slots, doesn't occur when reduced to 10 or below):

Code
129829 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving to ..\saves/save_Testing_8759369790073092877...
130468 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Finished saving
195523 [Thread-5] INFO  com.fs.starfarer.combat.CombatEngine  - FP1: 0, FP2: 435, maxFP1: 120, maxFP2: 180
248951 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.specs.Oo0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.getHiddenAngleOffset(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.B.Object(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.J.fireProjectile(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.String.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.String(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.J.advance(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.F.øÒÒ000(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
« Last Edit: October 26, 2013, 01:15:09 PM by TimeDiver »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1031 on: October 26, 2013, 01:19:27 PM »

@TimeDiver: Looks like a problem with one of the hidden weapons, not slots. Probably a mismatch in the number of offsets and angleOffsets, or something along those lines. (I.E. if you have 4 values for offsets - two points from which the weapon fires - but only one value for angleOffset, instead of two.)
Logged

TimeDiver

  • Captain
  • ****
  • Posts: 345
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1032 on: October 26, 2013, 01:40:15 PM »

@TimeDiver: Looks like a problem with one of the hidden weapons, not slots. Probably a mismatch in the number of offsets and angleOffsets, or something along those lines. (I.E. if you have 4 values for offsets - two points from which the weapon fires - but only one value for angleOffset, instead of two.)
Turns out that was exactly the case; when I switched the 'hidden' mount(s) that had the faulty weapon equipped to 'turret', I mis-interpreted the results.

Thanks for clearing that one up, Alex.  :-[
Logged

maximilianyuen

  • Captain
  • ****
  • Posts: 358
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1033 on: October 26, 2013, 08:58:30 PM »

problem on Sound json in Config folder:
I was just looking to adding a custom engine and flux sound:

1) from the core I see
Spoiler
Quote
   "engine_loop":{
      "sounds":[
         {"file":"sounds/sfx_engines/engine_01_lotek_00_fighter.ogg","pitch":0.67,"volume":1}, # index:  0
         {"file":"sounds/sfx_engines/engine_01_lotek_01_frigate.ogg","pitch":1,"volume":1},    # index:  1
         {"file":"sounds/sfx_engines/engine_01_lotek_02_destroyer.ogg","pitch":1,"volume":1},  # index:  2
         {"file":"sounds/sfx_engines/engine_01_lotek_03_cruiser.ogg","pitch":1,"volume":1},    # index:  3
         {"file":"sounds/sfx_engines/engine_01_lotek_04_capital.ogg","pitch":1,"volume":1},    # index:  4
         {"file":"sounds/sfx_engines/engine_02_midtek_00_fighter.ogg","pitch":0.67,"volume":1},# index:  5
         {"file":"sounds/sfx_engines/engine_02_midtek_01_frigate.ogg","pitch":1,"volume":1},   # index:  6
         {"file":"sounds/sfx_engines/engine_02_midtek_02_destroyer.ogg","pitch":1,"volume":1}, # index:  7
         {"file":"sounds/sfx_engines/engine_02_midtek_03_cruiser.ogg","pitch":1,"volume":1},   # index:  8
         {"file":"sounds/sfx_engines/engine_02_midtek_04_capital.ogg","pitch":1,"volume":1},   # index:  9
         {"file":"sounds/sfx_engines/engine_03_hitek_00_fighter.ogg","pitch":0.67,"volume":1}, # index: 10
         {"file":"sounds/sfx_engines/engine_03_hitek_01_frigate.ogg","pitch":1,"volume":1},    # index: 11
         {"file":"sounds/sfx_engines/engine_03_hitek_02_destroyer.ogg","pitch":1,"volume":1},  # index: 12
         {"file":"sounds/sfx_engines/engine_03_hitek_03_cruiser.ogg","pitch":1,"volume":1},    # index: 13
         {"file":"sounds/sfx_engines/engine_03_hitek_04_capital.ogg","pitch":1,"volume":1},    # index: 14
         ],

      "LOW_TECH":{"sounds":[0,1,2,3,4], "pitch":1, "volume":0.5},
      "MIDLINE":{"sounds":[5,6,7,8,9], "pitch":1, "volume":0.3},
      "HIGH_TECH":{"sounds":[10,11,12,13,14], "pitch":1, "volume":0.5},
      "FIGHTER":{"sounds":[0,5,10], "pitch":1, "volume":0.4},
      "FRIGATE":{"sounds":[1,6,11], "pitch":1, "volume":0.7},
      "DESTROYER":{"sounds":[2,7,12], "pitch":1, "volume":0.7},
      "CRUISER":{"sounds":[3,8,13], "pitch":1, "volume":0.7},
      "CAPITAL_SHIP":{"sounds":[4,9,14], "pitch":1, "volume":1},   
      },
[close]

and from the other mod i see if I add any engine sound the first sound needed to be starting at #15.

so..when I already have another mod that did the same thing, say added the #15 engine sound, how will I know when I am adding mine it will be #15 or #16?

and if i treat it as #16, later when disable that mod and just use my mod that added #16 sound which naturally become #15, my "CAPITAL_SHIP":{"sounds":[16], "pitch":1, "volume":1},   will then be invalid right?


same goes for the flux....since the core already use #0 so i am very confused when other mod use #1 and should I use #2 and never disable that mod...
« Last Edit: October 26, 2013, 11:09:24 PM by maximilianyuen »
Logged
Fleet construction in progress.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1034 on: October 27, 2013, 09:11:06 AM »

Yeah that... doesn't work very well, as far as being extensible by mods. Something I need to take a look at; it's on my list.
Logged
Pages: 1 ... 67 68 [69] 70 71 ... 706