Skip to content

Commit

Permalink
sdeewad
Browse files Browse the repository at this point in the history
  • Loading branch information
nikothedude committed Sep 24, 2024
1 parent 45ad26d commit 6510f36
Show file tree
Hide file tree
Showing 19 changed files with 398 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .idea/libraries/IndEvo.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions .idea/libraries/Station_Augments.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Station_Augments2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/libraries/indev.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions MCTE.version
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
9 changes: 8 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions data/config/LunaSettings.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified jars/niko_MCTE.jar
Binary file not shown.
13 changes: 13 additions & 0 deletions jars/src/niko/MCTE/combatEffectTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Int, Int> ?: return
instance.targetSidesToInstance.forEach { instance.targetSidesToInstance[it.key] = instance.targetSidesToInstance[it.key]!! + newSides[it.key]!! }
}
},
BLACKHOLE {
override fun createEffectInstance(): blackHoleEffectScript {
return blackHoleEffectScript()
Expand Down
1 change: 1 addition & 0 deletions jars/src/niko/MCTE/listeners/objectiveTerrainAdder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<IncomingMine> = 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<IncomingMine>(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<IncomingMine>()
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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6510f36

Please sign in to comment.