Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e5f0f75
Functional Stable Update Post-5.2 (#1937)
ari-steas Mar 23, 2025
a264515
Untapping Hydra (#1965)
FP-Anomaly Mar 26, 2025
1068953
Increase climbing cost between shield controllers and SI generators
ari-steas Mar 28, 2025
9e35608
Modification to Logic | Model Fix (#1969)
CommodoreChet Mar 28, 2025
78147a1
Add NHI Fenrir to block category
ari-steas Mar 28, 2025
ac4f99e
Fix ARM Targetting (#1970)
CommodoreChet Mar 28, 2025
b782215
Fusion Heat Nerf
ari-steas Mar 31, 2025
f73a37b
Stable Update Pre-5.3 (#1968)
ari-steas Mar 31, 2025
4000702
Merge branch 'stable'
ari-steas Mar 31, 2025
b952f7e
Update BlockCategories_StarCoreCorporate.sbc
ari-steas Mar 31, 2025
05fab8e
Update BlockCategories_StarCoreCorporate.sbc (#1971)
ari-steas Mar 31, 2025
f409dbe
MWO Clanner ERPPC
BadM0dder Apr 1, 2025
b932443
Merge branch 'main' into season-5
BadM0dder Apr 1, 2025
93171de
MWO Clanner ERPPC (#1972)
BadM0dder Apr 1, 2025
65fac03
Add RocketCore Gamemode (#1973)
ari-steas Apr 2, 2025
615319e
Iowa Particle Visibility Fix (#1974)
ari-steas Apr 2, 2025
afaf289
Disable GridStopped check for Siege Mode resistance (#1975)
ari-steas Apr 4, 2025
fc0126f
Missed Bool Flip (#1976)
CommodoreChet Apr 4, 2025
5eed1d5
Sigen patch two (#1977)
ari-steas Apr 5, 2025
dab4670
Fusion Storage Patch (#1979)
ari-steas Apr 5, 2025
a683e0b
Fusion patch (#1980)
ari-steas Apr 5, 2025
a27be5e
Fusion Storage Patch (#1981)
ari-steas Apr 5, 2025
6915a0d
Merge branch 'stable'
ari-steas Apr 5, 2025
829e764
Disable some Hydra fragment effects
ari-steas Apr 7, 2025
ab9c11e
Update Hydra_12GA_Ammo.cs
ari-steas Apr 7, 2025
f6c45d6
Fix 'Sticky' Block Points Display (#1962)
ari-steas Apr 8, 2025
e6aa066
Fusion Thruster Rebalance
ari-steas Apr 10, 2025
176aac1
charon buff charon buff charon buff
BadM0dder Apr 10, 2025
0872c63
Merge branch 'season-5' of https://github.com/BadM0dder/SCModReposito…
BadM0dder Apr 10, 2025
bc59990
first draft nyx fix
BadM0dder Apr 10, 2025
127035c
Merge branch 'main' into season-5
BadM0dder Apr 10, 2025
de6fa33
hold on the active radiator shouldn't be LoS checking there
ari-steas Apr 10, 2025
5a22558
Merge branch 'main' into season-5
BadM0dder Apr 10, 2025
f344b46
charon buff (#1986)
BadM0dder Apr 10, 2025
907c817
Update Nyx.cs
BadM0dder Apr 10, 2025
edeff19
Merge branch 'season-5' of https://github.com/BadM0dder/SCModReposito…
BadM0dder Apr 10, 2025
593e025
Merge branch 'main' into season-5
BadM0dder Apr 10, 2025
b6720bf
Un Nerf X4
BadM0dder Apr 10, 2025
96405a4
Merge branch 'season-5' of https://github.com/BadM0dder/SCModReposito…
BadM0dder Apr 10, 2025
a62b9cf
fixing the phobos
BadM0dder Apr 10, 2025
6f4e720
ion points
BadM0dder Apr 10, 2025
efa4e50
Season 5 (#1987)
BadM0dder Apr 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,345 changes: 2,345 additions & 0 deletions Gamemode Mods/StarCore SUGMA Gamemodes/Data/Prefabs/RocketBall.sbc

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
using SC.SUGMA.API;
using SC.SUGMA.GameState;
using System;
using System.Collections.Generic;
using System.Linq;
using RichHudFramework;
using VRage.Game.ModAPI;
using SC.SUGMA.Utilities;
using Sandbox.ModAPI;
using Sandbox.Game.Entities;
using Sandbox.Game;
using VRageMath;
using VRage.ModAPI;

namespace SC.SUGMA.GameModes.RocketCore
{
internal class RocketCoreGamemode : GamemodeBase
{
public static double MatchDuration = 20;

/// <summary>
/// Lists currently tracked factions.
/// </summary>
public readonly List<IMyFaction> TrackedFactions = new List<IMyFaction>();
public List<IMyFaction> InFactions { get; private set; } = new List<IMyFaction>();
protected IMyFaction _winningFaction;

public PointTracker PointTracker;

protected ShareTrackApi ShareTrackApi => SUGMA_SessionComponent.I.ShareTrackApi;
public MatchTimer MatchTimer => SUGMA_SessionComponent.I.GetComponent<MatchTimer>("MatchTimer");
public Dictionary<IMyFaction, SphereZone> FactionGoals = new Dictionary<IMyFaction, SphereZone>();
private bool _waitingForBallSpawn = false;
public override string ReadableName { get; internal set; } = "RocketCore";

public IMyCubeGrid BallEntity = null;

public override string Description { get; internal set; } =
"Score by pushing the ball into the enemy team's goal! Grids are made invincible.";

public RocketCoreGamemode()
{
ArgumentParser += new ArgumentParser(
new ArgumentParser.ArgumentDefinition(
time => double.TryParse(time, out MatchDuration),
"t",
"match-time",
"Match time, in minutes.")
);
}

public override void Close()
{
StopRound();
}

public override void UpdateActive()
{
if (PointTracker == null || MatchTimer == null ||
TrackedFactions == null) // ten billion nullchecks of aristeas
return;

if (MatchTimer.IsMatchEnded && MyAPIGateway.Session.IsServer)
StopRound();

if (_waitingForBallSpawn)
return;

foreach (var zoneSet in FactionGoals)
{
if (zoneSet.Value.ContainedGrids.Count <= 0)
continue;
// Goal was made
PointTracker.AddFactionPoints(zoneSet.Key, -1);
SUGMA_SessionComponent.I.GetComponent<RocketCoreHud>("rocHud")?.GoalScored(zoneSet.Key);

if (_winningFaction != null)
break;

SpawnBall();
Log.Info($"Goal was scored against {zoneSet.Key.Name}! New points: {PointTracker.GetFactionPoints(zoneSet.Key)}");

_waitingForBallSpawn = true;
}
}

public override void StartRound(string[] arguments = null)
{
_waitingForBallSpawn = false;
_winningFaction = null;
PointTracker = new PointTracker(3, 0);
PointTracker.OnFactionWin += OnFactionLose;

SUGMA_SessionComponent.I.UnregisterComponent("ROCPointTracker");
if (!MyAPIGateway.Utilities.IsDedicated)
SUGMA_SessionComponent.I.UnregisterComponent("rocHud");

foreach (var grid in ShareTrackApi.GetTrackedGrids())
{
var faction = PlayerTracker.I.GetGridFaction(grid);
if (faction == null || !ShareTrackApi.IsGridAlive(grid))
continue;

if (!TrackedFactions.Contains(faction))
TrackedFactions.Add(faction);

List<IMyCubeGrid> subGrids = new List<IMyCubeGrid>();
grid.GetGridGroup(GridLinkTypeEnum.Physical).GetGrids(subGrids);
foreach (var subGrid in subGrids)
{
((MyCubeGrid)subGrid).Immune = true;
((MyCubeGrid)subGrid).DestructibleBlocks = false;
}
}

if (TrackedFactions.Count <= 1)
{
MyAPIGateway.Utilities.ShowNotification("There aren't any combatants, idiot!", 10000, "Red");
StopRound();
return;
}

SUGMA_SessionComponent.I.RegisterComponent("ROCPointTracker", PointTracker);

var factionNames = new List<string>();
var factionSpawns = SUtils.GetFactionSpawns();
foreach (var faction in TrackedFactions)
{
factionNames.Add($"|{faction.Tag}|");
foreach (var compareFaction in TrackedFactions)
{
if (faction == compareFaction)
continue;

MyAPIGateway.Session.Factions.DeclareWar(faction.FactionId, compareFaction.FactionId);
//MyAPIGateway.Utilities.ShowMessage("ROC", $"Declared war between {factionKvp.Key.Name} and {faction.Name}");
}

if (factionSpawns.ContainsKey(faction))
{
var zone = new SphereZone(
factionSpawns[faction].GetPosition() - factionSpawns[faction].GetPosition().Normalized() * 2500,
750)
{
SphereDrawColor = faction.CustomColor.ColorMaskToRgb().SetAlphaPct(0.25f),
GridFilter = Array.Empty<IMyCubeGrid>()
};
FactionGoals[faction] = zone;
SUGMA_SessionComponent.I.RegisterComponent($"RocZone{faction.FactionId}", zone);
}
}

InFactions = new List<IMyFaction>(TrackedFactions);

base.StartRound(arguments);
MyAPIGateway.Utilities.ShowNotification("Combatants: " + string.Join(" vs ", factionNames), 10000, "Red");
MatchTimer.Start(MatchDuration);

if (!MyAPIGateway.Utilities.IsDedicated)
SUGMA_SessionComponent.I.RegisterComponent("rocHud", new RocketCoreHud(this));

SpawnBall();

Log.Info("Started a ROC match." +
$"\n- Combatants: {string.Join(" vs ", factionNames)}");
}

private void OnFactionLose(IMyFaction loser)
{
foreach (var grid in ShareTrackApi.GetTrackedGrids())
{
var faction = PlayerTracker.I.GetGridFaction(grid);
if (faction == null || !ShareTrackApi.IsGridAlive(grid) || faction != loser) continue;

List<IMyCubeGrid> subGrids = new List<IMyCubeGrid>();
grid.GetGridGroup(GridLinkTypeEnum.Physical).GetGrids(subGrids);
foreach (var subGrid in subGrids)
{
((MyCubeGrid)subGrid).Immune = false;
((MyCubeGrid)subGrid).DestructibleBlocks = true;
}

FactionGoals[loser].IsVisible = false;
InFactions.Remove(loser);
}

if (InFactions.Count > 1) return;

_winningFaction = InFactions[0];
StopRound();
}

public override void StopRound()
{
BallEntity?.Close();
bool setWinnerFromArgs = false;
foreach (var arg in Arguments)
{
if (arg.StartsWith("win"))
{
long factionId;
long.TryParse(arg.Remove(0, 3), out factionId);

_winningFaction = MyAPIGateway.Session.Factions.TryGetFactionById(factionId);
setWinnerFromArgs = true;
Log.Info($"Winner in arguments found: {factionId} ({_winningFaction?.Name})");
break;
}
}

if (!setWinnerFromArgs && MyAPIGateway.Session.IsServer)
{
Arguments = Arguments.Concat(new[] { $"win{_winningFaction?.FactionId ?? -1}" }).ToArray();
}

SUGMA_SessionComponent.I.GetComponent<RocketCoreHud>("rocHud")?.MatchEnded(_winningFaction);

foreach (var factionKvp in TrackedFactions)
{
foreach (var faction in TrackedFactions)
{
if (faction == factionKvp)
continue;

MyAPIGateway.Session.Factions.SendPeaceRequest(factionKvp.FactionId, faction.FactionId);
MyAPIGateway.Session.Factions.AcceptPeace(faction.FactionId, factionKvp.FactionId);
}
}

// Reset destructibility
foreach (var grid in ShareTrackApi.GetTrackedGrids())
{
List<IMyCubeGrid> subGrids = new List<IMyCubeGrid>();
grid.GetGridGroup(GridLinkTypeEnum.Physical).GetGrids(subGrids);
foreach (var subGrid in subGrids)
{
((MyCubeGrid)subGrid).Immune = false;
((MyCubeGrid)subGrid).DestructibleBlocks = true;
}
}

foreach (var zone in FactionGoals)
SUGMA_SessionComponent.I.UnregisterComponent(zone.Value.ComponentId);

MatchTimer?.Stop();
SUGMA_SessionComponent.I.UnregisterComponent("PointTracker");

base.StopRound();
InFactions.Clear();
TrackedFactions.Clear();
FactionGoals.Clear();
PointTracker = null;
}

protected void SpawnBall()
{
if (!MyAPIGateway.Session.IsServer)
return;

BallEntity?.Close();
MyVisualScriptLogicProvider.PrefabSpawned += PrefabSpawned;
MyVisualScriptLogicProvider.SpawnPrefab("THE BALL", SUtils.RandVector().Normalized() * 250, Vector3D.Forward, Vector3D.Up, entityName: "SugmaTheBall");
}

private void PrefabSpawned(string entityName)
{
try
{
IMyEntity ballEnt;
if (!MyAPIGateway.Entities.TryGetEntityByName(entityName, out ballEnt))
throw new Exception("Could not find ball entity!");

BallEntity = (IMyCubeGrid) ballEnt;
SUGMA_SessionComponent.I.ShareTrackApi.TrackGrid(BallEntity);

MyVisualScriptLogicProvider.PrefabSpawned -= PrefabSpawned;
Log.Info("RocketCoreGamemode spawned ball entity " + entityName + " at " + BallEntity.GetPosition());

var array = new[]
{
BallEntity
};

foreach (var zone in FactionGoals)
zone.Value.GridFilter = array;
_waitingForBallSpawn = false;
}
catch (Exception ex)
{
Log.Exception(ex, typeof(RocketCoreGamemode));
}
}

internal override void DisplayWinMessage()
{
if (_winningFaction == null)
{
MyAPIGateway.Utilities.ShowNotification("YOU ARE ALL LOSERS.", 10000, "Red");
return;
}

MyAPIGateway.Utilities.ShowNotification($"A WINNER IS [{_winningFaction?.Name}]!", 10000);
}
}
}
Loading
Loading