Ability to change weapons - gadgets runtime.

This commit is contained in:
MrOkiDoki 2023-08-11 19:14:47 +03:00
parent 120b94c5f9
commit aa32ced799
8 changed files with 546 additions and 272 deletions

View File

@ -126,224 +126,223 @@
this.HeavyGadgetExtra = ser.ReadInt8();
this.ThrowableExtra = ser.ReadInt8();
}
}
public struct WeaponItem
{
public string ToolName;
public string MainSightName;
public string TopSightName;
public string CantedSightName;
public string BarrelName;
public string SideRailName;
public string UnderRailName;
public string BoltActionName;
public byte SkinIndex;
public byte MagazineIndex;
public struct WeaponItem
public Weapon Tool
{
public string ToolName;
public string MainSightName;
public string TopSightName;
public string CantedSightName;
public string BarrelName;
public string SideRailName;
public string UnderRailName;
public string BoltActionName;
public byte SkinIndex;
public byte MagazineIndex;
get
{
if (Weapons.TryFind(ToolName, out var weapon))
return weapon;
return null;
}
set
{
if (value == null)
this.ToolName = "none";
else
this.ToolName = value.Name;
}
}
public Attachment MainSight
{
get
{
if (Attachments.TryFind(MainSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.MainSightName = "none";
else
this.MainSightName = value.Name;
}
}
public Attachment TopSight
{
get
{
if (Attachments.TryFind(TopSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.TopSightName = "none";
else
this.TopSightName = value.Name;
}
}
public Attachment CantedSight
{
get
{
if (Attachments.TryFind(CantedSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.CantedSightName = "none";
else
this.CantedSightName = value.Name;
}
}
public Attachment Barrel
{
get
{
if (Attachments.TryFind(BarrelName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.BarrelName = "none";
else
this.BarrelName = value.Name;
}
}
public Attachment SideRail
{
get
{
if (Attachments.TryFind(SideRailName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.SideRailName = "none";
else
this.SideRailName = value.Name;
}
}
public Attachment UnderRail
{
get
{
if (Attachments.TryFind(UnderRailName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.UnderRailName = "none";
else
this.UnderRailName = value.Name;
}
}
public Attachment BoltAction
{
get
{
if (Attachments.TryFind(BoltActionName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.BoltActionName = "none";
else
this.BoltActionName = value.Name;
}
}
public Weapon Tool
public bool HasAttachment(Attachment attachment)
{
switch (attachment.AttachmentType)
{
get
{
if (Weapons.TryFind(ToolName, out var weapon))
return weapon;
return null;
}
set
{
if (value == null)
this.ToolName = "none";
else
this.ToolName = value.Name;
}
case AttachmentType.MainSight:
return this.MainSight == attachment;
case AttachmentType.TopSight:
return this.TopSight == attachment;
case AttachmentType.CantedSight:
return this.CantedSight == attachment;
case AttachmentType.Barrel:
return this.Barrel == attachment;
case AttachmentType.UnderRail:
return this.Barrel == attachment;
case AttachmentType.SideRail:
return this.SideRail == attachment;
case AttachmentType.Bolt:
return this.BoltAction == attachment;
}
public Attachment MainSight
return false;
}
public void SetAttachment(Attachment attachment)
{
switch (attachment.AttachmentType)
{
get
{
if (Attachments.TryFind(MainSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.MainSightName = "none";
else
this.MainSightName = value.Name;
}
}
public Attachment TopSight
{
get
{
if (Attachments.TryFind(TopSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.TopSightName = "none";
else
this.TopSightName = value.Name;
}
}
public Attachment CantedSight
{
get
{
if (Attachments.TryFind(CantedSightName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.CantedSightName = "none";
else
this.CantedSightName = value.Name;
}
}
public Attachment Barrel
{
get
{
if (Attachments.TryFind(BarrelName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.BarrelName = "none";
else
this.BarrelName = value.Name;
}
}
public Attachment SideRail
{
get
{
if (Attachments.TryFind(SideRailName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.SideRailName = "none";
else
this.SideRailName = value.Name;
}
}
public Attachment UnderRail
{
get
{
if (Attachments.TryFind(UnderRailName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.UnderRailName = "none";
else
this.UnderRailName = value.Name;
}
}
public Attachment BoltAction
{
get
{
if (Attachments.TryFind(BoltActionName, out var attachment))
return attachment;
return null;
}
set
{
if (value == null)
this.BoltActionName = "none";
else
this.BoltActionName = value.Name;
}
case AttachmentType.MainSight:
this.MainSight = attachment;
break;
case AttachmentType.TopSight:
this.TopSight = attachment;
break;
case AttachmentType.CantedSight:
this.CantedSight = attachment;
break;
case AttachmentType.Barrel:
this.Barrel = attachment;
break;
case AttachmentType.UnderRail:
this.Barrel = attachment;
break;
case AttachmentType.SideRail:
this.SideRail = attachment;
break;
case AttachmentType.Bolt:
this.BoltAction = attachment;
break;
}
}
public bool HasAttachment(Attachment attachment)
{
switch (attachment.AttachmentType)
{
case AttachmentType.MainSight:
return this.MainSight == attachment;
case AttachmentType.TopSight:
return this.TopSight == attachment;
case AttachmentType.CantedSight:
return this.CantedSight == attachment;
case AttachmentType.Barrel:
return this.Barrel == attachment;
case AttachmentType.UnderRail:
return this.Barrel == attachment;
case AttachmentType.SideRail:
return this.SideRail == attachment;
case AttachmentType.Bolt:
return this.BoltAction == attachment;
}
return false;
}
public void SetAttachment(Attachment attachment)
{
switch (attachment.AttachmentType)
{
case AttachmentType.MainSight:
this.MainSight = attachment;
break;
case AttachmentType.TopSight:
this.TopSight = attachment;
break;
case AttachmentType.CantedSight:
this.CantedSight = attachment;
break;
case AttachmentType.Barrel:
this.Barrel = attachment;
break;
case AttachmentType.UnderRail:
this.Barrel = attachment;
break;
case AttachmentType.SideRail:
this.SideRail = attachment;
break;
case AttachmentType.Bolt:
this.BoltAction = attachment;
break;
}
}
public void Write(Common.Serialization.Stream ser)
{
ser.WriteStringItem(this.ToolName);
ser.WriteStringItem(this.MainSightName);
ser.WriteStringItem(this.TopSightName);
ser.WriteStringItem(this.CantedSightName);
ser.WriteStringItem(this.BarrelName);
ser.WriteStringItem(this.SideRailName);
ser.WriteStringItem(this.UnderRailName);
ser.WriteStringItem(this.BoltActionName);
ser.Write(this.SkinIndex);
ser.Write(this.MagazineIndex);
}
public void Read(Common.Serialization.Stream ser)
{
ser.TryReadString(out this.ToolName);
ser.TryReadString(out this.MainSightName);
ser.TryReadString(out this.TopSightName);
ser.TryReadString(out this.CantedSightName);
ser.TryReadString(out this.BarrelName);
ser.TryReadString(out this.SideRailName);
ser.TryReadString(out this.UnderRailName);
ser.TryReadString(out this.BoltActionName);
this.SkinIndex = ser.ReadInt8();
this.MagazineIndex = ser.ReadInt8();
}
public void Write(Common.Serialization.Stream ser)
{
ser.WriteStringItem(this.ToolName);
ser.WriteStringItem(this.MainSightName);
ser.WriteStringItem(this.TopSightName);
ser.WriteStringItem(this.CantedSightName);
ser.WriteStringItem(this.BarrelName);
ser.WriteStringItem(this.SideRailName);
ser.WriteStringItem(this.UnderRailName);
ser.WriteStringItem(this.BoltActionName);
ser.Write(this.SkinIndex);
ser.Write(this.MagazineIndex);
}
public void Read(Common.Serialization.Stream ser)
{
ser.TryReadString(out this.ToolName);
ser.TryReadString(out this.MainSightName);
ser.TryReadString(out this.TopSightName);
ser.TryReadString(out this.CantedSightName);
ser.TryReadString(out this.BarrelName);
ser.TryReadString(out this.SideRailName);
ser.TryReadString(out this.UnderRailName);
ser.TryReadString(out this.BoltActionName);
this.SkinIndex = ser.ReadInt8();
this.MagazineIndex = ser.ReadInt8();
}
}
}

View File

@ -99,10 +99,10 @@ namespace BattleBitAPI.Common.Serialization
}
public unsafe void Write(double value)
{
EnsureWriteBufferSize(16);
EnsureWriteBufferSize(8);
fixed (byte* ptr = &Buffer[WritePosition])
*((double*)ptr) = value;
WritePosition += 16;
WritePosition += 8;
}
public unsafe void Write(float value)
{
@ -423,7 +423,7 @@ namespace BattleBitAPI.Common.Serialization
{
value = *((double*)ptr);
}
ReadPosition += 16;
ReadPosition += 8;
return value;
}

View File

@ -12,6 +12,9 @@
SpawnPlayer = 12,
SetNewRoomSettings = 13,
RespondPlayerMessage = 14,
SetNewRoundState = 15,
SetPlayerWeapon = 16,
SetPlayerGadget = 17,
PlayerConnected = 50,
PlayerDisconnected = 51,
@ -30,5 +33,6 @@
OnPlayerDie = 64,
NotifyNewMapRotation = 65,
NotifyNewGamemodeRotation = 66,
NotifyNewRoundState = 67,
}
}

View File

@ -1,4 +1,5 @@
using BattleBitAPI.Common;
using BattleBitAPI.Networking;
using BattleBitAPI.Server;
using System.Net;
using System.Numerics;
@ -83,7 +84,62 @@ namespace BattleBitAPI
{
GameServer.SpawnPlayer(this, loadout, wearings, position, lookDirection, stand, spawnProtection);
}
public void SetHP(float newHP)
{
GameServer.SetHP(this, newHP);
}
public void GiveDamage(float damage)
{
GameServer.GiveDamage(this, damage);
}
public void Heal(float hp)
{
GameServer.Heal(this, hp);
}
public void SetRunningSpeedMultiplier(float value)
{
GameServer.SetRunningSpeedMultiplier(this, value);
}
public void SetReceiveDamageMultiplier(float value)
{
GameServer.SetReceiveDamageMultiplier(this, value);
}
public void SetGiveDamageMultiplier(float value)
{
GameServer.SetGiveDamageMultiplier(this, value);
}
public void SetJumpMultiplier(float value)
{
GameServer.SetJumpMultiplier(this, value);
}
public void SetFallDamageMultiplier(float value)
{
GameServer.SetFallDamageMultiplier(this, value);
}
public void SetPrimaryWeapon(WeaponItem item, int extraMagazines,bool clear=false)
{
GameServer.SetPrimaryWeapon(this, item, extraMagazines, clear);
}
public void SetSecondaryWeapon(WeaponItem item, int extraMagazines, bool clear = false)
{
GameServer.SetSecondaryWeapon(this, item, extraMagazines, clear);
}
public void SetFirstAidGadget(string item, int extra, bool clear = false)
{
GameServer.SetFirstAid(this, item, extra, clear);
}
public void SetLightGadget(string item, int extra, bool clear = false)
{
GameServer.SetLightGadget(this, item, extra, clear);
}
public void SetHeavyGadget(string item, int extra, bool clear = false)
{
GameServer.SetHeavyGadget(this, item, extra, clear);
}
public void SetThrowable(string item, int extra, bool clear = false)
{
GameServer.SetThrowable(this, item, extra, clear);
}
public override string ToString()
{
return this.Name + " (" + this.SteamID + ")";

View File

@ -88,6 +88,18 @@ namespace BattleBitAPI.Server
}
this.ExecuteCommand(this.mInternal.mBuilder.ToString());
}
if (this.mInternal.IsDirtyRoundSettings)
{
this.mInternal.IsDirtyRoundSettings = false;
//Send new round settings
using (var pck = Common.Serialization.Stream.Get())
{
pck.Write((byte)NetworkCommuncation.SetNewRoundState);
this.mInternal._RoundSettings.Write(pck);
WriteToSocket(pck);
}
}
try
{
@ -299,6 +311,18 @@ namespace BattleBitAPI.Server
public virtual async Task OnPlayerReported(TPlayer from, TPlayer to, ReportReason reason, string additional)
{
}
public virtual async Task OnGameStateChanged(GameState oldState, GameState newState)
{
}
public virtual async Task OnRoundStarted()
{
}
public virtual async Task OnRoundEnded()
{
}
// ---- Functions ----
@ -469,6 +493,179 @@ namespace BattleBitAPI.Server
{
SpawnPlayer(player.SteamID, loadout, wearings, position, lookDirection, stand, spawnProtection);
}
public void SetHP(ulong steamID, float newHP)
{
ExecuteCommand("sethp " + steamID + " " + newHP);
}
public void SetHP(Player<TPlayer> player, float newHP)
{
SetHP(player.SteamID, newHP);
}
public void GiveDamage(ulong steamID, float damage)
{
ExecuteCommand("givedamage " + steamID + " " + damage);
}
public void GiveDamage(Player<TPlayer> player, float damage)
{
GiveDamage(player.SteamID, damage);
}
public void Heal(ulong steamID, float heal)
{
ExecuteCommand("heal " + steamID + " " + heal);
}
public void Heal(Player<TPlayer> player, float heal)
{
Heal(player.SteamID, heal);
}
public void SetRunningSpeedMultiplier(ulong steamID, float value)
{
ExecuteCommand("setrunningspeed " + steamID + " " + value);
}
public void SetRunningSpeedMultiplier(Player<TPlayer> player, float value)
{
SetRunningSpeedMultiplier(player.SteamID, value);
}
public void SetReceiveDamageMultiplier(ulong steamID, float value)
{
ExecuteCommand("setreceivedamagemultiplier " + steamID + " " + value);
}
public void SetReceiveDamageMultiplier(Player<TPlayer> player, float value)
{
SetReceiveDamageMultiplier(player.SteamID, value);
}
public void SetGiveDamageMultiplier(ulong steamID, float value)
{
ExecuteCommand("setgivedamagemultiplier " + steamID + " " + value);
}
public void SetGiveDamageMultiplier(Player<TPlayer> player, float value)
{
SetGiveDamageMultiplier(player.SteamID, value);
}
public void SetJumpMultiplier(ulong steamID, float value)
{
ExecuteCommand("setjumpmultiplier " + steamID + " " + value);
}
public void SetJumpMultiplier(Player<TPlayer> player, float value)
{
SetJumpMultiplier(player.SteamID, value);
}
public void SetFallDamageMultiplier(ulong steamID, float value)
{
ExecuteCommand("setfalldamagemultiplier " + steamID + " " + value);
}
public void SetFallDamageMultiplier(Player<TPlayer> player, float value)
{
SetFallDamageMultiplier(player.SteamID, value);
}
public void SetPrimaryWeapon(ulong steamID, WeaponItem item, int extraMagazines, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerWeapon);
packet.Write(steamID);
packet.Write((byte)0);//Primary
item.Write(packet);
packet.Write((byte)extraMagazines);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetPrimaryWeapon(Player<TPlayer> player, WeaponItem item, int extraMagazines, bool clear = false)
{
SetPrimaryWeapon(player.SteamID, item, extraMagazines, clear);
}
public void SetSecondaryWeapon(ulong steamID, WeaponItem item, int extraMagazines, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerWeapon);
packet.Write(steamID);
packet.Write((byte)1);//Secondary
item.Write(packet);
packet.Write((byte)extraMagazines);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetSecondaryWeapon(Player<TPlayer> player, WeaponItem item, int extraMagazines, bool clear = false)
{
SetSecondaryWeapon(player.SteamID, item, extraMagazines, clear);
}
public void SetFirstAid(ulong steamID, string tool, int extra, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerGadget);
packet.Write(steamID);
packet.Write((byte)2);//first aid
packet.Write(tool);
packet.Write((byte)extra);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetFirstAid(Player<TPlayer> player, string tool, int extra, bool clear = false)
{
SetFirstAid(player.SteamID, tool, extra, clear);
}
public void SetLightGadget(ulong steamID, string tool, int extra, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerGadget);
packet.Write(steamID);
packet.Write((byte)3);//Tool A
packet.Write(tool);
packet.Write((byte)extra);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetLightGadget(Player<TPlayer> player, string tool, int extra, bool clear = false)
{
SetLightGadget(player.SteamID, tool, extra, clear);
}
public void SetHeavyGadget(ulong steamID, string tool, int extra, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerGadget);
packet.Write(steamID);
packet.Write((byte)4);//Tool A
packet.Write(tool);
packet.Write((byte)extra);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetHeavyGadget(Player<TPlayer> player, string tool, int extra, bool clear = false)
{
SetHeavyGadget(player.SteamID, tool, extra, clear);
}
public void SetThrowable(ulong steamID, string tool, int extra, bool clear = false)
{
using (var packet = Common.Serialization.Stream.Get())
{
packet.Write((byte)NetworkCommuncation.SetPlayerGadget);
packet.Write(steamID);
packet.Write((byte)5);//Tool A
packet.Write(tool);
packet.Write((byte)extra);
packet.Write(clear);
WriteToSocket(packet);
}
}
public void SetThrowable(Player<TPlayer> player, string tool, int extra, bool clear = false)
{
SetThrowable(player.SteamID, tool, extra,clear);
}
// ---- Closing ----
public void CloseConnection(string additionInfo = "")
@ -739,44 +936,42 @@ namespace BattleBitAPI.Server
}
public class mRoundSettings
{
public const int Size = 1 + 8 + 8 + 8 + 4 + 4;
public GameState State = GameState.WaitingForPlayers;
public int TeamATickets = 0;
public int TeamAMaxTickets = 1;
public int TeamBTickets = 0;
public int TeamBMaxTickets = 1;
public double TeamATickets = 0;
public double TeamBTickets = 0;
public double MaxTickets = 1;
public int PlayersToStart = 16;
public int SecondsLeftToEndOfRound = 60;
public int SecondsLeft = 60;
public void Write(Common.Serialization.Stream ser)
{
ser.Write((byte)this.State);
ser.Write(this.TeamATickets);
ser.Write(this.TeamAMaxTickets);
ser.Write(this.TeamBTickets);
ser.Write(this.TeamBMaxTickets);
ser.Write(this.MaxTickets);
ser.Write(this.PlayersToStart);
ser.Write(this.SecondsLeftToEndOfRound);
ser.Write(this.SecondsLeft);
}
public void Read(Common.Serialization.Stream ser)
{
this.State = (GameState)ser.ReadInt8();
this.TeamATickets = ser.ReadInt32();
this.TeamAMaxTickets = ser.ReadInt32();
this.TeamBTickets = ser.ReadInt32();
this.TeamBMaxTickets = ser.ReadInt32();
this.TeamATickets = ser.ReadDouble();
this.TeamBTickets = ser.ReadDouble();
this.MaxTickets = ser.ReadDouble();
this.PlayersToStart = ser.ReadInt32();
this.SecondsLeftToEndOfRound = ser.ReadInt32();
this.SecondsLeft = ser.ReadInt32();
}
public void Reset()
{
this.State = GameState.WaitingForPlayers;
this.TeamATickets = 0;
this.TeamAMaxTickets = 1;
this.TeamBTickets = 0;
this.TeamBMaxTickets = 1;
this.MaxTickets = 1;
this.PlayersToStart = 16;
this.SecondsLeftToEndOfRound = 60;
this.SecondsLeft = 60;
}
}
}

View File

@ -14,7 +14,7 @@ namespace BattleBitAPI.Server
{
get => this.mResources._RoundSettings.State;
}
public int TeamATickets
public double TeamATickets
{
get => this.mResources._RoundSettings.TeamATickets;
set
@ -23,16 +23,7 @@ namespace BattleBitAPI.Server
this.mResources.IsDirtyRoundSettings = true;
}
}
public int TeamAMaxTickets
{
get => this.mResources._RoundSettings.TeamAMaxTickets;
set
{
this.mResources._RoundSettings.TeamAMaxTickets = value;
this.mResources.IsDirtyRoundSettings = true;
}
}
public int TeamBTickets
public double TeamBTickets
{
get => this.mResources._RoundSettings.TeamBTickets;
set
@ -41,12 +32,12 @@ namespace BattleBitAPI.Server
this.mResources.IsDirtyRoundSettings = true;
}
}
public int TeamBMaxTickets
public double MaxTickets
{
get => this.mResources._RoundSettings.TeamBMaxTickets;
get => this.mResources._RoundSettings.MaxTickets;
set
{
this.mResources._RoundSettings.TeamBTickets = value;
this.mResources._RoundSettings.MaxTickets = value;
this.mResources.IsDirtyRoundSettings = true;
}
}
@ -59,12 +50,12 @@ namespace BattleBitAPI.Server
this.mResources.IsDirtyRoundSettings = true;
}
}
public int SecondsLeftToEndOfRound
public int SecondsLeft
{
get => this.mResources._RoundSettings.SecondsLeftToEndOfRound;
get => this.mResources._RoundSettings.SecondsLeft;
set
{
this.mResources._RoundSettings.SecondsLeftToEndOfRound = value;
this.mResources._RoundSettings.SecondsLeft = value;
this.mResources.IsDirtyRoundSettings = true;
}
}

View File

@ -385,6 +385,14 @@ namespace BattleBitAPI.Server
}
}
//Round Settings
{
readStream.Reset();
if (!await networkStream.TryRead(readStream, GameServer<TPlayer>.mRoundSettings.Size, source.Token))
throw new Exception("Unable to read the round settings");
resources._RoundSettings.Read(readStream);
}
//Client Count
int clientCount = 0;
{
@ -979,6 +987,26 @@ namespace BattleBitAPI.Server
}
break;
}
case NetworkCommuncation.NotifyNewRoundState:
{
if (stream.CanRead(GameServer<TPlayer>.mRoundSettings.Size))
{
var oldState = resources._RoundSettings.State;
resources._RoundSettings.Read(stream);
var newState = resources._RoundSettings.State;
if (newState != oldState)
{
server.OnGameStateChanged(oldState, newState);
if (newState == GameState.Playing)
server.OnRoundStarted();
else if (newState == GameState.EndingGame)
server.OnRoundEnded();
}
}
break;
}
}
}

View File

@ -2,6 +2,7 @@
using BattleBitAPI.Common;
using BattleBitAPI.Server;
using System.Threading.Channels;
using System.Xml;
class Program
{
@ -15,38 +16,38 @@ class Program
}
class MyPlayer : Player<MyPlayer>
{
public int NumberOfKills;
}
class MyGameServer : GameServer<MyPlayer>
{
public List<string> ChatMessages = new List<string>();
public override async Task<bool> OnPlayerTypedMessage(MyPlayer player, ChatChannel channel, string msg)
public WeaponItem[] WeaponList = new WeaponItem[]
{
return true;
}
public override async Task OnConnected()
{
await Console.Out.WriteLineAsync(this.GameIP + " Connected");
}
public override async Task OnDisconnected()
{
await Console.Out.WriteLineAsync(this.GameIP + " Disconnected");
}
new WeaponItem(){ Tool = Weapons.M4A1, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.SVD, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.SCARH, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.ScorpionEVO, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.M249, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.Groza, MainSight = Attachments._6xScope},
new WeaponItem(){ Tool = Weapons.Glock18, MainSight = Attachments._6xScope},
};
public override async Task OnTick()
{
if (RoundSettings.State == GameState.WaitingForPlayers)
{
int numberOfPeopleInServer = this.CurrentPlayers;
if (numberOfPeopleInServer > 4)
{
ForceStartGame();
}
}
else if (RoundSettings.State == GameState.Playing)
{
if (this.RoundSettings.State == GameState.WaitingForPlayers)
ForceStartGame();
}
await Task.Delay(1000);
}
public override async Task<OnPlayerSpawnArguments> OnPlayerSpawning(MyPlayer player, OnPlayerSpawnArguments request)
{
request.Loadout.PrimaryWeapon = WeaponList[player.NumberOfKills];
return request;
}
public override async Task OnAPlayerKilledAnotherPlayer(OnPlayerKillArguments<MyPlayer> args)
{
args.Killer.NumberOfKills++;
args.Killer.SetPrimaryWeapon(WeaponList[args.Killer.NumberOfKills], 0);
}
}