Skip to content

Commit

Permalink
CTF: Allow configuring tag distance threshold (Thanks Venk)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jan 15, 2021
1 parent 5fe6104 commit f2ece15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions MCGalaxy/Bots/PlayerBot.cs
Expand Up @@ -295,11 +295,11 @@ public sealed class PlayerBot : Entity {

public void DisplayInfo(Player p) {
p.Message("Bot {0} %S({1}) has:", ColoredName, name);
p.Message(" Owner: %f{0}", string.IsNullOrEmpty(Owner) ? "no one" : p.FormatNick(Owner));
if (!String.IsNullOrEmpty(AIName)) { p.Message(" AI: %f{0}", AIName); }
if (hunt || kill) { p.Message(" Hunt: %f{0}%S, Kill: %f{1}", hunt, kill); }
if (SkinName != name) { p.Message(" Skin: %f{0}", SkinName); }
if (Model != "humanoid") { p.Message(" Model: %f{0}", Model); }
p.Message(" Owner: &f{0}", string.IsNullOrEmpty(Owner) ? "no one" : p.FormatNick(Owner));
if (!String.IsNullOrEmpty(AIName)) { p.Message(" AI: &f{0}", AIName); }
if (hunt || kill) { p.Message(" Hunt: &f{0}%S, Kill: %f{1}", hunt, kill); }
if (SkinName != name) { p.Message(" Skin: &f{0}", SkinName); }
if (Model != "humanoid") { p.Message(" Model: &f{0}", Model); }
if (!(ScaleX == 0 && ScaleY == 0 && ScaleZ == 0)) {
p.Message(" X scale: &a{0}%S, Y scale: &a{1}%S, Z scale: &a{2}",
ScaleX == 0 ? "none" : ScaleX.ToString(),
Expand Down
3 changes: 3 additions & 0 deletions MCGalaxy/Games/CTF/CtfConfig.cs
Expand Up @@ -29,6 +29,9 @@ public sealed class CTFConfig : RoundsGameConfig {
public override bool AllowAutoload { get { return false; } }
protected override string GameName { get { return "CTF"; } }
protected override string PropsPath { get { return "properties/ctf.properties"; } }

[ConfigFloat("tag-distance", "Player", 1f)]
public float TagDistance = 1f;
}

public sealed class CTFMapConfig : RoundsGameMapConfig {
Expand Down
4 changes: 3 additions & 1 deletion MCGalaxy/Games/CTF/CtfGame.Round.cs
Expand Up @@ -42,7 +42,9 @@ public sealed partial class CTFGame : RoundsGame {
}

void Tick() {
int dist = (int)(Config.TagDistance * 32);
Player[] online = PlayerInfo.Online.Items;

foreach (Player p in online) {
if (p.level != Map) continue;
CtfTeam team = TeamOf(p);
Expand All @@ -57,7 +59,7 @@ public sealed partial class CTFGame : RoundsGame {

Player[] opponents = opposing.Members.Items;
foreach (Player other in opponents) {
if (!MovementCheck.InRange(p, other, 2 * 32)) continue;
if (!MovementCheck.InRange(p, other, dist)) continue;
CtfData otherData = Get(other);

otherData.TagCooldown = true;
Expand Down

0 comments on commit f2ece15

Please sign in to comment.