diff --git a/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx b/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx deleted file mode 100644 index fba731a..0000000 Binary files a/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx and /dev/null differ diff --git a/.vs/CommunityServerAPI/FileContentIndex/3f674688-c877-4266-8c58-bd270599fe48.vsidx b/.vs/CommunityServerAPI/FileContentIndex/3f674688-c877-4266-8c58-bd270599fe48.vsidx new file mode 100644 index 0000000..f052502 Binary files /dev/null and b/.vs/CommunityServerAPI/FileContentIndex/3f674688-c877-4266-8c58-bd270599fe48.vsidx differ diff --git a/.vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx b/.vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx deleted file mode 100644 index aee4d8c..0000000 Binary files a/.vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx and /dev/null differ diff --git a/.vs/CommunityServerAPI/FileContentIndex/9de6c087-44d0-4e02-afba-877dc5c6677d.vsidx b/.vs/CommunityServerAPI/FileContentIndex/9de6c087-44d0-4e02-afba-877dc5c6677d.vsidx new file mode 100644 index 0000000..11db182 Binary files /dev/null and b/.vs/CommunityServerAPI/FileContentIndex/9de6c087-44d0-4e02-afba-877dc5c6677d.vsidx differ diff --git a/.vs/CommunityServerAPI/FileContentIndex/cc99f8fd-7397-4b04-aeef-05963411d290.vsidx b/.vs/CommunityServerAPI/FileContentIndex/cc99f8fd-7397-4b04-aeef-05963411d290.vsidx new file mode 100644 index 0000000..e60a235 Binary files /dev/null and b/.vs/CommunityServerAPI/FileContentIndex/cc99f8fd-7397-4b04-aeef-05963411d290.vsidx differ diff --git a/.vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx b/.vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx deleted file mode 100644 index 55ab044..0000000 Binary files a/.vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx and /dev/null differ diff --git a/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs new file mode 100644 index 0000000..aafc2fa --- /dev/null +++ b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs @@ -0,0 +1,17 @@ +using System.Numerics; + +namespace BattleBitAPI.Common +{ + public struct OnPlayerKillArguments where TPlayer : Player + { + public TPlayer Killer; + public Vector3 KillerPosition; + + public TPlayer Victim; + public Vector3 VictimPosition; + + public string KillerTool; + public PlayerBody BodyPart; + public ReasonOfDamage SourceOfDamage; + } +} diff --git a/BattleBitAPI/Common/Enums/DamageReason.cs b/BattleBitAPI/Common/Enums/DamageReason.cs new file mode 100644 index 0000000..5d69631 --- /dev/null +++ b/BattleBitAPI/Common/Enums/DamageReason.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BattleBitAPI.Common +{ + public enum ReasonOfDamage : byte + { + Server = 0, + Weapon = 1, + Bleeding = 2, + Fall = 3, + HelicopterBlade = 4, + VehicleExplosion = 5, + Explosion = 6, + vehicleRunOver = 7, + BuildingCollapsing = 8, + SledgeHammer = 9, + TreeFall = 10, + CountAsKill = 11, + Suicide = 12, + HelicopterCrash = 13, + BarbedWire = 14, + } +} diff --git a/BattleBitAPI/Common/Enums/PlayerBody.cs b/BattleBitAPI/Common/Enums/PlayerBody.cs new file mode 100644 index 0000000..90b8b84 --- /dev/null +++ b/BattleBitAPI/Common/Enums/PlayerBody.cs @@ -0,0 +1,15 @@ +namespace BattleBitAPI.Common +{ + public enum PlayerBody : byte + { + None = 0, + Head = 2, + Neck = 3, + Shoulder = 4, + Arm = 5, + Leg = 6, + Foot = 7, + Chest = 10, + } + +} diff --git a/BattleBitAPI/Server/ServerListener.cs b/BattleBitAPI/Server/ServerListener.cs index c191906..3c46813 100644 --- a/BattleBitAPI/Server/ServerListener.cs +++ b/BattleBitAPI/Server/ServerListener.cs @@ -102,13 +102,9 @@ namespace BattleBitAPI.Server /// /// /// - /// Player: The killer player
- /// Vector3: The position of killer
- /// Player: The target player that got killed
- /// Vector3: The target player's position
- /// string - Tool: The tool user to kill the player
+ /// OnPlayerKillArguments: Details about the kill
///
- public Func OnAPlayerKilledAnotherPlayer { get; set; } + public Func, Task> OnAPlayerKilledAnotherPlayer { get; set; } /// /// Fired when game server requests the stats of a player, this function should return in 3000ms or player will not able to join to server. @@ -826,7 +822,7 @@ namespace BattleBitAPI.Server } case NetworkCommuncation.OnPlayerKilledAnotherPlayer: { - if (stream.CanRead(8 + 12 + 8 + 12 + 2)) + if (stream.CanRead(8 + 12 + 8 + 12 + 2 + 1 + 1)) { ulong killer = stream.ReadUInt64(); Vector3 killerPos = new Vector3(stream.ReadFloat(), stream.ReadFloat(), stream.ReadFloat()); @@ -836,10 +832,31 @@ namespace BattleBitAPI.Server if (stream.TryReadString(out var tool)) { + PlayerBody body = (PlayerBody)stream.ReadInt8(); + ReasonOfDamage source = (ReasonOfDamage)stream.ReadInt8(); + if (resources.TryGetPlayer(killer, out var killerClient)) + { if (resources.TryGetPlayer(victim, out var victimClient)) + { if (OnAPlayerKilledAnotherPlayer != null) - await OnAPlayerKilledAnotherPlayer.Invoke((TPlayer)killerClient, killerPos, (TPlayer)victimClient, victimPos, tool); + { + var args = new OnPlayerKillArguments() + { + Killer = (TPlayer)killerClient, + KillerPosition = killerPos, + Victim = (TPlayer)victimClient, + VictimPosition = victimPos, + BodyPart = body, + SourceOfDamage = source, + KillerTool = tool, + }; + + await OnAPlayerKilledAnotherPlayer.Invoke(args); + + } + } + } } } diff --git a/Program.cs b/Program.cs index e79826e..f8a4e17 100644 --- a/Program.cs +++ b/Program.cs @@ -13,27 +13,14 @@ class Program var listener = new ServerListener(); listener.Start(29294); - listener.OnPlayerTypedMessage += OnPlayerTypedMessage; + listener.OnAPlayerKilledAnotherPlayer += OnAPlayerKilledAnotherPlayer; Thread.Sleep(-1); } - private static async Task OnPlayerTypedMessage(MyPlayer player, ChatChannel ch, string msg) + private static async Task OnAPlayerKilledAnotherPlayer(OnPlayerKillArguments arg) { - if (msg == "nword") - { - player.NumberOfNWord++; - if (player.NumberOfNWord > 4) - { - player.Kick("N word is not accepted!"); - } - else - { - player.Message("Do not type nword, this is your " + player.NumberOfNWord + "th warning"); - } - return false; - } - return true; + await Console.Out.WriteLineAsync(arg.Killer + " killed " + arg.Victim + " with " + arg.KillerTool + " (" + arg.BodyPart + ")"); } } class MyPlayer : Player diff --git a/bin/Debug/net6.0/CommunityServerAPI.dll b/bin/Debug/net6.0/CommunityServerAPI.dll index 7ecc677..a04a779 100644 Binary files a/bin/Debug/net6.0/CommunityServerAPI.dll and b/bin/Debug/net6.0/CommunityServerAPI.dll differ diff --git a/bin/Debug/net6.0/CommunityServerAPI.pdb b/bin/Debug/net6.0/CommunityServerAPI.pdb index f084d54..1f7f305 100644 Binary files a/bin/Debug/net6.0/CommunityServerAPI.pdb and b/bin/Debug/net6.0/CommunityServerAPI.pdb differ diff --git a/obj/Debug/net6.0/CommunityServerAPI.csproj.CoreCompileInputs.cache b/obj/Debug/net6.0/CommunityServerAPI.csproj.CoreCompileInputs.cache index 00bffdf..84320fd 100644 --- a/obj/Debug/net6.0/CommunityServerAPI.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net6.0/CommunityServerAPI.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -d1f232126136336fb7f4efeeb67c0c5982544fe4 +8f0a13b55a78de27b4bd6f14afc4adfc26b55b80 diff --git a/obj/Debug/net6.0/CommunityServerAPI.dll b/obj/Debug/net6.0/CommunityServerAPI.dll index 7ecc677..a04a779 100644 Binary files a/obj/Debug/net6.0/CommunityServerAPI.dll and b/obj/Debug/net6.0/CommunityServerAPI.dll differ diff --git a/obj/Debug/net6.0/CommunityServerAPI.pdb b/obj/Debug/net6.0/CommunityServerAPI.pdb index f084d54..1f7f305 100644 Binary files a/obj/Debug/net6.0/CommunityServerAPI.pdb and b/obj/Debug/net6.0/CommunityServerAPI.pdb differ diff --git a/obj/Debug/net6.0/ref/CommunityServerAPI.dll b/obj/Debug/net6.0/ref/CommunityServerAPI.dll index c7d507c..36f64a8 100644 Binary files a/obj/Debug/net6.0/ref/CommunityServerAPI.dll and b/obj/Debug/net6.0/ref/CommunityServerAPI.dll differ diff --git a/obj/Debug/net6.0/refint/CommunityServerAPI.dll b/obj/Debug/net6.0/refint/CommunityServerAPI.dll index c7d507c..36f64a8 100644 Binary files a/obj/Debug/net6.0/refint/CommunityServerAPI.dll and b/obj/Debug/net6.0/refint/CommunityServerAPI.dll differ