[+] Add Gangwar System (bugs incl.)
This commit is contained in:
@@ -14,7 +14,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
public class Turf
|
||||
{
|
||||
|
||||
|
||||
public int TurfID { get; set; }
|
||||
public string TurfName { get; set; }
|
||||
public int Color { get; set; }
|
||||
@@ -36,8 +36,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
this.Color = color;
|
||||
this.Owner = Owner;
|
||||
this.Attacker = null;
|
||||
this.Att_Score = 5;
|
||||
this.Def_Score = 5;
|
||||
this.Att_Score = 50;
|
||||
this.Def_Score = 50;
|
||||
this.status = "normal";
|
||||
this.timer = null;
|
||||
this.playerInside = new List<Client>();
|
||||
@@ -68,7 +68,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
return this.Attacker;
|
||||
}
|
||||
|
||||
|
||||
private void TurfTick()
|
||||
{
|
||||
this.timer = new System.Timers.Timer(1000);
|
||||
@@ -81,7 +81,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
|
||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
if(this.status == "attack")
|
||||
{
|
||||
update();
|
||||
}
|
||||
@@ -91,6 +91,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
|
||||
private void update()
|
||||
{
|
||||
#region Ticket system
|
||||
/*
|
||||
try
|
||||
{
|
||||
@@ -113,6 +114,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
if(owners.Length < attackers.Length)
|
||||
this.Def_Score -= attackers.Length - owners.Length;
|
||||
*/
|
||||
#endregion
|
||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
@@ -120,43 +122,40 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
if (this.Def_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
}
|
||||
else if (this.Att_Score <= 0)
|
||||
} else if (this.Att_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Owner);
|
||||
}
|
||||
timerCount += 1;
|
||||
if (timerCount >= 60) //change to 900 before release
|
||||
if(timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
if (this.Def_Score > this.Att_Score)
|
||||
if(this.Def_Score > this.Att_Score)
|
||||
{
|
||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Owner);
|
||||
this.Att_Score = 0;
|
||||
}else if(this.Def_Score < this.Att_Score)
|
||||
{
|
||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
}
|
||||
else if (this.Def_Score < this.Att_Score)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (this.Def_Score == this.Att_Score)
|
||||
else if(this.Def_Score == this.Att_Score)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -179,9 +178,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerInside.Find(c => c == client) == null)
|
||||
{
|
||||
|
||||
if(playerInside.Find(c => c == client) == null) {
|
||||
playerInside.Add(client);
|
||||
client.SetData("GotInsideOfTurf", true);
|
||||
}
|
||||
@@ -189,10 +187,10 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
|
||||
public void leave(Client client)
|
||||
{
|
||||
if (playerInside.Find(c => c == client) != null)
|
||||
if(playerInside.Find(c => c == client) != null)
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||
if (this.status != "attack")
|
||||
if(this.status != "attack")
|
||||
client.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
}
|
||||
@@ -216,14 +214,10 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
a.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
else if (getOwner() != FactionName)
|
||||
{
|
||||
foreach (var c in playerInGangwar)
|
||||
{
|
||||
|
||||
}
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
@@ -242,10 +236,10 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.Attacker = null;
|
||||
foreach (var c in playerInGangwar)
|
||||
foreach(var c in playerInGangwar)
|
||||
{
|
||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||
c.ResetData("inGangWar");
|
||||
@@ -258,9 +252,9 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
|
||||
public void attack(string attacker)
|
||||
{
|
||||
if (this.status == "normal")
|
||||
if(this.status == "normal")
|
||||
{
|
||||
if (this.timer != null)
|
||||
if(this.timer != null)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
@@ -277,7 +271,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
u.SetData("inGangWar", getId());
|
||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " hat das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~"+ TurfName +"~w~ der "+ getOwner() +" angegriffen.");
|
||||
clientsInGangwar.Add(u);
|
||||
}
|
||||
playerInGangwar = clientsInGangwar.ToArray();
|
||||
|
||||
Reference in New Issue
Block a user