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

Commit 18acfdc

Browse files
authored
Merge pull request #522 from cortex-command-community/4zk-content-source
5.2 additions v2: Electric Boogaloo
2 parents 5fb92a0 + 43d6eca commit 18acfdc

22 files changed

+92
-228
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
601601

602602
- New `MovableObject` Lua (R) property `DistanceTravelled` which returns the amount of pixels the object has travelled since its creation.
603603

604-
- Added `Activity` Lua function `ForceSetTeamAsActive(team)`, which forcefully sets a team as active. Necessary for `Activity`s that don't want to define/show all used teams, but still want `Actor`s of hidden teams to work properly.
605-
606604
- Added `GameActivity` INI property `DefaultGoldMaxDifficulty`, which lets you specify the default gold when the difficulty slider is maxed out.
607605

608606
- Added `HDFirearm` Lua (R/W) property `BaseReloadTime` that lets you get and set the `HDFirearm`'s base reload time (i.e. the reload time before it's adjusted for one-handed reloads where appropriate).
@@ -637,6 +635,8 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
637635

638636
- Added `Activity` Lua function `GetPlayerController`, which gets you the `Controller` used for GUI stuff and when there's no `Actor` selected in an `Activity`. Be aware, it's very likely possible to cause problems by doing dumb things with this.
639637

638+
- Added `Leg` Lua (R/W) property `MoveSpeed`, which lets you get and set the `Leg`'s `MoveSpeed` scalar, similar to `Arm`s. 1 means instant movement and 0 means no movement.
639+
640640
- Added `LuaMan` Lua function `FileExists`, which lets you check whether a specified file exists. Like with `FileOpen`, the file must be inside a folder ending in `.rte`.
641641

642642
</details>
@@ -861,6 +861,8 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
861861

862862
- Changed `LuaMan:FileOpen` access modes so it only allows `"r", "r+", "w", "w+", "a", "a+"`, i.e. specifying type (text, binary) is not supported. See [this reference page](https://cplusplus.com/reference/cstdio/fopen) for details on the access modes.
863863

864+
- Moved `FlashWhite` function from `Actor` to `MOSRotating`.
865+
864866
</details>
865867

866868
<details><summary><b>Fixed</b></summary>

Entities/ACrab.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,15 @@ void ACrab::Update()
24472447

24482448
// Reset the right-side walking stride if it's taking longer than it should.
24492449
if (m_StrideTimer[RIGHTSIDE].IsPastSimMS(static_cast<double>(m_Paths[RIGHTSIDE][FGROUND][WALK].GetTotalPathTime() * 1.1F))) { m_StrideStart[RIGHTSIDE] = true; }
2450-
2451-
if (restarted && m_StrideSound) { m_StrideSound->Play(m_Pos); }
2450+
2451+
if (m_StrideSound) {
2452+
m_StrideSound->SetPosition(m_Pos);
2453+
if (m_StrideSound->GetLoopSetting() < 0) {
2454+
if (!m_StrideSound->IsBeingPlayed()) { m_StrideSound->Play(); }
2455+
} else if (restarted) {
2456+
m_StrideSound->Play();
2457+
}
2458+
}
24522459
} else if (m_pLFGLeg || m_pLBGLeg || m_pRFGLeg || m_pRBGLeg) {
24532460
if (m_MoveState == JUMP) {
24542461
// TODO: Utilize jump paths in an intuitive way?
@@ -2498,6 +2505,9 @@ void ACrab::Update()
24982505

24992506
if (m_pRBGLeg) { m_pRBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pRBGLeg->GetParentOffset()), m_pRBGLeg->GetMaxLength(), m_PrevVel * m_pRBGLeg->GetJointStiffness(), m_AngularVel, m_pRBGLeg->GetMass(), deltaTime); }
25002507
}
2508+
if (m_MoveState != WALK && m_StrideSound && m_StrideSound->GetLoopSetting() < 0) {
2509+
m_StrideSound->Stop();
2510+
}
25012511

25022512
/////////////////////////////////
25032513
// Manage Attachable:s

Entities/ACraft.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -800,37 +800,6 @@ float ACraft::GetCollectedInventoryMass() const {
800800
return inventoryMass;
801801
}
802802

803-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
804-
805-
//////////////////////////////////////////////////////////////////////////////////////////
806-
// Virtual method: OnMOHit
807-
//////////////////////////////////////////////////////////////////////////////////////////
808-
// Description: Defines what should happen when this MovableObject hits another MO.
809-
// This is called by the owned Atom/AtomGroup of this MovableObject during
810-
// travel.
811-
812-
bool ACraft::OnMOHit(MovableObject *pOtherMO)
813-
{
814-
/* Obviously don't put craft into craft
815-
// See if we hit any craft with open doors to get sucked into
816-
ACraft *pCraft = dynamic_cast<ACraft *>(pOtherMO);
817-
818-
// Don't let things of wrong teams get sucked into other team's craft
819-
if (!IsSetToDelete() && pCraft && m_Team == pCraft->GetTeam() && (pCraft->GetHatchState() == ACraft::OPEN || pCraft->GetHatchState() == ACraft::OPENING))
820-
{
821-
// Add (copy) to the ship's inventory
822-
pCraft->AddInventoryItem(dynamic_cast<MovableObject *>(this->Clone()));
823-
// Delete the original from scene - this is safer than 'removing' or handing over ownership halfway through MovableMan's update
824-
this->SetToDelete();
825-
// Terminate; we got sucked into the craft; so communicate this out
826-
return true;
827-
}
828-
*/
829-
// Don't terminate, continue travel
830-
return false;
831-
}
832-
833-
834803
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
835804

836805
void ACraft::GibThis(const Vector &impactImpulse, MovableObject *movableObjectToIgnore) {

Entities/ACraft.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,6 @@ enum Side
461461
/// </summary>
462462
void ResetAllTimers() override;
463463

464-
//////////////////////////////////////////////////////////////////////////////////////////
465-
// Virtual method: OnMOHit
466-
//////////////////////////////////////////////////////////////////////////////////////////
467-
// Description: Defines what should happen when this MovableObject hits another MO.
468-
// This is called by the owned Atom/AtomGroup of this MovableObject during
469-
// travel.
470-
// Arguments: The other MO hit. Ownership is not transferred.
471-
// Return value: Wheter the MovableObject should immediately halt any travel going on
472-
// after this hit.
473-
474-
bool OnMOHit(MovableObject *pOtherMO) override;
475-
476-
477464
//////////////////////////////////////////////////////////////////////////////////////////
478465
// Virtual method: Update
479466
//////////////////////////////////////////////////////////////////////////////////////////

Entities/AHuman.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,13 +3582,20 @@ void AHuman::Update()
35823582
}
35833583
bool climbing = m_ArmClimbing[FGROUND] || m_ArmClimbing[BGROUND];
35843584

3585+
if (m_StrideSound) {
3586+
m_StrideSound->SetPosition(m_Pos);
3587+
if (m_StrideSound->GetLoopSetting() < 0) {
3588+
if (!m_StrideSound->IsBeingPlayed()) { m_StrideSound->Play(); }
3589+
} else if (restarted && !climbing) {
3590+
m_StrideSound->Play();
3591+
}
3592+
}
35853593
if (restarted) {
3586-
if (!climbing) {
3587-
if (m_StrideSound) { m_StrideSound->Play(m_Pos); }
3588-
RunScriptedFunctionInAppropriateScripts("OnStride");
3589-
} else {
3594+
if (climbing) {
35903595
m_WalkAngle[FGROUND] = Matrix();
35913596
m_WalkAngle[BGROUND] = Matrix();
3597+
} else {
3598+
RunScriptedFunctionInAppropriateScripts("OnStride");
35923599
}
35933600
}
35943601

@@ -3732,6 +3739,9 @@ void AHuman::Update()
37323739

37333740
if (m_pBGLeg) { m_pBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pBGLeg->GetParentOffset()), m_pBGLeg->GetMaxLength(), m_PrevVel * m_pBGLeg->GetJointStiffness(), m_AngularVel, m_pBGLeg->GetMass(), deltaTime); }
37343741
}
3742+
if (m_MoveState != WALK && m_StrideSound && m_StrideSound->GetLoopSetting() < 0) {
3743+
m_StrideSound->Stop();
3744+
}
37353745

37363746
/////////////////////////////////
37373747
// Manage Attachables
@@ -4048,7 +4058,7 @@ void AHuman::DrawThrowingReticle(BITMAP *targetBitmap, const Vector &targetPos,
40484058
void AHuman::Draw(BITMAP *pTargetBitmap, const Vector &targetPos, DrawMode mode, bool onlyPhysical) const {
40494059
Actor::Draw(pTargetBitmap, targetPos, mode, onlyPhysical);
40504060

4051-
DrawMode realMode = (mode == g_DrawColor && m_FlashWhiteMS) ? g_DrawWhite : mode;
4061+
DrawMode realMode = (mode == g_DrawColor && !m_FlashWhiteTimer.IsPastRealTimeLimit()) ? g_DrawWhite : mode;
40524062
// Note: For some reason the ordering of the attachables list can get messed up. The most important thing here is that the FGArm is on top of everything else.
40534063
if (m_pHead && m_pHead->IsDrawnAfterParent()) { m_pHead->Draw(pTargetBitmap, targetPos, realMode, onlyPhysical); }
40544064
if (m_pFGArm) { m_pFGArm->Draw(pTargetBitmap, targetPos, realMode, onlyPhysical); }

Entities/Activity.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void Activity::Clear() {
632632
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
633633

634634
std::string Activity::GetDifficultyString(int difficulty) {
635-
if (difficulty < DifficultySetting::CakeDifficulty) {
635+
if (difficulty <= DifficultySetting::CakeDifficulty) {
636636
return "Cake";
637637
} else if (difficulty <= DifficultySetting::EasyDifficulty) {
638638
return "Easy";
@@ -804,24 +804,29 @@ void Activity::Clear() {
804804
}
805805

806806
float totalValue = orbitedCraft->GetTotalValue(0, foreignCostMult, nativeCostMult);
807-
std::snprintf(messageString, sizeof(messageString), "Returned Craft + Cargo added %.0f oz to Funds!", totalValue);
808807

808+
std::string craftText = "Returned craft";
809+
if (!orbitedCraft->IsInventoryEmpty()) {
810+
craftText += " + cargo";
811+
}
812+
if (totalValue > 0.0F) {
813+
m_TeamFunds[orbitedCraftTeam] += totalValue;
814+
std::snprintf(messageString, sizeof(messageString), "%s added %.0f oz to funds!", craftText.c_str(), totalValue);
815+
}
809816
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
810817
if (m_IsActive[player]) {
811818
if (brainOnBoard && orbitedCraft == GetPlayerBrain(static_cast<Players>(player))) {
812819
m_BrainEvacuated[player] = true;
813-
std::snprintf(messageString, sizeof(messageString), "YOUR BRAIN HAS BEEN EVACUATED BACK INTO ORBIT!");
814-
}
815-
816-
if (m_Team[player] == orbitedCraftTeam) {
817-
g_FrameMan.ClearScreenText(ScreenOfPlayer(ScreenOfPlayer(static_cast<Players>(player))));
820+
g_FrameMan.ClearScreenText(ScreenOfPlayer(static_cast<Players>(player)));
821+
g_FrameMan.SetScreenText("YOUR BRAIN HAS BEEN EVACUATED BACK INTO ORBIT!", ScreenOfPlayer(static_cast<Players>(player)), 0, 3500);
822+
} else if (m_Team[player] == orbitedCraftTeam && totalValue > 0.0F) {
823+
g_FrameMan.ClearScreenText(ScreenOfPlayer(static_cast<Players>(player)));
818824
g_FrameMan.SetScreenText(messageString, ScreenOfPlayer(static_cast<Players>(player)), 0, 3500);
819825
m_MessageTimer[player].Reset();
820826
}
821827
}
822828
}
823829

824-
m_TeamFunds[orbitedCraftTeam] += totalValue;
825830
orbitedCraft->SetGoldCarried(0);
826831
orbitedCraft->SetHealth(orbitedCraft->GetMaxHealth());
827832

Entities/Actor.cpp

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ void Actor::Clear() {
109109
m_MaxInventoryMass = -1.0F;
110110
m_pItemInReach = nullptr;
111111
m_HUDStack = 0;
112-
m_FlashWhiteMS = 0;
113-
m_WhiteFlashTimer.Reset();
114112
m_DeploymentID = 0;
115113
m_PassengerSlots = 1;
116114

@@ -610,7 +608,7 @@ bool Actor::HasObjectInGroup(std::string groupName) const
610608

611609
void Actor::SetTeam(int team)
612610
{
613-
SceneObject::SetTeam(team);
611+
MovableObject::SetTeam(team);
614612

615613
// Change the Team Icon to display
616614
m_pTeamIcon = 0;
@@ -1153,40 +1151,6 @@ bool Actor::ParticlePenetration(HitData &hd) {
11531151
return penetrated;
11541152
}
11551153

1156-
1157-
//////////////////////////////////////////////////////////////////////////////////////////
1158-
// Virtual method: OnMOHit
1159-
//////////////////////////////////////////////////////////////////////////////////////////
1160-
// Description: Defines what should happen when this MovableObject hits another MO.
1161-
// This is called by the owned Atom/AtomGroup of this MovableObject during
1162-
// travel.
1163-
1164-
bool Actor::OnMOHit(MovableObject *pOtherMO)
1165-
{
1166-
/* The ACraft now actively suck things in with cast rays instead
1167-
// See if we hit any craft with open doors to get sucked into
1168-
ACraft *pCraft = dynamic_cast<ACraft *>(pOtherMO);
1169-
1170-
// Don't let things of wrong teams get sucked into other team's craft
1171-
if (!IsSetToDelete() && pCraft && m_Team == pCraft->GetTeam() && (pCraft->GetHatchState() == ACraft::OPEN || pCraft->GetHatchState() == ACraft::OPENING))
1172-
{
1173-
// Switch control to the craft we just entered, if this is currently player controlled
1174-
// Set AI controller of this one going into the ship
1175-
if (g_ActivityMan.GetActivity() && this->GetController()->IsPlayerControlled())
1176-
g_ActivityMan.GetActivity()->SwitchToActor(pCraft, this->GetController()->GetPlayer(), this->GetTeam());
1177-
// Add (copy) to the ship's inventory
1178-
pCraft->AddInventoryItem(dynamic_cast<MovableObject *>(this->Clone()));
1179-
// Delete the original from scene - this is safer than 'removing' or handing over ownership halfway through MovableMan's update
1180-
this->SetToDelete();
1181-
// Terminate; we got sucked into the craft; so communicate this out
1182-
return true;
1183-
}
1184-
*/
1185-
// Don't terminate, continue travel
1186-
return false;
1187-
}
1188-
1189-
11901154
//////////////////////////////////////////////////////////////////////////////////////////
11911155
// Virtual method: GetAIModeIcon
11921156
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1588,15 +1552,6 @@ void Actor::Update()
15881552
g_MovableMan.SortTeamRoster(m_Team);
15891553
}
15901554

1591-
// Reduce the remaining white flash time
1592-
if (m_FlashWhiteMS)
1593-
{
1594-
m_FlashWhiteMS -= m_WhiteFlashTimer.GetElapsedRealTimeMS();
1595-
m_WhiteFlashTimer.Reset();
1596-
if (m_FlashWhiteMS < 0)
1597-
m_FlashWhiteMS = 0;
1598-
}
1599-
16001555
int brainOfPlayer = g_ActivityMan.GetActivity()->IsBrainOfWhichPlayer(this);
16011556
if (brainOfPlayer != Players::NoPlayer && g_ActivityMan.GetActivity()->PlayerHuman(brainOfPlayer)) {
16021557
if (m_PrevHealth - m_Health > 1.5F) {
@@ -1631,22 +1586,6 @@ void Actor::Update()
16311586
}
16321587

16331588

1634-
//////////////////////////////////////////////////////////////////////////////////////////
1635-
// Virtual method: Draw
1636-
//////////////////////////////////////////////////////////////////////////////////////////
1637-
// Description: Draws this Actor's current graphical representation to a
1638-
// BITMAP of choice.
1639-
1640-
void Actor::Draw(BITMAP *pTargetBitmap,
1641-
const Vector &targetPos,
1642-
DrawMode mode,
1643-
bool onlyPhysical) const
1644-
{
1645-
// Make it draw white if is going to be drawn as color
1646-
MOSRotating::Draw(pTargetBitmap, targetPos, mode == g_DrawColor && m_FlashWhiteMS ? g_DrawWhite : mode, onlyPhysical);
1647-
}
1648-
1649-
16501589
//////////////////////////////////////////////////////////////////////////////////////////
16511590
// Virtual method: DrawHUD
16521591
//////////////////////////////////////////////////////////////////////////////////////////

Entities/Actor.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,17 +1003,6 @@ ClassInfoGetters;
10031003
void SetAimRange(float range) { m_AimRange = range; }
10041004

10051005

1006-
//////////////////////////////////////////////////////////////////////////////////////////
1007-
// Method: FlashWhite
1008-
//////////////////////////////////////////////////////////////////////////////////////////
1009-
// Description: Tells to make this and all children get drawn as completely white, but
1010-
// only for a specified amount of time.
1011-
// Arguments: For how long to flash the whiteness, in MS.
1012-
// Return value: None.
1013-
1014-
void FlashWhite(int howLongMS = 32) { m_FlashWhiteMS = howLongMS; m_WhiteFlashTimer.Reset(); }
1015-
1016-
10171006
//////////////////////////////////////////////////////////////////////////////////////////
10181007
// Method: DrawWaypoints
10191008
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1063,20 +1052,6 @@ ClassInfoGetters;
10631052

10641053
bool ParticlePenetration(HitData &hd) override;
10651054

1066-
1067-
//////////////////////////////////////////////////////////////////////////////////////////
1068-
// Virtual method: OnMOHit
1069-
//////////////////////////////////////////////////////////////////////////////////////////
1070-
// Description: Defines what should happen when this MovableObject hits another MO.
1071-
// This is called by the owned Atom/AtomGroup of this MovableObject during
1072-
// travel.
1073-
// Arguments: The other MO hit. Ownership is not transferred.
1074-
// Return value: Wheter the MovableObject should immediately halt any travel going on
1075-
// after this hit.
1076-
1077-
bool OnMOHit(MovableObject *pOtherMO) override;
1078-
1079-
10801055
//////////////////////////////////////////////////////////////////////////////////////////
10811056
// Virtual method: PreTravel
10821057
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1212,20 +1187,6 @@ ClassInfoGetters;
12121187

12131188
void SetSightDistance(float newValue) { m_SightDistance = newValue; }
12141189

1215-
//////////////////////////////////////////////////////////////////////////////////////////
1216-
// Virtual method: Draw
1217-
//////////////////////////////////////////////////////////////////////////////////////////
1218-
// Description: Draws this Actor's current graphical representation to a
1219-
// BITMAP of choice.
1220-
// Arguments: A pointer to a BITMAP to draw on.
1221-
// The absolute position of the target bitmap's upper left corner in the Scene.
1222-
// In which mode to draw in. See the DrawMode enumeration for the modes.
1223-
// Whether to not draw any extra 'ghost' items of this MovableObject,
1224-
// indicator arrows or hovering HUD text and so on.
1225-
// Return value: None.
1226-
1227-
void Draw(BITMAP *pTargetBitmap, const Vector &targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override;
1228-
12291190

12301191
//////////////////////////////////////////////////////////////////////////////////////////
12311192
// Virtual method: DrawHUD
@@ -1524,10 +1485,6 @@ ClassInfoGetters;
15241485
HeldDevice *m_pItemInReach;
15251486
// HUD positioning aid
15261487
int m_HUDStack;
1527-
// For how much longer to draw this as white. 0 means don't draw as white
1528-
int m_FlashWhiteMS;
1529-
// The timer that measures and deducts past time from the remaining white flash time
1530-
Timer m_WhiteFlashTimer;
15311488
// ID of deployment which spawned this actor
15321489
unsigned int m_DeploymentID;
15331490
// How many passenger slots this actor will take in a craft

Entities/AtomGroup.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,12 +1465,6 @@ namespace RTE {
14651465
if (!intersectedMO) {
14661466
return false;
14671467
}
1468-
if (m_OwnerMOSR->OnMOHit(intersectedMO)) {
1469-
return false;
1470-
}
1471-
if (intersectedMO->OnMOHit(m_OwnerMOSR->GetRootParent())) {
1472-
return false;
1473-
}
14741468

14751469
std::list<Atom *> intersectingAtoms;
14761470

Entities/HDFirearm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ void HDFirearm::Activate() {
655655

656656
if (!IsReloading()) {
657657
if (m_DeactivationSound && m_DeactivationSound->IsBeingPlayed()) { m_DeactivationSound->FadeOut(); }
658-
if (m_ActiveSound && !m_ActiveSound->IsBeingPlayed()) { m_ActiveSound->Play(this->m_Pos); }
658+
if (m_ActiveSound && !m_ActiveSound->IsBeingPlayed() && (m_ActiveSound->GetLoopSetting() == -1 || !wasActivated)) { m_ActiveSound->Play(this->m_Pos); }
659659
if (m_PreFireSound && !wasActivated && !m_PreFireSound->IsBeingPlayed()) { m_PreFireSound->Play(this->m_Pos); }
660660
}
661661
}

0 commit comments

Comments
 (0)