001package com.fs.starfarer.api.impl.campaign.missions.academy; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.campaign.SectorEntityToken; 007import com.fs.starfarer.api.campaign.StarSystemAPI; 008import com.fs.starfarer.api.campaign.econ.MarketAPI; 009import com.fs.starfarer.api.characters.PersonAPI; 010import com.fs.starfarer.api.impl.campaign.ids.Factions; 011import com.fs.starfarer.api.impl.campaign.ids.FleetTypes; 012import com.fs.starfarer.api.impl.campaign.ids.People; 013import com.fs.starfarer.api.impl.campaign.world.NamelessRock; 014import com.fs.starfarer.api.ui.TooltipMakerAPI; 015import com.fs.starfarer.api.util.Misc; 016 017public class GADetectHyperspaceOddity extends GABaseMission { 018 019 public static enum Stage { 020 VISIT_ELEK, 021 GO_TO_ARRAY, 022 GO_TO_LOCATION, 023 INVESTIGATE_SHIP, 024 RETURN_TO_ELEK, 025 COMPLETED, 026 FAILED, 027 ARRAY_THEN_ELEK, 028 ARRAY_THEN_ABYSS, 029 ABYSS_NO_ELEK, 030 } 031 032 protected StarSystemAPI arraySystem; 033 protected StarSystemAPI oneslaughtSystem; 034 protected SectorEntityToken array; 035 protected SectorEntityToken oneslaught; 036 protected PersonAPI elek; 037 protected int rewardAmount; 038 039 @Override 040 protected boolean create(MarketAPI createdAt, boolean barEvent) { 041 042 // if this mission was already accepted by the player, abort 043 if (!setGlobalReference("$gaDHO_ref", "$gaDHO_inProgress")) return false; 044 045 elek = getImportantPerson(People.ELEK); 046 if (elek == null) return false; 047 048 array = (SectorEntityToken) Global.getSector().getPersistentData().get(NamelessRock.ONESLAUGHT_SENSOR_ARRAY); 049 if (array == null) return false; 050 051 oneslaughtSystem = Global.getSector().getStarSystem(NamelessRock.NAMELESS_ROCK_LOCATION_ID); 052 if (oneslaughtSystem == null) return false; 053 054 055 for (SectorEntityToken entity : oneslaughtSystem.getAllEntities()) { 056 if(entity.getMemoryWithoutUpdate().contains("$onslaughtMkI")) { 057 oneslaught = entity; 058 break; 059 } 060 } 061 if(oneslaught == null) return false; 062 063 arraySystem = array.getStarSystem(); 064 if(arraySystem == null) return false; 065 066 setStartingStage(Stage.VISIT_ELEK); 067 addSuccessStages(Stage.COMPLETED); 068 addFailureStages(Stage.FAILED); 069 070 setStageOnGlobalFlag(Stage.FAILED, "$gaDHO_declinedTwice"); 071 072 setStageOnGlobalFlag(Stage.GO_TO_ARRAY, "$gaDHO_gotScanPackage"); 073 setStageOnGlobalFlag(Stage.GO_TO_LOCATION, "$gaDHO_gotCoordinates"); 074 setStageOnGlobalFlag(Stage.INVESTIGATE_SHIP, "$gaDHO_foundRock"); 075 setStageOnGlobalFlag(Stage.RETURN_TO_ELEK, "$gaDHO_foundOneslaught"); 076 setStageOnGlobalFlag(Stage.COMPLETED, "$gaDHO_completed"); 077 078 setStageOnGlobalFlag(Stage.ARRAY_THEN_ELEK, "$gaDHO_arrayFirstThenElek"); 079 setStageOnGlobalFlag(Stage.ARRAY_THEN_ABYSS, "$gaDHO_arrayFirstThenAbyss"); 080 setStageOnGlobalFlag(Stage.ABYSS_NO_ELEK, "$gaDHO_playerMadeElekMad"); 081 082 makeImportant(elek, "$gaDHO_answerInvite", Stage.VISIT_ELEK); 083 makeImportant(array, "$gaDHO_object", Stage.GO_TO_ARRAY); 084 085 makeImportant(oneslaughtSystem.getEntityById("nameless_rock"), null, Stage.GO_TO_LOCATION); 086 makeImportant(oneslaughtSystem.getEntityById("nameless_rock"), null, Stage.ARRAY_THEN_ABYSS); 087 makeImportant(oneslaughtSystem.getEntityById("nameless_rock"), null, Stage.ABYSS_NO_ELEK); 088 089 //SectorEntityToken node2 = spawnMissionNode(new LocData(oneslaughtSystem.getEntityById("nameless_rock"))); 090 //makeImportant(node2, null, Stage.GO_TO_ARRAY); 091 092 makeImportant(elek, "$gaDHO_elekReturn", Stage.RETURN_TO_ELEK); 093 makeImportant(elek, "$gaDHO_elekReturn", Stage.ARRAY_THEN_ELEK); 094 095 makeImportant(oneslaught, null, Stage.INVESTIGATE_SHIP); 096 097 setMapMarkerNameColorBasedOnStar(arraySystem); 098 setStoryMission(); 099 100 setStartingStage(Stage.VISIT_ELEK); 101 addSuccessStages(Stage.COMPLETED); 102 103 // spawn a spicy pirate fleet if player found the array first. 104 beginStageTrigger(Stage.VISIT_ELEK); 105 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.HIGHER, Factions.PIRATES, FleetTypes.PATROL_MEDIUM, array.getStarSystem()); 106 triggerPickLocationAtClosestToPlayerJumpPoint(array.getStarSystem()); 107 triggerSpawnFleetAtPickedLocation("$gaDHO_arrayFleet", null); 108 triggerOrderFleetPatrol(false, array); 109 //triggerOrderFleetInterceptPlayer(); 110 endTrigger(); 111 112 113 beginStageTrigger(Stage.COMPLETED); 114 triggerSetGlobalMemoryValue("$gaDHO_missionCompleted", true); 115 //triggerMakeNonStoryCritical(kazeron, chicomoztoc, epiphany, siyavong.getMarket(), kanta.getMarket()); 116 endTrigger(); 117 118 return true; 119 } 120 121 protected void updateInteractionDataImpl() { 122 set("$gaDHO_stage", getCurrentStage()); 123 set("$gaDHO_starName", arraySystem.getNameWithNoType()); 124 set("$gaDHO_systemName", arraySystem.getNameWithLowercaseTypeShort()); 125 set("$gaDHO_dist", getDistanceLY(array)); 126 set("$gaDHO_reward", Misc.getWithDGS(rewardAmount)); 127 } 128 129 @Override 130 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) { 131 float opad = 10f; 132 Color h = Misc.getHighlightColor(); 133 //if(Global.getSector().getMemoryWithoutUpdate().contains("$gaDHO_foundArrayFirst")) { 134 135 if (currentStage == Stage.VISIT_ELEK) { 136 if(Global.getSector().getMemoryWithoutUpdate().contains("$gaDHO_foundArrayFirst")) { 137 info.addPara("Talk to Academician " + elek.getNameString() + " about the sensor array data.", opad); 138 info.addPara("Or go directly to the coordinates held in the array's data.", opad); 139 info.addImage(elek.getPortraitSprite(), width, 128, opad); 140 } 141 else { 142 info.addPara("Talk to Academician " + elek.getNameString() + " about the services he requires. " 143 + "He is at the Galatia Academy, which orbits Pontus in the Galatia system.", opad); 144 info.addImage(elek.getPortraitSprite(), width, 128, opad); 145 } 146 } 147 else if (currentStage == Stage.GO_TO_ARRAY) { 148 info.addPara("Install the modification package on the Sensor Array located in the " + 149 arraySystem.getNameWithLowercaseTypeShort() + ".", opad); 150 info.addImage(Global.getSettings().getSpriteName("illustrations", "sensor_array"), width, opad); 151 } 152 else if (currentStage == Stage.GO_TO_LOCATION) { 153 info.addPara("Go to the location deep in the Abyss to find what Academician Elek's patron was looking for.", opad); 154 } 155 else if (currentStage == Stage.ARRAY_THEN_ABYSS) { 156 info.addPara("Go to the location deep in the Abyss to find out what the sensor array detected.", opad); 157 } 158 else if (currentStage == Stage.ABYSS_NO_ELEK) { 159 info.addPara("Go to the location deep in the Abyss to find out what the sensor array detected.", opad); 160 } 161 else if (currentStage == Stage.ARRAY_THEN_ELEK) { 162 info.addPara("Talk to Academician " + elek.getNameString() + " about what his sensor array modifications were looking for. " 163 + "He is at the Galatia Academy, which orbits Pontus in the Galatia system.", opad); 164 info.addImage(elek.getPortraitSprite(), width, 128, opad); 165 } 166 else if (currentStage == Stage.INVESTIGATE_SHIP) { 167 info.addPara("Investigate the strange ship orbiting Nameless Rock.", opad); 168 } 169 else if (currentStage == Stage.RETURN_TO_ELEK) { 170 if(Global.getSector().getMemoryWithoutUpdate().contains("$gaDHO_arrayFirstThenAbyss")) { 171 info.addPara("Talk to Academician " + elek.getNameString() + " about what he thought he was looking for.", opad); 172 info.addPara("And maybe some kind of reward.", opad); 173 } 174 else { 175 info.addPara("Talk to Academician " + elek.getNameString() + " about a reward. And about his 'patron'.", opad); 176 } 177 178 info.addImage(elek.getPortraitSprite(), width, 128, opad); 179 } 180 } 181 182 @Override 183 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) { 184 Color h = Misc.getHighlightColor(); 185 // 186 if (currentStage == Stage.VISIT_ELEK) { 187 if(Global.getSector().getMemoryWithoutUpdate().contains("$gaDHO_foundArrayFirst")) { 188 info.addPara("Talk to Academician " + elek.getNameString() + " at the Galatia Academy about the sensor array data.", tc, pad); 189 info.addPara("Or go directly to the coordinates extracted from the array's data", tc, pad); 190 } 191 else { 192 info.addPara("Talk to Academician " + elek.getNameString() + " at the Galatia Academy, which orbits Pontus in the Galatia system.", tc, pad); 193 } 194 return true; 195 } 196 else if (currentStage == Stage.GO_TO_ARRAY) { 197 info.addPara("Go to the Sensor Array located in the " + 198 arraySystem.getNameWithLowercaseTypeShort() + ".", tc, pad); 199 return true; 200 } 201 else if (currentStage == Stage.GO_TO_LOCATION) { 202 info.addPara("Go to the location deep in the Abyss and discover what the Sensor Array found.", tc, pad); 203 return true; 204 } 205 else if (currentStage == Stage.ARRAY_THEN_ABYSS) { 206 info.addPara("Go to the location deep in the Abyss and discover what the Sensor Array found.", tc, pad); 207 return true; 208 } 209 else if (currentStage == Stage.ABYSS_NO_ELEK) { 210 info.addPara("Go to the location deep in the Abyss and discover what the Sensor Array found.", tc, pad); 211 return true; 212 } 213 else if (currentStage == Stage.ARRAY_THEN_ELEK) { 214 info.addPara("Talk to Academician " + elek.getNameString() + " at the Galatia Academy.", tc, pad); 215 return true; 216 } 217 else if (currentStage == Stage.RETURN_TO_ELEK) { 218 info.addPara("Talk to Academician " + elek.getNameString() + 219 " at the Galatia Academy.", tc, pad); 220 return true; 221 } 222 else if (currentStage == Stage.GO_TO_LOCATION) { 223 info.addPara("Go to the location deep in the Abyss and discover what the Sensor Array found.", tc, pad); 224 return true; 225 } 226 else if (currentStage == Stage.INVESTIGATE_SHIP) { 227 info.addPara("Investigate the strange ship orbiting Nameless Rock.", tc, pad); 228 return true; 229 } 230 else if (currentStage == Stage.RETURN_TO_ELEK) { 231 // return to elek *after finding the Oneslaught* to finish the mission. 232 info.addPara("Talk to Academician " + elek.getNameString() + " at the Galatia Academy.", tc, pad); 233 return true; 234 } 235 236 return false; 237 } 238 239 /* 240 @Override 241 protected boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) { 242 if ("discoveredArrayOutOfSequence".equals(action)) { 243 244 245 return true; 246 } 247 return false; 248 }*/ 249 250 @Override 251 public String getBaseName() { 252 //return "Detect Hyperspace Oddity"; 253 return "Abyssal Space Oddity"; 254 } 255 256} 257 258