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

Commit d9dd256

Browse files
committed
Merge branch 'pre4-testing' into 4zk-content-source
2 parents a121a27 + e69ff9e commit d9dd256

File tree

8 files changed

+44
-38
lines changed

8 files changed

+44
-38
lines changed

CHANGELOG.md

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

253253
- New `AHuman` and `ACrab` INI and Lua (R/W) property `JetReplenishRate`, which determines how fast jump time (i.e. jetpack fuel) is replenished during downtime.
254254

255+
- Added `Entity` Lua function `entity:RemoveFromGroup(groupToRemoveFrom)` which removes the given group from the `Entity`. The reverse of `AddToGroup`.
256+
255257
</details>
256258

257259
<details><summary><b>Changed</b></summary>

Entities/AHuman.cpp

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,8 +3868,10 @@ void AHuman::Update()
38683868
m_pBGArm->ReachToward(m_pBGHandGroup->GetLimbPos(m_HFlipped));
38693869

38703870
} else {
3871-
if (m_pFGArm && m_pFGArm->HoldsHeldDevice() && !m_pBGArm->HoldsHeldDevice()) {
3872-
if (!EquipShieldInBGArm()) {
3871+
if (HeldDevice * heldDevice = dynamic_cast<HeldDevice *>(GetEquippedItem())) {
3872+
if (GetEquippedBGItem() && !heldDevice->IsOneHanded()) {
3873+
UnequipBGArm();
3874+
} else {
38733875
m_pBGArm->Reach(m_pFGArm->GetHeldDevice()->GetSupportPos());
38743876
if (m_pBGArm->DidReach()) {
38753877
m_pFGArm->GetHeldDevice()->SetSupported(true);
@@ -4300,44 +4302,39 @@ void AHuman::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whichSc
43004302

43014303
m_HUDStack -= 10;
43024304
if (m_pFGArm && !m_EquipHUDTimer.IsPastRealMS(500)) {
4303-
if (m_pFGArm->HoldsSomething()) {
4304-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, m_pFGArm->GetHeldMO()->GetPresetName().c_str(), GUIFont::Centre);
4305-
} else {
4306-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, "EMPTY", GUIFont::Centre);
4307-
}
4305+
std::string equippedItemsString = (m_pFGArm->HoldsSomething() ? m_pFGArm->GetHeldMO()->GetPresetName() : "EMPTY") + (m_pBGArm->HoldsSomething() ? " | " + m_pBGArm->GetHeldMO()->GetPresetName() : "");
4306+
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, equippedItemsString, GUIFont::Centre);
43084307
m_HUDStack -= 9;
43094308
}
43104309
}
43114310
// Held-related GUI stuff
4312-
else if (m_pFGArm) {
4313-
HDFirearm *pHeldFirearm = dynamic_cast<HDFirearm *>(m_pFGArm->GetHeldDevice());
4314-
4315-
// Ammo
4316-
if (pHeldFirearm)
4317-
{
4318-
MovableObject *bgHeldItem = GetEquippedBGItem();
4319-
HDFirearm const *bgHeldFirearm = bgHeldItem == NULL ? NULL : dynamic_cast<HDFirearm *>(bgHeldItem);
4311+
else if (m_pFGArm || m_pBGArm) {
4312+
HDFirearm *fgHeldFirearm = dynamic_cast<HDFirearm *>(m_pFGArm->GetHeldDevice());
4313+
MovableObject *bgHeldItem = GetEquippedBGItem();
4314+
const HDFirearm *bgHeldFirearm = dynamic_cast<HDFirearm *>(bgHeldItem);
43204315

4316+
if (fgHeldFirearm || bgHeldFirearm) {
43214317
str[0] = -56; str[1] = 0;
4322-
pSymbolFont->DrawAligned(&allegroBitmap, drawPos.m_X - 10, drawPos.m_Y + m_HUDStack, str, GUIFont::Left);
4323-
std::string fgWeaponString;
4324-
4325-
if (pHeldFirearm->IsReloading()) {
4326-
fgWeaponString = "Reloading";
4327-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4328-
rectfill(pTargetBitmap, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * pHeldFirearm->GetReloadProgress() + 0.5F), drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4329-
} else {
4330-
fgWeaponString = pHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(pHeldFirearm->GetRoundInMagCount());
4318+
pSymbolFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() - 10, drawPos.GetFloorIntY() + m_HUDStack, str, GUIFont::Left);
4319+
4320+
std::string fgWeaponString = "EMPTY";
4321+
if (fgHeldFirearm) {
4322+
if (fgHeldFirearm->IsReloading()) {
4323+
fgWeaponString = "Reloading";
4324+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4325+
rectfill(pTargetBitmap, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * fgHeldFirearm->GetReloadProgress() + 0.5F), drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4326+
} else {
4327+
fgWeaponString = fgHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(fgHeldFirearm->GetRoundInMagCount());
4328+
}
43314329
}
43324330

43334331
if (bgHeldItem && bgHeldFirearm) {
43344332
std::string bgWeaponString;
4335-
43364333
if (bgHeldFirearm->IsReloading()) {
43374334
bgWeaponString = "Reloading";
4338-
int textWidth = pSmallFont->CalculateWidth(fgWeaponString) + 6;
4339-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1 + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29 + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4340-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * bgHeldFirearm->GetReloadProgress() + 0.5F) + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4335+
int totalTextWidth = pSmallFont->CalculateWidth(fgWeaponString) + 6;
4336+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1 + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29 + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4337+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * bgHeldFirearm->GetReloadProgress() + 0.5F) + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
43414338
} else {
43424339
bgWeaponString = bgHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(bgHeldFirearm->GetRoundInMagCount());
43434340
}
@@ -4363,11 +4360,8 @@ void AHuman::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whichSc
43634360
m_HUDStack -= 11;
43644361
}
43654362
*/
4366-
if (m_pFGArm->HoldsSomething()) {
4367-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, m_pFGArm->GetHeldMO()->GetPresetName().c_str(), GUIFont::Centre);
4368-
} else {
4369-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, "EMPTY", GUIFont::Centre);
4370-
}
4363+
std::string equippedItemsString = (m_pFGArm->HoldsSomething() ? m_pFGArm->GetHeldMO()->GetPresetName() : "EMPTY") + (m_pBGArm->HoldsSomething() ? " | " + m_pBGArm->GetHeldMO()->GetPresetName() : "");
4364+
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, equippedItemsString, GUIFont::Centre);
43714365
m_HUDStack -= 9;
43724366
/*
43734367
// Reload GUI, only show when there's nothing to pick up

Entities/AHuman.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ ClassInfoGetters;
373373

374374
void SetJetTimeLeft(float newValue) { m_JetTimeLeft = newValue < m_JetTimeTotal ? newValue : m_JetTimeTotal; }
375375

376-
377376
/// <summary>
378377
/// Gets the rate at which this AHuman's jetpack is replenished during downtime.
379378
/// </summary>
@@ -394,7 +393,6 @@ ClassInfoGetters;
394393
/// <returns>The ratio at which this jetpack follows the aim angle of the user.</returns>
395394
float GetJetAngleRange() const { return m_JetAngleRange; }
396395

397-
398396
/// <summary>
399397
/// Sets the scalar ratio at which this jetpack's thrust angle follows the aim angle of the user.
400398
/// </summary>

Entities/Actor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,8 @@ void Actor::VerifyMOIDs()
13711371

13721372
void Actor::Update()
13731373
{
1374-
// Update the controller!
1374+
//TODO This should be after MOSRotating::Update call. It's here because this lets Attachable scripts affect their parent's control states, but this is a bad, hacky solution.
1375+
//See https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/commit/ea20b6d790cd4cbb41eb923057b3db9982f6545d
13751376
m_Controller.Update();
13761377

13771378
/////////////////////////////////

Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace RTE {
2222
.def("Reset", &Entity::Reset)
2323
.def("GetModuleAndPresetName", &Entity::GetModuleAndPresetName)
2424
.def("AddToGroup", &Entity::AddToGroup)
25+
.def("RemoveFromGroup", &Entity::RemoveFromGroup)
2526
.def("IsInGroup", &Entity::IsInGroup);
2627
}
2728

Menus/InventoryMenuGUI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,10 @@ namespace RTE {
11631163
if (buttonEquippedItemIndex > -1) {
11641164
Arm *selectedItemArm = dynamic_cast<Arm *>(m_GUISelectedItem->Object->GetParent());
11651165
Arm *buttonObjectArm = selectedItemArm && buttonObject ? dynamic_cast<Arm *>(buttonObject->GetParent()) : nullptr;
1166+
if (!buttonObject) {
1167+
const AHuman *inventoryActorAsAHuman = dynamic_cast<const AHuman *>(m_InventoryActor);
1168+
buttonObjectArm = buttonEquippedItemIndex == 0 ? inventoryActorAsAHuman->GetFGArm() : inventoryActorAsAHuman->GetBGArm();
1169+
}
11661170
if (selectedItemArm && buttonObjectArm) {
11671171
selectedItemArm->ReleaseHeldMO();
11681172
buttonObjectArm->ReleaseHeldMO();

System/Controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace RTE {
162162
}
163163

164164
// Update the AI state of the Actor we're controlling and to use any scripted AI defined for this Actor.
165-
if (m_ControlledActor && !m_ControlledActor->UpdateAIScripted()) {
165+
if (m_ControlledActor && m_ControlledActor->ObjectScriptsInitialized() && !m_ControlledActor->UpdateAIScripted()) {
166166
// If we can't, fall back on the legacy C++ implementation
167167
m_ControlledActor->UpdateAI();
168168
}

System/Entity.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,13 @@ namespace RTE {
382382
/// Adds this Entity to a new grouping.
383383
/// </summary>
384384
/// <param name="newGroup">A string which describes the group to add this to. Duplicates will be ignored.</param>
385-
void AddToGroup(std::string newGroup) { m_Groups.push_back(newGroup); m_Groups.sort(); m_Groups.unique(); m_LastGroupSearch.clear(); }
385+
void AddToGroup(const std::string &newGroup) { m_Groups.push_back(newGroup); m_Groups.sort(); m_Groups.unique(); m_LastGroupSearch.clear(); }
386+
387+
/// <summary>
388+
/// Removes this Entity from the specified grouping.
389+
/// </summary>
390+
/// <param name="groupToRemoveFrom">A string which describes the group to remove this from.</param>
391+
void RemoveFromGroup(const std::string &groupToRemoveFrom) { m_Groups.remove(groupToRemoveFrom); m_LastGroupSearch.clear(); }
386392

387393
/// <summary>
388394
/// Returns random weight used in PresetMan::GetRandomBuyableOfGroupFromTech.

0 commit comments

Comments
 (0)