Skip to content

Commit

Permalink
Reworked crab bombing
Browse files Browse the repository at this point in the history
Missed a bracket
Changelog entry for MetaGame crash fix and fixing some typos
  • Loading branch information
MaximDude committed May 18, 2020
1 parent 99a5146 commit ce87d40
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 27 deletions.
24 changes: 16 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
...
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)`
Expand Down
26 changes: 11 additions & 15 deletions Entities/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MovableObject *>::iterator gItr = m_Inventory.begin(); gItr != m_Inventory.end(); ++gItr)
if (dynamic_cast<ACrab *>(*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<MOSRotating *>(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<Actor *>(g_MovableMan.GetMOFromID(moid));
if (actor && actor != this && actor->GetClassName() != "ADoor" && !actor->IsInGroup("Brains")) { actor->GibThis(); }
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Entities/MOSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void MOSprite::Update() {
m_SpriteAnimTimer.Reset();
break;
case OVERLIFETIME:
lifeTimeFrame = static_cast<double>(m_FrameCount) * m_AgeTimer.GetElapsedSimTimeMS() / static_cast<double>(m_Lifetime));
lifeTimeFrame = static_cast<double>(m_FrameCount) * (m_AgeTimer.GetElapsedSimTimeMS() / static_cast<double>(m_Lifetime));
m_Frame = std::floorf(lifeTimeFrame);
break;
default:
Expand Down
10 changes: 10 additions & 0 deletions Managers/SettingsMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 17 additions & 3 deletions Managers/SettingsMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,22 @@ namespace RTE {
void SetShowForeignItems(bool newValue) { m_ShowForeignItems = newValue; }

/// <summary>
/// Whether random hats on actors are enabled or not.
/// Whether randomized hat attachables will be attached to all AHuman actors.
/// </summary>
/// <returns>Whether random hats are enabled or not.</returns>
bool EnableHats() const { return m_EnableHats; }

/// <summary>
/// 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.
/// </summary>
/// <returns>Whether the crab bomb effect is enabled or not.</returns>
bool EnableCrabBombs() const { return m_EnableCrabBombs; }

/// <summary>
/// Gets the number of crabs needed to be released at once to trigger the crab bomb effect.
/// </summary>
/// <returns>The number of crabs needed to be released at once to trigger the crab bomb effect.</returns>
unsigned short CrabBombThreshold() const { return m_CrabBombThreshold; }
#pragma endregion

#pragma region Default Activity Settings
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ce87d40

Please sign in to comment.