Skip to content

Commit daaa2ff

Browse files
authored
Merge branch 'main' into lua
2 parents 62c9ab6 + 62578bc commit daaa2ff

105 files changed

Lines changed: 3152 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Game.Client/C_Rope.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ public partial class C_RopeKeyframe : C_BaseEntity
8181
public float Width;
8282
[NetworkVar("m_flScrollSpeed")]
8383
public float ScrollSpeed;
84+
85+
public override Vector3 WorldSpaceCenter() => GetAbsOrigin();
8486
}
8587

‎Game.Client/DetailObjectSystem.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ int BuildOutSortedSprites(FastDetailLeafSpriteList data, in Vector3 viewOrigin,
12841284
FastSpriteX4[] sprites = data.Sprites!;
12851285
SortInfo[] outSort = FastSortInfos!;
12861286
FastSpriteQuadBuildoutBufferX4[] quadBufferOut = BuildoutBuffer!;
1287-
int spriteIdx = 0;
1287+
int spriteIdx = data.StartSIMDSprite;
12881288
int outIdx = 0;
12891289
int quadIdx = 0;
12901290
int curidx = 0;

‎Game.Server/AI_BaseNPC.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,20 @@ public static ReadOnlySpan<char> GetActivityName(Activity actID) {
379379
DEFINE.FIELD(nameof(DidDeathCleanup), FieldType.Boolean),
380380
DEFINE.OUTPUT(nameof(OnDeath), "OnDeath", eventFuncs),
381381
DEFINE.OUTPUT(nameof(OnDenyCommanderUse), "OnDenyCommanderUse", eventFuncs),
382+
383+
DEFINE.INPUTFUNC(FieldType.Integer, "SetHealth", nameof(InputSetHealth), (INPUTFUNCPTR)((self, data) => ((AI_BaseNPC)self).InputSetHealth(data))),
382384
]);
383385
public override DataMap? GetDataDescMap() => DataDesc;
384386

387+
public void InputSetHealth(InputData inputdata) {
388+
int newHealth = inputdata.Value.Int();
389+
int delta = Math.Abs(GetHealth() - newHealth);
390+
if (newHealth > GetHealth())
391+
TakeHealth(delta, DamageType.Generic);
392+
else if (newHealth < GetHealth())
393+
TakeDamage(new TakeDamageInfo(this, this, delta, DamageType.Generic));
394+
}
395+
385396
[NetworkVar("m_bPerformAvoidance")]
386397
public partial bool PerformAvoidance { get; set; }
387398
[NetworkVar("m_bIsMoving")]

‎Game.Server/BaseCombatCharacter.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public BaseCombatCharacter() {
7676

7777
public bool ForceServerRagdoll;
7878

79+
public override int TakeHealth(float health, DamageType damageType) {
80+
if (m_takedamage == 0)
81+
return 0;
82+
83+
return base.TakeHealth(health, damageType);
84+
}
85+
7986
public virtual Source.Common.Mathematics.QAngle BodyAngles() => GetAbsAngles();
8087

8188
public virtual Vector3 BodyDirection2D() {

‎Game.Server/BaseCombatWeapon.cs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,36 @@ public override void Use(BaseEntity? activator, BaseEntity? caller, UseType useT
111111
public override bool IsWeapon() => true;
112112
public override GarrysMod.LuaClass Lua_GetLuaClass() => GarrysMod.LuaEntity.LC_Weapon;
113113

114+
public static short g_sModelIndexLaser;
115+
public const string g_pModelNameLaser = "sprites/laserbeam.vmt";
116+
public static short g_sModelIndexFireball;
117+
public static short g_sModelIndexSmoke;
118+
public static short g_sModelIndexBubbles;
119+
114120
public static void W_Precache() {
121+
WeaponParse.PrecacheFileWeaponInfoDatabase(filesystem);
122+
123+
g_sModelIndexFireball = -1;
124+
125+
g_sModelIndexSmoke = (short)PrecacheModel("sprites/steam1.vmt");
126+
g_sModelIndexBubbles = (short)PrecacheModel("sprites/bubble.vmt");
127+
g_sModelIndexLaser = (short)PrecacheModel(g_pModelNameLaser);
128+
129+
PrecacheParticleSystem("blood_impact_red_01");
130+
PrecacheParticleSystem("blood_impact_green_01");
131+
PrecacheParticleSystem("blood_impact_yellow_01");
132+
#if GMOD_DLL
133+
PrecacheParticleSystem("blood_impact_antlion_01");
134+
PrecacheParticleSystem("blood_impact_zombie_01");
135+
PrecacheParticleSystem("blood_impact_antlion_worker_01");
136+
#endif
137+
138+
PrecacheModel("effects/bubble.vmt");
139+
140+
PrecacheModel("models/weapons/w_bullet.mdl");
115141

142+
PrecacheScriptSound("BaseCombatWeapon.WeaponDrop");
143+
PrecacheScriptSound("BaseCombatWeapon.WeaponMaterialize");
116144
}
117145

118146
public virtual Capability CapabilitiesGet() => 0;

‎Game.Server/BaseEntity.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ public float HealthFraction() {
20652065
return fraction;
20662066
}
20672067

2068-
public int TakeHealth(float health, DamageType damageType) {
2068+
public virtual int TakeHealth(float health, DamageType damageType) {
20692069
if (Edict() == null || (Damage)m_takedamage < Damage.Yes)
20702070
return 0;
20712071

‎Game.Server/BaseTempEntity.cs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
using Source.Common;
3+
using Source.Common.Mathematics;
4+
5+
using System.Numerics;
36

47
namespace Game.Server;
58

@@ -25,10 +28,22 @@ public void Create<IRF>(scoped ref IRF filter, float delay) where IRF : IRecipie
2528
}
2629

2730
public static BaseTempEntity? GetList() => s_pTempEntities;
31+
public ReadOnlySpan<char> GetName() => Name;
2832
public BaseTempEntity? GetNext() => Next;
2933

30-
public void Precache(){
34+
public virtual void Precache(){
35+
36+
}
37+
38+
public virtual void Test(in Vector3 current_origin, in QAngle current_angles) {
39+
Msg($"{Name}\n");
40+
MathLib.AngleVectors(current_angles, out Vector3 forward);
41+
42+
MathLib.VectorMA(current_origin, 20, forward, out Vector3 origin);
43+
44+
BroadcastRecipientFilter filter = new();
3145

46+
Create(ref filter, 0.0f);
3247
}
3348

3449
public static void PrecacheTempEnts() {

‎Game.Server/FuncBreak.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Game.Server;
77
[LinkEntityToClass("func_breakable")]
88
public class Breakable : BaseEntity, IBreakableWithPropData
99
{
10+
// todo: SetHealth/AddHealth/RemoveHealth inputs, they need UpdateHealth, OnHealthChanged and Break ported first
1011
public void SetDmgModBullet(float dmgMod) => DmgModBullet = dmgMod;
1112
public void SetDmgModClub(float dmgMod) => DmgModClub = dmgMod;
1213
public void SetDmgModExplosive(float dmgMod) => DmgModExplosive = dmgMod;

‎Game.Server/Player.cs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,33 @@ public void SetArmorValue(int value) {
268268
}
269269
}
270270

271+
public static readonly new DataMap DataDesc = new(typeof(BasePlayer), BaseCombatCharacter.DataDesc, [
272+
DEFINE<BasePlayer>.INPUTFUNC(FieldType.Integer, "SetHealth", nameof(InputSetHealth), (INPUTFUNCPTR)((self, data) => ((BasePlayer)self).InputSetHealth(data))),
273+
]);
274+
public override DataMap? GetDataDescMap() => DataDesc;
275+
276+
public override int TakeHealth(float health, DamageType damageType) {
277+
if (m_takedamage != 0) {
278+
DamageType bitsDmgTimeBased = g_pGameRules.Damage_GetTimeBased();
279+
bitsDamageType &= ~(damageType & ~bitsDmgTimeBased);
280+
}
281+
282+
return base.TakeHealth(health, damageType);
283+
}
284+
285+
public void InputSetHealth(InputData inputdata) {
286+
int newHealth = inputdata.Value.Int();
287+
int delta = Math.Abs(GetHealth() - newHealth);
288+
if (newHealth > GetHealth())
289+
TakeHealth(delta, DamageType.Generic);
290+
else if (newHealth < GetHealth()) {
291+
int armor = ArmorValue;
292+
ArmorValue = 0;
293+
TakeDamage(new TakeDamageInfo(this, this, delta, DamageType.Generic));
294+
ArmorValue = armor;
295+
}
296+
}
297+
271298
static InlineArray1024<char> InfoBuffer;
272299

273300
public ReadOnlySpan<char> GetInfo(ReadOnlySpan<char> name) {
@@ -696,6 +723,14 @@ public void UnforceButtons(InButtons buttons) {
696723
AfButtonForced &= ~buttons;
697724
}
698725

726+
public void DisableButtons(InButtons buttons) {
727+
AfButtonDisabled |= buttons;
728+
}
729+
730+
public void EnableButtons(InButtons buttons) {
731+
AfButtonDisabled &= ~buttons;
732+
}
733+
699734
public bool GamePaused;
700735

701736
public virtual void EquipSuit(bool playEffects = false) {

‎Game.Server/Props.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void ParsePropData() { }
5959
[NetworkName("CBreakableProp")]
6060
public partial class BreakableProp : BaseProp, IBreakableWithPropData, IPlayerPickupVPhysics
6161
{
62+
// todo: SetHealth/AddHealth/RemoveHealth inputs, they need UpdateHealth, OnHealthChanged and Break ported first
6263
[NetworkTable]
6364
public static readonly new NetworkProp[] Props = [
6465
];

0 commit comments

Comments
 (0)