From ce87d4051b6f25cf0c3fcac60f937b5018828a85 Mon Sep 17 00:00:00 2001 From: MaximDude Date: Mon, 18 May 2020 06:48:02 +0300 Subject: [PATCH] Reworked crab bombing Missed a bracket Changelog entry for MetaGame crash fix and fixing some typos --- CHANGELOG.md | 24 ++++++++++++++++-------- Entities/Actor.cpp | 26 +++++++++++--------------- Entities/MOSprite.cpp | 2 +- Managers/SettingsMan.cpp | 10 ++++++++++ Managers/SettingsMan.h | 20 +++++++++++++++++--- 5 files changed, 55 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b1b8f7ae..68bba75e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,12 +53,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ``` This mode handles exactly like (now removed) `MOSParticle.Framerate = 0` and will complete the sprite's animation cycle over the course of it's existence. `SpriteAnimDuration` is inapplicable when using this mode and will do nothing. For example, an object that has a sprite with 10 frames and a lifetime of 10 seconds will animate at a rate of 1 frame per second, finishing it's animation cycle just before being deleted from the scene. - If this mode is used on an object that has `LifeTime = 0` (infinite) it will be overriden to `SpriteAnimMode = 1` (ALWAYSLOOP) otherwise it will never animate. + If this mode is used on an object that has `LifeTime = 0` (infinite) it will be overridden to `SpriteAnimMode = 1` (ALWAYSLOOP) otherwise it will never animate. ``` SpriteAnimMode = 8 // ONCOLLIDE ``` This mode will drive the animation forward based on collisions this object has with other MOs or the terrain. `SpriteAnimDuration` is inapplicable when using this mode and will do nothing. - This mode is `MOSParticle` specific and used mainly for animating casings. Using this mode on anything other than `MOSParticle` will do nothing. + This mode is `MOSParticle` specific and used mainly for animating casings and small gibs. Using this mode on anything other than `MOSParticle` will do nothing. + +- New `Settings.ini` properties `EnableCrabBombs = 0/1` and `CrabBombThreshold = intValue`. + When `EnableCrabBombs` is enabled, releasing a number of crabs equal to `CrabBombThreshold` or more at once will trigger the crab bomb effect. + If disabled releasing whatever number of crabs will do nothing except release whatever number of crabs. ### Changed @@ -78,9 +82,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), for attachable in ToMOSRotating(self:GetParent()).Attachables do ... end - + ``` Or - + ``` local parent = ToMOSRotating(self:GetParent()); for attachable in parent.Attachables do ... @@ -94,8 +98,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `MOSParticle` animation can now be set with `SpriteAnimMode` and `SpriteAnimDuration`. If the property isn't defined it will default to `SpriteAnimMode = 7` (OVERLIFETIME). +- Reworked crab bombing behavior. When enabled through `Settings.ini` and triggered will gib all living actors on scene except brains and doors. Devices and non-actor MOs will remain untouched. + ### Fixed +- Fix crash when returning to `MetaGame` scenario screen after activity end. + - Control schemes will no longer get deleted when being configured. Resetting the control scheme will load a preset instead of leaving it blank. ([Issue #121](https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/issues/121)) - Fix glow effects being drawn one frame past `EffectStartTime` making objects that exist for a single frame not draw glows. ([Issue #67](https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/issues/67)) @@ -135,7 +143,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Added the concept of `SoundSets`, which are collections of sounds inside a `SoundContainer`. This allows you to, for example, put multiple sounds for a given gunshot inside a `SoundSet` so they're played together. -- `SoundContainers` have been overhauled to allow for a lot more customization, including per-sound customization. The following INI example shows all currently availble capabilities with explanatory comments: +- `SoundContainers` have been overhauled to allow for a lot more customization, including per-sound customization. The following INI example shows all currently available capabilities with explanatory comments: ``` AddSoundContainer = SoundContainer // Note that SoundContainers replace Sounds, so this can be used for things like FireSound = SoundContainer PresetName = Preset Name Here @@ -271,7 +279,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Resolution multiplier properties (`NxWindowed` and `NxFullscreen`) in settings merged into a single property `ResolutionMultiplier`. -- Incompatible/bad resolution settings will be overriden at startup with messages expaining the issue instead of multiple mode switches and eventually a reset to default VGA. +- Incompatible/bad resolution settings will be overridden at startup with messages explaining the issue instead of multiple mode switches and eventually a reset to default VGA. Reset to defaults (now 960x540) will happen only on horrible aspect ratio or if you managed to really destroy something. - You can no longer toggle native fullscreen mode from the settings menu or ini. Instead, either select your desktop resolution at 1X mode or desktop resolution divided by 2 at 2X mode for borderless fullscreen windowed mode. @@ -360,11 +368,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `ACrab.AimRange` can now be split into `AimRangeUpperLimit` and `AimRangeLowerLimit`, allowing asymmetric ranges. -- Objective arrows and Delivery arrows are now color co-ordinated to match their teams, instead of being only green or red. +- Objective arrows and Delivery arrows are now color coordinated to match their teams, instead of being only green or red. - BuyMenu `Bombs` tab will now show all `ThrownDevices` instead of just `TDExplosives`. -- The list of `MOSRotating` attchables (`mosr.Attachables`) now includes hardcoded attachables like dropship engines, legs, etc. +- The list of `MOSRotating` attachables (`mosr.Attachables`) now includes hardcoded attachables like dropship engines, legs, etc. - Attachable lua manipulation has been significantly revamped. The old method of doing `attachable:Attach(parent)` has been replaced with the following: **Addition:** `parent:AddAttachable(attachableToAdd)` or `parent:AddAttachable(attachableToAdd, parentOffsetVector)` diff --git a/Entities/Actor.cpp b/Entities/Actor.cpp index 715bed804..fee8792e5 100644 --- a/Entities/Actor.cpp +++ b/Entities/Actor.cpp @@ -984,21 +984,17 @@ void Actor::GibThis(Vector impactImpulse, float internalBlast, MovableObject *pI // Gib all the regular gibs MOSRotating::GibThis(impactImpulse, internalBlast, pIgnoreMO); - // Count crabs to simulate crab-bomb behavior - int crabs = 0; - for (deque::iterator gItr = m_Inventory.begin(); gItr != m_Inventory.end(); ++gItr) - if (dynamic_cast(*gItr) && (*gItr)->GetPresetName() == "Crab") - crabs++; - - // If we have enough crabs - gib everything - if (crabs > 10 && g_MovableMan.GetMOIDCount() + crabs * 5 > 255) - { - for (int id = 1; id < g_MovableMan.GetMOIDCount() - 1; id++) - { - MovableObject * MO = g_MovableMan.GetMOFromID(id); - MOSRotating * MOSR = dynamic_cast(MO); - if (MOSR && MOSR != this) - MOSR->GibThis(); + if (g_SettingsMan.EnableCrabBombs()) { + unsigned short crabCount = 0; + for (const MovableObject *inventoryEntry : m_Inventory) { + if (inventoryEntry->GetPresetName() == "Crab") { crabCount++; } + } + // If we have enough crabs gib all actors on scene except brains and doors + if (crabCount >= g_SettingsMan.CrabBombThreshold()) { + for (int moid = 1; moid < g_MovableMan.GetMOIDCount() - 1; moid++) { + Actor *actor = dynamic_cast(g_MovableMan.GetMOFromID(moid)); + if (actor && actor != this && actor->GetClassName() != "ADoor" && !actor->IsInGroup("Brains")) { actor->GibThis(); } + } } } diff --git a/Entities/MOSprite.cpp b/Entities/MOSprite.cpp index efa064ee6..ca348c3e1 100644 --- a/Entities/MOSprite.cpp +++ b/Entities/MOSprite.cpp @@ -501,7 +501,7 @@ void MOSprite::Update() { m_SpriteAnimTimer.Reset(); break; case OVERLIFETIME: - lifeTimeFrame = static_cast(m_FrameCount) * m_AgeTimer.GetElapsedSimTimeMS() / static_cast(m_Lifetime)); + lifeTimeFrame = static_cast(m_FrameCount) * (m_AgeTimer.GetElapsedSimTimeMS() / static_cast(m_Lifetime)); m_Frame = std::floorf(lifeTimeFrame); break; default: diff --git a/Managers/SettingsMan.cpp b/Managers/SettingsMan.cpp index e9e0d7e9a..62e365041 100644 --- a/Managers/SettingsMan.cpp +++ b/Managers/SettingsMan.cpp @@ -29,6 +29,8 @@ namespace RTE { m_BlipOnRevealUnseen = true; m_EndlessMode = false; m_EnableHats = false; + m_EnableCrabBombs = false; + m_CrabBombThreshold = 42; m_NetworkServerAddress = "127.0.0.1:8000"; m_PlayerNetworkName = "Dummy"; @@ -136,6 +138,10 @@ namespace RTE { reader >> m_EndlessMode; } else if (propName == "EnableHats") { reader >> m_EnableHats; + } else if (propName == "EnableCrabBombs") { + reader >> m_EnableCrabBombs; + } else if (propName == "CrabBombThreshold") { + reader >> m_CrabBombThreshold; } else if (propName == "LaunchIntoActivity") { reader >> m_LaunchIntoActivity; } else if (propName == "DefaultActivityType") { @@ -299,6 +305,10 @@ namespace RTE { writer << m_EndlessMode; writer.NewProperty("EnableHats"); writer << m_EnableHats; + writer.NewProperty("EnableCrabBombs"); + writer << m_EnableCrabBombs; + writer.NewProperty("CrabBombThreshold"); + writer << m_CrabBombThreshold; writer.NewLine(false, 2); writer.NewDivider(false); diff --git a/Managers/SettingsMan.h b/Managers/SettingsMan.h index a086d8622..10d25a01f 100644 --- a/Managers/SettingsMan.h +++ b/Managers/SettingsMan.h @@ -162,10 +162,22 @@ namespace RTE { void SetShowForeignItems(bool newValue) { m_ShowForeignItems = newValue; } /// - /// Whether random hats on actors are enabled or not. + /// Whether randomized hat attachables will be attached to all AHuman actors. /// /// Whether random hats are enabled or not. bool EnableHats() const { return m_EnableHats; } + + /// + /// Gets whether the crab bomb effect is enabled or not. False means releasing whatever number of crabs will do nothing except release a whatever number of crabs. + /// + /// Whether the crab bomb effect is enabled or not. + bool EnableCrabBombs() const { return m_EnableCrabBombs; } + + /// + /// Gets the number of crabs needed to be released at once to trigger the crab bomb effect. + /// + /// The number of crabs needed to be released at once to trigger the crab bomb effect. + unsigned short CrabBombThreshold() const { return m_CrabBombThreshold; } #pragma endregion #pragma region Default Activity Settings @@ -475,8 +487,10 @@ namespace RTE { bool m_ShowForeignItems; //!< Do not show foreign items in buy menu. bool m_FlashOnBrainDamage; //!< Whether red flashes on brain damage are on or off. bool m_BlipOnRevealUnseen; //!< Blip if unseen is revealed. - bool m_EndlessMode; //!< Endless metagame mode. - bool m_EnableHats; //!< Hats enabled. + bool m_EndlessMode; //!< Endless MetaGame mode. + bool m_EnableHats; //!< Whether randomized hat attachables will be attached to all AHuman actors. + bool m_EnableCrabBombs; //!< Whether all actors (except Brains and Doors) should be annihilated if a number exceeding the crab bomb threshold is released at once. + unsigned short m_CrabBombThreshold; //!< The number of crabs needed to be released at once to trigger the crab bomb effect. std::string m_PlayerNetworkName; //!< Player name used in network multiplayer matches. std::string m_NetworkServerAddress; //!< LAN server address to connect to.