Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 32 33 [34] 35 36 ... 710

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

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #495 on: May 02, 2013, 02:28:20 PM »

Check that the image has been saved with a bit depth greater than 8
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)

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #496 on: May 02, 2013, 03:45:50 PM »

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

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

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

public class PodshipHomingPlasmoid implements EveryFrameCombatPlugin
{

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

        for (Iterator allMissiles = engine.getMissiles().iterator();
                allMissiles.hasNext();)
        {
            MissileAPI plasmoid = (MissileAPI) allMissiles.next();
                
            if(plasmoid.isFizzling())
            {
                if(SHELL_ID_1.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_2, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_2.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_3, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_3.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_4, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else {
                    return;
                }
            }  
        }
    }//advance
}//class

Wow, honestly I could use that as well, you guys are amazing.
Logged

TrashMan

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

Check that the image has been saved with a bit depth greater than 8

I did, that wasn't the problem.
And for some reason the ships started working. Funnily enough, I had to open them in the editor and re-save them. Why did that work?
Your guess is as good as mine....
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #498 on: May 03, 2013, 12:06:16 AM »

No idea mate, it happens to me often, just shrug it off
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)

Upgradecap

  • Admiral
  • *****
  • Posts: 5422
  • CEO of the TimCORP
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #499 on: May 03, 2013, 01:53:50 AM »

Probably because the editor might've gotten stuck or written to the file incorrectly.
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #500 on: May 04, 2013, 12:50:17 PM »

Alrighty, while trying implement a suggestion from strompt I've hit a bit of a brick wall and I'm not entirely certain how to proceed.  Getting the following error:

Code
[Thread-6] ERROR com.fs.starfarer.combat.O0OO  - java.lang.ClassCastException: data.scripts.weapons.WavebeamMaster cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
java.lang.ClassCastException: data.scripts.weapons.WavebeamMaster cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
at com.fs.starfarer.loading.specs.dosuper.õo0000(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.oooO.<init>(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.title.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.title.oOOO.String(Unknown Source)
at com.fs.starfarer.title.oOOO.String(Unknown Source)
at com.fs.starfarer.title.oOOO.super(Unknown Source)
at com.fs.starfarer.combat.super.OoOO.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.title.B.o00000(Unknown Source)
at com.fs.starfarer.super.this.do$super(Unknown Source)
at com.fs.A.super.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

From firing this code:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI;

public class WavebeamMaster implements EveryFrameWeaponEffectPlugin
{
    private ShipAPI ship;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused()) {
            return;
        }
       
        {
            if(weapon.isFiring())
            {
                engine.spawnProjectile(ship, weapon, "ms_1wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                engine.spawnProjectile(ship, weapon, "ms_2wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                engine.spawnProjectile(ship, weapon, "ms_3wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
            }
        }
    }
   
}

The error is not entirely clear, and netbeans is giving the script its okay, which is making figuring out what's wrong a bit too tricky for me.  Any ideas?
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #501 on: May 04, 2013, 01:05:10 PM »

instead of declaring the ship outside the advance declare it inside and then using the weapon, get ur ship object:

ShipAPI ship = weapon.getShip();

Also be very careful how your spawning projectiles using when weapon.IsFiring();
Heres an example of a code, that while its not perfect, it shows how many conditions i had to go tro with just so it only spawned the right projectile at the right time:

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;

        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 = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                   
                    if (chargedlvl2)   
                    {
                        chargedlvl2 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        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 = 2;
                        animation.setFrame(6);
                        animation.play();
                    }
                   
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        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 = 3;
                        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 = 4;
                        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)
                {
                    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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                    }       
                }
    }//advance
}
« Last Edit: May 04, 2013, 01:08:54 PM by silentstormpt »
Logged

TrashMan

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

AAAAAAAAAAAAArgh.....

Code
7921 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error compiling [data.scripts.world.corvus.Corvus]
java.lang.RuntimeException: Error compiling [data.scripts.world.corvus.Corvus]
at com.fs.starfarer.loading.scripts.ScriptStore$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: Compiling unit "data/scripts/world/corvus/Corvus.java"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:212)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more
[b]Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/world/corvus/xleattackSpawnPoint.java" does not declare class "data.scripts.world.corvus.xleattackSpawnPoint"[/b]


WTFUQ?
How the hell does it not contain?


This is the XLEattackSpawnPoint.java
Code
package data.scripts.world.corvus;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import data.scripts.world.BaseSpawnPoint;

public class XLEattackSpawnPoint extends BaseSpawnPoint {

private final SectorEntityToken station;

public XLEattackSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor, SectorEntityToken station) {
super(sector, location, daysInterval, maxFleets, anchor);
this.station = station;
}

@Override
protected CampaignFleetAPI spawnFleet() {


String type = null;
float r = (float) Math.random();
if (r > .5f) {
type = "scouts";
} else {type = "armada";}


CampaignFleetAPI fleet = getSector().createFleet("XLE", type);
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);


if (type.equals("scouts")) {
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
} else {
fleet.addAssignment(FleetAssignment.ATTACK_LOCATION, station, 50);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
}

return fleet;
}

}


This is in the Corvus.java
Code
				//XLE strike force
XLEattackSpawnPoint xleattackSpawn = new xleattackSpawnPoint(sector, system, 20, 1, RSFStation, VNSStation);
system.addSpawnPoint(xleattackSpawn);
for (int i = 0; i < 2; i++)
xleattackSpawn.spawnFleet();



The XLE have their fleets,, relatiosn are set to hostile...WWWTTTFFF????
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #503 on: May 04, 2013, 03:05:13 PM »

@MShadowy: That source file looks good (except for the ship thing), I don't see why you're getting that error. Tried it myself and it works (again, aside from the ship always being null.) I'd make sure that you're actually running the game with the files you think you're running the game with. A quick way to make sure would be to totally mangle that file so it doesn't compile and make sure the game reflects that (i.e., doesn't even start).

@TrashMan: Language, sir. (Filenames and class names are case sensitive in Java.)
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #504 on: May 04, 2013, 06:28:13 PM »

Well, I have the code working now, but the shots keep desynching.  Fiddling with the floating values just changes when they desynch, so I'm putting the idea off for now.
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #505 on: May 05, 2013, 01:21:08 PM »

Ive made the Trader weapon using the Beam as you have suggested Alex, my problem now is, when it stops firing it should "release" the projectile. it seems that !weapon.IsFiring() doesnt work for this, you know any other method to do this?

Heres my code right now (everything's working fine, that includes the animation since they are running blow 30 frames), while i use the weapon.getChargeLevel() to pick up the beam going down, it also means it will spawn quite a few shots before it actually passes that condition:

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;

        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 = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if (chargedlvl2)  
                    {
                        chargedlvl2 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        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 = 2;
                        animation.setFrame(6);
                        animation.play();
                    }
                    
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        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 = 3;
                        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 = 4;
                        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)
                {
                    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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            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.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                    }        
                }
    }//advance
}

2nd Question:
Ive got very little experience with movement vectors, and its one of my main problems i got since i need to change the actual ship movement on SS to be like SC2, my main issues are with the Probe, its movement is in the diagonal so up, down, left and right would be 45º, 225º , 315º, 135º. they also dont "reverse" movement, so pressing back would only make them stop and not reverse.
If the Probe movement was actually replicated the Skiff movement would be literally a copy/paste.
« Last Edit: May 07, 2013, 06:40:15 AM by silentstormpt »
Logged

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #506 on: May 10, 2013, 01:41:34 PM »

I've got a quick question: is there any way to get the ShipAPI object from a CombatEntityAPI object, assuming the combat entity is an instance of ShipAPI? I've tried quite a few things, and just when I think something should work just fine, I get this when I shoot my beam weapon:



Spoiler
Code
39601 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.VerifyError: (class: data/asc/weapons/mhyp_effect, method: advance signature: (FLcom/fs/starfarer/api/combat/CombatEngineAPI;Lcom/fs/starfarer/api/combat/BeamAPI;)V) Register 7 contains wrong type
java.lang.VerifyError: (class: data/asc/weapons/mhyp_effect, method: advance signature: (FLcom/fs/starfarer/api/combat/CombatEngineAPI;Lcom/fs/starfarer/api/combat/BeamAPI;)V) Register 7 contains wrong type
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.fs.starfarer.loading.scripts.ScriptStore.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.supersuper.ÕÓ0000(Unknown Source)
at com.fs.starfarer.combat.entities.BeamWeaponRay.<init>(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.õO0000(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.createBeam(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.return.super(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.o0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.o0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.return.super(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.advance(Unknown Source)
at com.fs.starfarer.combat.systems.WeaponGroup.String(Unknown Source)
at com.fs.starfarer.combat.systems.WeaponGroup.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.super(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.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)
[close]


Here's the problematic code in question:


Spoiler
Code
		   ShipAPI ship;
   ShipAPI tmp;
   
   for (Iterator iter = engine.getShips().iterator(); iter.hasNext();) {

tmp = (ShipAPI) iter.next();

if (tmp.getLocation() == target.getLocation()) { //If these two entities are in exact same location, then they're obviously the same ship. Also, target is a CombatEntityAPI object.
ship = tmp;
break;
}

}


//Here's what causes the crash on firing the beam. Technically, none of this should even be ran, as it's only supposed to be ran if the beam is actually hitting a ship. I'm using the same requirements for the tachyon lance's every frame effect.
FluxTrackerAPI flux = ship.getFluxTracker();
flux.forceOverload(2.0f);

[close]


Any help would be greatly appreciated.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #507 on: May 10, 2013, 01:58:04 PM »

This looks like a bug with Janino, the error is being thrown because the compiled bytecode it generates is invalid, so it doesn't even get to run.

I've seen this before, too. I think if you make sure to initialize all variables, it'll get around the issue. Alternatively, you could bite the bullet, set up an IDE, and use jar files for your code, sidestepping on-startup compilation via Janino entirely.

Spoiler

         ShipAPI ship;
         ShipAPI tmp;
         
         for (Iterator iter = engine.getShips().iterator(); iter.hasNext();) {
         
         tmp = (ShipAPI) iter.next();
         
            if (tmp.getLocation() == target.getLocation()) { //If these two entities are in exact same location, then they're obviously the same ship. Also, target is a CombatEntityAPI object.
               ship = tmp;
               break;
            }
            
         }
         
         
         //Here's what causes the crash on firing the beam. Technically, none of this should even be ran, as it's only supposed to be ran if the beam is actually hitting a ship. I'm using the same requirements for the tachyon lance's every frame effect.
            FluxTrackerAPI flux = ship.getFluxTracker();
            flux.forceOverload(2.0f);

            
[close]
So, in the above, change it to
ShipAPI ship = null;
ShipAPI tmp = null;
Btw, when you're using == to compare locations, what's happening is you're comparing that the objects (Vector2f for each location) are the same, not that the objects' contents are the same. In this case, that's actually what you want, but using if (tmp == target) would make more "sense".

(Also: code tags in spoliers don't work so well. [pre][/pre] tags seem to work better.)
Logged

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #508 on: May 10, 2013, 02:48:14 PM »

Huh, that's an odd bug. Your suggestion worked perfectly though; thank you.

Btw, when you're using == to compare locations, what's happening is you're comparing that the objects (Vector2f for each location) are the same, not that the objects' contents are the same. In this case, that's actually what you want, but using if (tmp == target) would make more "sense".
Oh, cool, good to know that works. I was in "Oh god everything is crashing let's not try to do anything that might not work" mode when I was tinkering with this.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #509 on: May 10, 2013, 06:34:50 PM »

Glad that worked. Barely remembered it from a previous time (searching on the forum turned up nothing, guess it was via PM - a good argument for keeping questions to the forum rather than PMs...)

It was a rather odd one, yeah. Janino has some ... issues. It mostly works, and it's nice for a lower barrier-to-entry for some of the scripting, but I've pretty much entirely moved away from using scripts from new dev because of it, and its lack of support for a few things like generics and anonymous classes. Putting new moddable stuff inside an impl package in starfarer.api.jar, with the source code being available in starfarer.api.zip. (A current example would be the on-hit script for the Tachyon Lance, and other such.)

Oh, cool, good to know that works. I was in "Oh god everything is crashing let's not try to do anything that might not work" mode when I was tinkering with this.

Ah yes, I'm quite familiar with that :)
Logged
Pages: 1 ... 32 33 [34] 35 36 ... 710