Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 9508341

Browse files
committed
Review changes
1 parent b29c1e2 commit 9508341

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
256256

257257
- New `AHuman` Lua functions `GetWalkAngle(layer)` and `SetWalkAngle(layer, angle)`, which can be used to read and override walk path rotation of both Legs/Layers respectively. Note that the walk path rotation is automatically updated on each step to match the curvature of the terrain, so this value resets every update.
258258

259+
- New `AHuman` INI and Lua (R/W) property `ArmSwingRate`, which now controls the arms' walking animation, according to each arm's `IdleOffset`. `1` is the default value, `0` means that the arms stay still.
260+
261+
- New `Attachable` Lua (R) property `JointPos`, which gets the position of the object's joint in scene coordinates.
262+
259263
</details>
260264

261265
<details><summary><b>Changed</b></summary>
262266

267+
- `ThrownDevice`s will now use `StanceOffset`, `SharpStanceOffset` and `SupportOffset` in the same way as any other `HeldDevice`. In addition, `EndThrowOffset` will be used to set the BG hand position while sharp aiming or throwing.
268+
269+
- `AHuman` throwing angle will no longer be affected by the rotation of the body.
270+
263271
- Exposed `MovableObject` property `RestThreshold` to Lua (R/W).
264272

265273
- `ACRocket`s can now function without a full set of thrusters. This also means that "Null Emitter" thrusters are no longer required for rockets.

Entities/AHuman.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void AHuman::Clear()
8383
m_BGArmFlailScalar = 0.7F;
8484
m_EquipHUDTimer.Reset();
8585
m_WalkAngle.fill(Matrix());
86-
m_FlailArms = 1.0F;
86+
m_ArmSwingRate = 1.0F;
8787

8888
m_DeviceState = SCANNING;
8989
m_SweepState = NOSWEEP;
@@ -180,7 +180,7 @@ int AHuman::Create(const AHuman &reference) {
180180
m_JetAngleRange = reference.m_JetAngleRange;
181181
m_FGArmFlailScalar = reference.m_FGArmFlailScalar;
182182
m_BGArmFlailScalar = reference.m_BGArmFlailScalar;
183-
m_FlailArms = reference.m_FlailArms;
183+
m_ArmSwingRate = reference.m_ArmSwingRate;
184184

185185
m_pFGHandGroup = dynamic_cast<AtomGroup *>(reference.m_pFGHandGroup->Clone());
186186
m_pFGHandGroup->SetOwner(this);
@@ -255,8 +255,8 @@ int AHuman::ReadProperty(const std::string_view &propName, Reader &reader) {
255255
reader >> m_FGArmFlailScalar;
256256
} else if (propName == "BGArmFlailScalar") {
257257
reader >> m_BGArmFlailScalar;
258-
} else if (propName == "FlailArms") {
259-
reader >> m_FlailArms;
258+
} else if (propName == "ArmSwingRate") {
259+
reader >> m_ArmSwingRate;
260260
} else if (propName == "FGArm") {
261261
SetFGArm(dynamic_cast<Arm *>(g_PresetMan.ReadReflectedPreset(reader)));
262262
} else if (propName == "BGArm") {
@@ -356,8 +356,8 @@ int AHuman::Save(Writer &writer) const
356356
writer << m_FGArmFlailScalar;
357357
writer.NewProperty("BGArmFlailScalar");
358358
writer << m_BGArmFlailScalar;
359-
writer.NewProperty("FlailArms");
360-
writer << m_FlailArms;
359+
writer.NewProperty("ArmSwingRate");
360+
writer << m_ArmSwingRate;
361361
writer.NewProperty("FGArm");
362362
writer << m_pFGArm;
363363
writer.NewProperty("BGArm");
@@ -3186,8 +3186,8 @@ void AHuman::Update()
31863186
////////////////////////////////////
31873187
// Movement direction
31883188

3189-
bool isStill = m_Vel.GetMagnitude() + m_PrevVel.GetMagnitude() < 1.0F;
3190-
bool aiming = m_Controller.IsState(AIM_SHARP);
3189+
bool isStill = (m_Vel + m_PrevVel).GetMagnitude() < 1.0F;
3190+
bool isSharpAiming = m_Controller.IsState(AIM_SHARP);
31913191

31923192
// If the pie menu is on, try to preserve whatever move state we had before it going into effect.
31933193
if (!m_Controller.IsState(PIE_MENU_ACTIVE)) {
@@ -3218,7 +3218,7 @@ void AHuman::Update()
32183218
}
32193219

32203220
// Walk backwards if the aiming is already focused in the opposite direction of travel.
3221-
if (analogAim.GetMagnitude() != 0 || aiming) {
3221+
if (analogAim.GetMagnitude() != 0 || isSharpAiming) {
32223222
m_Paths[FGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
32233223
m_Paths[BGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
32243224
} else if ((m_Controller.IsState(MOVE_RIGHT) && m_HFlipped) || (m_Controller.IsState(MOVE_LEFT) && !m_HFlipped)) {
@@ -3307,14 +3307,14 @@ void AHuman::Update()
33073307
// Set the timer to a base number so we don't get a sluggish feeling at start.
33083308
if (m_AimState != AIMUP) { m_AimTmr.SetElapsedSimTimeMS(m_AimState == AIMSTILL ? 150 : 300); }
33093309
m_AimState = AIMUP;
3310-
m_AimAngle += aiming ? std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00005F, 0.05F) : std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00015F, 0.15F) * m_Controller.GetDigitalAimSpeed();
3310+
m_AimAngle += isSharpAiming ? std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00005F, 0.05F) : std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00015F, 0.15F) * m_Controller.GetDigitalAimSpeed();
33113311
if (m_AimAngle > m_AimRange) { m_AimAngle = m_AimRange; }
33123312

33133313
} else if (m_Controller.IsState(AIM_DOWN) && m_Status != INACTIVE) {
33143314
// Set the timer to a base number so we don't get a sluggish feeling at start.
33153315
if (m_AimState != AIMDOWN) {m_AimTmr.SetElapsedSimTimeMS(m_AimState == AIMSTILL ? 150 : 300); }
33163316
m_AimState = AIMDOWN;
3317-
m_AimAngle -= aiming ? std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00005F, 0.05F) : std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00015F, 0.15F) * m_Controller.GetDigitalAimSpeed();
3317+
m_AimAngle -= isSharpAiming ? std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00005F, 0.05F) : std::min(static_cast<float>(m_AimTmr.GetElapsedSimTimeMS()) * 0.00015F, 0.15F) * m_Controller.GetDigitalAimSpeed();
33183318
if (m_AimAngle < -m_AimRange) { m_AimAngle = -m_AimRange; }
33193319

33203320
} else if (analogAim.GetMagnitude() != 0 && m_Status != INACTIVE) {
@@ -3350,7 +3350,7 @@ void AHuman::Update()
33503350

33513351
// TODO: make the delay data driven by both the actor and the device!
33523352
//
3353-
if (aiming && m_Status == STABLE && (m_MoveState == STAND || m_MoveState == CROUCH || m_MoveState == NOMOVE || m_MoveState == WALK) && m_Vel.GetMagnitude() < 5.0F && GetEquippedItem()) {
3353+
if (isSharpAiming && m_Status == STABLE && (m_MoveState == STAND || m_MoveState == CROUCH || m_MoveState == NOMOVE || m_MoveState == WALK) && m_Vel.GetMagnitude() < 5.0F && GetEquippedItem()) {
33543354
float aimMag = analogAim.GetMagnitude();
33553355

33563356
// If aim sharp is being done digitally, then translate to full analog aim mag
@@ -3383,10 +3383,10 @@ void AHuman::Update()
33833383

33843384
ThrownDevice *pThrown = nullptr;
33853385
if (m_pFGArm && m_Status != INACTIVE) {
3386-
if (m_pBGLeg && m_MoveState == WALK && m_FlailArms > 0) {
3387-
m_pFGArm->ReachToward(m_pFGArm->GetJointPos() + m_pFGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pBGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_FlailArms));
3388-
} else if (m_pFGLeg && m_FlailArms > 0) {
3389-
m_pFGArm->ReachToward(m_pFGArm->GetJointPos() + m_pFGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pFGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_FlailArms));
3386+
if (m_pBGLeg && m_MoveState == WALK && m_ArmSwingRate > 0) {
3387+
m_pFGArm->ReachToward(m_pFGArm->GetJointPos() + m_pFGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pBGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_ArmSwingRate));
3388+
} else if (m_pFGLeg && m_ArmSwingRate > 0) {
3389+
m_pFGArm->ReachToward(m_pFGArm->GetJointPos() + m_pFGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pFGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_ArmSwingRate));
33903390
} else {
33913391
// Force arm to idle by reaching toward a virtually inaccessible point.
33923392
m_pFGArm->ReachToward(Vector());
@@ -3405,7 +3405,7 @@ void AHuman::Update()
34053405
else if (m_pFGArm->GetHeldMO()) {
34063406
pThrown = dynamic_cast<ThrownDevice *>(m_pFGArm->GetHeldMO());
34073407
if (pThrown) {
3408-
pThrown->SetSharpAim(aiming ? 1.0F : 0);
3408+
pThrown->SetSharpAim(isSharpAiming ? 1.0F : 0);
34093409
if (m_Controller.IsState(WEAPON_FIRE)) {
34103410
if (m_ArmsState != THROWING_PREP) {
34113411
m_ThrowTmr.Reset();
@@ -3430,8 +3430,7 @@ void AHuman::Update()
34303430
minThrowVel = maxThrowVel * 0.2F;
34313431
}
34323432
Vector tossVec(minThrowVel + (maxThrowVel - minThrowVel) * GetThrowProgress(), 0.5F * RandomNormalNum());
3433-
tossVec.RadRotate(m_AimAngle + m_AngularVel * deltaTime);
3434-
pMO->SetVel(tossVec.GetXFlipped(m_HFlipped));
3433+
pMO->SetVel(m_Vel * 0.5F + tossVec.RadRotate(m_AimAngle).GetXFlipped(m_HFlipped));
34353434
pMO->SetAngularVel(m_AngularVel + RandomNum(-5.0F, 2.5F) * GetFlipFactor());
34363435
pMO->SetRotAngle(adjustedAimAngle);
34373436

@@ -3854,9 +3853,9 @@ void AHuman::Update()
38543853
m_pBGArm->ReachToward(m_pBGHandGroup->GetLimbPos(m_HFlipped));
38553854

38563855
} else {
3857-
HeldDevice * heldDevice = dynamic_cast<HeldDevice *>(GetEquippedItem());
3858-
ThrownDevice * thrownDevice = dynamic_cast<ThrownDevice *>(heldDevice);
3859-
if (thrownDevice && (m_ArmsState == THROWING_PREP || aiming)) {
3856+
HeldDevice *heldDevice = dynamic_cast<HeldDevice *>(GetEquippedItem());
3857+
ThrownDevice *thrownDevice = dynamic_cast<ThrownDevice *>(heldDevice);
3858+
if (thrownDevice && (m_ArmsState == THROWING_PREP || isSharpAiming)) {
38603859
m_pBGArm->ReachToward(m_pBGArm->GetJointPos() + thrownDevice->GetEndThrowOffset().RadRotate(m_AimAngle).GetXFlipped(m_HFlipped));
38613860
} else if (heldDevice) {
38623861
if (GetEquippedBGItem() && !heldDevice->IsOneHanded()) {
@@ -3872,10 +3871,10 @@ void AHuman::Update()
38723871
m_pBGArm->SetRecoil(Vector(), Vector(), false);
38733872
}
38743873
}
3875-
} else if (m_pFGLeg && m_MoveState == WALK && m_FlailArms > 0) {
3876-
m_pBGArm->ReachToward(m_pBGArm->GetJointPos() + m_pBGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pFGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_FlailArms));
3877-
} else if (m_pBGLeg && m_FlailArms > 0) {
3878-
m_pBGArm->ReachToward(m_pBGArm->GetJointPos() + m_pBGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pBGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_FlailArms));
3874+
} else if (m_pFGLeg && m_MoveState == WALK && m_ArmSwingRate > 0) {
3875+
m_pBGArm->ReachToward(m_pBGArm->GetJointPos() + m_pBGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pFGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_ArmSwingRate));
3876+
} else if (m_pBGLeg && m_ArmSwingRate > 0) {
3877+
m_pBGArm->ReachToward(m_pBGArm->GetJointPos() + m_pBGArm->GetIdleOffset().GetXFlipped(m_HFlipped).RadRotate(std::sin(m_pBGLeg->GetRotAngle() + c_HalfPI * GetFlipFactor()) * m_ArmSwingRate));
38793878
} else {
38803879
// Force arm to idle by reaching toward a virtually inaccessible point.
38813880
m_pBGArm->ReachToward(Vector());
@@ -4098,13 +4097,14 @@ void AHuman::DrawThrowingReticle(BITMAP *targetBitmap, const Vector &targetPos,
40984097
points[index].SetXY(static_cast<float>(index * 4), 0.0F);
40994098
}
41004099
Vector outOffset(m_pFGArm->GetMaxLength() * GetFlipFactor(), -m_pFGArm->GetMaxLength() * 0.5F);
4100+
float adjustedAimAngle = m_AimAngle * GetFlipFactor();
41014101

41024102
acquire_bitmap(targetBitmap);
41034103

41044104
for (int i = 0; i < pointCount * progressScalar; ++i) {
41054105
points[i].FlipX(m_HFlipped);
41064106
points[i] += outOffset;
4107-
points[i].RadRotate(m_AimAngle * GetFlipFactor() + m_AngularVel * g_TimerMan.GetDeltaTimeSecs());
4107+
points[i].RadRotate(adjustedAimAngle);
41084108
points[i] += m_pFGArm->GetJointPos();
41094109

41104110
g_PostProcessMan.RegisterGlowDotEffect(points[i], YellowDot, RandomNum(63, 127));

Entities/AHuman.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -926,16 +926,16 @@ ClassInfoGetters;
926926
void SetThrowPrepTime(long newPrepTime) { m_ThrowPrepTime = newPrepTime; }
927927

928928
/// <summary>
929-
/// Gets whether this AHuman is set to flail its arms while walking, overriding the arms' idle behavior.
929+
/// Gets the rate at which this AHuman is set to swing its arms while walking.
930930
/// </summary>
931-
/// <returns>Whether this AHuman is set to flail its arms.</returns>
932-
float GetFlailArms() const { return m_FlailArms; }
931+
/// <returns>The arm swing rate of this AHuman.</returns>
932+
float GetArmSwingRate() const { return m_ArmSwingRate; }
933933

934934
/// <summary>
935-
/// Sets whether this AHuman is set to flail its arms while walking.
935+
/// Sets the rate at which this AHuman is set to swing its arms while walking.
936936
/// </summary>
937-
/// <param name="newValue">Whether this AHuman should flail its arms.</param>
938-
void SetFlailArms(float newValue) { m_FlailArms = newValue; }
937+
/// <param name="newValue">The new arm swing rate for this AHuman.</param>
938+
void SetArmSwingRate(float newValue) { m_ArmSwingRate = newValue; }
939939

940940
/// <summary>
941941
/// Gets this AHuman's stride sound. Ownership is NOT transferred!
@@ -1042,7 +1042,7 @@ ClassInfoGetters;
10421042
float m_BGArmFlailScalar; //!< The rate at which this AHuman's BG Arm follows the the bodily rotation. Set to a negative value for a "counterweight" effect.
10431043
Timer m_EquipHUDTimer; //!< Timer for showing the name of any newly equipped Device.
10441044
std::array<Matrix, 2> m_WalkAngle; //!< An array of rot angle targets for different movement states.
1045-
float m_FlailArms; //!< Toggles the arm sway when walking.
1045+
float m_ArmSwingRate; //!< Controls the rate at which this AHuman's arms follow the movement of its legs.
10461046

10471047
////////////////
10481048
// AI States

Entities/Attachable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ namespace RTE {
242242
/// Gets the absolute position of the joint that the parent of this Attachable sets upon Update().
243243
/// </summary>
244244
/// <returns>A Vector describing the current absolute position of the joint.</returns>
245-
Vector GetJointPos() const { return m_JointPos; }
245+
const Vector & GetJointPos() const { return m_JointPos; }
246246
#pragma endregion
247247

248248
#pragma region Force Transferral

Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ namespace RTE {
424424
.property("FirearmIsSemiAuto", &AHuman::FirearmIsSemiAuto)
425425
.property("FirearmActivationDelay", &AHuman::FirearmActivationDelay)
426426
.property("LimbPathPushForce", &AHuman::GetLimbPathPushForce, &AHuman::SetLimbPathPushForce)
427-
.property("FlailArms", &AHuman::GetFlailArms, &AHuman::SetFlailArms)
427+
.property("ArmSwingRate", &AHuman::GetArmSwingRate, &AHuman::SetArmSwingRate)
428428

429429
.def("EquipFirearm", &AHuman::EquipFirearm)
430430
.def("EquipThrowable", &AHuman::EquipThrowable)

0 commit comments

Comments
 (0)