Skip to content

Commit bd55030

Browse files
committed
dwarf engineer, props with disabled physics, dynamic health
1 parent ec8335d commit bd55030

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

WarcraftPlugin/Classes/DwarfEngineer.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,26 @@ internal class Prop
253253
{
254254
public string ModelPath { get; set; }
255255
public Vector Offset { get; set; } = new Vector(0, 0, 0);
256+
public Vector RotationOffset { get; set; } = new Vector(0, 0, 0);
257+
public bool EnableGravity { get; set; } = true;
256258
}
257259

260+
private const float PropHealthScalingFactor = 100f; //Higher number = less health
258261
internal static readonly List<Prop> Props =
259262
[
263+
//Sloped
264+
new Prop{ModelPath = "models/props/hr_massive/wood_fence/wood_fence_128.vmdl",
265+
EnableGravity = false,
266+
RotationOffset = new Vector(40,0,0),
267+
Offset = new Vector(0,0,-30)},
268+
269+
//Vertical
270+
new Prop{ModelPath = "models/props/hr_massive/wood_fence/wood_fence_128.vmdl",
271+
EnableGravity = false,
272+
Offset = new Vector(0,20,-40)},
260273
new Prop{ModelPath = "models/props/de_dust/hr_dust/dust_crates/dust_crate_style_01_32x32x32.vmdl"},
261274
new Prop{ModelPath = "models/props/de_dust/dust_rusty_barrel.vmdl" },
262-
new Prop{ModelPath = "models/props/de_inferno/hr_i/barrel_a/barrel_a_full.vmdl" },
263-
new Prop{ModelPath = "models/de_anubis/trims/mudbrick_roof_trim01_128.vmdl", Offset = new (60,0,0)},
264-
new Prop{ModelPath = "models/de_anubis/trims/mudbrick_roof_trim01a_64_01.vmdl", Offset = new (30,0,0)},
265-
new Prop{ModelPath = "models/props/hr_massive/wood_fence/wood_fence_128.vmdl"},
266-
new Prop{ModelPath = "models/props/de_vertigo/wood_pallet_01.vmdl",Offset = new (0,0,20)},
267-
new Prop{ModelPath = "models/props/de_inferno/chairantique_static.vmdl"},
268275
new Prop{ModelPath = "models/props/de_inferno/furniturecouch001a.vmdl"},
269-
new Prop{ModelPath = "models/props/cs_office/vending_machine.vmdl"},
270-
new Prop{ModelPath = "models/chicken/chicken_roasted.vmdl",Offset = new (0,0,20)},
271276
new Prop{ModelPath = "models/de_overpass/stuffed_animals/stuffed_elephant.vmdl"},
272277
new Prop{ModelPath = "weapons/models/c4/weapon_c4.vmdl", Offset = new (0,0,30)},
273278
];
@@ -299,7 +304,8 @@ public override void OnTick()
299304
{
300305
Vector velocity = Warcraft.CalculateTravelVelocity(_blueprintProp.AbsOrigin, BlueprintPosition(), 0.1f);
301306
var eyeAngles = Owner.PlayerPawn.Value.EyeAngles;
302-
QAngle rotation = new(0, eyeAngles.Y + _yawOffset, 0);
307+
var currentDef = Props[_currentPropIndex];
308+
QAngle rotation = new(eyeAngles.X + currentDef.RotationOffset.X, eyeAngles.Y + _yawOffset + currentDef.RotationOffset.Y, eyeAngles.Z + currentDef.RotationOffset.Z);
303309
_blueprintProp.Teleport(null, rotation, velocity);
304310

305311
if (Server.CurrentTime - _lastActionTick < 0.3) return;
@@ -348,11 +354,17 @@ public void SpawnProp()
348354
prop.Teleport(_blueprintProp.AbsOrigin, _blueprintProp.AbsRotation);
349355
prop.SetModel(currentDef.ModelPath);
350356

357+
if (!currentDef.EnableGravity)
358+
{
359+
prop.AcceptInput("DisableMotion", prop, prop);
360+
}
361+
351362
Server.NextWorldUpdate(() =>
352363
{
353364
prop.Collision.CollisionAttribute.InteractsAs = 136446081;
354365
prop.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PUSHAWAY;
355-
prop.Health = 50;
366+
var propHealth = prop.CollisionBox().Volume / PropHealthScalingFactor;
367+
prop.Health = (int)Math.Max(1f, propHealth);
356368
prop.TakeDamageFlags = TakeDamageFlags_t.DFLAG_NONE;
357369
prop.ExplodeRadius = 1f;
358370
});

0 commit comments

Comments
 (0)