Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
418 changes: 418 additions & 0 deletions GameMod/MPDestructibleMissiles.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion GameMod/MPDoors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ internal class MPShootDoors
// In Multiplayer, players now open doors by shooting them or touching them.
private static void Postfix(GameObject go, ref bool __result)
{
if (go != null && (go.layer == 13 || go.layer == 9 || go.layer == 31) && GameplayManager.IsMultiplayerActive)
// layer 27: server-side destructible missiles (re-layered from 13 by MPDestructibleMissiles)
if (go != null && (go.layer == 13 || go.layer == 9 || go.layer == 31 || go.layer == MPDestructibleMissiles.MISSILE_LAYER) && GameplayManager.IsMultiplayerActive)
__result = true;
}
}
Expand Down
6 changes: 6 additions & 0 deletions GameMod/MPMatchInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public static void DrawMatchInfo(UIElement uie, Vector2 position)
uie.DrawStringSmall("SMASH ATTACK ENABLED", position - Vector2.right * LEFT_OFFSET, TEXT_SIZE, StringOffset.LEFT, UIManager.m_col_ui1, 1f, 200f);
position.y += LINE_SIZE;
}
if (MPModPrivateData.DestructibleMissiles)
{
show = true;
uie.DrawStringSmall("DESTRUCTIBLE MISSILES ENABLED", position - Vector2.right * LEFT_OFFSET, TEXT_SIZE, StringOffset.LEFT, UIManager.m_col_ui1, 1f, 200f);
position.y += LINE_SIZE;
}
if (MPModPrivateData.CtfCarrierBoostEnabled)
{
show = true;
Expand Down
23 changes: 22 additions & 1 deletion GameMod/MPModPrivateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ public static int LoadoutFilterBitmask
get { return MPLoadouts.LoadoutFilterBitmask; }
set { MPLoadouts.LoadoutFilterBitmask = value; }
}

public static bool ClientPhysics
{
get { return MPServerOptimization.enabled; }
Expand All @@ -1303,6 +1303,18 @@ public static int RollSpeedLimit
}
}

public static bool DestructibleMissiles
{
get { return MPDestructibleMissiles.Enabled; }
set { MPDestructibleMissiles.Enabled = value; }
}

public static float[] MissileTypeHealth
{
get { return MPDestructibleMissiles.MissileTypeHealth; }
set { MPDestructibleMissiles.MissileTypeHealth = value; }
}

public static JObject Serialize()
{
JObject jobject = new JObject();
Expand Down Expand Up @@ -1333,6 +1345,8 @@ public static JObject Serialize()
jobject["loadoutfilter"] = (int)LoadoutFilterBitmask;
jobject["clientphysics"] = ClientPhysics;
jobject["rollspeedlimit"] = RollSpeedLimit;
jobject["destructiblemissiles"] = DestructibleMissiles;
jobject["missiletypehealth"] = new JArray(MissileTypeHealth.Select(h => (JToken)(float)h));
return jobject;
}

Expand Down Expand Up @@ -1369,6 +1383,12 @@ public static void Deserialize(JToken root)
LoadoutFilterBitmask = root["loadoutfilter"].GetInt(MPLoadouts.MASK_DEFAULT);
ClientPhysics = root["clientphysics"].GetBool(false);
RollSpeedLimit = root["rollspeedlimit"].GetInt(7);
DestructibleMissiles = root["destructiblemissiles"].GetBool(false);
var hArr = root["missiletypehealth"] as JArray;
if (hArr != null && hArr.Count == 8)
MissileTypeHealth = hArr.Select((t, i) => t?.Value<float>() ?? MPDestructibleMissiles.DefaultHealth[i]).ToArray();
// a server's olmodsettings.json HP overrides win over the match creator's values
MPDestructibleMissiles.ApplyServerOverrides();
}

public static string GetModeString(MatchMode mode)
Expand Down Expand Up @@ -1666,6 +1686,7 @@ public static void PatchModPrivateData(MatchmakerPlayerRequest matchmakerPlayerR
MPModPrivateData.LoadoutFilterBitmask = MPLoadouts.LoadoutFilterBitmask;
MPModPrivateData.ClientPhysics = MPServerOptimization.prefEnabled;
MPModPrivateData.RollSpeedLimit = MPServerOptimization.RollSpeedLimit;
MPModPrivateData.DestructibleMissiles = Menus.mms_destructible_missiles;
if (Menus.mms_mp_projdata_fn == "STOCK") {
MPModPrivateData.CustomProjdata = string.Empty;
} else {
Expand Down
2 changes: 2 additions & 0 deletions GameMod/MPSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ static void Postfix(string filename)
Menus.mms_classic_spawns = ModPrefs.GetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
Menus.mms_assist_scoring = ModPrefs.GetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
Menus.mms_allow_smash = ModPrefs.GetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);
Menus.mms_destructible_missiles = ModPrefs.GetBool("MP_DESTRUCTIBLE_MISSILES", Menus.mms_destructible_missiles);

JoystickRotationFix.alt_turn_ramp_mode = ModPrefs.GetBool("SCALE_UP_ROTATION", JoystickRotationFix.alt_turn_ramp_mode);
MPColoredPlayerNames.isActive = ModPrefs.GetBool("MP_COLORED_NAMES", MPColoredPlayerNames.isActive);
Expand Down Expand Up @@ -391,6 +392,7 @@ private static void Prefix(string filename)
ModPrefs.SetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
ModPrefs.SetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
ModPrefs.SetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);
ModPrefs.SetBool("MP_DESTRUCTIBLE_MISSILES", Menus.mms_destructible_missiles);
ModPrefs.SetBool("MP_CREEPER_COLORS", Menus.mms_creeper_colors);
ModPrefs.SetBool("MP_AUDIOTAUNTS_ACTIVE", MPAudioTaunts.AClient.active);
ModPrefs.SetInt("MP_AUDIOTAUNT_VOLUME", MPAudioTaunts.AClient.audio_taunt_volume);
Expand Down
2 changes: 1 addition & 1 deletion GameMod/MPTweaks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private static void Prefix(AcceptedToLobbyMessage accept_msg)
caps.Add("ModVersion", OlmodVersion.FullVersionString);
caps.Add("Modded", Core.GameMod.Modded ? "1" : "0");
caps.Add("ModsLoaded", Core.GameMod.ModsLoaded);
caps.Add("SupportsTweaks", "changeteam,deathreview,sniper,jip,nocompress_0_3_6,customloadouts,damagenumbers,ctfjoin,efirepacket,incompleteloadouts,cphysics" + (MPAudioTaunts.AClient.active ? ",audiotaunts":""));
caps.Add("SupportsTweaks", "changeteam,deathreview,sniper,jip,nocompress_0_3_6,customloadouts,damagenumbers,ctfjoin,efirepacket,incompleteloadouts,cphysics,destructiblemissiles"+ (MPAudioTaunts.AClient.active ? ",audiotaunts":""));
caps.Add("ModPrivateData", "1");
caps.Add("ClassicWeaponSpawns", "1");
caps.Add("NetVersion", MPTweaks.NET_VERSION.ToString());
Expand Down
36 changes: 25 additions & 11 deletions GameMod/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static bool mms_scale_respawn_time
public static bool mms_always_cloaked { get; set; }
public static bool mms_allow_smash { get; set; }
public static bool mms_damage_numbers { get; set; }
public static bool mms_destructible_missiles { get; set; }
public static bool mms_client_damage_numbers { get; set; } = true;
public static bool mms_assist_scoring { get; set; } = true;
public static bool mms_team_color_default { get; set; } = true;
Expand Down Expand Up @@ -131,6 +132,11 @@ public static string GetMMSDamageNumbers()
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_damage_numbers));
}

public static string GetMMSDestructibleMissiles()
{
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_destructible_missiles));
}

public static string GetMMSScaleRespawnTime()
{
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_scale_respawn_time));
Expand Down Expand Up @@ -323,11 +329,11 @@ private static void DrawRightColumn(UIElement uie, ref Vector2 position)
position.x += 600f;
position.y = col_top - 250f;
uie.SelectAndDrawStringOptionItem(Loc.LS("ALLOW REAR VIEW CAMERA"), position, 11, Menus.GetMMSRearViewPIP(), Loc.LS("CLIENTS CAN CHOOSE TO HAVE REAR VIEW"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("ALWAYS CLOAKED"), position, 15, Menus.GetMMSAlwaysCloaked(), Loc.LS("SHIPS ARE ALWAYS CLOAKED"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("CLASSIC SPAWNS"), position, 13, Menus.GetMMSClassicSpawns(), Loc.LS("SPAWN WITH IMPULSE+ DUALS AND FALCONS"), 1f, false);
position.y += 50f;
position.y += 45f;

if (MenuManager.mms_mode == ExtMatchMode.CTF)
{
Expand All @@ -338,22 +344,25 @@ private static void DrawRightColumn(UIElement uie, ref Vector2 position)
uie.SelectAndDrawStringOptionItem(Loc.LS("ASSISTS"), position, 18, Menus.GetMMSAssistScoring(), Loc.LS("AWARD POINTS FOR ASSISTING WITH KILLS"), 1f, false);
}

position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("PROJECTILE DATA"), position, 16, Menus.mms_mp_projdata_fn == "STOCK" ? "STOCK" : System.IO.Path.GetFileName(Menus.mms_mp_projdata_fn), string.Empty, 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("ALLOW SMASH ATTACK"), position, 17, Menus.GetMMSAllowSmash(), Loc.LS("ALLOWS PLAYERS TO USE THE SMASH ATTACK"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("TB PENETRATION"), position, 20, MPThunderboltPassthrough.isAllowed ? "ON" : "OFF", Loc.LS("ALLOWS THUNDERBOLT SHOTS TO PENETRATE SHIPS"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("DAMAGE NUMBERS"), position, 21, Menus.GetMMSDamageNumbers(), Loc.LS("SHOWS THE DAMAGE YOU DO TO OTHER SHIPS"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("CLIENT-SIDE PHYSICS"), position, 23, MPServerOptimization.prefEnabled ? "ENABLED" : "DISABLED", Loc.LS("ALLOWS CLIENTS TO PASS PRE-PROCESSED PHYSICS RATHER THAN RESIMULATING INPUTS ON THE SERVER"), 1f, false);
position.y += 50f;
position.y += 45f;
//uie.SelectAndDrawStringOptionItem(Loc.LS("SERVER INPUT BUFFER LENGTH"), position, 24, MPServerOptimization.InputBufferLength.ToString(), Loc.LS("NUMBER OF FRAMES TO BUFFER BEFORE SERVER PROCESSES INPUT IT HAS RECEIVED (OVERLOAD STOCK IS 3, TESTING VERSION IS 2)"), 1f, false); // TESTING
uie.SelectAndDrawStringOptionItem(Loc.LS("ROLL SPEED LIMIT"), position, 24, "+" + (MPServerOptimization.RollSpeedLimit - 3), Loc.LS("MAXIMUM ROLL SPEED MODIFIER TO ALLOW FOR THIS ROUND"), 1f, false);
position.y += 50f;
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("COLLISION MESH"), position, 22, Menus.GetMMSCollisionMesh(), Loc.LS("COLLIDER TO USE FOR PROJECTILE->SHIP COLLISIONS"), 1f, false);
}
position.y += 45f;
uie.SelectAndDrawStringOptionItem(Loc.LS("DESTRUCTIBLE MISSILES"), position, 25, Menus.GetMMSDestructibleMissiles(), Loc.LS("ALLOWS MISSILES TO BE SHOT DOWN IN FLIGHT"), 1f, false);

}

private static void AdjustAdvancedPositionCenterColumn(ref Vector2 position)
{
Expand Down Expand Up @@ -690,6 +699,11 @@ static void ProcessAdditional()
MPServerOptimization.RollSpeedLimit = 3 + ((2 + MPServerOptimization.RollSpeedLimit + UIManager.m_select_dir) % 5);
MenuManager.PlayCycleSound(1f, (float)UIManager.m_select_dir);
break;
case 25:
Menus.mms_destructible_missiles = !Menus.mms_destructible_missiles;
MenuManager.PlayCycleSound(1f, (float)UIManager.m_select_dir);
break;

}
}
else if (MenuManager.m_menu_micro_state == 10)
Expand Down
3 changes: 3 additions & 0 deletions GameMod/MessageTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public class MessageTypes
public const short MsgAudioTauntPacket = 153;

public const short MsgEnhancedFirePacket = 154;

public const short MsgPlayerPhysics = 155;

public const short MsgDestroyMissile = 156;

// Do not use 400, it is in use by Mod-Projdata.dll.
}
}