Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 236 237 [238] 239 240 ... 710

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

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3555 on: September 03, 2017, 02:45:24 AM »

Getting this
Code
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.ship.A.if.startedChargeup(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.OoOO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.OoOO.String(Unknown Source)
at com.fs.starfarer.combat.entities.ship.A.if.advance(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

each time i try to test fire a weapon i'm making for a private mod
.wpn file looks like
Code
{
"id":"ADF_PC",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"LARGE",
"turretSprite":"graphics/weapons/ADF_PC.png",
"hardpointSprite":"graphics/weapons/ADF_PC.png",
"turretOffsets":[8.5, 0.5],
"turretAngleOffsets":[0],
"hardpointOffsets":[8.5, 0.5],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",
"muzzleFlashSpec":{
"length": 75,
    "particleColor": [100,150,255,255],
    "particleCount": 30,
    "particleDuration": 2,
    "particleSizeMin": 3,
    "particleSizeRange": 4,
    "spread": 20
  },
"autocharge":true,  # whether the weapon will continue charging and fire if the LMB is tapped instead of held
"projectileSpecId":"ADF_PC_shot",  # projectile that will be fired
"fireSoundOne":"ADF_PC_CHARGE",
"firesoundTwo":"ADF_PC_FIRE",
}
.proj file looks like
Code
{
"id":"ADF_PC_shot",
"specClass":"projectile",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
"length":53.0,
"hitGlowRadius":400,
"width":21.0,
"fadeTime":0.20,
"fringeColor":[96,208,240,200],
"coreColor":[96,208,240,200],
"textureScrollSpeed":64.0,
"pixelsPerTexel":5.0,
"bulletSprite":"graphics/missiles/ADF_PC_SHOT.png",

}
and the .csv entry looks like
Code
Godbreaker	ADF_PC	3			2000		60000	65000	1000	0		1			ENERGY	10000		4.8	60			0	0	0	0		12000			400	SYSTEM, SHOW_IN_CODEX		
Yes, it's supposed to be that ridiculously powerful, it's made for crushing battlestations.
Any way to fix it?
-Edit: It works if i comment out the first sound effect, but neither one plays.
« Last Edit: September 03, 2017, 03:37:05 AM by Tufted Titmouse »
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3556 on: September 04, 2017, 07:22:53 PM »

Is there any way to stop the battle before the battle occured?
And, how to make a fleet change faction when it come close to another hostile faction's fleet?
Logged
My mods


bananana

  • Commander
  • ***
  • Posts: 228
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3557 on: September 06, 2017, 11:21:07 PM »

sup.
about lasers. the guardian PD has attribute "convergeOnPoint": true
i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.
if not, does anyone have a suggestion on to how such a vveapon should behave? (2 barrels vvith about 500px spacing betvveen)
Logged
Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
i do NOT want to see my name appear in the credits section of any published mod and will consider it a personal insult.

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3558 on: September 07, 2017, 12:30:31 AM »

i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.

I think by default beams like this will always converge to the first offset coordinates set, so in order to get them to converge directly in the center you'd need a third beam (with its offset specified first in the array) firing from the middle of the ship.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3559 on: September 07, 2017, 08:42:59 AM »


Why does the game complain hullSize is unknown variable or Type?

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class VNSArmorRepair extends BaseHullMod
{
    private static final float ARMOR_REPAIRED_PER_SECOND = 5f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 10f);
mag.put(HullSize.FRIGATE, 5f);
mag.put(HullSize.DESTROYER, 3f);
mag.put(HullSize.CRUISER, 2f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

    @Override
    public void advanceInCombat(ShipAPI ship, float amount)
    {
        // Grab the ship's armor grid and raw armor values
        final ArmorGridAPI armor = ship.getArmorGrid();
        final float[][] grid = armor.getGrid();

        // Calculate how much armor to repair per cell this frame
        // Armor per cell is NOT the same as the listed armor rating, so we have
        // to compensate by dividing max armor per cell by the 'actual' rating
        // This means 5 armor per second might only be ~0.3 armor per cell

        final float maxArmor = armor.getMaxArmorInCell(),
                toHeal = ((Float) mag.get(hullSize)) * amount * (maxArmor / armor.getArmorRating());


// If you want to repair a percentage of total armor per second instead, just change toHeal's value to
//toHeal = maxArmor * (ARMOR_REPAIRED_PER_SECOND / 100f) * amount.

        // Iterate over all armor cells and add repairs to their current value
        for (int x = 0; x < grid.length; x++)
        {
            for (int y = 0; y < grid[0].length; y++)
            {
                armor.setArmorValue(x, y, Math.min(grid[x][y] + toHeal, maxArmor));
            }
        }
    }
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getFluxDissipation().modifyPercent(id, -20f);
}


}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3560 on: September 07, 2017, 09:16:23 AM »

Is there any way to stop the battle before the battle occured?

Depends on exactly what you mean. You can provide your own implementation of FleetInteractionDialogPluginImpl, though, which means you could do just about anything in theory.

And, how to make a fleet change faction when it come close to another hostile faction's fleet?

See: com.fs.starfarer.api.impl.campaign.SmugglingFactionChangeScript


i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.

I think by default beams like this will always converge to the first offset coordinates set, so in order to get them to converge directly in the center you'd need a third beam (with its offset specified first in the array) firing from the middle of the ship.

Yeah, exactly. The whole thing is a bit of a hack.
Logged

Nicke535

  • Commander
  • ***
  • Posts: 240
  • Degenerate Core
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3561 on: September 07, 2017, 10:15:09 AM »


Why does the game complain hullSize is unknown variable or Type?

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class VNSArmorRepair extends BaseHullMod
{
    private static final float ARMOR_REPAIRED_PER_SECOND = 5f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 10f);
mag.put(HullSize.FRIGATE, 5f);
mag.put(HullSize.DESTROYER, 3f);
mag.put(HullSize.CRUISER, 2f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

    @Override
    public void advanceInCombat(ShipAPI ship, float amount)
    {
        // Grab the ship's armor grid and raw armor values
        final ArmorGridAPI armor = ship.getArmorGrid();
        final float[][] grid = armor.getGrid();

        // Calculate how much armor to repair per cell this frame
        // Armor per cell is NOT the same as the listed armor rating, so we have
        // to compensate by dividing max armor per cell by the 'actual' rating
        // This means 5 armor per second might only be ~0.3 armor per cell

        final float maxArmor = armor.getMaxArmorInCell(),
                toHeal = ((Float) mag.get(hullSize)) * amount * (maxArmor / armor.getArmorRating());


// If you want to repair a percentage of total armor per second instead, just change toHeal's value to
//toHeal = maxArmor * (ARMOR_REPAIRED_PER_SECOND / 100f) * amount.

        // Iterate over all armor cells and add repairs to their current value
        for (int x = 0; x < grid.length; x++)
        {
            for (int y = 0; y < grid[0].length; y++)
            {
                armor.setArmorValue(x, y, Math.min(grid[x][y] + toHeal, maxArmor));
            }
        }
    }
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getFluxDissipation().modifyPercent(id, -20f);
}


}

I can immidiately see 2 things:

1. At "final float maxArmor = armor.getMaxArmorInCell()," (row 38, I think) the line ends in a comma, not a semicolon

2. In the "advanceInCombat" function the hullSize variable is, indeed, an unknown variable. The function passes in a ShipAPI, but not the ships hullSize directly. To fix this, you would need to add:
Code
HullSize hullSize = ship.getHullSize();
inside the function. It also has to be before you try to call it (row 39, I think?).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3562 on: September 07, 2017, 01:48:48 PM »

(Seriously, use an IDE. At this point you've spent *way* more time on errors that wouldn't happen if you had one, and if you set one up, you'll probably learn something generally-useful as well.)
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3563 on: September 07, 2017, 04:50:12 PM »

@Tufted Titmouse: Just to quickly check, do you have the corresponding sounds.json entries set up?
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 69
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3564 on: September 08, 2017, 04:07:10 AM »

@Tufted Titmouse: Just to quickly check, do you have the corresponding sounds.json entries set up?

There's supposed to be a sounds.json? Where does it go?
Nevermind, i found it, Will fix


-edit Nope, That didn't fix it
@Histidine
« Last Edit: September 08, 2017, 04:32:19 AM by Tufted Titmouse »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3565 on: September 08, 2017, 11:01:28 AM »

(Seriously, use an IDE. At this point you've spent *way* more time on errors that wouldn't happen if you had one, and if you set one up, you'll probably learn something generally-useful as well.)

I know. I got it and i reported that toHeal doesn't have a type (should be float).

But one thing hat I can't figure out, since this isn't my code, someone else wrote it - where the hell is "amount" defined?
It is called as a variable, but I see nothing defining it....

EDIT: Nevermind. Module works now.
« Last Edit: September 08, 2017, 11:43:02 AM by TrashMan »
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3566 on: September 08, 2017, 11:30:56 AM »



See: com.fs.starfarer.api.impl.campaign.SmugglingFactionChangeScript


Thanks a lot! And I found that, if one fleet addAssignment(FleetAssignment.GO_TO_LOCATION, somewhere, 30f), it may stop  in the half way and the fleet would try to catch nearby hostile fleet, ignoring the assignment what i have gived. Is there anyway to make AI fleets concertrate on my assignments?
Logged
My mods


Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3567 on: September 09, 2017, 08:27:30 PM »

2 things:

1) Anyone using intellij know why recompiling would add 100mb each compile despite no script changes?? My jar is now at 1.2 gb from relatively minor scrip cleanup and other small changes. At this point netbeans is looking way more attractive... >:(

2) I'm looking for a way to call a memory map variable in a script to check for "easymode"

something like:

Code
       easyMode = memoryMap.get(MemKeys.GLOBAL).getBoolean("$EasyStart");

Can't find the variable in a dump anywhere in the campaign.

Even just pointing to a class or script that contains it would be good enough.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3568 on: September 09, 2017, 10:09:16 PM »

2) I'm looking for a way to call a memory map variable in a script to check for "easymode"

com.fs.starfarer.api.util.Misc.isEasy()
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3569 on: September 09, 2017, 11:33:01 PM »

com.fs.starfarer.api.util.Misc.isEasy()

Thank you! Worked perfectly!
Logged
Pages: 1 ... 236 237 [238] 239 240 ... 710