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)

Author Topic: How to add a campaign ability?  (Read 4333 times)

hqz

  • Lieutenant
  • **
  • Posts: 73
    • View Profile
How to add a campaign ability?
« on: March 23, 2016, 01:50:23 PM »

I just want a button in the ability bar for an action that is instantaneous, i.e. no cooldown, the player clicks on it and it displays some message.

But I can't manage to make it work. I can't even get a copy of an existing ability to work.

mod_info.json
Code
{
    "id": "mod-examples",
    "name": "Mod Examples",
    "author": "hqz",
    "version": "1",
    "description": "Examples",
    "gameVersion": "0.7a",
    "jars": [],
}

data/campaign/abilities.json
Code
{
  "example_ability":{
    "plugin":"com.fs.starfarer.api.impl.campaign.abilities.SensorBurstAbility",
    "unlockedAtStart":true,
    "defaultForAIFleet":false,
    "sortOrder":500,

    "musicSuppression":0,
    "uiOn":"ui_sensor_burst_on",
    "worldOn":"world_sensor_burst_on",
  },
}

Note: these are the 2 only files in the mod. I'm trying to keep it simple so that I'm sure it's not some side effect from something else messing with my ability.

If I make a deliberate error in the ability definition (e.g. wrong class name), the game crashes, which means it somehow registers that an ability is defined. But it never shows up in the ability bar in game.

I've read the code from other mods and I don't see what I'm doing differently.
e.g. ExerelinCore/exerelin/campaign/abilities/FollowMeAbility.java

What am I missing here?
Logged

Harpuea

  • Lieutenant
  • **
  • Posts: 58
    • View Profile
Re: How to add a campaign ability?
« Reply #1 on: March 29, 2016, 06:58:20 PM »

You also need to add the png directory in settings.json.

Logged

hqz

  • Lieutenant
  • **
  • Posts: 73
    • View Profile
Re: How to add a campaign ability?
« Reply #2 on: March 31, 2016, 09:44:19 PM »

You also need to add the png directory in settings.json.

Even if I reuse an existing icon as I did in my example?

Code
  "uiOn":"ui_sensor_burst_on",
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: How to add a campaign ability?
« Reply #3 on: April 01, 2016, 07:24:47 PM »

That's the sound file. Image is defined in the ability's Java class file.

Anyway, my (completely uninformed) guess is two abilities can't have the same class, though that sounds like a really odd limitation. Try making a stub class for your test ability.
Logged