Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 184 185 [186] 187 188 ... 710

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2775 on: March 29, 2016, 10:26:25 PM »

How can the plugin access the skills/skill levels? I haven't found a method in the combatEngineAPI to get that, and I'm guessing you know the easy way :P

I was thinking something like if (Global.getCombatEngine().isInCampaign()) and then Global.getSector().getCharacterData() etc.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2776 on: March 31, 2016, 08:54:33 PM »

How can the plugin access the skills/skill levels? I haven't found a method in the combatEngineAPI to get that, and I'm guessing you know the easy way :P

I was thinking something like if (Global.getCombatEngine().isInCampaign()) and then Global.getSector().getCharacterData() etc.

Right, Global. I totally remembered Global. *cough*

Another question: I added a sensor profile reduction to the navigation skill, but it appears to only work for the player ship. Did I do something silly, or is this actually a bug?

Effect code:
Code: java
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.ShipSkillEffect;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class NavigationEffect2 implements ShipSkillEffect {

public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
stats.getSensorProfile().modifyMult(id, (1f - SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL * level * 0.01f));
}

public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
stats.getSensorProfile().unmodify(id);
}

public String getEffectDescription(float level) {

return "-" + (int)(SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL * level) + "% sensor profile";
}

public String getEffectPerLevelDescription() {
return "" + (int)(SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL) + "%";
}

public ScopeDescription getScopeDescription() {
return ScopeDescription.ALL_SHIPS;
}

}

.skill file:
Code
{
"id":"navigation",
"governingAptitude":"technology",
"effectGroups":[
{
"effects":[
{
"type":"CHARACTER_STATS",
"script":"data.characters.skills.scripts.NavigationEffect1",
},
{
"type":"SHIP",
"script":"data.characters.skills.scripts.NavigationEffect2",
},
]
},
],
}
« Last Edit: March 31, 2016, 08:56:23 PM by Thaago »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2777 on: March 31, 2016, 09:21:15 PM »

In the .skill file, you want type:ALL_SHIPS_IN_FLEET, not SHIP. Type SHIP is for skills that only apply to a ship captained by the person with the skill. ALL_SHIPS_IN_FLEET apply to all ships in the fleet commanded by a person that has the skill.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2778 on: March 31, 2016, 09:22:37 PM »

Ah, stupid mistake it was! Thanks :)
Logged

Liet

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2779 on: April 01, 2016, 01:12:12 PM »

Can anybody tell me how I can get my ship into the actual game world, that is it appears in fleets, shows up in markets? Using a mod folder it's in the game (can read it in codex), but not in the world. I'm using SS+ and Nexerelin. Do I need to edit the data/world faction files in SS+ or SS-core? Thanks for any help.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2780 on: April 01, 2016, 06:32:46 PM »

Can anybody tell me how I can get my ship into the actual game world, that is it appears in fleets, shows up in markets? Using a mod folder it's in the game (can read it in codex), but not in the world. I'm using SS+ and Nexerelin. Do I need to edit the data/world faction files in SS+ or SS-core? Thanks for any help.

You are correct that you need to use .faction files (or rather, this is the easiest way). If I understand you correctly, you already have your own mod that contains the .ship, .variant, and appropriate csv files (and of course its own mod_info.json so that it can be turned on and off in the launcher). You can now make your own data/world/factions/<faction> files to add your ships to whatever factions you want, in whatever roles.

For examples, the following code (in my mod folder/data/world/factions/, called hegemony.faction) will add the "hyperion_Attack" variant to the "fastAttack" role of their faction. It also sets its relative weight to 100, so it should show up a lot! Remember to use variants, not ship names. If I also wanted the hyperion to appear in escorts, I need to add it to that role as well. I believe if it is showing up in fleets, it will show up in the markets (though probably in the military market at high rep only, give the Hyperion's quality :P).
Code
{
"shipRoles":{
"fastAttack":{
"hyperion_Attack":100,
},
},
},

The way json files like the .faction files work is that their contents are merged - see this page for more info: http://fractalsoftworks.com/forum/index.php?topic=5016.0

So in this case "hyperion_Attack":100 is being tacked onto the end of the fastAttack list.
Logged

Polmax

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2781 on: April 08, 2016, 11:03:47 AM »

So im kinda confused , first thing , i do not need a custom .jar file for my mod do i? i mean i can have thye .java of my scripts be compiled during execution , or am i wrong?

snd is im trying to make something really simple , use the OnHitEffect interface to just change the sound of my projectiles when they hit

--code

Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lwjgl.util.vector.Vector2f;

public class AziimobOnHitEffect implements OnHitEffectPlugin {

private static final Vector2f ZERO = new Vector2f();

    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {

            Global.getSoundPlayer().playSound("aziimob_impact", 1f, 1f, point, ZERO);

        }
}

now i have this file in C:\Games\Starsector\mods\Azura Fleet\jars\src\data\scripts\weapons

all the sounds are ready and everything, but everytime i execute it i get error compiling blablabla AziimobOnHitEffect, in the log i get this

Code
10217 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.weapons.AziimobOnHitEffect]
java.lang.RuntimeException: Error compiling [data.scripts.weapons.AziimobOnHitEffect]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.AziimobOnHitEffect
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

so im guessing its not find the .java  , so what am i doing wrong ?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2782 on: April 08, 2016, 06:00:12 PM »

If you want to use Janino (auto-compile Java scripts on runtime), put your script file in [MyMod]/data/scripts[/any subdirectory]. Anything else will need compiling.
Logged

Polmax

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2783 on: April 09, 2016, 03:24:14 AM »

Thank you
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2784 on: April 11, 2016, 06:40:24 AM »

How does the economy handle supply/demand for different commodities with the same demand class?

Spoiler
In Nexerelin, I have "agents" and "saboteurs", which have the marines demand class, the military tag and an utility of 3. They are made only from military bases, which in Nexerelin use a modified class:

Code: java
public class ExerelinMilitaryBase extends MilitaryBase {
public static final float EXTRA_MARINES_MULT = 1.25f; // hax

public void apply(String id) {
super.apply(id);
if (this.market.getFactionId().equals("templars"))
{
market.removeSubmarket(Submarkets.GENERIC_MILITARY);
}
market.getCommodityData(Commodities.MARINES).getSupply().modifyFlat(id, ConditionData.MILITARY_BASE_MARINES_SUPPLY * EXTRA_MARINES_MULT);
market.getCommodityData("agent").getSupply().modifyFlat(id, 1);
market.getCommodityData("saboteur").getSupply().modifyFlat(id, 1);
}

public void unapply(String id) {
super.unapply(id);
market.getCommodityData("agent").getSupply().unmodify(id);
market.getCommodityData("saboteur").getSupply().unmodify(id);
}

}
ConditionData.MILITARY_BASE_MARINES_SUPPLY * EXTRA_MARINES_MULT equals 125, so I'd expect there to be tons of marines and few agents or saboteurs.

Instead I routinely see things like this:


(agents are the blue suits, saboteurs are orange)

Are the agents and saboteurs being overproduced, and/or not being consumed? Can I fix this?
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2785 on: April 11, 2016, 09:09:07 AM »

Do you have lots of demand for marines? If you're setting that somewhere, make sure to also set the non-consuming demand for marines to a high value, so that the demand ends up generating stockpiles instead of consuming the marines entirely.

The actual consumption is based on (demand - nonConsumingDemand), and is distributed among the commodities sharing that demand class proportionally to their total stockpile utility.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2786 on: April 11, 2016, 02:19:11 PM »

Soooo... a few AI-related questions, dealing with some final polish issues I'm having before I (finally) release a Vanilla-compliant AI project I've been gradually messing with.

1.  How is the engine spawning MIRV projectileSpecs?

Because, well, it's not doing it by spawnProjectile(), unless there is a .wpn inherent to every .proj with a specific naming convention that I don't know about, lol. 

I need a method to deal with that, because the MissileAI is supposed to handle that behavior somehow, not the .proj, apparently.  So if I want to handle that generically in an AI, I need to know how to trigger it or produce the projectiles.

2.  I have a probably-stupid one about JSON parsing and Drones in general.

How do I parse the droneBehavior to get the values out of the sub-objects, and how do I get a Drone's index number?

i.e., I want to get the Drone's index number, realize it's 0, and get the behavior per:

Spoiler
   "droneBehavior":[
      {"droneIndex":[0],
       "defaultFacing":"MATCH_SHIP_FACING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":0,
       "freeRoamRange":150,
       "targetPriority":[FIGHTER, SHIP],
       "initialOrbitAngle":60,
       "orbitRadius":-100,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
[close]
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2787 on: April 12, 2016, 02:11:06 PM »

It's using spawnProjectile. The weapon passed in is the weapon that fired the original missile.



2.  I have a probably-stupid one about JSON parsing and Drones in general.

How do I parse the droneBehavior to get the values out of the sub-objects, and how do I get a Drone's index number?

i.e., I want to get the Drone's index number, realize it's 0, and get the behavior per:

Spoiler
   "droneBehavior":[
      {"droneIndex":[0],
       "defaultFacing":"MATCH_SHIP_FACING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":0,
       "freeRoamRange":150,
       "targetPriority":[FIGHTER, SHIP],
       "initialOrbitAngle":60,
       "orbitRadius":-100,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
[close]

No good way to get the index - added a getIndex() method to DroneLauncherShipSystemAPI. For now, your best bet would be to get the list of all drones for a given mothership, and then sort them according to their order in the list returned by CombatEngineAPI.getAllShips(). Note that the index will change as drones get destroyed.

For how to parse it, you've got the JSONObject returned by DroneLauncherShipSystemAPI.getSpecJson(), right? From there it's just using the varius getJSONArray()/getJSONObject() etc methods. Something like:

JSONArray behaviors = json.getJSONArray("droneBehavior");
for (int i = 0; i < behaviors.length(); i++) {
   JSONObject behavior = behaviors.getJSONObject(i);
   // read the details of the behavior here
}
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2788 on: April 12, 2016, 06:38:05 PM »

Quote
It's using spawnProjectile. The weapon passed in is the weapon that fired the original missile.
Ah.  Will test that.  It'd be good to get that under my AI.

I'll look at the drone / JSON issue; that sounds like it might be a bit more work (and more computationally expensive) than I'd like to tackle for the first release, as it'd have to get updated quite often.  It's a minor issue anyhow; fixed-formation Drones don't get used much in Vanilla.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

shuul

  • Ensign
  • *
  • Posts: 42
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #2789 on: April 13, 2016, 01:03:56 AM »

Is it possible to create fighter wing with only one fighter in it?
Logged
Pages: 1 ... 184 185 [186] 187 188 ... 710