Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Wilson
6349c11d07 fix: revert base entity teleport changes, add warning to player controller (#688) 2024-11-27 21:25:12 +10:00
ZoNiCaL
b2046b21c4 [no ci] Shuffle player documentation, add to game event documentation (#685) 2024-11-25 10:48:25 +10:00
Michael Wilson
3c6be481c5 [no ci] Update publish-docs.yml 2024-11-25 10:48:05 +10:00
Michael Wilson
0a6fe0946d [no ci] Allow manual publish-docs.yml 2024-11-25 10:47:01 +10:00
schwarper
79297511e3 Added hitgroup to CTakeDamageInfo (#665)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-11-23 10:55:22 +00:00
8 changed files with 51 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read

View File

@@ -54,6 +54,9 @@ The specific subclass of `GameEvent` will provide strongly typed parameters from
These event properties are mutable so you can update them as normal and they will update in the event instance.
> [!CAUTION]
> `GameEvent` instances and their properties will cease to exist after the event listener function is called, which means that you will encounter errors when accessing properties in timers and functions like `Server.NextFrame()`. You should store the value of properties in variables before calling functions like `Server.NextFrame()` so you can read the data safely.
## Preventing Broadcast
You can modify a game event so that it does not get broadcast to clients by modifying the `bool info.DontBroadcast` property. e.g.

View File

@@ -6,3 +6,6 @@
- name: Dependency Injection
href: dependency-injection.md
- name: Referencing Players
href: referencing-players.md

View File

@@ -1,5 +1,2 @@
- name: Core Configuration
href: core-configuration.md
- name: Referencing Players
href: referencing-players.md
href: core-configuration.md

View File

@@ -12,21 +12,17 @@ public partial class CBaseEntity
public void Teleport(Vector? position = null, QAngle? angles = null, Vector? velocity = null)
{
Guard.IsValidEntity(this);
if (position == null && angles == null && velocity == null)
throw new ArgumentNullException("No valid argument");
nint _position = position?.Handle ?? 0;
nint _angles = angles?.Handle ?? 0;
nint _velocity = velocity?.Handle ?? 0;
nint _handle = Handle;
if (this is CCSPlayerController player && player.PlayerPawn.Value is CCSPlayerPawn playerPawn)
{
_handle = playerPawn.Handle;
}
VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(_handle, GameData.GetOffset("CBaseEntity_Teleport"))(_handle, _position, _angles, _velocity);
VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(_handle, GameData.GetOffset("CBaseEntity_Teleport"))(_handle, _position,
_angles, _velocity);
}
/// <exception cref="InvalidOperationException">Entity is not valid</exception>

View File

@@ -340,4 +340,11 @@ public partial class CCSPlayerController
NativeAPI.SetClientVoiceFlags(Handle, (Byte)value);
}
}
[Obsolete(
"You are trying to call Teleport on a non-physical player. Maybe you mean Pawn? (See: https://docs.cssharp.dev/docs/guides/referencing-players.html#controllers--pawns)")]
public new void Teleport(Vector? position = null, QAngle? angles = null, Vector? velocity = null)
{
base.Teleport(position, angles, velocity);
}
}

View File

@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;
namespace CounterStrikeSharp.API.Core;
public partial class CTakeDamageInfo
{
/// <summary>
/// Retrieves the hitgroup
/// </summary>
/// <returns>
/// Returns a <see cref="HitGroup_t"/> enumeration representing the player's current hit group,
/// or <see cref="HitGroup_t.HITGROUP_INVALID"/> if the hit group cannot be determined.
/// </returns>
public HitGroup_t GetHitGroup()
{
IntPtr v4 = Marshal.ReadIntPtr(Handle, 0x78);
if (v4 == nint.Zero)
{
return HitGroup_t.HITGROUP_INVALID;
}
IntPtr v1 = Marshal.ReadIntPtr(v4, 16);
if (v1 == nint.Zero)
{
return HitGroup_t.HITGROUP_GENERIC;
}
return (HitGroup_t)Marshal.ReadInt32(v1, 56);
}
}