MissionDefinition.java
Jump to navigation
Jump to search
Description
MissionDefinition.java file contains the configuration inside a mission, while descriptor.json, mission.txt, a picture file and a mission_list.csv entry handle how the mission is displayed in the mission list. It is written in Java.
Example
A Fistful of Credits
package data.missions.afistfulofcredits;
import com.fs.starfarer.api.fleet.FleetGoal;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.ids.StarTypes;
import com.fs.starfarer.api.mission.FleetSide;
import com.fs.starfarer.api.mission.MissionDefinitionAPI;
import com.fs.starfarer.api.mission.MissionDefinitionPlugin;
public class MissionDefinition implements MissionDefinitionPlugin {
public void defineMission(MissionDefinitionAPI api) {
// Set up the fleets so we can add ships and fighter wings to them.
// In this scenario, the fleets are attacking each other, but
// in other scenarios, a fleet may be defending or trying to escape
api.initFleet(FleetSide.PLAYER, "ISS", FleetGoal.ATTACK, false);
api.initFleet(FleetSide.ENEMY, "ISS", FleetGoal.ATTACK, true);
// api.getDefaultCommander(FleetSide.PLAYER).getStats().setSkillLevel(Skills.COORDINATED_MANEUVERS, 3);
// api.getDefaultCommander(FleetSide.PLAYER).getStats().setSkillLevel(Skills.ELECTRONIC_WARFARE, 3);
// Set a small blurb for each fleet that shows up on the mission detail and
// mission results screens to identify each side.
api.setFleetTagline(FleetSide.PLAYER, "'Just an honest trader trying to make a living, officer.'");
api.setFleetTagline(FleetSide.ENEMY, "No-good two-timing 'High Rad' Moon Salazar in a rustbucket mule");
// These show up as items in the bulleted list under
// "Tactical Objectives" on the mission detail screen
api.addBriefingItem("Show 'High Rad' Moon what it means to break a deal.");
api.addBriefingItem("Don't lose 'Stranger II' - it's my most valuable possession.");
api.addBriefingItem("Moon's ship has delicate engine mods; use Salamander Missiles to leave her adrift");
// Set up the player's fleet. Variant names come from the
// files in data/variants and data/variants/fighters
api.addToFleet(FleetSide.PLAYER, "lasher_Standard", FleetMemberType.SHIP, "Stranger II", true);
api.addToFleet(FleetSide.PLAYER, "hound_d_Standard", FleetMemberType.SHIP, "Milk Run", false);
// Set up the enemy fleet.
api.addToFleet(FleetSide.ENEMY, "mule_d_pirates_Smuggler", FleetMemberType.SHIP, "Cherenkov Bloom", false);
api.defeatOnShipLoss("Stranger II");
// Set up the map.
float width = 12000f;
float height = 12000f;
api.initMap((float)-width/2f, (float)width/2f, (float)-height/2f, (float)height/2f);
float minX = -width/2;
float minY = -height/2;
// Add an asteroid field
api.addAsteroidField(minX, minY + height / 2, 0, 8000f,
20f, 70f, 100);
api.addPlanet(0, 0, 50f, StarTypes.RED_GIANT, 250f, true);
}
}
Elements
package
- Must match the directory structure for the mission. So if the folder is data/missions/ha_challenge, the top of your MissionDefinition.java should read package data.missions.ha_challenge
import
-
- Required. Handles displaying the mission in the mission list. com.fs.starfarer.api.mission.MissionDefinitionPlugin
-
- Required. Contains a lot of useful methods for setting up the briefing, fleets and battle space. com.fs.starfarer.api.mission.MissionDefinitionAPI
-
- Required to set which side ships are on, either PLAYER or ENEMY. com.fs.starfarer.api.mission.FleetSide
At least two versions out of date. Last verified for version 0.8.1a. Please refer to Version History and update this page.
---
Return to Modding
Categories:
- Pages using deprecated source tags
- Potentially outdated
- Modding