Skip to content

Commit

Permalink
added turret tossing, nerfed warheads
Browse files Browse the repository at this point in the history
  • Loading branch information
xianson committed Sep 16, 2024
1 parent f6abdf0 commit 89def56
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,23 @@
using Sandbox.Game;
using System;
using System.Collections.Generic;
using System.IO;
using VRageMath;
using VRage.Game;
using VRage.Game.Components;
using VRage.Game.ModAPI;
using VRage.Utils;
using System.Collections;
using Sandbox.Game.Entities.Cube;
using Sandbox.Game.Entities.Debris;
using Sandbox.Game.Entities;
using VRage.Game.Entity;
using SpaceEngineers.Game.Entities.Blocks;
using SpaceEngineers.Game.ModAPI;
using VRage.ModAPI;
using Sandbox.Common.ObjectBuilders.Definitions;
using Sandbox.Game.Weapons;
using System.Linq;

namespace Shrapnel
{
[MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
public class Core : MySessionComponentBase
{
HashSet<ChainLocation> chainLocations = new HashSet<ChainLocation>();
Dictionary<long, IMyAttachableTopBlock> turretTossPair = new Dictionary<long, IMyAttachableTopBlock>();

long tick;
private Queue<ShrapnelData> queue = new Queue<ShrapnelData>();

Expand Down Expand Up @@ -131,7 +125,12 @@ public void ProcessDamage(object target, ref MyDamageInformation info)
//MyAPIGateway.Utilities.ShowNotification($"Damage: {info.Amount}, {slim.BlockDefinition.Id.SubtypeName}", 500);
if (slim.BlockDefinition.Id.SubtypeName.Contains("AdvancedTurretRotor") && (slim.Integrity - info.Amount) < slim.MaxIntegrity * 0.7)
{
slim.FatBlock.CubeGrid.RazeBlock(slim.Position);
IMyAttachableTopBlock block = slim.FatBlock as IMyAttachableTopBlock;
if(block != null && block.Base != null && !turretTossPair.ContainsKey(block.EntityId))
{
turretTossPair.Add(block.EntityId, block);
block.Base.Detach();
}
}


Expand Down Expand Up @@ -348,14 +347,27 @@ public override void UpdateBeforeSimulation()

foreach (ChainLocation chain in explosionsToTrigger)
{
float totalDamage = 200f + (20 * chain.ammorackCount);
float totalRadius = 1f + (1f * chain.ammorackCount);
float totalDamage = 200f + (50 * chain.ammorackCount);
float totalRadius = 1.5f * chain.ammorackCount;
CreateExplosion(chain.position, totalDamage, totalRadius, null,false);
//MyAPIGateway.Utilities.ShowNotification($"Chain reaction with {chain.ammorackCount} ammo racks", 5000);
chainLocations.Remove(chain);
}
explosionsToTrigger.Clear();
}

foreach (IMyAttachableTopBlock block in turretTossPair.Values.ToList())
{
if(block.Base == null)
{
IMyCubeGrid grid = block.CubeGrid;
MatrixD gridMatrix = grid.WorldMatrix;
gridMatrix.Translation = grid.WorldMatrix.Translation + block.WorldMatrix.Up * 0.5;
grid.WorldMatrix = gridMatrix;
grid.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, block.WorldMatrix.Up * 1e7, grid.Physics.CenterOfMassWorld, null);
turretTossPair.Remove(block.EntityId);
}
}
}
}

Expand Down
42 changes: 42 additions & 0 deletions ModernWarfareGuns/Data/Utilities/turretrotors.sbc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,48 @@
<PCU>1</PCU>
</Definition>

<Definition xsi:type="MyObjectBuilder_WarheadDefinition">
<Id>
<TypeId>Warhead</TypeId>
<SubtypeId>SmallWarhead</SubtypeId>
</Id>
<DisplayName>DisplayName_Block_Warhead</DisplayName>
<Icon>Textures\GUI\Icons\Cubes\warhead.dds</Icon>
<Description>Description_Warhead</Description>
<CubeSize>Small</CubeSize>
<BlockTopology>TriangleMesh</BlockTopology>
<Size x="1" y="1" z="1" />
<ModelOffset x="0" y="0" z="0" />
<Model>Models\Cubes\Small\warhead.mwm</Model>
<Components>
<Component Subtype="SteelPlate" Count="1" />
<Component Subtype="Girder" Count="1" />
<Component Subtype="Construction" Count="1" />
<Component Subtype="SmallTube" Count="2" />
<Component Subtype="Computer" Count="1" />
<Component Subtype="Explosives" Count="2" />
<Component Subtype="SteelPlate" Count="3" />
</Components>
<CriticalComponent Subtype="Explosives" Index="0" />
<BuildProgressModels>
<Model BuildPercentUpperBound="0.50" File="Models\Cubes\Small\WarheadConstruction_1.mwm" />
<Model BuildPercentUpperBound="1.00" File="Models\Cubes\Small\WarheadConstruction_2.mwm" />
</BuildProgressModels>
<BlockPairName>Warhead</BlockPairName>
<ActionSound>WepLrgWarheadExpl</ActionSound>
<EdgeType>Light</EdgeType>
<BuildTimeSeconds>10</BuildTimeSeconds>
<ExplosionRadius> 2 </ExplosionRadius>
<WarheadExplosionDamage>13000</WarheadExplosionDamage>
<EmissiveColorPreset>Timer</EmissiveColorPreset>
<DestroyEffect>BlockDestroyedExplosion_Small</DestroyEffect>
<DestroySound>WepSmallWarheadExpl</DestroySound>
<PCU>50</PCU>
<IsAirTight>false</IsAirTight>
<TargetingGroups>
<string>Weapons</string>
</TargetingGroups>
</Definition>
<Definition xsi:type="MyObjectBuilder_MergeBlockDefinition">
<Id>
<TypeId>MergeBlock</TypeId>
Expand Down

0 comments on commit 89def56

Please sign in to comment.