001package com.fs.starfarer.api.impl.campaign.missions.luddic; 002 003import java.awt.Color; 004import java.util.List; 005import java.util.Map; 006 007import org.lwjgl.util.vector.Vector2f; 008 009import com.fs.starfarer.api.Global; 010import com.fs.starfarer.api.campaign.InteractionDialogAPI; 011import com.fs.starfarer.api.campaign.econ.MarketAPI; 012import com.fs.starfarer.api.campaign.rules.MemoryAPI; 013import com.fs.starfarer.api.characters.PersonAPI; 014import com.fs.starfarer.api.impl.campaign.econ.RecentUnrest; 015import com.fs.starfarer.api.impl.campaign.ids.Factions; 016import com.fs.starfarer.api.impl.campaign.ids.FleetTypes; 017import com.fs.starfarer.api.impl.campaign.ids.People; 018import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch; 019import com.fs.starfarer.api.ui.TooltipMakerAPI; 020import com.fs.starfarer.api.util.Misc.Token; 021 022public class LuddicKnightErrant extends HubMissionWithSearch { 023 024 public static enum Stage { 025 GO_TO_CHALCEDON, 026 CONTACT_RECRUITER, 027 GO_TO_MAZALOT, 028 CONTACT_VIRENS, 029 CONTACT_BORNANEW, 030 RETURN_TO_GILEAD, 031 RETURN_TO_GILEAD2, 032 COMPLETED, 033 } 034 035 protected PersonAPI bornanew; 036 protected PersonAPI jaspis; 037 protected PersonAPI nile_virens; 038 039 protected MarketAPI chalcedon; 040 protected MarketAPI mazalot; 041 protected MarketAPI gilead; 042 043 //public static float MISSION_DAYS = 120f; 044 045 //protected int payment; 046 //protected int paymentHigh; 047 048 @Override 049 protected boolean create(MarketAPI createdAt, boolean barEvent) { 050 // if already accepted by the player, abort 051 if (!setGlobalReference("$lke_ref", "$lke_inProgress")) { 052 return false; 053 } 054 055 chalcedon = Global.getSector().getEconomy().getMarket("chalcedon"); 056 if (chalcedon == null) return false; 057 if (!chalcedon.getFactionId().equals(Factions.LUDDIC_PATH)) return false; 058 059 gilead = Global.getSector().getEconomy().getMarket("gilead"); 060 if (gilead == null) return false; 061 if (!gilead.getFactionId().equals(Factions.LUDDIC_CHURCH)) return false; 062 063 mazalot = Global.getSector().getEconomy().getMarket("mazalot"); 064 if (mazalot == null) return false; 065 if (!mazalot.getFactionId().equals(Factions.PERSEAN)) return false; 066 067 bornanew = getImportantPerson(People.BORNANEW); 068 if (bornanew == null) return false; 069 070 jaspis = getImportantPerson(People.JASPIS); 071 if (bornanew == null) return false; 072 073 nile_virens = getImportantPerson(People.VIRENS); 074 if (nile_virens == null) return false; 075 076 setStoryMission(); 077 078 setStartingStage(Stage.GO_TO_CHALCEDON); 079 makeImportant(chalcedon, "$lke_searchForBornanew", Stage.GO_TO_CHALCEDON); 080 081 setStageOnGlobalFlag(Stage.CONTACT_RECRUITER, "$lke_contactRecruiter"); 082 makeImportant(chalcedon, "$lke_contactRecruiter", Stage.CONTACT_RECRUITER); 083 084 setStageOnGlobalFlag(Stage.GO_TO_MAZALOT, "$lke_gotBornanewLead"); 085 makeImportant(mazalot, "$lke_searchForBornanew2", Stage.GO_TO_MAZALOT); 086 087 setStageOnGlobalFlag(Stage.CONTACT_VIRENS, "$lke_contactVirens"); 088 makeImportant(mazalot, "$lke_contactVirens", Stage.CONTACT_VIRENS); 089 090 setStageOnGlobalFlag(Stage.CONTACT_BORNANEW, "$lke_contactBornanew"); 091 makeImportant(mazalot, "$lke_contactBornanew", Stage.CONTACT_BORNANEW); 092 093 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD, "$lke_foundBornanew"); // he's alive 094 makeImportant(gilead, "$lke_returnWithBornanew", Stage.RETURN_TO_GILEAD); 095 makeImportant(jaspis, "$lke_returnWithBornanew", Stage.RETURN_TO_GILEAD); 096 097 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD2, "$lke_foundBornanew2"); // he's "dead" 098 makeImportant(gilead, "$lke_returnWithBornanewNews", Stage.RETURN_TO_GILEAD2); 099 makeImportant(jaspis, "$lke_returnWithBornanewNews", Stage.RETURN_TO_GILEAD2); 100 101 setStageOnGlobalFlag(Stage.COMPLETED, "$lke_completed"); 102 addSuccessStages(Stage.COMPLETED); 103 104 105 setName("Knight Errant"); 106 setRepFactionChangesNone(); 107 setRepPersonChangesNone(); 108 109 beginStageTrigger(Stage.COMPLETED); 110 triggerMakeNonStoryCritical("chalcedon", "mazalot", "gilead"); 111 triggerSetGlobalMemoryValue("$lke_missionCompleted", true); 112 endTrigger(); 113 114 115 // Spawn a Pather fleet near Chalcedon to spice things up. 116 //beginStageTrigger(Stage.GO_TO_CHALCEDON); 117 beginWithinHyperspaceRangeTrigger(chalcedon.getPlanetEntity(), 1f, false,Stage.GO_TO_CHALCEDON); 118 triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT, Factions.LUDDIC_PATH, FleetTypes.PATROL_LARGE, chalcedon.getPlanetEntity()); 119 triggerSetFleetFaction(Factions.LUDDIC_PATH); 120 triggerPickLocationAroundEntity(chalcedon.getPlanetEntity(), 800f); 121 triggerOrderFleetPatrol(chalcedon.getPlanetEntity()); 122 triggerSpawnFleetAtPickedLocation("$lke_patherGoblins", null); 123 triggerSetFleetMissionRef("$lke_ref"); 124 125 // if player is hostile to Path, Path fleet is hostile to player. 126 // if( Global.getSector().getFaction(Factions.LUDDIC_PATH).getRelToPlayer().isAtBest(RepLevel.HOSTILE) ) 127 //{ 128 // triggerMakeHostileAndAggressive(); 129 //} 130 131 //triggerFleetSetPatrolLeashRange(1000f); 132 //triggerMakeFleetGoAwayAfterDefeat(); 133 endTrigger(); 134 135 // Luddic intercept fleet post-Chalcedon 136 beginWithinHyperspaceRangeTrigger(chalcedon, 3f, true, Stage.GO_TO_MAZALOT); 137 triggerCreateFleet(FleetSize.LARGER, FleetQuality.HIGHER, Factions.LUDDIC_PATH, FleetTypes.PATROL_LARGE, mazalot.getLocationInHyperspace()); 138 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER); 139 triggerMakeHostileAndAggressive(); 140 triggerMakeLowRepImpact(); 141 triggerFleetMakeFaster(true, 2, true); 142 triggerSetFleetAlwaysPursue(); 143 triggerPickLocationTowardsEntity(chalcedon.getStarSystem().getHyperspaceAnchor(), 30f, getUnits(1.5f)); 144 triggerSpawnFleetAtPickedLocation("$lke_patherIntercept", null); 145 triggerOrderFleetInterceptPlayer(); 146 triggerOrderFleetEBurn(1f); 147 triggerSetFleetMissionRef("$lke_ref"); 148 triggerFleetMakeImportant(null, Stage.GO_TO_MAZALOT); 149 endTrigger(); 150 151 return true; 152 } 153 154 protected void updateInteractionDataImpl() { 155 set("$lke_stage", getCurrentStage()); 156 //set("$anh_robedman", robed_man); 157 } 158 159 @Override 160 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, 161 List<Token> params, final Map<String, MemoryAPI> memoryMap) { 162// if ("THEDUEL".equals(action)) { 163// TextPanelAPI text = dialog.getTextPanel(); 164// text.setFontOrbitronUnnecessarilyLarge(); 165// Color color = Misc.getBasePlayerColor(); 166// color = Global.getSector().getFaction(Factions.HEGEMONY).getBaseUIColor(); 167// text.addPara("THE DUEL", color); 168// text.setFontInsignia(); 169// text.addImage("misc", "THEDUEL"); 170// return true; 171// } 172 173 if ("postMissionCleanup".equals(action)) { 174 // clean up any unneeded memory things. 175 //Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHesperusFirstShrineAttempt"); 176 Global.getSector().getMemoryWithoutUpdate().unset("$global.lke_foundBornanew"); 177 178 mazalot.getMemoryWithoutUpdate().unset("$market.dardanWontTalkLKE"); 179 180 return true; 181 } 182 else if ("shootEm".equals(action)) 183 { 184 Global.getSoundPlayer().playSound("storyevent_diktat_execution", 1, 1, Global.getSoundPlayer().getListenerPos(), new Vector2f()); 185 return true; 186 } 187 else if ("resumeMusic".equals(action)) 188 { 189 Global.getSoundPlayer().setSuspendDefaultMusicPlayback(false); 190 Global.getSoundPlayer().restartCurrentMusic(); 191 return true; 192 } 193 else if ("endMusic".equals(action)) 194 { 195 Global.getSoundPlayer().setSuspendDefaultMusicPlayback(true); 196 Global.getSoundPlayer().pauseMusic(); 197 //Global.getSoundPlayer().restartCurrentMusic(); 198 return true; 199 } 200 else if ("playMusicCombat".equals(action)) 201 { 202 Global.getSoundPlayer().playCustomMusic(1, 1, "music_combat", true); 203 return true; 204 } 205 else if ("playMusicSedge".equals(action)) 206 { 207 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_encounter_hostile", true); 208 return true; 209 } 210 else if ("playMusicVirens".equals(action)) 211 { 212 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_market_hostile", true); 213 return true; 214 } 215 else if ("playMusicJethro".equals(action)) 216 { 217 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_market_friendly", true); 218 return true; 219 } 220 else if ("playMusicDardan".equals(action)) 221 { 222 Global.getSoundPlayer().playCustomMusic(1, 1, "music_persean_league_market_hostile", true); 223 return true; 224 } 225 else if ("didMazalotRaid".equals(action)) 226 { 227 RecentUnrest.get(mazalot).add(10, "Raided Mazalot and caused a Luddic uprising"); 228 return true; 229 } 230 else if ("doCleanup".equals(action)) 231 { 232 233 Global.getSector().getMemoryWithoutUpdate().unset("$lke_gotVirensContactFreebie"); 234 Global.getSector().getMemoryWithoutUpdate().unset("$lke_didMazBarAgentEncounter"); 235 chalcedon.getMemoryWithoutUpdate().unset("$lkeBuggedVIPs"); 236 mazalot.getMemoryWithoutUpdate().unset("$lke_wontTellLied"); 237 mazalot.getMemoryWithoutUpdate().unset("$lke_askedPMChurch"); 238 mazalot.getMemoryWithoutUpdate().unset("$lkeSetUpVirensMeeting"); 239 mazalot.getMemoryWithoutUpdate().unset("$dardanWontTalkLKE"); 240 241 return true; 242 } 243 244 return super.callAction(action, ruleId, dialog, params, memoryMap); 245 } 246 247 /* 248 @Override 249 public void createSmallDescription(TooltipMakerAPI info, float width, float height) { 250 Color h = Misc.getHighlightColor(); 251 Color g = Misc.getGrayColor(); 252 float pad = 3f; 253 float opad = 10f; 254 255 FactionAPI faction = getFactionForUIColors(); 256 PersonAPI person = getPerson(); 257 258 //info.addImage(Global.getSettings().getSpriteName("illustrations", "luddic_shrine"), width, opad); 259 260 addDescriptionForCurrentStage(info, width, height); 261 262 addBulletPoints(info, ListInfoMode.IN_DESC); 263 } 264 */ 265 266 @Override 267 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) { 268 float opad = 10f; 269 //Color h = Misc.getHighlightColor(); 270 271 //Color h2 = Misc.getDarkHighlightColor(); 272 //FactionAPI church = Global.getSector().getFaction(Factions.LUDDIC_CHURCH); 273 274 //info.addImage(robed_man.getPortraitSprite(), width, 128, opad); 275 276 if (currentStage == Stage.GO_TO_CHALCEDON) { 277 info.addPara("Find Bornanew. His last mission was the infiltration of a Pather cell; someone must known something about where he is.", opad); 278 addStandardMarketDesc("Go to " + chalcedon.getOnOrAt(), chalcedon, info, opad); 279 } 280 else if (currentStage == Stage.CONTACT_RECRUITER) { 281 info.addPara("You have been told to meet with someone in a spacer bar on the surface of Chalcedon, presumably a recruiter for the Luddic Path.", opad); 282 addStandardMarketDesc("Go to " + chalcedon.getOnOrAt(), chalcedon, info, opad); 283 } 284 else if (currentStage == Stage.GO_TO_MAZALOT) { 285 info.addPara("A Pather, Sedge, claims that Jethro Bornanew travelled to Mazalot. Find him, or find where he has gone from there.", opad); 286 addStandardMarketDesc("Go to " + mazalot.getOnOrAt(), mazalot, info, opad); 287 } 288 else if (currentStage == Stage.CONTACT_VIRENS) { 289 info.addPara("Nile Virens runs the Luddic Path on Mazalot. If anyone knows where Bornanew is, it would be him or his organization. He might be persuaded to help by force or diplomacy.", opad); 290 addStandardMarketDesc("Contact Nile Virens " + mazalot.getOnOrAt(), mazalot, info, opad); 291 info.addImage(nile_virens.getPortraitSprite(), width, 128, opad); 292 info.addImage(nile_virens.getFaction().getCrest(), width, 128, opad); 293 } 294 else if (currentStage == Stage.CONTACT_BORNANEW) { 295 info.addPara("Nile Virens has provided you with the location of Jethro Bornanew, or so he claims. This consists of coordinates for a location on the surface of Mazalot, outside of a Luddic-majority settlement.", opad); 296 addStandardMarketDesc("Contact Jethro Bornanew " + mazalot.getOnOrAt(), mazalot, info, opad); 297 //info.addImage(bornanew.getPortraitSprite(), width, 128, opad); 298 } 299 else if (currentStage == Stage.RETURN_TO_GILEAD) { 300 info.addPara("Return with Jethro Bornanew to the office of Archcurate Jaspis.", opad); 301 addStandardMarketDesc("Go to " + gilead.getOnOrAt(), gilead, info, opad); 302 } 303 else if (currentStage == Stage.RETURN_TO_GILEAD2) { 304 info.addPara("Return to the office of Archcurate Jaspis with news of Jethro Bornanew's 'death'.", opad); 305 addStandardMarketDesc("Go to " + gilead.getOnOrAt(), gilead, info, opad); 306 } 307 308 } 309 310 @Override 311 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) { 312 //Color h = Misc.getHighlightColor(); 313 314 if (currentStage == Stage.GO_TO_CHALCEDON) { 315 info.addPara("Go to Chalcedon and find Jethro Bornanew", tc, pad); 316 return true; 317 } 318 else if (currentStage == Stage.CONTACT_RECRUITER) { 319 info.addPara("Go to the spacer bar on Chalcedon and speak with the Luddic Path recruiter", tc, pad); 320 return true; 321 } 322 else if (currentStage == Stage.GO_TO_MAZALOT) { 323 info.addPara("Go to Mazalot and find Jethro Bornanew", tc, pad); 324 return true; 325 } 326 else if (currentStage == Stage.CONTACT_VIRENS) { 327 info.addPara("Talk to or raid Nile Virens on Mazalot", tc, pad); 328 return true; 329 } 330 else if (currentStage == Stage.CONTACT_BORNANEW) { 331 info.addPara("Go to the alleged location of Jethro Bornanew on Mazalot", tc, pad); 332 return true; 333 } 334 else if (currentStage == Stage.RETURN_TO_GILEAD) { 335 info.addPara("Return to Gilead with Bornanew", tc, pad); 336 return true; 337 } 338 else if (currentStage == Stage.RETURN_TO_GILEAD2) { 339 info.addPara("Return to Gilead with news of Bornanew's 'death'.", tc, pad); 340 return true; 341 } 342 343 return false; 344 345 /* 346 Color h = Misc.getHighlightColor(); 347 if (currentStage == Stage.DROP_OFF) { 348 info.addPara("Deliver " + getWithoutArticle(thing) + " to specified location in the " + 349 system.getNameWithLowercaseTypeShort(), tc, pad); 350 return true; 351 } 352 */ 353 } 354 355 @Override 356 public String getBaseName() { 357 return "Knight Errant"; 358 } 359 360 @Override 361 public String getPostfixForState() { 362 if (startingStage != null) { 363 return ""; 364 } 365 return super.getPostfixForState(); 366 } 367} 368 369 370 371 372