forked from shobhit-pathak/MatchZy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrenadeThrownData.cs
More file actions
129 lines (113 loc) · 3.74 KB
/
Copy pathGrenadeThrownData.cs
File metadata and controls
129 lines (113 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
namespace MatchZy;
public class GrenadeThrownData
{
public Vector Position { get; private set; }
public QAngle Angle { get; private set; }
public Vector Velocity { get; private set; }
public Vector PlayerPosition { get; private set; }
public QAngle PlayerAngle { get; private set; }
public string Type { get; private set; }
public DateTime ThrownTime { get; private set; }
public float Delay { get; set; }
public UInt16 ItemIndex { get; set; }
public GrenadeThrownData(Vector nadePosition, QAngle nadeAngle, Vector nadeVelocity, Vector playerPosition, QAngle playerAngle, string grenadeType, DateTime thrownTime, UInt16 itemIndex)
{
Position = new Vector(nadePosition.X, nadePosition.Y, nadePosition.Z);
Angle = new QAngle(nadeAngle.X, nadeAngle.Y, nadeAngle.Z);
Velocity = new Vector(nadeVelocity.X, nadeVelocity.Y, nadeVelocity.Z);
PlayerPosition = new Vector(playerPosition.X, playerPosition.Y, playerPosition.Z);
PlayerAngle = new QAngle(playerAngle.X, playerAngle.Y, playerAngle.Z);
Type = grenadeType;
ThrownTime = thrownTime;
Delay = 0;
ItemIndex = itemIndex;
}
public void LoadPosition(CCSPlayerController player)
{
if (player == null || player.PlayerPawn.Value == null) return;
player.PlayerPawn.Value.Teleport(PlayerPosition, PlayerAngle, new Vector(0, 0, 0));
}
public void Throw(CCSPlayerController player)
{
CBaseCSGrenadeProjectile? grenadeEntity = null;
switch (Type)
{
case "smoke":
{
grenadeEntity = GrenadeFunctions.CSmokeGrenadeProjectile_CreateFunc.Invoke(
Position.Handle,
Angle.Handle,
Velocity.Handle,
Velocity.Handle,
IntPtr.Zero,
ItemIndex,
(int)player.Team);
break;
}
case "molotov":
{
grenadeEntity = GrenadeFunctions.CMolotovProjectile_CreateFunc.Invoke(
Position.Handle,
Angle.Handle,
Velocity.Handle,
Velocity.Handle,
IntPtr.Zero,
ItemIndex);
break;
}
case "hegrenade":
{
grenadeEntity = GrenadeFunctions.CHEGrenadeProjectile_CreateFunc.Invoke(
Position.Handle,
Angle.Handle,
Velocity.Handle,
Velocity.Handle,
IntPtr.Zero,
ItemIndex);
break;
}
case "decoy":
{
grenadeEntity = GrenadeFunctions.CDecoyProjectile_CreateFunc.Invoke(
Position.Handle,
Angle.Handle,
Velocity.Handle,
Velocity.Handle,
IntPtr.Zero,
ItemIndex);
break;
}
case "flash":
{
grenadeEntity = Utilities.CreateEntityByName<CFlashbangProjectile>("flashbang_projectile");
if (grenadeEntity == null) return;
grenadeEntity.DispatchSpawn();
break;
}
default:
Console.WriteLine($"[MatchZy] Unknown Grenade: {Type}");
break;
}
if (grenadeEntity != null && grenadeEntity.DesignerName != "smokegrenade_projectile")
{
grenadeEntity.InitialPosition.X = Position.X;
grenadeEntity.InitialPosition.Y = Position.Y;
grenadeEntity.InitialPosition.Z = Position.Z;
grenadeEntity.InitialVelocity.X = Velocity.X;
grenadeEntity.InitialVelocity.Y = Velocity.Y;
grenadeEntity.InitialVelocity.Z = Velocity.Z;
grenadeEntity.AngVelocity.X = Velocity.X;
grenadeEntity.AngVelocity.Y = Velocity.Y;
grenadeEntity.AngVelocity.Z = Velocity.Z;
grenadeEntity.Teleport(Position, Angle, Velocity);
grenadeEntity.Globalname = "custom";
grenadeEntity.TeamNum = player.TeamNum;
grenadeEntity.Thrower.Raw = player.PlayerPawn.Raw;
grenadeEntity.OriginalThrower.Raw = player.PlayerPawn.Raw;
grenadeEntity.OwnerEntity.Raw = player.PlayerPawn.Raw;
}
}
}