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 ... 45 46 [47] 48 49 ... 706

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

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #690 on: August 21, 2013, 05:09:46 PM »

I think my head will just pop, here is the problem:

I am creating animated beam weapon, base sprite is loaded and visible, on fire it disappears and become visible at the end of animation. BUT! (and that´s what grinds my gears) if I replace it with different animated sprite, for example shredder or something from different mod it works. BUT WAIT, there is more. If I move that working sprite from different mod to my mod (whole folder with animation), and change path it just stops to work again (same error as in first place). If I move my sprite to different mode and try to load it from there, then again same error. Ideas?

If I move that sprite to my mod (remove it from original folder in another mode) and turn off that mod then same bug as always, on the other hand if the second mod is still active then it is working again. It seems to like there is some config file (similar to sounds config file) that just point on "that is animation". But ffs I went through every single file six times and there is (and actually there is no reason to be) anything like that. So what the hell?

Hmm, maybe I got it

« Last Edit: August 21, 2013, 05:42:39 PM by Ravendarke »
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #691 on: August 21, 2013, 05:29:03 PM »

I think my head will just pop, here is the problem:

I am creating animated beam weapon, base sprite is loaded and visible, on fire it disappears and become visible at the end of animation. BUT! (and that´s what grinds my gears) if I replace it with different animated sprite, for example shredder or something from different mod it works. BUT WAIT, there is more. If I move that working sprite from different mod to my mod (whole folder with animation), and change path it just stops to work again (same error as in first place). If I move my sprite to different mode and try to load it from there, then again same error. Ideas?

If I move that sprite to my mod (remove it from original folder in another mode) and turn off that mod then same bug as always, on the other hand if the second mod is still active then it is working again. It seems to like there is some config file (similar to sounds config file) that just point on "that is animation". But ffs I went through every single file six times and there is (and actually there is no reason to be) anything like that. So what the hell?

How is ur sprites named?
Heres an example of a huge animation sprite group:
Spoiler
[close]

Do you see anything different from what ur doing (note that the size is not the same for one reason, my weapon is outside the ship)?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #692 on: August 21, 2013, 05:32:03 PM »

Also worth making sure, just in case, that all the frames are saved as 24-bit pngs, not 8-bit.
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #693 on: August 21, 2013, 05:47:00 PM »

As I said, when I moved that sprite from other mode to my mod then it wasn´t working again as long as I didn´t had second mode activated (when I activated it it was ok). I´ve named frames according to shredder.. so in this case terror_rail_00.png .... terror_rail_30.png ...

And yeap, format is alright....

Point is this, it looks like, some script is actually checking if there are all frames of sprites while loading the game.

EDIT: I mean, if I remove one frame of shredder (or rename it) for example if I remove chaingun2_hardpoint_base02.png then game crash on loading, where is defined that engine should load this up? How does it know how many frames while starting the game?


AAAA I think I got it... but this is imho bug, let me test it, brb in 5 minutes.
« Last Edit: August 21, 2013, 05:58:04 PM by Ravendarke »
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #694 on: August 21, 2013, 05:59:58 PM »

As I said, when I moved that sprite from other mode to my mod then it wasn´t working again as long as I didn´t had second mode activated (when I activated it it was ok). I´ve named frames according to shredder.. so in this case terror_rail_00.png .... terror_rail_30.png ...

And yeap, format is alright....

Point is this, it looks like, some script is actually checking if there are all frames of sprites while loading the game.

EDIT: I mean, if I remove one frame of shredder (or rename it) for example if I remove chaingun2_hardpoint_base02.png then game crash on loading, where is defined that engine should load this up? How does it know how many frames while starting the game?
In these lines:
Code
	"numFrames":21,
"frameRate":10,
"alwaysAnimate":"false",

And your weapon needs to be the "_00" of the animation sprites:
Quote
   "everyFrameEffect":"data.scripts.plugins.TraderVariablePowerBlasterEffect",
   "turretSprite":       "graphics/missiles/animation/trader_variant_00.png",
   "hardpointSprite":    "graphics/missiles/animation/trader_variant_00.png",
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #695 on: August 21, 2013, 06:08:19 PM »

Got it, fixed it (workaround) and yes it is a bug... When weapon is set to beam mode then game doesnt suppose that there is going to be animation (when loading game), so it wont load .pngs... tho animation for beam weapons is implemented so then it is trying to render frames that are not loaded (that´s why it disappear)... Work around: Create PROJECTILE weapon, that will load that animation and then just use it in beam weapon (so I just created projectile weapon vs_load_rail that I wont never ever use)... WIN

EDIT: I am not sure if I didn´t lose some of my sanity.. so I am just going to kill few of those pink kitties with shaving blade just to make sure.

Btw: I need to control beam weapon animation through script (pause it for few frames, just it only on beam charging up and such a things) I know it can be done easily for Projectile weapons through implementing EveryFrameWeaponEffect... but I suppose it is going to be pain for beam weapon with BeamEffectPlugin... but let´s see. (actually I suppose the "only" problem will be to prevent beam weapon from animating while it is on cooldown, in case if someone would press fire button... but it is going to be weapon used only by Ai anyway, so not such a big deal I guess)
« Last Edit: August 21, 2013, 06:34:36 PM by Ravendarke »
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #696 on: August 21, 2013, 06:39:20 PM »

Heres an example (i need to update this code but im waiting for 0.6a to do it):

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements BeamEffectPlugin
{  
    // weapon takes 7 seconds to fully charge
    private IntervalUtil weaponcooldownlvl = new IntervalUtil(4.0f, 4.0f);
    
    private static int currentCharge = 0;
    
    private static boolean chargedlvl1 = true;
    private static boolean chargedlvl2 = false;
    private static boolean chargedlvl3 = false;
    private static boolean chargedlvl4 = false;

    @Override
        public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
        {
            ShipAPI ship = beam.getSource();
            if (ship == null)
            {
                return;
            }
            
            AnimationAPI animation = beam.getWeapon().getAnimation();
            WeaponAPI weapon = beam.getWeapon();

                if(ship.isHulk())
                {
                    animation.setFrame(0);
                    animation.pause();
                }
                
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());            
                if(weapon.isFiring())
                {                    
                    weaponcooldownlvl.advance(amount);
                    
                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 1) {
                        chargedlvl2 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 2) {
                        chargedlvl3 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 3) {
                        chargedlvl4 = true;
                    }
                    
                    if(chargedlvl1 && weapon.getCooldownRemaining() == 0)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        //engine.addFloatingText(ship.getLocation(), "Power Level 1",15f,Color.GREEN,weapon.getShip(),0f,0f);
                        chargedlvl1 = false;
                        currentCharge++;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if (chargedlvl2)  
                    {
                        chargedlvl2 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",20f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(6);
                        animation.play();
                    }
                    
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(11);
                        animation.play();
                    }
                    
                    if(chargedlvl4)
                    {
                        chargedlvl4 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",30f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(16);
                        animation.play();
                    }
                    
                    switch (currentCharge)
                    {
                        case 0:
                        {

                            animation.setFrame(0);
                            animation.pause();
                            break;
                        }
                        case 1:
                        {
                            if(animation.getFrame() == 5)
                            {
                                    animation.setFrame(1);
                                    animation.play();
                            }
                            break;
                        }
                        case 2:
                        {
                            if(animation.getFrame() == 10)
                            {
                                animation.setFrame(6);
                                animation.play();
                            }
                            break;
                        }
                        case 3:
                        {
                            if(animation.getFrame() == 15)
                            {
                                animation.setFrame(11);
                                animation.play();
                            }
                            break;
                        }
                        case 4:
                        {
                            if(animation.getFrame() == 20)
                            {
                                animation.setFrame(16);
                                animation.play();
                            }
                            break;
                        }
                    }
                }
                
                if(weapon.getChargeLevel() <= 0.1f && currentCharge > 0)
                {
                    switch (currentCharge)
                    {
                        case 1:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 2:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 3:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 4:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s4_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                    }
                }
    }//advance
}

EDIT: my weapon has    "alwaysAnimate":"false",
« Last Edit: August 21, 2013, 07:17:39 PM by silentstormpt »
Logged

FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #697 on: August 21, 2013, 06:47:20 PM »

Got it, fixed it (workaround) and yes it is a bug... When weapon is set to beam mode then game doesnt suppose that there is going to be animation (when loading game), so it wont load .pngs... tho animation for beam weapons is implemented so then it is trying to render frames that are not loaded (that´s why it disappear)... Work around: Create PROJECTILE weapon, that will load that animation and then just use it in beam weapon (so I just created projectile weapon vs_load_rail that I wont never ever use)... WIN

EDIT: I am not sure if I didn´t lose some of my sanity.. so I am just going to kill few of those pink kitties with shaving blade just to make sure.

Btw: I need to control beam weapon animation through script (pause it for few frames, just it only on beam charging up and such a things) I know it can be done easily for Projectile weapons through implementing EveryFrameWeaponEffect... but I suppose it is going to be pain for beam weapon with BeamEffectPlugin... but let´s see. (actually I suppose the "only" problem will be to prevent beam weapon from animating while it is on cooldown, in case if someone would press fire button... but it is going to be weapon used only by Ai anyway, so not such a big deal I guess)

Guess you were having the same problem as me, but I guess you solved yours lol

Spoiler
Since the reverse burn drive thing I tried didn't work, on to the next one :D


0.54.1a

Modding:
Beam and burst beam weapons can now be animated (but the glow sprite can not, must remain the same for all frames)

Well I tried to make an animated weapon, but the animation part of it doesn't work >>"

Apology for not being able to take consecutive screenshots, Starsector crashes after just one screenshot, So this is how it looks,

Spoiler



[close]

It shows only the first frame, once you fire, the weapon disappears, and the reappears after what probably means it cycled through all the frames.

Code
{
"id":"neutrino_phasedarray2",
"specClass":"beam",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1100,
"turretSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"hardpointSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"numFrames":16,
"frameRate":30,
"turretOffsets":[-80, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[-80, 0],
"hardpointAngleOffsets":[0],
"fringeColor":[212,60,25,255],
"coreColor":[255,255,255,255],
#"glowColor":[212,60,25,235],
"darkCore":false,
"width":50.0,
"textureType":ROUGH,
#"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"],
"textureScrollSpeed":292.0,
"pixelsPerTexel":5.0,
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF,FIGHTER],
"fireSoundOne":"neutrino_heavybeam_firing",
"fireSoundTwo":"beam_heavy_loop",
}

Am I missing something  ???
[close]
Do You mind if I ask to see the .wpn file? I tried it with projectile type, but the beam part of the weapon doesn't work now but I've got the animation part, lol sigh.
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #698 on: August 21, 2013, 07:06:01 PM »

You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).
« Last Edit: August 21, 2013, 07:09:54 PM by Ravendarke »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #699 on: August 21, 2013, 07:32:05 PM »

Ahhh! Thank you for catching that beam-animation-not-loading bug, fixed it up. That's pretty evil.

By the way - beam weapons can have an everyFrameEffect, along with a beamEffect. The difference is that beamEffect will be called for every beam, if the weapon happens to have multiple barrels.
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #700 on: August 21, 2013, 07:51:22 PM »

Ahhh! Thank you for catching that beam-animation-not-loading bug, fixed it up. That's pretty evil.

By the way - beam weapons can have an everyFrameEffect, along with a beamEffect. The difference is that beamEffect will be called for every beam, if the weapon happens to have multiple barrels.

Np. Observation about that BeamEffectPlugin: lets say I have some declared and defined variables for that class. It seems like (not seems, I am pretty sure) engine resets them to their initial values. Point is this: I need  to animate sprite while charging up (done) then after weapon is firing no more, then I need to finish rest of animation and also there is cooldown for this weapon, in which if someone click fire then animation of sprite is played (which I don´t want to). And now I have to chose, I can prevent animation when weapon is on CD, but then I am unable to finish part of animation after weapon stops to fire... (coz I basicaly stop and prevent animation when weapon.isFiring() = false)... I would create a interval and countdown that will prevent animation from stopping for some time after beam is finished with firing but I am afraid that countdown wont work coz it will be always set to it´s initial value... actually not sure if I even can anyhow manipulated with those done in BeamEffectPlugin when the weapon is not actually firing.....

Hmmmm... I should just rewrite as EveryFrame.. :D

Simply: BeamEffectPlugin isn´t called when beam isn´t active, right? (while everyframe should be called on everyframe no matter what is weapon doing... or do I get it wrong?)
« Last Edit: August 21, 2013, 08:15:58 PM by Ravendarke »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #701 on: August 21, 2013, 08:15:44 PM »

Np. Observation about that BeamEffectPlugin: lets say I have some declared and defined variables for that class. It seems like (not seems, I am pretty sure) engine resets them to their initial values.

Almost sounds like you're creating local variables inside the method, rather than data members inside the class. If you look at  com.fs.starfarer.api.impl.combatTachyonLanceEffect (in starfarer.api.zip), it declares some member variables and those certainly don't get reset, or the effect wouldn't work.

If that's not what you're doing, can you post your code here?
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #702 on: August 21, 2013, 08:18:31 PM »

Nope, variables were right, just observation kinda wrong... so new statement:

BeamEffectPlugin isn´t called when beam is actually not active and when it get active next time it will start with initial values of variables.

« Last Edit: August 21, 2013, 08:32:25 PM by Ravendarke »
Logged

FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #703 on: August 21, 2013, 09:03:35 PM »

You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).

Now I got it working, was a little confused, but It's just a second weapon just to load the sprites itself, sneaky. :D

But why is the dilemmas always similar, Just gotta make the animation hold mid way for couple of seconds, and rather not rename 60 frames of... the same thing.
Though Cycerin has a script that does this, idk how to make it work midway instead at the beginning of it.
Logged

Ravendarke

  • Captain
  • ****
  • Posts: 276
  • Nemesis
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #704 on: August 21, 2013, 09:06:05 PM »

You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).

Now I got it working, was a little confused, but It's just a second weapon just to load the sprites itself, sneaky. :D

But why is the dilemmas always similar, Just gotta make the animation hold mid way for couple of seconds, and rather not rename 60 frames of... the same thing.
Though Cycerin has a script that does this, idk how to make it work midway instead at the beginning of it.

If you are talking about pausing animation then that isn´t a problem. But I am not sure that I understand what do you mean.

Edit: got everything working, uploading, result in few minutes :)

Result: http://www.youtube.com/watch?v=Gi18_BVSOFY&feature=youtu.be
« Last Edit: August 21, 2013, 09:22:48 PM by Ravendarke »
Logged
Pages: 1 ... 45 46 [47] 48 49 ... 706