diff --git a/Levels/Level.cs b/Levels/Level.cs
index 460f0bed6..2ecae614b 100644
--- a/Levels/Level.cs
+++ b/Levels/Level.cs
@@ -1268,12 +1268,7 @@ namespace MCGalaxy
}
}
- ///
- /// Gets or sets a value indicating whether physics are enabled.
- ///
- ///
- /// true if physics are enabled; otherwise, false.
- ///
+ /// Gets or sets a value indicating whether physics are enabled.
public bool PhysicsEnabled { get; set; }
public void Physics()
@@ -1522,80 +1517,7 @@ namespace MCGalaxy
}
else
{
- switch (blocks[C.b])
- {
- case Block.door_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door2_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door3_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door4_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door5_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door6_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door7_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door8_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door10_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door12_air:
- case Block.door13_air:
- case Block.door_iron_air:
- case Block.door_gold_air:
- case Block.door_cobblestone_air:
- case Block.door_red_air:
-
- case Block.door_dirt_air:
- case Block.door_grass_air:
- case Block.door_blue_air:
- case Block.door_book_air:
- AnyDoor(C, x, y, z, 16);
- break;
- case Block.door11_air:
- case Block.door14_air:
- AnyDoor(C, x, y, z, 4, true);
- break;
- case Block.door9_air:
- //door_air Change any door blocks nearby into door_air
- AnyDoor(C, x, y, z, 4);
- break;
-
- case Block.odoor1_air:
- case Block.odoor2_air:
- case Block.odoor3_air:
- case Block.odoor4_air:
- case Block.odoor5_air:
- case Block.odoor6_air:
- case Block.odoor7_air:
- case Block.odoor8_air:
- case Block.odoor9_air:
- case Block.odoor10_air:
- case Block.odoor11_air:
- case Block.odoor12_air:
-
- case Block.odoor1:
- case Block.odoor2:
- case Block.odoor3:
- case Block.odoor4:
- case Block.odoor5:
- case Block.odoor6:
- case Block.odoor7:
- case Block.odoor8:
- case Block.odoor9:
- case Block.odoor10:
- case Block.odoor11:
- case Block.odoor12:
- odoor(C);
- break;
- default:
- //non special blocks are then ignored, maybe it would be better to avoid getting here and cutting down the list
- if (!C.extraInfo.Contains("wait")) C.time = 255;
- break;
- }
+ DoorPhysics.Do(this, C);
}
}
catch
@@ -2581,74 +2503,6 @@ namespace MCGalaxy
}
break;
- case Block.door_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door2_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door3_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door4_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door5_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door6_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door7_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door8_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door10_air:
- //door_air Change any door blocks nearby into door_air
- case Block.door12_air:
- case Block.door13_air:
- case Block.door_iron_air:
- case Block.door_gold_air:
- case Block.door_cobblestone_air:
- case Block.door_red_air:
-
- case Block.door_dirt_air:
- case Block.door_grass_air:
- case Block.door_blue_air:
- case Block.door_book_air:
- AnyDoor(C, x, y, z, 16);
- break;
- case Block.door11_air:
- case Block.door14_air:
- AnyDoor(C, x, y, z, 4, true);
- break;
- case Block.door9_air:
- //door_air Change any door blocks nearby into door_air
- AnyDoor(C, x, y, z, 4);
- break;
-
- case Block.odoor1_air:
- case Block.odoor2_air:
- case Block.odoor3_air:
- case Block.odoor4_air:
- case Block.odoor5_air:
- case Block.odoor6_air:
- case Block.odoor7_air:
- case Block.odoor8_air:
- case Block.odoor9_air:
- case Block.odoor10_air:
- case Block.odoor11_air:
- case Block.odoor12_air:
-
- case Block.odoor1:
- case Block.odoor2:
- case Block.odoor3:
- case Block.odoor4:
- case Block.odoor5:
- case Block.odoor6:
- case Block.odoor7:
- case Block.odoor8:
- case Block.odoor9:
- case Block.odoor10:
- case Block.odoor11:
- case Block.odoor12:
- odoor(C);
- break;
-
case Block.air_flood_layer: //air_flood_layer
if (C.time < 1)
{
@@ -2717,229 +2571,21 @@ namespace MCGalaxy
break;
case Block.smalltnt:
- //For TNT Wars
- if (C.p != null && C.p.PlayingTntWars)
- {
- int ExplodeDistance = -1;
- switch (TntWarsGame.GetTntWarsGame(C.p).GameDifficulty)
- {
- case TntWarsGame.TntWarsDifficulty.Easy:
- if (C.time < 7)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- }
- else ExplodeDistance = 2;
- break;
-
- case TntWarsGame.TntWarsDifficulty.Normal:
- if (C.time < 5)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- }
- else ExplodeDistance = 2;
- break;
-
- case TntWarsGame.TntWarsDifficulty.Hard:
- if (C.time < 3)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- }
- else
- {
- ExplodeDistance = 2;
- }
- break;
-
- case TntWarsGame.TntWarsDifficulty.Extreme:
- if (C.time < 3)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- }
- else
- {
- ExplodeDistance = 3;
- }
- break;
- }
- if (ExplodeDistance != -1)
- {
- if (C.p.TntWarsKillStreak >= TntWarsGame.Properties.DefaultStreakTwoAmount && TntWarsGame.GetTntWarsGame(C.p).Streaks)
- {
- ExplodeDistance += 1;
- }
- MakeExplosion(x, y, z, ExplodeDistance - 2, true, TntWarsGame.GetTntWarsGame(C.p));
- List Killed = new List();
- players.ForEach(delegate(Player p1)
- {
- if (p1.PlayingTntWars && p1 != C.p && Math.Abs((int)(p1.pos[0] / 32) - x) + Math.Abs((int)(p1.pos[1] / 32) - y) + Math.Abs((int)(p1.pos[2] / 32) - z) < ((ExplodeDistance * 3) + 1))
- {
- Killed.Add(p1);
- }
- });
- TntWarsGame.GetTntWarsGame(C.p).HandleKill(C.p, Killed);
- }
- }
- //Normal
- else
- {
- if (physics < 3) Blockchange(x, y, z, Block.air);
-
- if (physics >= 3)
- {
- rand = new Random();
-
- if (C.time < 5 && physics == 3)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- break;
- }
-
- MakeExplosion(x, y, z, 0);
- }
- else
- {
- Blockchange(x, y, z, Block.air);
- }
- }
+ TntPhysics.DoSmallTnt(this, C, rand);
break;
-
case Block.bigtnt:
- if (physics < 3) Blockchange(x, y, z, Block.air);
-
- if (physics >= 3)
- {
- rand = new Random();
-
- if (C.time < 5 && physics == 3)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 1), z,
- GetTile(x, (ushort)(y + 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, (ushort)(y - 1), z,
- GetTile(x, (ushort)(y - 1), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange((ushort)(x + 1), y, z,
- GetTile((ushort)(x + 1), y, z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange((ushort)(x - 1), y, z,
- GetTile((ushort)(x - 1), y, z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, y, (ushort)(z + 1),
- GetTile(x, y, (ushort)(z + 1)) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, y, (ushort)(z - 1),
- GetTile(x, y, (ushort)(z - 1)) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
-
- break;
- }
-
- MakeExplosion(x, y, z, 1);
- }
- else
- {
- Blockchange(x, y, z, Block.air);
- }
+ TntPhysics.DoLargeTnt(this, C, rand, 1);
break;
-
case Block.nuketnt:
- if (physics < 3) Blockchange(x, y, z, Block.air);
-
- if (physics >= 3)
- {
- rand = new Random();
-
- if (C.time < 5 && physics == 3)
- {
- C.time += 1;
- Blockchange(x, (ushort)(y + 2), z,
- GetTile(x, (ushort)(y + 2), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, (ushort)(y - 2), z,
- GetTile(x, (ushort)(y - 2), z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange((ushort)(x + 1), y, z,
- GetTile((ushort)(x + 1), y, z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange((ushort)(x - 1), y, z,
- GetTile((ushort)(x - 1), y, z) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, y, (ushort)(z + 1),
- GetTile(x, y, (ushort)(z + 1)) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
- Blockchange(x, y, (ushort)(z - 1),
- GetTile(x, y, (ushort)(z - 1)) ==
- Block.lavastill
- ? Block.air
- : Block.lavastill);
-
- break;
- }
-
- MakeExplosion(x, y, z, 4);
- }
- else
- {
- Blockchange(x, y, z, Block.air);
- }
+ TntPhysics.DoLargeTnt(this, C, rand, 4);
break;
-
case Block.tntexplosion:
- if (rand.Next(1, 11) <= 7) AddUpdate(C.b, Block.air);
+ if (rand.Next(1, 11) <= 7)
+ AddUpdate(C.b, Block.air);
break;
-
case Block.train:
TrainPhysics.Do(this, C, rand);
break;
-
case Block.magma:
C.time++;
if (C.time < 3) break;
@@ -3360,542 +3006,20 @@ namespace MCGalaxy
case Block.birdred:
case Block.birdblue:
case Block.birdkill:
-
- #region HUNTER BIRDS
- foundPlayer = AIPhysics.ClosestPlayer(this, C);
-
- randomMovement:
- if (foundPlayer != null && rand.Next(1, 20) < 19)
- {
- currentNum = rand.Next(1, 10);
- foundNum = 0;
-
- switch (currentNum)
- {
- case 1:
- case 2:
- case 3:
- if ((foundPlayer.pos[0] / 32) - x != 0)
- {
- newNum =
- PosToInt(
- (ushort)
- (x +
- Math.Sign((foundPlayer.pos[0] / 32) -
- x)), y, z);
- if (GetTile(newNum) == Block.air)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 4;
- case 4:
- case 5:
- case 6:
- if ((foundPlayer.pos[1] / 32) - y != 0)
- {
- newNum = PosToInt(x,
- (ushort)
- (y +
- Math.Sign(
- (foundPlayer.pos[1] /
- 32) - y)), z);
- if (GetTile(newNum) == Block.air)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 7;
- case 7:
- case 8:
- case 9:
- if ((foundPlayer.pos[2] / 32) - z != 0)
- {
- newNum = PosToInt(x, y,
- (ushort)
- (z +
- Math.Sign(
- (foundPlayer.pos[2] /
- 32) - z)));
- if (GetTile(newNum) == Block.air)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 1;
- default:
- foundPlayer = null;
- goto randomMovement;
- }
- }
- else
- {
- switch (rand.Next(1, 15))
- {
- case 1:
- if (GetTile(x, (ushort)(y - 1), z) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y - 1), z),
- blocks[C.b])) break;
- else goto case 3;
- else goto case 3;
- case 2:
- if (GetTile(x, (ushort)(y + 1), z) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y + 1), z),
- blocks[C.b])) break;
- else goto case 6;
- else goto case 6;
- case 3:
- case 4:
- case 5:
- if (GetTile((ushort)(x - 1), y, z) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt((ushort)(x - 1), y, z),
- blocks[C.b])) break;
- else goto case 9;
- else goto case 9;
- case 6:
- case 7:
- case 8:
- if (GetTile((ushort)(x + 1), y, z) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt((ushort)(x + 1), y, z),
- blocks[C.b])) break;
- else goto case 12;
- else goto case 12;
- case 9:
- case 10:
- case 11:
- if (GetTile(x, y, (ushort)(z - 1)) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z - 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- case 12:
- case 13:
- case 14:
- default:
- if (GetTile(x, y, (ushort)(z + 1)) ==
- Block.air)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z + 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- }
- }
-
- removeSelf:
- if (!InnerChange)
- AddUpdate(C.b, Block.air);
+ HunterPhysics.DoKiller(this, C, rand, Block.air);
break;
-
- #endregion
-
case Block.fishbetta:
+ case Block.fishshark:
+ HunterPhysics.DoKiller(this, C, rand, Block.water);
+ break;
case Block.fishgold:
case Block.fishsalmon:
- case Block.fishshark:
case Block.fishsponge:
-
- #region FISH
- foundPlayer = AIPhysics.ClosestPlayer(this, C);
-
- randomMovement_fish:
- if (foundPlayer != null && rand.Next(1, 20) < 19)
- {
- currentNum = rand.Next(1, 10);
- foundNum = 0;
-
- switch (currentNum)
- {
- case 1:
- case 2:
- case 3:
- if ((foundPlayer.pos[0] / 32) - x != 0)
- {
- if (blocks[C.b] == Block.fishbetta ||
- blocks[C.b] == Block.fishshark)
- newNum =
- PosToInt(
- (ushort)
- (x +
- Math.Sign(
- (foundPlayer.pos[0] / 32) -
- x)), y, z);
- else
- newNum =
- PosToInt(
- (ushort)
- (x -
- Math.Sign(
- (foundPlayer.pos[0] / 32) -
- x)), y, z);
-
-
- if (GetTile(newNum) == Block.water)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_fish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 4;
- case 4:
- case 5:
- case 6:
- if ((foundPlayer.pos[1] / 32) - y != 0)
- {
- if (blocks[C.b] == Block.fishbetta ||
- blocks[C.b] == Block.fishshark)
- newNum = PosToInt(x,
- (ushort)
- (y +
- Math.Sign(
- (foundPlayer.
- pos[1] / 32) -
- y)), z);
- else
- newNum = PosToInt(x,
- (ushort)
- (y -
- Math.Sign(
- (foundPlayer.
- pos[1] / 32) -
- y)), z);
-
- if (GetTile(newNum) == Block.water)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_fish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 7;
- case 7:
- case 8:
- case 9:
- if ((foundPlayer.pos[2] / 32) - z != 0)
- {
- if (blocks[C.b] == Block.fishbetta ||
- blocks[C.b] == Block.fishshark)
- newNum = PosToInt(x, y,
- (ushort)
- (z +
- Math.Sign(
- (foundPlayer.
- pos[2] / 32) -
- z)));
- else
- newNum = PosToInt(x, y,
- (ushort)
- (z -
- Math.Sign(
- (foundPlayer.
- pos[2] / 32) -
- z)));
-
- if (GetTile(newNum) == Block.water)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_fish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 1;
- default:
- foundPlayer = null;
- goto randomMovement_fish;
- }
- }
- else
- {
- switch (rand.Next(1, 15))
- {
- case 1:
- if (GetTile(x, (ushort)(y - 1), z) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y - 1), z),
- blocks[C.b])) break;
- else goto case 3;
- else goto case 3;
- case 2:
- if (GetTile(x, (ushort)(y + 1), z) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y + 1), z),
- blocks[C.b])) break;
- else goto case 6;
- else goto case 6;
- case 3:
- case 4:
- case 5:
- if (GetTile((ushort)(x - 1), y, z) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt((ushort)(x - 1), y, z),
- blocks[C.b])) break;
- else goto case 9;
- else goto case 9;
- case 6:
- case 7:
- case 8:
- if (GetTile((ushort)(x + 1), y, z) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt((ushort)(x + 1), y, z),
- blocks[C.b])) break;
- else goto case 12;
- else goto case 12;
- case 9:
- case 10:
- case 11:
- if (GetTile(x, y, (ushort)(z - 1)) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z - 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- case 12:
- case 13:
- case 14:
- default:
- if (GetTile(x, y, (ushort)(z + 1)) ==
- Block.water)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z + 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- }
- }
-
- removeSelf_fish:
- if (!InnerChange)
- AddUpdate(C.b, Block.water);
+ HunterPhysics.DoFlee(this, C, rand, Block.water);
break;
-
- #endregion
-
case Block.fishlavashark:
-
- #region lavafish
- foundPlayer = AIPhysics.ClosestPlayer(this, C);
-
- randomMovement_lavafish:
- if (foundPlayer != null && rand.Next(1, 20) < 19)
- {
- currentNum = rand.Next(1, 10);
- foundNum = 0;
-
- switch (currentNum)
- {
- case 1:
- case 2:
- case 3:
- if ((foundPlayer.pos[0] / 32) - x != 0)
- {
- if (blocks[C.b] == Block.fishlavashark)
- newNum =
- PosToInt(
- (ushort)
- (x +
- Math.Sign(
- (foundPlayer.pos[0] / 32) -
- x)), y, z);
- else
- newNum =
- PosToInt(
- (ushort)
- (x -
- Math.Sign(
- (foundPlayer.pos[0] / 32) -
- x)), y, z);
-
-
- if (GetTile(newNum) == Block.lava)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_lavafish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 4;
- case 4:
- case 5:
- case 6:
- if ((foundPlayer.pos[1] / 32) - y != 0)
- {
- if (blocks[C.b] == Block.fishlavashark)
- newNum = PosToInt(x,
- (ushort)
- (y +
- Math.Sign(
- (foundPlayer.
- pos[1] / 32) -
- y)), z);
- else
- newNum = PosToInt(x,
- (ushort)
- (y -
- Math.Sign(
- (foundPlayer.
- pos[1] / 32) -
- y)), z);
-
- if (GetTile(newNum) == Block.lava)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_lavafish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 7;
- case 7:
- case 8:
- case 9:
- if ((foundPlayer.pos[2] / 32) - z != 0)
- {
- if (blocks[C.b] == Block.fishlavashark)
- newNum = PosToInt(x, y,
- (ushort)
- (z +
- Math.Sign(
- (foundPlayer.
- pos[2] / 32) -
- z)));
- else
- newNum = PosToInt(x, y,
- (ushort)
- (z -
- Math.Sign(
- (foundPlayer.
- pos[2] / 32) -
- z)));
-
- if (GetTile(newNum) == Block.lava)
- if (AddUpdate(newNum, blocks[C.b]))
- goto removeSelf_lavafish;
- }
-
- foundNum++;
- if (foundNum >= 3) goto default;
- else goto case 1;
- default:
- foundPlayer = null;
- goto randomMovement_lavafish;
- }
- }
- else
- {
- switch (rand.Next(1, 15))
- {
- case 1:
- if (GetTile(x, (ushort)(y - 1), z) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y - 1), z),
- blocks[C.b])) break;
- else goto case 3;
- else goto case 3;
- case 2:
- if (GetTile(x, (ushort)(y + 1), z) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt(x, (ushort)(y + 1), z),
- blocks[C.b])) break;
- else goto case 6;
- else goto case 6;
- case 3:
- case 4:
- case 5:
- if (GetTile((ushort)(x - 1), y, z) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt((ushort)(x - 1), y, z),
- blocks[C.b])) break;
- else goto case 9;
- else goto case 9;
- case 6:
- case 7:
- case 8:
- if (GetTile((ushort)(x + 1), y, z) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt((ushort)(x + 1), y, z),
- blocks[C.b])) break;
- else goto case 12;
- else goto case 12;
- case 9:
- case 10:
- case 11:
- if (GetTile(x, y, (ushort)(z - 1)) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z - 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- case 12:
- case 13:
- case 14:
- default:
- if (GetTile(x, y, (ushort)(z + 1)) ==
- Block.lava)
- if (
- AddUpdate(
- PosToInt(x, y, (ushort)(z + 1)),
- blocks[C.b])) break;
- else InnerChange = true;
- else InnerChange = true;
- break;
- }
- }
-
- removeSelf_lavafish:
- if (!InnerChange)
- AddUpdate(C.b, Block.lava);
+ HunterPhysics.DoKiller(this, C, rand, Block.lava);
break;
-
- #endregion
-
case Block.rockethead:
RocketPhysics.Do(this, C, rand);
break;
@@ -3966,8 +3090,7 @@ namespace MCGalaxy
break;
default:
- //non special blocks are then ignored, maybe it would be better to avoid getting here and cutting down the list
- if (!C.extraInfo.Contains("wait")) C.time = 255;
+ DoorPhysics.Do(this, C);
break;
}
}
@@ -4795,191 +3918,6 @@ namespace MCGalaxy
//================================================================================================================
-
- public void odoor(Check C)
- {
- if (C.time == 0)
- {
- byte foundBlock;
-
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, -1, 0, 0)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, -1, 0, 0), foundBlock, true);
- }
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, 1, 0, 0)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, 1, 0, 0), foundBlock, true);
- }
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, 0, -1, 0)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, 0, -1, 0), foundBlock, true);
- }
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, 0, 1, 0)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, 0, 1, 0), foundBlock, true);
- }
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, 0, 0, -1)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, 0, 0, -1), foundBlock, true);
- }
- foundBlock = Block.odoor(GetTile(IntOffset(C.b, 0, 0, 1)));
- if (foundBlock == blocks[C.b])
- {
- AddUpdate(IntOffset(C.b, 0, 0, 1), foundBlock, true);
- }
- }
- else
- {
- C.time = 255;
- }
- C.time++;
- }
-
- public void AnyDoor(Check C, ushort x, ushort y, ushort z, int timer, bool instaUpdate = false)
- {
- if (C.time == 0)
- {
- try
- {
- PhysDoor((ushort)(x + 1), y, z, instaUpdate);
- }
- catch
- {
- }
- try
- {
- PhysDoor((ushort)(x - 1), y, z, instaUpdate);
- }
- catch
- {
- }
- try
- {
- PhysDoor(x, y, (ushort)(z + 1), instaUpdate);
- }
- catch
- {
- }
- try
- {
- PhysDoor(x, y, (ushort)(z - 1), instaUpdate);
- }
- catch
- {
- }
- try
- {
- PhysDoor(x, (ushort)(y - 1), z, instaUpdate);
- }
- catch
- {
- }
- try
- {
- PhysDoor(x, (ushort)(y + 1), z, instaUpdate);
- }
- catch
- {
- }
-
- try
- {
- if (blocks[C.b] == Block.door8_air)
- {
- for (int xx = -1; xx <= 1; xx++)
- {
- for (int yy = -1; yy <= 1; yy++)
- {
- for (int zz = -1; zz <= 1; zz++)
- {
- byte b = GetTile(IntOffset(C.b, xx, yy, zz));
- if (b == Block.rocketstart)
- {
- if (physics == 5)
- {
- Blockchange(x, y, z, Block.air);
- return;
- }
- int b1 = IntOffset(C.b, xx * 3, yy * 3, zz * 3);
- int b2 = IntOffset(C.b, xx * 2, yy * 2, zz * 2);
- bool unblocked = blocks[b1] == Block.air && blocks[b2] == Block.air &&
- !ListUpdate.Exists(Update => Update.b == b1) &&
- !ListUpdate.Exists(Update => Update.b == b2);
- if (unblocked)
- {
- AddUpdate(IntOffset(C.b, xx * 3, yy * 3, zz * 3), Block.rockethead);
- AddUpdate(IntOffset(C.b, xx * 2, yy * 2, zz * 2), Block.fire);
- }
- }
- else if (b == Block.firework)
- {
- if (physics == 5)
- {
- Blockchange(x, y, z, Block.air);
- return;
- }
- int b1 = IntOffset(C.b, xx, yy + 1, zz);
- int b2 = IntOffset(C.b, xx, yy + 2, zz);
- bool unblocked = blocks[b1] == Block.air && blocks[b2] == Block.air &&
- !ListUpdate.Exists(Update => Update.b == b1) &&
- !ListUpdate.Exists(Update => Update.b == b2);
- if (unblocked)
- {
- AddUpdate(b2, Block.firework);
- AddUpdate(b1, Block.lavastill, false, "dissipate 100");
- }
- }
- else if (b == Block.tnt)
- {
- if (physics == 5)
- {
- Blockchange(x, y, z, Block.air);
- return;
- }
- MakeExplosion((ushort)(x + xx), (ushort)(y + yy), (ushort)(z + zz), 0);
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- }
- if (C.time < timer) C.time++;
- else
- {
- AddUpdate(C.b, Block.SaveConvert(blocks[C.b])); //turn back into door
- C.time = 255;
- }
- }
-
- public void PhysDoor(ushort x, ushort y, ushort z, bool instaUpdate)
- {
- int foundInt = PosToInt(x, y, z);
- byte FoundAir = Block.DoorAirs(blocks[foundInt]);
-
- if (FoundAir != 0)
- {
- if (!instaUpdate) AddUpdate(foundInt, FoundAir);
- else Blockchange(x, y, z, FoundAir);
- return;
- }
-
- if (Block.tDoor(blocks[foundInt]))
- {
- AddUpdate(foundInt, Block.air, false, "wait 16 door 1 revert " + blocks[foundInt].ToString());
- }
-
- if (Block.odoor(blocks[foundInt]) != Block.Zero) AddUpdate(foundInt, Block.odoor(blocks[foundInt]), true);
- }
-
public void MakeExplosion(ushort x, ushort y, ushort z, int size, bool force = false, TntWarsGame CheckForExplosionZone = null)
{
//DateTime start = DateTime.Now;
diff --git a/Levels/Physics/DoorPhysics.cs b/Levels/Physics/DoorPhysics.cs
new file mode 100644
index 000000000..da80c6eb6
--- /dev/null
+++ b/Levels/Physics/DoorPhysics.cs
@@ -0,0 +1,211 @@
+/*
+ Copyright 2015 MCGalaxy
+
+ Dual-licensed under the Educational Community License, Version 2.0 and
+ the GNU General Public License, Version 3 (the "Licenses"); you may
+ not use this file except in compliance with the Licenses. You may
+ obtain a copy of the Licenses at
+
+ http://www.opensource.org/licenses/ecl2.php
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the Licenses are distributed on an "AS IS"
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ or implied. See the Licenses for the specific language governing
+ permissions and limitations under the Licenses.
+ */
+using System;
+
+namespace MCGalaxy.BlockPhysics {
+
+ public static class DoorPhysics {
+
+ public static void Do(Level lvl, Check C) {
+ ushort x, y, z;
+ lvl.IntToPos(C.b, out x, out y, out z);
+
+ switch (lvl.blocks[C.b]) {
+
+ //Change any door blocks nearby into door_air
+ case Block.door_air:
+ case Block.door2_air:
+ case Block.door3_air:
+ case Block.door4_air:
+ case Block.door5_air:
+ case Block.door6_air:
+ case Block.door7_air:
+ case Block.door8_air:
+ case Block.door10_air:
+ case Block.door12_air:
+ case Block.door13_air:
+ case Block.door_iron_air:
+ case Block.door_gold_air:
+ case Block.door_cobblestone_air:
+ case Block.door_red_air:
+
+ case Block.door_dirt_air:
+ case Block.door_grass_air:
+ case Block.door_blue_air:
+ case Block.door_book_air:
+ AnyDoor(lvl, C, x, y, z, 16);
+ break;
+ case Block.door11_air:
+ case Block.door14_air:
+ AnyDoor(lvl, C, x, y, z, 4, true);
+ break;
+ case Block.door9_air:
+ AnyDoor(lvl, C, x, y, z, 4);
+ break;
+
+ case Block.odoor1_air:
+ case Block.odoor2_air:
+ case Block.odoor3_air:
+ case Block.odoor4_air:
+ case Block.odoor5_air:
+ case Block.odoor6_air:
+ case Block.odoor7_air:
+ case Block.odoor8_air:
+ case Block.odoor9_air:
+ case Block.odoor10_air:
+ case Block.odoor11_air:
+ case Block.odoor12_air:
+
+ case Block.odoor1:
+ case Block.odoor2:
+ case Block.odoor3:
+ case Block.odoor4:
+ case Block.odoor5:
+ case Block.odoor6:
+ case Block.odoor7:
+ case Block.odoor8:
+ case Block.odoor9:
+ case Block.odoor10:
+ case Block.odoor11:
+ case Block.odoor12:
+ odoorPhysics(lvl, C);
+ break;
+ default:
+ //non special blocks are then ignored, maybe it would be better to avoid getting here and cutting down the list
+ if (!C.extraInfo.Contains("wait")) C.time = 255;
+ break;
+ }
+ }
+
+ public static void odoorPhysics(Level lvl, Check C) {
+ if (C.time != 0) {
+ C.time = 0;
+ return;
+ }
+
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, -1, 0, 0));
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, +1, 0, 0));
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, -1, 0));
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, +1, 0));
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, -1));
+ odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, +1));
+ C.time++;
+ }
+
+ static void odoorNeighbour(Level lvl, Check C, int offset) {
+ int index = C.b + offset;
+ byte block = Block.odoor(lvl.GetTile(index));
+
+ if (block == lvl.blocks[C.b])
+ lvl.AddUpdate(index, block, true);
+ }
+
+ static void AnyDoor(Level lvl, Check C, ushort x, ushort y, ushort z, int timer, bool instaUpdate = false) {
+ if (C.time != 0) {
+ CheckDoorRevert(lvl, C, timer);
+ return;
+ }
+ PhysDoor(lvl, (ushort)(x + 1), y, z, instaUpdate);
+ PhysDoor(lvl, (ushort)(x - 1), y, z, instaUpdate);
+ PhysDoor(lvl, x, y, (ushort)(z + 1), instaUpdate);
+ PhysDoor(lvl, x, y, (ushort)(z - 1), instaUpdate);
+ PhysDoor(lvl, x, (ushort)(y - 1), z, instaUpdate);
+ PhysDoor(lvl, x, (ushort)(y + 1), z, instaUpdate);
+
+ if (lvl.blocks[C.b] != Block.door8_air) {
+ CheckDoorRevert(lvl, C, timer);
+ return;
+ }
+
+ for (int xx = -1; xx <= 1; xx++)
+ for (int yy = -1; yy <= 1; yy++)
+ for (int zz = -1; zz <= 1; zz++)
+ {
+ byte b = lvl.GetTile(lvl.IntOffset(C.b, xx, yy, zz));
+ if (b == Block.rocketstart) {
+ if (lvl.physics == 5) {
+ lvl.Blockchange(x, y, z, Block.air);
+ return;
+ }
+ int b1 = lvl.IntOffset(C.b, xx * 3, yy * 3, zz * 3);
+ int b2 = lvl.IntOffset(C.b, xx * 2, yy * 2, zz * 2);
+ bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
+ !lvl.ListUpdate.Exists(u => u.b == b1) &&
+ !lvl.ListUpdate.Exists(u => u.b == b2);
+
+ if (unblocked) {
+ lvl.AddUpdate(b1, Block.rockethead);
+ lvl.AddUpdate(b2, Block.fire);
+ }
+ } else if (b == Block.firework) {
+ if (lvl.physics == 5) {
+ lvl.Blockchange(x, y, z, Block.air);
+ return;
+ }
+ int b1 = lvl.IntOffset(C.b, xx, yy + 1, zz);
+ int b2 = lvl.IntOffset(C.b, xx, yy + 2, zz);
+ bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
+ !lvl.ListUpdate.Exists(u => u.b == b1) &&
+ !lvl.ListUpdate.Exists(u => u.b == b2);
+
+ if (unblocked) {
+ lvl.AddUpdate(b2, Block.firework);
+ lvl.AddUpdate(b1, Block.lavastill, false, "dissipate 100");
+ }
+ } else if (b == Block.tnt) {
+ if (lvl.physics == 5) {
+ lvl.Blockchange(x, y, z, Block.air);
+ return;
+ }
+ lvl.MakeExplosion((ushort)(x + xx), (ushort)(y + yy), (ushort)(z + zz), 0);
+ }
+ }
+ CheckDoorRevert(lvl, C, timer);
+ }
+
+ static void CheckDoorRevert(Level lvl, Check C, int timer) {
+ if (C.time < timer) {
+ C.time++;
+ } else {
+ lvl.AddUpdate(C.b, Block.SaveConvert(lvl.blocks[C.b])); //turn back into door
+ C.time = 255;
+ }
+ }
+
+ static void PhysDoor(Level lvl, ushort x, ushort y, ushort z, bool instaUpdate) {
+ int index = lvl.PosToInt(x, y, z);
+ if (index < 0) return;
+ byte rawBlock = lvl.blocks[index];
+
+ byte airDoor = Block.DoorAirs(rawBlock);
+ if (airDoor != 0) {
+ if (!instaUpdate)
+ lvl.AddUpdate(index, airDoor);
+ else
+ lvl.Blockchange(x, y, z, airDoor);
+ return;
+ }
+
+ if (Block.tDoor(rawBlock))
+ lvl.AddUpdate(index, Block.air, false, "wait 16 door 1 revert " + rawBlock.ToString());
+ byte oDoor = Block.odoor(rawBlock);
+ if (oDoor != Block.Zero)
+ lvl.AddUpdate(index, oDoor, true);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Levels/Physics/HunterPhysics.cs b/Levels/Physics/HunterPhysics.cs
new file mode 100644
index 000000000..8212c6c2b
--- /dev/null
+++ b/Levels/Physics/HunterPhysics.cs
@@ -0,0 +1,151 @@
+/*
+ Copyright 2015 MCGalaxy
+
+ Dual-licensed under the Educational Community License, Version 2.0 and
+ the GNU General Public License, Version 3 (the "Licenses"); you may
+ not use this file except in compliance with the Licenses. You may
+ obtain a copy of the Licenses at
+
+ http://www.opensource.org/licenses/ecl2.php
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the Licenses are distributed on an "AS IS"
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ or implied. See the Licenses for the specific language governing
+ permissions and limitations under the Licenses.
+ */
+using System;
+
+namespace MCGalaxy.BlockPhysics {
+
+ public static class HunterPhysics {
+
+ public static void DoKiller(Level lvl, Check C, Random rand, byte target) {
+ Player closest = AIPhysics.ClosestPlayer(lvl, C);
+ ushort x, y, z;
+ lvl.IntToPos(C.b, out x, out y, out z);
+
+ if (closest != null && rand.Next(1, 20) < 19) {
+ int index = 0, dirsVisited = 0;
+
+ switch (rand.Next(1, 10)) {
+ case 1:
+ case 2:
+ case 3:
+ if ((closest.pos[0] / 32) - x != 0) {
+ index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 4;
+ case 4:
+ case 5:
+ case 6:
+ if ((closest.pos[1] / 32) - y != 0) {
+ index = lvl.PosToInt(x, (ushort)(y + Math.Sign((closest.pos[1] / 32) - y)), z);
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 7;
+ case 7:
+ case 8:
+ case 9:
+ if ((closest.pos[2] / 32) - z != 0) {
+ index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 1;
+ }
+ }
+ RandomlyMove(lvl, C, rand, x, y, z, target);
+ }
+
+ public static void DoFlee(Level lvl, Check C, Random rand, byte target) {
+ Player closest = AIPhysics.ClosestPlayer(lvl, C);
+ ushort x, y, z;
+ lvl.IntToPos(C.b, out x, out y, out z);
+
+ if (closest != null && rand.Next(1, 20) < 19) {
+ int index = 0, dirsVisited = 0;
+
+ switch (rand.Next(1, 10)) {
+ case 1:
+ case 2:
+ case 3:
+ if ((closest.pos[0] / 32) - x != 0) {
+ index = lvl.PosToInt((ushort)(x - Math.Sign((closest.pos[0] / 32) - x)), y, z);
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 4;
+ case 4:
+ case 5:
+ case 6:
+ if ((closest.pos[1] / 32) - y != 0) {
+ index = lvl.PosToInt(x, (ushort)(y - Math.Sign((closest.pos[1] / 32) - y)), z);
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 7;
+ case 7:
+ case 8:
+ case 9:
+ if ((closest.pos[2] / 32) - z != 0) {
+ index = lvl.PosToInt(x, y, (ushort)(z - Math.Sign((closest.pos[2] / 32) - z)));
+ if (MoveFish(lvl, C, index, target)) return;
+ }
+ dirsVisited++;
+ if (dirsVisited >= 3) break;
+ goto case 1;
+ }
+ }
+ RandomlyMove(lvl, C, rand, x, y, z, target);
+ }
+
+ static bool MoveFish(Level lvl, Check C, int index, byte target) {
+ if (index >= 0 && lvl.blocks[index] == target && lvl.AddUpdate(index, lvl.blocks[C.b])) {
+ lvl.AddUpdate(C.b, target);
+ return true;
+ }
+ return false;
+ }
+
+ static void RandomlyMove(Level lvl, Check C, Random rand, ushort x, ushort y, ushort z, byte target ) {
+ switch (rand.Next(1, 15)) {
+ case 1:
+ if (MoveFish(lvl, C, lvl.PosToInt(x, (ushort)(y - 1), z), target)) return;
+ goto case 3;
+ case 2:
+ if (MoveFish(lvl, C, lvl.PosToInt(x, (ushort)(y + 1), z), target)) return;
+ goto case 6;
+ case 3:
+ case 4:
+ case 5:
+ if (MoveFish(lvl, C, lvl.PosToInt((ushort)(x - 1), y, z), target)) return;
+ goto case 9;
+ case 6:
+ case 7:
+ case 8:
+ if (MoveFish(lvl, C, lvl.PosToInt((ushort)(x + 1), y, z), target)) return;
+ goto case 12;
+ case 9:
+ case 10:
+ case 11:
+ MoveFish(lvl, C, lvl.PosToInt(x, y, (ushort)(z - 1)), target);
+ break;
+ case 12:
+ case 13:
+ case 14:
+ MoveFish(lvl, C, lvl.PosToInt(x, y, (ushort)(z + 1)), target);
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Levels/Physics/TntPhysics.cs b/Levels/Physics/TntPhysics.cs
new file mode 100644
index 000000000..a06aee342
--- /dev/null
+++ b/Levels/Physics/TntPhysics.cs
@@ -0,0 +1,105 @@
+/*
+ Copyright 2015 MCGalaxy
+
+ Dual-licensed under the Educational Community License, Version 2.0 and
+ the GNU General Public License, Version 3 (the "Licenses"); you may
+ not use this file except in compliance with the Licenses. You may
+ obtain a copy of the Licenses at
+
+ http://www.opensource.org/licenses/ecl2.php
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the Licenses are distributed on an "AS IS"
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ or implied. See the Licenses for the specific language governing
+ permissions and limitations under the Licenses.
+ */
+using System;
+using System.Collections.Generic;
+
+namespace MCGalaxy.BlockPhysics {
+
+ public static class TntPhysics {
+
+ static void ShowWarningFuse(Level lvl, ushort x, ushort y, ushort z) {
+ lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill ? Block.air : Block.lavastill);
+ lvl.Blockchange(x, (ushort)(y - 1), z, lvl.GetTile(x, (ushort)(y - 1), z) == Block.lavastill ? Block.air : Block.lavastill);
+ lvl.Blockchange((ushort)(x + 1), y, z, lvl.GetTile((ushort)(x + 1), y, z) == Block.lavastill ? Block.air : Block.lavastill);
+ lvl.Blockchange((ushort)(x - 1), y, z, lvl.GetTile((ushort)(x - 1), y, z) == Block.lavastill ? Block.air : Block.lavastill);
+ lvl.Blockchange(x, y, (ushort)(z + 1), lvl.GetTile(x, y, (ushort)(z + 1)) == Block.lavastill ? Block.air : Block.lavastill);
+ lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill);
+ }
+
+ public static void DoLargeTnt(Level lvl, Check C, Random rand, int power) {
+ ushort x, y, z;
+ lvl.IntToPos(C.b, out x, out y, out z);
+
+ if (lvl.physics < 3) {
+ lvl.Blockchange(x, y, z, Block.air);
+ } else {
+ if (C.time < 5 && lvl.physics == 3) {
+ C.time++;
+ ShowWarningFuse(lvl, x, y, z);
+ return;
+ }
+ lvl.MakeExplosion(x, y, z, power);
+ }
+ }
+
+ public static void DoSmallTnt(Level lvl, Check C, Random rand) {
+ ushort x, y, z;
+ lvl.IntToPos(C.b, out x, out y, out z);
+
+ if (C.p != null && C.p.PlayingTntWars) {
+ int power = 2, threshold = 3;
+ switch (TntWarsGame.GetTntWarsGame(C.p).GameDifficulty) {
+ case TntWarsGame.TntWarsDifficulty.Easy:
+ threshold = 7;
+ break;
+ case TntWarsGame.TntWarsDifficulty.Normal:
+ threshold = 5;
+ break;
+ case TntWarsGame.TntWarsDifficulty.Extreme:
+ power = 3;
+ break;
+ }
+
+ if (C.time < threshold) {
+ C.time++;
+ lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
+ ? Block.air : Block.lavastill);
+ return;
+ }
+ if (C.p.TntWarsKillStreak >= TntWarsGame.Properties.DefaultStreakTwoAmount
+ && TntWarsGame.GetTntWarsGame(C.p).Streaks) {
+ power++;
+ }
+ lvl.MakeExplosion(x, y, z, power - 2, true, TntWarsGame.GetTntWarsGame(C.p));
+
+ List Killed = new List();
+ Player.players.ForEach(
+ delegate(Player p1)
+ {
+ if (p1.level == lvl && p1.PlayingTntWars && p1 != C.p
+ && Math.Abs((int)(p1.pos[0] / 32) - x) + Math.Abs((int)(p1.pos[1] / 32) - y) + Math.Abs((int)(p1.pos[2] / 32) - z) < ((power * 3) + 1)) {
+ Killed.Add(p1);
+ }
+ });
+ TntWarsGame.GetTntWarsGame(C.p).HandleKill(C.p, Killed);
+ } else {
+ if (lvl.physics < 3) {
+ lvl.Blockchange(x, y, z, Block.air);
+ } else {
+ if (C.time < 5 && lvl.physics == 3) {
+ C.time++;
+ lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
+ ? Block.air : Block.lavastill);
+ return;
+ }
+ lvl.MakeExplosion(x, y, z, 0);
+ }
+ }
+ }
+ }
+}
diff --git a/Levels/Physics/ZombiePhysics.cs b/Levels/Physics/ZombiePhysics.cs
index 312015a0a..cbd634532 100644
--- a/Levels/Physics/ZombiePhysics.cs
+++ b/Levels/Physics/ZombiePhysics.cs
@@ -32,28 +32,28 @@ namespace MCGalaxy.BlockPhysics {
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
return;
}
- bool skip = false;
+ bool checkTime = true;
int index = 0;
- Player foundPlayer = AIPhysics.ClosestPlayer(lvl, C);
+ Player closest = AIPhysics.ClosestPlayer(lvl, C);
- if (foundPlayer != null && rand.Next(1, 20) < 18) {
+ if (closest != null && rand.Next(1, 20) < 18) {
if (rand.Next(1, 7) <= 3) {
- index = lvl.PosToInt((ushort)(x + Math.Sign((foundPlayer.pos[0] / 32) - x)), y, z);
- if (index != C.b && MoveZombie(lvl, C, index, ref skip)) return;
+ index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
+ if (index != C.b && MoveZombie(lvl, C, index)) return;
- index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((foundPlayer.pos[2] / 32) - z)));
- if (index != C.b && MoveZombie(lvl, C, index, ref skip)) return;
+ index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
+ if (index != C.b && MoveZombie(lvl, C, index)) return;
} else {
- index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((foundPlayer.pos[2] / 32) - z)));
- if (index != C.b && MoveZombie(lvl, C, index, ref skip)) return;
+ index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
+ if (index != C.b && MoveZombie(lvl, C, index)) return;
- index = lvl.PosToInt((ushort)(x + Math.Sign((foundPlayer.pos[0] / 32) - x)), y, z);
- if (index != C.b && MoveZombie(lvl, C, index, ref skip)) return;
+ index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
+ if (index != C.b && MoveZombie(lvl, C, index)) return;
}
- skip = true;
+ checkTime = false;
}
- if (!skip && C.time < 3) {
+ if (checkTime && C.time < 3) {
C.time++;
return;
}
@@ -64,57 +64,47 @@ namespace MCGalaxy.BlockPhysics {
case 1:
case 2:
case 3:
- skip = false;
index = lvl.IntOffset(C.b, -1, 0, 0);
- if (MoveZombie(lvl, C, index, ref skip)) return;
+ if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
- else goto case 4;
- break;
+ goto case 4;
case 4:
case 5:
case 6:
- skip = false;
index = lvl.IntOffset(C.b, 1, 0, 0);
- if (MoveZombie(lvl, C, index, ref skip)) return;
+ if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
- else goto case 7;
- break;
+ goto case 7;
case 7:
case 8:
case 9:
- skip = false;
index = lvl.IntOffset(C.b, 0, 0, 1);
- if (MoveZombie(lvl, C, index, ref skip)) return;
+ if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
- else goto case 10;
- break;
+ goto case 10;
case 10:
case 11:
case 12:
- skip = false;
index = lvl.IntOffset(C.b, 0, 0, -1);
- if (MoveZombie(lvl, C, index, ref skip)) return;
+ if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
- else goto case 1;
- break;
+ goto case 1;
}
lvl.AddUpdate(C.b, Block.air);
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
}
- static bool MoveZombie(Level lvl, Check C, int index, ref bool skip) {
- skip = false;
-
+ static bool MoveZombie(Level lvl, Check C, int index) {
if(
lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
lvl.GetTile(index) == Block.air) {
@@ -127,10 +117,10 @@ namespace MCGalaxy.BlockPhysics {
lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
index = lvl.IntOffset(index, 0, 1, 0);
} else {
- skip = true;
+ return false;
}
- if (!skip && lvl.AddUpdate(index, lvl.blocks[C.b])) {
+ if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
lvl.AddUpdate(lvl.IntOffset(index, 0, 1, 0), Block.zombiehead);
lvl.AddUpdate(C.b, Block.air);
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj
index 02426176b..c36286f92 100644
--- a/MCGalaxy_.csproj
+++ b/MCGalaxy_.csproj
@@ -431,10 +431,13 @@
+
+
+
@@ -799,4 +802,4 @@
-
+
\ No newline at end of file