Skip to content

Commit

Permalink
Merge pull request #2893 from CombatExtended-Continued/HeightFuse
Browse files Browse the repository at this point in the history
height fuse
  • Loading branch information
N7Huntsman authored Jan 15, 2024
2 parents 39357a1 + 4f6709d commit 5fa6d2e
Show file tree
Hide file tree
Showing 8 changed files with 916 additions and 727 deletions.
1,375 changes: 738 additions & 637 deletions Defs/Ammo/Shell/81mmMortar.xml

Large diffs are not rendered by default.

170 changes: 85 additions & 85 deletions Defs/Effects/Motes.xml
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<!-- Suppression Mote -->
<!-- Suppression Mote -->

<ThingDef ParentName="MoteBase">
<defName>Mote_SuppressIcon</defName>
<graphicData>
<texPath>Things/Mote/Mote_SuppressIcon</texPath>
</graphicData>
<thingClass>MoteThrownAttached</thingClass>
<altitudeLayer>MetaOverlays</altitudeLayer>
<mote>
<fadeInTime>0.25</fadeInTime>
<solidTime>1</solidTime>
<fadeOutTime>1.4</fadeOutTime>
<attachedDrawOffset>(0.45, 0, 0.45)</attachedDrawOffset>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_SuppressIcon</defName>
<graphicData>
<texPath>Things/Mote/Mote_SuppressIcon</texPath>
</graphicData>
<thingClass>MoteThrownAttached</thingClass>
<altitudeLayer>MetaOverlays</altitudeLayer>
<mote>
<fadeInTime>0.25</fadeInTime>
<solidTime>1</solidTime>
<fadeOutTime>1.4</fadeOutTime>
<attachedDrawOffset>(0.45, 0, 0.45)</attachedDrawOffset>
</mote>
</ThingDef>

<ThingDef ParentName="MoteBase">
<defName>Mote_HunkerIcon</defName>
<graphicData>
<texPath>Things/Mote/Mote_HunkerDownIcon</texPath>
</graphicData>
<thingClass>MoteThrownAttached</thingClass>
<altitudeLayer>MetaOverlays</altitudeLayer>
<mote>
<fadeInTime>0.25</fadeInTime>
<solidTime>1</solidTime>
<fadeOutTime>1.4</fadeOutTime>
<attachedDrawOffset>(0.45, 0, 0.45)</attachedDrawOffset>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_HunkerIcon</defName>
<graphicData>
<texPath>Things/Mote/Mote_HunkerDownIcon</texPath>
</graphicData>
<thingClass>MoteThrownAttached</thingClass>
<altitudeLayer>MetaOverlays</altitudeLayer>
<mote>
<fadeInTime>0.25</fadeInTime>
<solidTime>1</solidTime>
<fadeOutTime>1.4</fadeOutTime>
<attachedDrawOffset>(0.45, 0, 0.45)</attachedDrawOffset>
</mote>
</ThingDef>

<!-- Legacy Motes -->
<!-- Legacy Motes -->

<ThingDef ParentName="MoteBase">
<defName>Mote_BigExplode</defName>
<graphicData>
<texPath>Things/Mote/BigExplode</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.05</fadeInTime>
<solidTime>0.4</solidTime>
<fadeOutTime>0.45</fadeOutTime>
<growthRate>15</growthRate>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_BigExplode</defName>
<graphicData>
<texPath>Things/Mote/BigExplode</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0</fadeInTime>
<solidTime>0.4</solidTime>
<fadeOutTime>0.45</fadeOutTime>
<growthRate>0</growthRate>
</mote>
</ThingDef>

<ThingDef ParentName="MoteBase">
<defName>Mote_Firetrail</defName>
<graphicData>
<texPath>Things/Mote/Mote_FireSmoked</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.083</fadeInTime>
<solidTime>0.083</solidTime>
<fadeOutTime>1</fadeOutTime>
<growthRate>0.035</growthRate>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_Firetrail</defName>
<graphicData>
<texPath>Things/Mote/Mote_FireSmoked</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.083</fadeInTime>
<solidTime>0.083</solidTime>
<fadeOutTime>1</fadeOutTime>
<growthRate>0.035</growthRate>
</mote>
</ThingDef>

<!-- Flare Motes -->
<!-- Flare Motes -->

<ThingDef ParentName="MoteBase">
<defName>Mote_FlareGlow</defName>
<thingClass>CombatExtended.MoteThrownCE</thingClass>
<graphicData>
<texPath>Things/Mote/FireGlow</texPath>
<shaderType>MoteGlow</shaderType>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.75</fadeInTime>
<solidTime>1.08</solidTime>
<fadeOutTime>0.8</fadeOutTime>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_FlareGlow</defName>
<thingClass>CombatExtended.MoteThrownCE</thingClass>
<graphicData>
<texPath>Things/Mote/FireGlow</texPath>
<shaderType>MoteGlow</shaderType>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.75</fadeInTime>
<solidTime>1.08</solidTime>
<fadeOutTime>0.8</fadeOutTime>
</mote>
</ThingDef>

<ThingDef ParentName="MoteBase">
<defName>Mote_FlareSmoke</defName>
<thingClass>CombatExtended.MoteThrownCE</thingClass>
<graphicData>
<texPath>Things/Mote/Smoke</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.50</fadeInTime>
<solidTime>6</solidTime>
<fadeOutTime>3.2</fadeOutTime>
<growthRate>0.005</growthRate>
</mote>
</ThingDef>
<ThingDef ParentName="MoteBase">
<defName>Mote_FlareSmoke</defName>
<thingClass>CombatExtended.MoteThrownCE</thingClass>
<graphicData>
<texPath>Things/Mote/Smoke</texPath>
</graphicData>
<altitudeLayer>MoteOverhead</altitudeLayer>
<mote>
<fadeInTime>0.50</fadeInTime>
<solidTime>6</solidTime>
<fadeOutTime>3.2</fadeOutTime>
<growthRate>0.005</growthRate>
</mote>
</ThingDef>

</Defs>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public virtual void Explode(Thing instigator, Vector3 pos, Map map, float scaleF
}

//Try to throw fragments -- increase count by scaleFactor
parent.TryGetComp<CompFragments>()?.Throw(pos, map, instigator);//scaleFactor);
foreach (var comp in parent.GetComps<CompFragments>())
{
comp.Throw(pos, map, instigator);
}

if (Props.explosiveRadius > 0 //&& Props.damageAmountBase > 0 Disabled to allow flame explosions etc
&& parent.def != null)
Expand Down
2 changes: 2 additions & 0 deletions Source/CombatExtended/CombatExtended/DefOfs/CE_ThingDefOf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace CombatExtended
[DefOf]
public static class CE_ThingDefOf
{
public static ThingDef Mote_BigExplode;

public static ThingDef Mote_FlareSmoke;

public static ThingDef Mote_FlareGlow;
Expand Down
17 changes: 15 additions & 2 deletions Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,14 +1352,27 @@ public virtual void Impact(Thing hitThing)
effecter.Trigger(new TargetInfo(explodePos.ToIntVec3(), Map, false), new TargetInfo(explodePos.ToIntVec3(), Map, false));
effecter.Cleanup();
}

ProjectilePropertiesCE projectileCE = def.projectile as ProjectilePropertiesCE;
float effectScale = projectileCE.detonateEffectsScaleOverride > 0 ? projectileCE.detonateEffectsScaleOverride : projectileCE.explosionRadius * 2;
if (projectileCE.detonateMoteDef != null)
{
MoteMaker.MakeStaticMote(DrawPos, Map, CE_ThingDefOf.Mote_BigExplode, effectScale);
}
if (projectileCE.detonateFleckDef != null)
{
FleckCreationData dataStatic = FleckMaker.GetDataStatic(DrawPos, MapHeld, projectileCE.detonateFleckDef, effectScale);
MapHeld.flecks.CreateFleck(dataStatic);
}
var projectilePropsCE = (def.projectile as ProjectilePropertiesCE);

var explodingComp = this.TryGetComp<CompExplosiveCE>();

if (explodingComp == null)
{
this.TryGetComp<CompFragments>()?.Throw(explodePos, Map, launcher);
foreach (var comp in GetComps<CompFragments>())
{
comp.Throw(explodePos, Map, launcher);
}
}

//If the comp exists, it'll already call CompFragments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public override void Impact(Thing hitThing)
postExplosionGasType: props.postExplosionGasType
);

if (this.TryGetComp<CompFragments>() != null)
foreach (var comp in GetComps<CompFragments>())
{
this.TryGetComp<CompFragments>().Throw(finalPos.ToVector3(), this.Map, this);
comp.Throw(finalPos.ToVector3(), this.Map, this);
}

this.Destroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.Sound;
using CombatExtended.Compatibility;
using CombatExtended.Lasers;
using ProjectileImpactFX;
using CombatExtended.Utilities;

namespace CombatExtended
{
class ProjectileCE_HeightFuse : ProjectileCE
{
float detonationHeight => (def.projectile as ProjectilePropertiesCE).aimHeightOffset;

bool armed;

public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref armed, "armed", false);
}

public override void Tick()
{
base.Tick();
if (!armed && LastPos.y > detonationHeight)
{
armed = true;
}
if (armed && Height <= detonationHeight)
{
HeightFuseAirBurst();
}
}

public override void Impact(Thing hitThing)
{
//intercept impact if it hit something after where height fuse should have triggered
if (armed && Height <= detonationHeight)
{
HeightFuseAirBurst();
}
else
{
base.Impact(hitThing);
}
}

void HeightFuseAirBurst()
{
float f = (LastPos.y - detonationHeight) / (LastPos.y - Height);
ExactPosition = f * (LastPos - ExactPosition);
if (!ExactPosition.ToIntVec3().IsValid)
{
Destroy();
return;
}
base.Impact(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class ProjectilePropertiesCE : ProjectileProperties
public float airborneSuppressionFactor = 1;
public float dangerFactor = 1;

public ThingDef detonateMoteDef;
public FleckDef detonateFleckDef;
public float detonateEffectsScaleOverride = -1;

#region Bunker Buster fields
/// <summary>
/// Amount of tiles ProjectileCE_BunkerBuster will detonate after after penetrating an obstacle
Expand Down

0 comments on commit 5fa6d2e

Please sign in to comment.