Skip to content

Commit

Permalink
LS: Allow configuring sponge lifetime (thanks Rulja1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Feb 9, 2023
1 parent 7189f4c commit 4acdd4f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 1 addition & 3 deletions MCGalaxy/Modules/Games/LavaSurvival/CmdLavaSurvival.cs
Expand Up @@ -79,7 +79,7 @@ sealed class CmdLavaSurvival : RoundsGameCmd

string prop = args[2];
if (prop.CaselessEq("flood")) {
p.Message("Place or destroy the block you want to be the total flood block spawn point.");
p.Message("Place or destroy the block you want to be the flood block spawn point.");
p.MakeSelection(1, cfg, SetFloodPos);
return;
} else if (prop.CaselessEq("layer")) {
Expand Down Expand Up @@ -211,8 +211,6 @@ sealed class CmdLavaSurvival : RoundsGameCmd
p.Message("&HSets chance of water instead of lava flood");
p.Message("&T/LS set block upwards [chance]");
p.Message("&HSets chance of lava/water flooding upwards");
p.Message("&T/LS set block destroy [chance]");
p.Message("&HSets chance of the lava/water destroying blocks");
} else if (message.CaselessEq("other")) {
p.Message("&T/LS set other &H- View times and safe zone location");
p.Message("&T/LS set other safe &H- Sets safe area that can't be flooded");
Expand Down
3 changes: 3 additions & 0 deletions MCGalaxy/Modules/Games/LavaSurvival/LSConfig.cs
Expand Up @@ -59,6 +59,9 @@ public sealed class LSConfig : RoundsGameConfig
public int WildChance = 5;
[ConfigInt("chance-extreme", "Mode chances", 0, 0, 100)]
public int ExtremeChance = 0;

[ConfigInt("sponge-life-ticks", "Sponges", 200, 0)]
public int SpongeLife = 200;

public override bool AllowAutoload { get { return false; } }
protected override string GameName { get { return "Lava Survival"; } }
Expand Down
10 changes: 5 additions & 5 deletions MCGalaxy/Modules/Games/LavaSurvival/LSGame.Physics.cs
Expand Up @@ -49,8 +49,7 @@ public sealed partial class LSGame : RoundsGame
}

void DoSponge(Level lvl, ref PhysInfo C) {
// revert to air after 200 ticks
if (C.Data.Value2++ <= 200) return;
if (C.Data.Value2++ < Config.SpongeLife) return;

lvl.AddUpdate(C.Index, Block.Air, default(PhysicsArgs));
OtherPhysics.DoSpongeRemoved(lvl, C.Index, !waterMode);
Expand Down Expand Up @@ -191,13 +190,14 @@ public sealed partial class LSGame : RoundsGame
}
} else if (!lvl.Props[block].OPBlock) {
PhysicsArgs C = default(PhysicsArgs);
C.Type1 = PhysicsArgs.Wait; C.Value1 = GetDestoryDelay();
C.Type2 = PhysicsArgs.Dissipate; C.Value2 = GetDissipateChance();
C.Type1 = PhysicsArgs.Wait; C.Value1 = destroyDelay;
C.Type2 = PhysicsArgs.Dissipate; C.Value2 = dissipateChance;
lvl.AddUpdate(index, Block.CoalOre, C);
}
}


byte GetDestoryDelay() {
byte GetDestroyDelay() {
LSFloodMode mode = floodMode;

if (mode == LSFloodMode.Disturbed) return 200;
Expand Down
7 changes: 5 additions & 2 deletions MCGalaxy/Modules/Games/LavaSurvival/LSGame.cs
Expand Up @@ -49,6 +49,7 @@ public sealed partial class LSGame : RoundsGame
LSFloodMode floodMode;
int curLayer, spreadDelay;
int roundTotalSecs, floodDelaySecs, layerIntervalSecs;
byte destroyDelay, dissipateChance;
static bool hooked;

public static LSGame Instance = new LSGame();
Expand Down Expand Up @@ -106,9 +107,11 @@ public sealed partial class LSGame : RoundsGame
}

public void SetFloodMode(LSFloodMode mode) {
floodMode = mode;
if (!RoundInProgress) return;
floodMode = mode;
destroyDelay = GetDestroyDelay();
dissipateChance = GetDissipateChance();

if (!RoundInProgress) return;
Map.SetPhysics(floodMode > LSFloodMode.Calm ? 2 : 1);
}

Expand Down

0 comments on commit 4acdd4f

Please sign in to comment.