Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 167 168 [169] 170 171 ... 710

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

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2520 on: December 05, 2015, 03:14:30 PM »

I wanted so much a ship who need so many fleets points for deployement and low supply/rec...

I cannot have big supply/rec  and then, for  calcul for "fleet repair" in campaign and decreases price with my faction?

If we can give salary per month with Nexerelin, i need search if i cannot reduce price of maintenance '.'

Quote
Low supply/rec could be a problem in general - it may encourage deploying more of these ships vs weak enemy forces so they take no hull damage and remain cheap to deploy.
If i up cost CR,  it will compensate,no?

...

Yeah, i think  your idea is better. I need just find this script who restore CR based on hull damage taken. Pirate are always happy after have win loot. (Like i want just use less supplies with my faction because 30 supplies per day just for one destroyer...)
« Last Edit: December 05, 2015, 03:32:09 PM by Snrasha »
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

kazi

  • Admiral
  • *****
  • Posts: 714
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2521 on: December 05, 2015, 04:43:13 PM »

How do I start a system bounty at a specific target?

Right now I'm trying to use:

Code
sector.getEventManager().startEvent(new CampaignEventTarget(ilk1.getMarket()), "system_bounty", null);

but have no idea what to put in the "param" argument (since it's just "java.lang.object param" in the documentation).

*edit - nvm got it, was being dumb with when I was spawning the event (the sector hadn't been created yet).
« Last Edit: December 05, 2015, 05:30:02 PM by kazi »
Logged

shuul

  • Ensign
  • *
  • Posts: 42
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2522 on: December 06, 2015, 06:05:53 AM »

Hey guys, trying to make a script for gun to apply extra damage when only shield is hit, but it is not working. help?
Spoiler
@Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {

        if (shieldHit = true) {              // Apply extra kintetic damage
            engine.applyDamage(
                    target,
                    point,
                    projectile.getWeapon().getDamage().getDamage(),
                    DamageType.KINETIC,
                    1000f,
                    false,
                    false,
                    projectile.getSource()
            );


        }
    }
[close]
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2523 on: December 06, 2015, 07:14:34 AM »

Three things:
if(shieldHit) is enough to check if a boolean is true. And for example if(!shieldHit) check if it's false.

Emp damage does nothing to shields, you can remove it.

And finally you should use projectile.getDamageAmount() to get the damage.
Logged
 

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2524 on: December 06, 2015, 07:48:07 AM »

I have this, no problem, functionnal hullmod who give 3 food per day(  Eh, Supplies is not only food.)
Code
package data.hullmods;  
 
import com.fs.starfarer.api.Global; 
import com.fs.starfarer.api.combat.BaseHullMod; 
import com.fs.starfarer.api.fleet.FleetMemberAPI; 
import com.fs.starfarer.api.impl.campaign.ids.Commodities; 
import com.fs.starfarer.api.util.IntervalUtil;
public class Lt_PortableFarm extends BaseHullMod { 


   protected IntervalUtil interval = new IntervalUtil(1,1); 
     
   @Override 
   public void advanceInCampaign(FleetMemberAPI member, float amount) { 
      float days = Global.getSector().getClock().convertToDays(amount); 
      interval.advance(days); 
      if (interval.intervalElapsed()) 
      { 
        float food = 3;
        member.getFleetData().getFleet().getCargo().addCommodity(Commodities.FOOD, food);     
      }
   } 

But: I want a hullmod as this who give depending on the size of the vessel for just do not create a hullmod for each hullsize.
Code
package data.hullmods;  
 
import com.fs.starfarer.api.Global; 
import com.fs.starfarer.api.combat.BaseHullMod; 
import com.fs.starfarer.api.fleet.FleetMemberAPI; 
import com.fs.starfarer.api.impl.campaign.ids.Commodities; 
import com.fs.starfarer.api.util.IntervalUtil; 
 
public class Lt_PortableFarm extends BaseHullMod { 
     
   public static final float FOOD_FRIGATE = 1; 
   public static final float FOOD_DESTROYER = 2; 
   public static final float FOOD_CRUISER = 4; 
   public static final float FOOD_CAPITAL = 8; 
     
   protected IntervalUtil interval = new IntervalUtil(1,1); 
     
   @Override 
   public void advanceInCampaign(FleetMemberAPI member, float amount) { 
      float days = Global.getSector().getClock().convertToDays(amount); 
      interval.advance(days); 
      if (interval.intervalElapsed()) 
      { 
         float food = 0; 
         switch (member.getHullSpec().getHullSize()) { 
            case FRIGATE:
               food = FOOD_FRIGATE; 
               break; 
            case FIGHTER: 
               food = FOOD_FRIGATE; 
               break; 
            case DESTROYER: 
               food = FOOD_DESTROYER; 
               break; 
            case CRUISER: 
               food = FOOD_CRUISER; 
               break; 
            case CAPITAL_SHIP: 
               food = FOOD_CAPITAL; 
               break; 
         } 
         member.getFleetData().getFleet().getCargo().addCommodity(Commodities.FOOD, food); 
      } 
   } 

But, i have this error: Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/LT_PortableFarm.java', Line 25, Column 16: Assignment conversion not possible from type "com.fs.starfarer.api.combat.ShipAPI$HullSize" to type "int"


PS: this hullmod was created by Histidine and I asked him too.

Why i have this error, so? Thank '.'
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

shuul

  • Ensign
  • *
  • Posts: 42
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2525 on: December 06, 2015, 07:57:38 AM »

Three things:
if(shieldHit) is enough to check if a boolean is true. And for example if(!shieldHit) check if it's false.

Emp damage does nothing to shields, you can remove it.

And finally you should use projectile.getDamageAmount() to get the damage.

thanks!
But were did you see EMP damage in my example?
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2526 on: December 06, 2015, 08:12:25 AM »

            engine.applyDamage(
                    target,
                    point,
                    projectile.getWeapon().getDamage().getDamage(),
                    DamageType.KINETIC,
                    1000f,
                    false,
                    false,
                    projectile.getSource()
            );
This is EMP damage. I cannot recomend enough using an IDE. It can display help popups and check you code for obvious mistakes.
Logged
 

TJJ

  • Admiral
  • *****
  • Posts: 1905
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2527 on: December 06, 2015, 08:47:12 AM »


/snip

But, i have this error: Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/LT_PortableFarm.java', Line 25, Column 16: Assignment conversion not possible from type "com.fs.starfarer.api.combat.ShipAPI$HullSize" to type "int"

That's an error coming from the Janino compiler.
Something about the enum switch it doesn't like.
Perhaps a bug in Janino, as it's supposed to support Java 1.5 enum switches.

Though you appear to have a filename case mismatch too, which might be contributing to the problem.
The class "Lt_PortableFarm" is defined in the file "LT_PortableFarm.java". (Note "Lt_" vs "LT_".)
The Java class file format & compiler require the two to be identical. (it's possible Janino doesn't explicitly check for this, and consequently fails at a later unrelated compilation step).

If correcting that mismatch doesn't fix it, I'd try tweaking the code to see if it's a bug in Janino's compiler that can be avoided.
e.g.
1) Try re-ordering the case statements.
2) Try adding the missing "case DEFAULT:" and/or add a "default:" case too.
3) Try assigning the hullsize to a local variable & switching on that instead.

Worst case scenario; avoid using the Janino compiler completely by compiling the class yourself.
« Last Edit: December 06, 2015, 08:49:10 AM by TJJ »
Logged

shuul

  • Ensign
  • *
  • Posts: 42
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2528 on: December 06, 2015, 09:34:29 AM »


This is EMP damage. I cannot recomend enough using an IDE. It can display help popups and check you code for obvious mistakes.

But Im using IntellijIDEA, not really experienced user, is there a way to set-up help popups?
Spoiler
[close]

EDIT: ok, it seems I didn't get it. Isn't it says damage.KINETIC? how can I change emp damage to kinetic then?
« Last Edit: December 06, 2015, 11:55:36 PM by shuul »
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2529 on: December 06, 2015, 09:49:32 AM »

Ok TJJ. Not a error of LT/Lt (I have copy a old error).

Not a error a case DEFAULT, i have test.
After, i can always create juste X hullmod for all, ah ah.

Thank.

EDIT: Fine now '.' .
« Last Edit: December 06, 2015, 11:11:16 PM by Snrasha »
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

shuul

  • Ensign
  • *
  • Posts: 42
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2530 on: December 07, 2015, 05:12:14 AM »

Im not sure on this one:

do scripts work if you place them in mod folder as .java?
Or they has to be compiled into jre?
Logged

Stalker

  • Lieutenant
  • **
  • Posts: 65
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2531 on: December 07, 2015, 06:35:50 AM »

Im not sure on this one:

do scripts work if you place them in mod folder as .java?
Or they has to be compiled into jre?

A question I can answer! :D

They work as *.java. They have to be under data/scripts in the appropriate folder (if applicable).

Compiling into a *.jar should be done for release, but doesn't have to be if you're just doing development.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2532 on: December 07, 2015, 07:02:46 AM »

Not exactly. .java files are compiled by the game's compiler Janino. That's quite enough for most cases. However there a some Java functions that Janino doesn't support, then you have to pre-compile your code in a jar to bypass janino. That also decrease the loading time since the game doens't have to do that. There are also some useful functions that comes with compiling, like modifying your code while the game is running.
Logged
 

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2533 on: December 07, 2015, 07:58:41 AM »

There are also some useful functions that comes with compiling, like modifying your code while the game is running.

Wat????
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2534 on: December 07, 2015, 02:50:19 PM »

Hey, i have question: Why i need so many supplies with my faction?
Spoiler

[close]

51 supplies per day for just a capital_ship? (It is correct value?)


I need less supply per day, if i give less hull and more armor, no?
« Last Edit: December 08, 2015, 01:30:58 AM by Snrasha »
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.
Pages: 1 ... 167 168 [169] 170 171 ... 710