diff --git a/.idea/libraries/IndEvo.xml b/.idea/libraries/IndEvo.xml index 5f1462a..c4c06a1 100644 --- a/.idea/libraries/IndEvo.xml +++ b/.idea/libraries/IndEvo.xml @@ -1,11 +1,11 @@ - + - + diff --git a/.idea/libraries/Station_Augments.xml b/.idea/libraries/Station_Augments.xml index dc66628..0a0a2f2 100644 --- a/.idea/libraries/Station_Augments.xml +++ b/.idea/libraries/Station_Augments.xml @@ -1,13 +1,13 @@ - + - - + + - - + + \ No newline at end of file diff --git a/.idea/libraries/Station_Augments2.xml b/.idea/libraries/Station_Augments2.xml new file mode 100644 index 0000000..0a0a2f2 --- /dev/null +++ b/.idea/libraries/Station_Augments2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/indev.xml b/.idea/libraries/indev.xml new file mode 100644 index 0000000..f5444d4 --- /dev/null +++ b/.idea/libraries/indev.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/MCTE.version b/MCTE.version index 901b182..9edcc58 100644 --- a/MCTE.version +++ b/MCTE.version @@ -31,7 +31,7 @@ "modVersion": { "major":1, - "minor":7, - "patch":2 # Can be a number, character or string (1, 2, a, b, "-RC2", etc) + "minor":8, + "patch":0 # Can be a number, character or string (1, 2, a, b, "-RC2", etc) }, } \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index d970dad..f36f209 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,7 +4,14 @@ Campaign objectives (Nav buoys, comm relays, sensor relays) now have in-combat e Increase CP regen Increase weapon range - Intensity increases based on campaign distance from these objectives + Intensity changes based on campaign distance from these objectives + +Indevo integration - minefields now spawn mines in-combat + Lower performance than star fortress mines + Can target both sides at once if neutral + Due to engine limitations, mines targetting enemies will always be allied, so you cant shoot them down + +Polished some numbers into ints and gave nebula a new icon 1.7.2 Update to station augments 1.0.0 diff --git a/data/config/LunaSettings.csv b/data/config/LunaSettings.csv index 3f37d98..4c4865e 100644 --- a/data/config/LunaSettings.csv +++ b/data/config/LunaSettings.csv @@ -22,9 +22,16 @@ MCTE_blackholeToggle,Black Holes,Boolean,true,"Black holes lose some of their CR Affected by solar shielding, but inversely: The timeflow decreases as effect resistance increases, but the gravity doesn't, so solar shielding is a strict nerf in this case.",,,Combat MCTE_pulsarToggle,Pulsars,Boolean,true,"Pulsars lose some of their CR penalty in exchange for decreasing shield efficiency, increasing shield upkeep, decreasing shield EMP arc pierce resist, randomly EMPing all ships, applying a flat EMP damage increase to all projectiles, pushing all combat entities away from it's campaign location, and slowly building hardflux. Effect scales with your proximity to the pulsar in the campaign layer. All effects except for the projectile EMP damage increase and push effect are affected by solar shielding.",,,Combat +MCTE_objectivesToggle,Objectives,Boolean,true,"Comm relays increase CP regeneration, nav buoys increase coordinated maneuvers, sensor relays increase weapon range.",,,Combat MCTE_moddedHeader,awdjdwai,Header,Inter-mod settings below,,,,Combat MCTE_MPCheader,awdjdwai,Header,More Planetary Conditions settings,,,,Combat MCTE_mesonToggle,Meson Fields,Boolean,true,"Meson fields increase vision and non-missile weapon range, with storms increasing this effect and also applying it to missiles, wings, and system range.",,,Combat +MCTE_indEvoheader,awdjdwai,Header,Industrial Evolution settings,,,,Combat +MCTE_minefieldToggle,Minefields,Boolean,true,Minefields spawn mines near hostile ships.,,,Combat +MCTE_minefieldMinSecsBetweenTicks,Minimum seconds between ticks,Double,1.8,"Each ""tick"" is a chance for mines to spawn.",,,Combat +MCTE_minefieldMaxSecsBetweenTicks,Maximum seconds between ticks,Double,2.6,,,,Combat +MCTE_minefieldMinMinesPerTick,Minimum mines per tick,Int,2,Cannot exceed the amount of ships currently active.,,,Combat +MCTE_minefieldMaxMinesPerTick,Maximum mines per tick,Int,5,,,,Combat MCTE_UNGPEffectMult,UNGP Effects Mult,Double,1.0,Controls how strong UNGP effects are.,0.0,100.0,UNGP MCTE_groundBattleEffectHeader,Ground Battle Effects,Header,Ground Battle Effects,,,,Nexerelin MCTE_hyperstormNexHeader,Hyperstorms,Header,Hyperstorms,,,,Nexerelin diff --git a/jars/niko_MCTE.jar b/jars/niko_MCTE.jar index 0842a07..1778292 100644 Binary files a/jars/niko_MCTE.jar and b/jars/niko_MCTE.jar differ diff --git a/jars/src/niko/MCTE/combatEffectTypes.kt b/jars/src/niko/MCTE/combatEffectTypes.kt index 4e55c0b..fbc5767 100644 --- a/jars/src/niko/MCTE/combatEffectTypes.kt +++ b/jars/src/niko/MCTE/combatEffectTypes.kt @@ -9,6 +9,7 @@ import niko.MCTE.scripts.everyFrames.combat.terrainEffects.deepHyperspace.cloudC import niko.MCTE.scripts.everyFrames.combat.terrainEffects.deepHyperspace.deepHyperspaceEffectScript import niko.MCTE.scripts.everyFrames.combat.terrainEffects.magField.magneticFieldEffect import niko.MCTE.scripts.everyFrames.combat.terrainEffects.mesonField.mesonFieldEffectScript +import niko.MCTE.scripts.everyFrames.combat.terrainEffects.minefield.minefieldEffectScript import niko.MCTE.scripts.everyFrames.combat.terrainEffects.pulsarBeam.pulsarEffectScript import niko.MCTE.scripts.everyFrames.combat.terrainEffects.slipstream.SlipstreamEffectScript import niko.MCTE.settings.MCTE_settings @@ -74,6 +75,18 @@ enum class combatEffectTypes { } } }, + MINEFIELD { + override fun createEffectInstance(): baseTerrainEffectScript { + return minefieldEffectScript() + } + + override fun modifyEffectInstance(instance: baseTerrainEffectScript, vararg args: Any) { + if (instance !is minefieldEffectScript) return + + val newSides = args[0] as? HashMap ?: return + instance.targetSidesToInstance.forEach { instance.targetSidesToInstance[it.key] = instance.targetSidesToInstance[it.key]!! + newSides[it.key]!! } + } + }, BLACKHOLE { override fun createEffectInstance(): blackHoleEffectScript { return blackHoleEffectScript() diff --git a/jars/src/niko/MCTE/listeners/objectiveTerrainAdder.kt b/jars/src/niko/MCTE/listeners/objectiveTerrainAdder.kt index 5b5faff..39537ab 100644 --- a/jars/src/niko/MCTE/listeners/objectiveTerrainAdder.kt +++ b/jars/src/niko/MCTE/listeners/objectiveTerrainAdder.kt @@ -14,6 +14,7 @@ class objectiveTerrainAdder: BaseCampaignEventListener(false) { to: JumpPointAPI.JumpDestination? ) { super.reportFleetJumped(fleet, from, to) + if (!MCTE_settings.OBJECTIVES_ENABLED) return if (fleet == null || !fleet.isPlayerFleet) return if (to == null) return diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/deepHyperspace/deepHyperspaceEffectScript.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/deepHyperspace/deepHyperspaceEffectScript.kt index 6578c2e..65f834e 100644 --- a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/deepHyperspace/deepHyperspaceEffectScript.kt +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/deepHyperspace/deepHyperspaceEffectScript.kt @@ -60,6 +60,8 @@ class deepHyperspaceEffectScript( dummyShip.collisionClass = CollisionClass.NONE dummyShip.shipAI = null dummyShip.owner = 100 + dummyShip.mutableStats.hullDamageTakenMult.modifyMult("MCTE_minefieldEffect", 0f) + dummyShip.alphaMult = 0f fleetManager.isSuppressDeploymentMessages = originalValue return dummyShip } @@ -331,7 +333,7 @@ class deepHyperspaceEffectScript( "niko_MCPE_hyperStorm2", icon, terrainName, - "Lightning strikes on this ship do ${getRawActualDamageForEntity(playerShip).roundTo(2)} energy damage and ${getRawEMPDamageForEntity(playerShip).roundTo(2)} EMP damage", + "Lightning strikes on this ship do ${getRawActualDamageForEntity(playerShip).toInt()} energy damage and ${getRawEMPDamageForEntity(playerShip).toInt()} EMP damage", true) engine.maintainStatusForPlayerShip( "niko_MCPE_hyperStorm1", diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/minefield/minefieldEffectScript.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/minefield/minefieldEffectScript.kt new file mode 100644 index 0000000..9213f11 --- /dev/null +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/minefield/minefieldEffectScript.kt @@ -0,0 +1,207 @@ +package niko.MCTE.scripts.everyFrames.combat.terrainEffects.minefield + +import com.fs.starfarer.api.Global +import com.fs.starfarer.api.combat.CollisionClass +import com.fs.starfarer.api.combat.MissileAPI +import com.fs.starfarer.api.combat.ShipAPI +import com.fs.starfarer.api.fleet.FleetMemberType +import com.fs.starfarer.api.util.IntervalUtil +import com.fs.starfarer.api.util.Misc +import com.fs.starfarer.api.util.WeightedRandomPicker +import niko.MCTE.combatEffectTypes +import niko.MCTE.scripts.everyFrames.combat.terrainEffects.baseTerrainEffectScript +import niko.MCTE.settings.MCTE_settings.MINEFIELD_MAX_MINES_PER_TICK +import niko.MCTE.settings.MCTE_settings.MINEFIELD_MAX_SECS_BETWEEN_TICKS +import niko.MCTE.settings.MCTE_settings.MINEFIELD_MIN_MINES_PER_TICK +import niko.MCTE.settings.MCTE_settings.MINEFIELD_MIN_SECS_BETWEEN_TICKS +import org.lazywizard.lazylib.MathUtils +import org.lwjgl.util.vector.Vector2f +import kotlin.math.max +import kotlin.math.min + +class minefieldEffectScript : baseTerrainEffectScript() { + + companion object { + const val MINE_SPAWN_CHANCE = 0.15f + const val MCTE_MINEFIELD_KEY = "MCTE_minefieldKey" + } + + class IncomingMine { + var targetOwner = 0 + var mineLoc: Vector2f? = null + var delay = 0f + var target: ShipAPI? = null + } + + class MinefieldData { + var tracker = IntervalUtil(MINEFIELD_MIN_SECS_BETWEEN_TICKS, MINEFIELD_MAX_SECS_BETWEEN_TICKS) + var incoming: List = ArrayList() + } + + override var effectPrototype: combatEffectTypes? = combatEffectTypes.MINEFIELD + var targetSidesToInstance = hashMapOf(Pair(0, 0), Pair(1, 0)) + + val playerAlignedDummy = createNewDummyShip(0) + val enemyAlignedDummy = createNewDummyShip(1) + + private fun createNewDummyShip(owner: Int): ShipAPI { + val fleetMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "talon_Interceptor") + val fleetManager = engine.getFleetManager(100) + val originalValue = fleetManager.isSuppressDeploymentMessages + fleetManager.isSuppressDeploymentMessages = true + fleetMember.shipName = "Minefield" + val dummyShip = fleetManager.spawnFleetMember(fleetMember, Vector2f(999999f, 999f), 5f, 0f) + dummyShip.name = "Minefield" + dummyShip.collisionClass = CollisionClass.NONE + dummyShip.shipAI = null + dummyShip.originalOwner = owner + dummyShip.owner = owner + if (owner == 0) dummyShip.isAlly = true + dummyShip.mutableStats.hullDamageTakenMult.modifyMult("MCTE_minefieldEffect", 0f) + dummyShip.alphaMult = 0f + fleetManager.isSuppressDeploymentMessages = originalValue + + return dummyShip + } + + override fun handleSounds(amount: Float) { + Global.getSoundPlayer().playUILoop("terrain_asteroid_field", 1f, 1f) + } + + override fun applyEffects(amount: Float) { + if (engine.isPaused) return + + var data = engine.customData[MCTE_MINEFIELD_KEY] as? MinefieldData + if (data == null) { + data = MinefieldData() + engine.customData[MCTE_MINEFIELD_KEY] = data + } + + for (inc in ArrayList(data.incoming)) { + inc.delay -= amount + if (inc.delay <= 0) { + spawnMine(inc.targetOwner, inc.mineLoc, inc.target) + data.incoming -= inc + } + } + + data.tracker.advance(amount) + if (!data.tracker.intervalElapsed()) return + + val picker = WeightedRandomPicker() + for (entry in targetSidesToInstance) { + val instances = entry.value + if (instances <= 0) continue + val side = entry.key + val fleetManager = engine.getFleetManager(side) + + var iterationsRemaining = instances + while (iterationsRemaining-- > 0) { + for (deployed in fleetManager.deployedCopyDFM) { + val enemy = deployed.ship + if (enemy.isHulk) continue + if (enemy.isFighter) continue + if (enemy.isDrone) continue + if (enemy.isStation) continue + if (enemy.isStationModule) continue + if (enemy.travelDrive != null && enemy.travelDrive.isActive) continue + + if (Math.random().toFloat() > MINE_SPAWN_CHANCE) continue + + val mineLoc = Misc.getPointAtRadius( + enemy.location, + enemy.collisionRadius + 400f + 200f * Math.random().toFloat() + ) + val minOk: Float = 400f + enemy.collisionRadius + if (!isAreaClear(mineLoc, minOk)) continue + + val inc = IncomingMine() + inc.delay = Math.random().toFloat() * 1.5f + inc.target = enemy + inc.mineLoc = mineLoc + inc.targetOwner = if (side == 1) 0 else 1 + + picker.add(inc) + } + } + } + val numToSpawn = max(1, min(MathUtils.getRandomNumberInRange(MINEFIELD_MIN_MINES_PER_TICK, MINEFIELD_MAX_MINES_PER_TICK), picker.items.size)) + + var i = 0 + while (i < numToSpawn && !picker.isEmpty) { + val inc = picker.pickAndRemove() + data.incoming += inc + i++ + } + } + + override fun handleNotification(amount: Float): Boolean { + if (!super.handleNotification(amount)) return false + + val icon = Global.getSettings().getSpriteName("ui", "icon_tactical_cr_penalty") + val playerShip = engine.playerShip.owner ?: return false + + if (targetSidesToInstance[0]!! > 0) { // player targeted + engine.maintainStatusForPlayerShip( + "niko_MCTE_minefield1", + icon, + "Minefield (MCTE FEATURE - NOT INDEVO)", + "Stealth mines targeting allies", + true + ) + } + if (targetSidesToInstance[1]!! > 0) { // enemy targeted + engine.maintainStatusForPlayerShip( + "niko_MCTE_minefield2", + icon, + "Minefield (MCTE FEATURE - NOT INDEVO)", + "Stealth mines targeting enemies", + false + ) + } + return true + } + + fun isAreaClear(loc: Vector2f?, range: Float): Boolean { + val engine = Global.getCombatEngine() + for (other in engine.ships) { + if (other.isFighter) continue + if (other.isDrone) continue + val dist = Misc.getDistance(loc, other.location) + if (dist < range) { + return false + } + } + for (other in Global.getCombatEngine().asteroids) { + val dist = Misc.getDistance(loc, other.location) + if (dist < other.collisionRadius + 100f) { + return false + } + } + return true + } + + fun spawnMine(targetOwner: Int, mineLoc: Vector2f?, target: ShipAPI?) { + if (target == null) return + if (mineLoc == null) return + + val source = if (targetOwner == 1) enemyAlignedDummy else playerAlignedDummy + val mineDir = Misc.getAngleInDegrees(mineLoc, target.location) + val currLoc = Misc.getPointAtRadius(mineLoc, 50f + Math.random().toFloat() * 50f) + val mine = engine.spawnProjectile( + source, null, + getWeaponId(), + currLoc, + mineDir, null + ) as MissileAPI + mine.owner = source.owner + + mine.flightTime = Math.random().toFloat() + mine.fadeOutThenIn(1f) + Global.getSoundPlayer().playSound("mine_spawn", 1f, 1f, mine.location, mine.velocity) + } + + private fun getWeaponId(): String { + return "minelayer1" + } +} \ No newline at end of file diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/nebula/nebulaEffectScript.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/nebula/nebulaEffectScript.kt index 01cec9e..c7154c3 100644 --- a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/nebula/nebulaEffectScript.kt +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/nebula/nebulaEffectScript.kt @@ -148,19 +148,19 @@ class nebulaEffectScript: baseTerrainEffectScript() { "niko_MCPE_nebulaEffect2", icon, "Nebula", - "Vision range reduced by ${(100-(getVisionMultForShip(playerShip))*100).roundTo(2)}%", + "Vision range reduced by ${(100-(getVisionMultForShip(playerShip))*100).toInt()}%", true) engine.maintainStatusForPlayerShip( "niko_MCPE_nebulaEffect3", icon, "Nebula", - "Weapon range reduced by ${(100-(getRangeMultForShip(playerShip))*100).roundTo(2)}%", + "Weapon range reduced by ${(100-(getRangeMultForShip(playerShip))*100).toInt()}%", true) engine.maintainStatusForPlayerShip( "niko_MCPE_nebulaEffect4", icon, "Nebula", - "Speed reduced by ${(-getSpeedDecrementForShip(playerShip)).roundTo(2)} Su", + "Speed reduced by ${(-getSpeedDecrementForShip(playerShip)).toInt()} Su", true) } return true diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/pulsarBeam/pulsarEffectScript.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/pulsarBeam/pulsarEffectScript.kt index a0eac6a..d40c47d 100644 --- a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/pulsarBeam/pulsarEffectScript.kt +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/pulsarBeam/pulsarEffectScript.kt @@ -392,7 +392,7 @@ class pulsarEffectScript( "niko_MCPE_pulsar2", icon, "Pulsar Beam", - "Generating hardflux at rate of ${calculateFluxGeneratedPerSecond(ship).roundTo(2)} per second", + "Generating hardflux at rate of ${calculateFluxGeneratedPerSecond(ship).toInt()} per second", true) engine.maintainStatusForPlayerShip( "niko_MCPE_pulsar5", diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/slipstream/SlipstreamEffectScript.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/slipstream/SlipstreamEffectScript.kt index ae8b428..8b37c7a 100644 --- a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/slipstream/SlipstreamEffectScript.kt +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/slipstream/SlipstreamEffectScript.kt @@ -224,7 +224,7 @@ class SlipstreamEffectScript( "niko_MCPE_slipstream3", icon, "Slipstream", - "Generating hardflux at rate of ${calculateFluxGeneratedPerSecond(playerShip).roundTo(2)} per second", + "Generating hardflux at rate of ${calculateFluxGeneratedPerSecond(playerShip).toInt()} per second", true) } engine.maintainStatusForPlayerShip( diff --git a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/terrainEffectScriptAdder.kt b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/terrainEffectScriptAdder.kt index 287869e..f550dc1 100644 --- a/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/terrainEffectScriptAdder.kt +++ b/jars/src/niko/MCTE/scripts/everyFrames/combat/terrainEffects/terrainEffectScriptAdder.kt @@ -7,16 +7,16 @@ import com.fs.starfarer.api.campaign.BattleAPI.BattleSide import com.fs.starfarer.api.combat.CombatEngineAPI import com.fs.starfarer.api.impl.campaign.fleets.FleetFactory import com.fs.starfarer.api.impl.campaign.ids.FleetTypes +import com.fs.starfarer.api.impl.campaign.ids.MemFlags import com.fs.starfarer.api.impl.campaign.ids.Tags import com.fs.starfarer.api.impl.campaign.terrain.* import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin.CellStateTracker import com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2 import com.fs.starfarer.api.input.InputEventAPI import data.scripts.campaign.terrain.niko_MPC_mesonField +import indevo.exploration.minefields.MineBeltTerrainPlugin import indevo.exploration.minefields.MineFieldTerrainPlugin import indevo.industries.artillery.entities.ArtilleryStationEntityPlugin -import indevo.industries.artillery.scripts.ArtilleryStationScript -import indevo.industries.artillery.scripts.CampaignAttackScript import niko.MCTE.ObjectiveEffect import niko.MCTE.combatEffectTypes import niko.MCTE.scripts.everyFrames.combat.ArtilleryStationEffect @@ -139,7 +139,7 @@ class terrainEffectScriptAdder: baseNikoCombatScript() { // MPC if (MCTE_debugUtils.MPCenabled && terrainPlugin is niko_MPC_mesonField) mesonFieldPlugins += terrainPlugin // INDEVO - if (MCTE_debugUtils.indEvoEnabled && terrainPlugin is MineFieldTerrainPlugin) mineFieldPlugins += terrainPlugin + if (MCTE_debugUtils.indEvoEnabled && terrainPlugin is MineBeltTerrainPlugin) mineFieldPlugins += terrainPlugin } } addMagneticFieldScripts(engine, playerFleet, playerLocation, magneticFieldPlugins) @@ -149,10 +149,95 @@ class terrainEffectScriptAdder: baseNikoCombatScript() { addHyperspaceTerrainScripts(engine, playerFleet, playerLocation, playerCoordinates, hyperspaceTerrainPlugins) addBlackHoleTerrainScripts(engine, playerFleet, playerLocation, playerCoordinates, blackHoleTerrainPlugins) addMesonFieldTerrainScripts(engine, playerFleet, playerLocation, playerCoordinates, mesonFieldPlugins) + addMinefieldTerrainPlugins(engine, playerFleet, playerLocation, playerCoordinates, mineFieldPlugins) //addRingSystemTerrainScripts(engine, playerFleet, playerLocation, playerCoordinates, ringTerrainPlugins) // dust clouds already have an effect } + private fun addMinefieldTerrainPlugins( + engine: CombatEngineAPI, + playerFleet: CampaignFleetAPI, + playerLocation: LocationAPI, + playerCoordinates: Vector2f, + mineFieldPlugins: MutableSet + ) { + if (!MCTE_debugUtils.indEvoEnabled || !MCTE_settings.MINEFIELD_ENABLED) return + if (mineFieldPlugins.isEmpty()) return + + val castedPlugins = (mineFieldPlugins as MutableSet) + val battle = playerFleet.battle ?: return + + val minefieldToHostileSide = HashMap>() + + for (plugin in mineFieldPlugins) { + val market = plugin.primary + val factionId = market.factionId + + if (battle.sideOne.any { plugin.canAttackFleet(it) }) { // this doesnt work :( it crashes :( it cant recognize the function :( + if (minefieldToHostileSide[plugin] == null) minefieldToHostileSide[plugin] = HashSet() + minefieldToHostileSide[plugin]!! += BattleSide.ONE + } + if (battle.sideTwo.any { plugin.canAttackFleet(it) }) { + if (minefieldToHostileSide[plugin] == null) minefieldToHostileSide[plugin] = HashSet() + minefieldToHostileSide[plugin]!! += BattleSide.TWO + } + } + + val targetsToInstances = HashMap() + targetsToInstances[0] = 0 // on player side + targetsToInstances[1] = 0 // on enemy side + //sidesToInstances[100] = 0 // targetting both sides + + for (entry in minefieldToHostileSide) { + val minefield = entry.key + val sides = entry.value + + val hostileToSideOne = sides.contains(BattleSide.ONE) + val hostileToSideTwo = sides.contains(BattleSide.TWO) + val playerSide = battle.pickSide(playerFleet) + + if (hostileToSideOne && hostileToSideTwo) { + targetsToInstances[0] = targetsToInstances[0]!! + 1 + targetsToInstances[1] = targetsToInstances[1]!! + 1 // attack both sides + } else { + if ((playerSide == BattleSide.ONE && hostileToSideOne) || (playerSide == BattleSide.TWO && hostileToSideTwo)) { + targetsToInstances[0] = targetsToInstances[0]!! + 1 // attack enemy + } else { + targetsToInstances[1] = targetsToInstances[1]!! + 1 // attack player + } + } + + //sides.forEach { sidesToInstances[it] += 1} + //val location = battle.computeCenterOfMass() + //val entity = stationToEntity[station]!! + //val angle = VectorUtils.getAngle(entity.location, location) + + //ArtilleryStationEffect(owner, angle, station.type).start() + } + if (targetsToInstances.any { it.value > 0 }) { + combatEffectTypes.MINEFIELD.createInformedEffectInstance(targetsToInstances).start() + } + } + + // i dont like that this exists but whatever lol + private fun MineBeltTerrainPlugin.canAttackFleet(fleet: CampaignFleetAPI): Boolean { + var friend = false + + val m = primary + + if (m != null && !m.isPlanetConditionMarketOnly) { + friend = fleet.isPlayerFleet && m.isPlayerOwned || fleet.faction.id == m.factionId || fleet.faction.getRelationshipLevel(m.factionId).isAtWorst(RepLevel.INHOSPITABLE) + if (!m.isPlayerOwned && fleet.isPlayerFleet && !fleet.isTransponderOn) { + friend = false + } + } + if (fleet.memoryWithoutUpdate.contains(MemFlags.MEMORY_KEY_MISSION_IMPORTANT)) friend = true + if (friend) return false + + for (area in disabledAreas) if (area.contains(fleet)) return false + return true + } + private fun addMesonFieldTerrainScripts( engine: CombatEngineAPI, playerFleet: CampaignFleetAPI, @@ -184,6 +269,8 @@ class terrainEffectScriptAdder: baseNikoCombatScript() { playerLocation: LocationAPI, playerCoordinates: Vector2f) { + if (!MCTE_settings.OBJECTIVES_ENABLED) return + val commRelays: MutableSet = HashSet() val navBuoys: MutableSet = HashSet() val sensorRelays: MutableSet = HashSet() diff --git a/jars/src/niko/MCTE/settings/MCTE_settings.kt b/jars/src/niko/MCTE/settings/MCTE_settings.kt index a537ad6..a41d86e 100644 --- a/jars/src/niko/MCTE/settings/MCTE_settings.kt +++ b/jars/src/niko/MCTE/settings/MCTE_settings.kt @@ -148,6 +148,9 @@ object MCTE_settings { var MAKESHIFT_OBJECTIVE_EFFECT_MULT = 0.85f + // OBJECTIVES + var OBJECTIVES_ENABLED = true + // COMMS RELAY var COMMS_RELAY_ENABLED = true var COMMS_RELAY_MAX_DISTANCE = 5000f @@ -179,6 +182,15 @@ object MCTE_settings { var MESON_STORM_SYSTEM_RANGE_MULT = 3f // :) var MESON_STORM_VISION_MULT = 3f // :))) + // INDEVO CONFIG + // MINEFIELD + var MINEFIELD_ENABLED = true + var MINEFIELD_MIN_SECS_BETWEEN_TICKS = 1.8f + var MINEFIELD_MAX_SECS_BETWEEN_TICKS = 2.6f + + var MINEFIELD_MIN_MINES_PER_TICK = 2 + var MINEFIELD_MAX_MINES_PER_TICK = 5 + @JvmStatic fun getHyperstormFearThreshold(): Float { return (HYPERSTORM_ENERGY_DAMAGE + HYPERSTORM_EMP_DAMAGE * EMP_DAMAGE_FEAR_MULT)*0.4f @@ -297,8 +309,14 @@ object MCTE_settings { //MAX_SHIPS_ALLOWED = configJson.getInt("MCTE_debrisFieldMaxPieces")!! + OBJECTIVES_ENABLED = LunaSettings.getBoolean(modId, "MCTE_objectivesToggle")!! + // COMMS RELAY + // NAV RELAY + + // SENSOR ARRAY + // MPC CONFIG // MESON FIELD MESON_FIELD_ENABLED = LunaSettings.getBoolean(modId, "MCTE_mesonToggle")!! @@ -310,6 +328,15 @@ object MCTE_settings { MESON_STORM_SYSTEM_RANGE_MULT = configJson.getFloat("MCTE_mesonStormSystemRangeMult") - 1 MESON_STORM_VISION_MULT = configJson.getFloat("MCTE_mesonStormVisionMult") - 1 + // INDEVO CONFIG + // MINEFIELD + MINEFIELD_ENABLED = LunaSettings.getBoolean(modId, "MCTE_minefieldToggle")!! + MINEFIELD_MIN_MINES_PER_TICK = LunaSettings.getInt(modId, "MCTE_minefieldMinMinesPerTick")!! + MINEFIELD_MAX_MINES_PER_TICK = LunaSettings.getInt(modId, "MCTE_minefieldMaxMinesPerTick")!! + MINEFIELD_MIN_SECS_BETWEEN_TICKS = LunaSettings.getFloat(modId, "MCTE_minefieldMinSecsBetweenTicks")!! + MINEFIELD_MAX_SECS_BETWEEN_TICKS = LunaSettings.getFloat(modId, "MCTE_minefieldMaxSecsBetweenTicks")!! + + // UNGP CONFIG UNGP_EFFECT_BASE_MULT = LunaSettings.getFloat(modId, "MCTE_UNGPEffectMult")!! } diff --git a/mod_info.json b/mod_info.json index 5b887cc..fddb870 100644 --- a/mod_info.json +++ b/mod_info.json @@ -3,7 +3,7 @@ "name":"More Combat Terrain Effects", # Displayed to the player "author":"Niko", "utility":"false", - "version":"1.7.2", + "version":"1.8.0", "description":"Adds combat effects to magnetic fields, slipstreams, nebulae, hyperstorms, pulsars, and black holes.", "gameVersion": "0.97a-RC11", "jars":["jars/niko_MCTE.jar"], diff --git a/niko_MCTE.iml b/niko_MCTE.iml index a121ec5..d6420e4 100644 --- a/niko_MCTE.iml +++ b/niko_MCTE.iml @@ -27,9 +27,10 @@ - + + \ No newline at end of file