Skip to content

Commit

Permalink
miners: Every miner built will increase the momentum floor.
Browse files Browse the repository at this point in the history
This means you will automatically be bumped to that momentum and cannot fall below it unless the miner is destroyed.
  • Loading branch information
DolceTriade committed Sep 18, 2022
1 parent 188f68a commit cfe3ed3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion daemon
Submodule daemon updated 1 files
+1 −1 cmake/DaemonCBSE.cmake
17 changes: 17 additions & 0 deletions src/sgame/sg_momentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.

#include "sg_local.h"
#include "Entities.h"
#include "CBSE.h"

// -----------
// definitions
Expand Down Expand Up @@ -332,9 +333,25 @@ void G_DecreaseMomentum()
// decrease momentum
for ( team = TEAM_NONE + 1; team < NUM_TEAMS; team++ )
{
float momentumFloor = 0.0f;
if ( g_maxMiners.Get() > 0 )
{
// TODO: Cache this in level_t.
int miners = 0;
ForEntities<MiningComponent> ( [&](Entity& entity, MiningComponent& miner)
{
if ( Entities::IsAlive(entity) && miner.Active() && G_Team( entity.oldEnt ) == team )
{
miners++;
}
});
// OM/RC counts as a miner, so don't count that...
momentumFloor = MOMENTUM_MAX * ( static_cast<float>( miners ) / g_maxMiners.Get() );
}
amount = level.team[ team ].momentum * ( decreaseFactor - 1.0f );

level.team[ team ].momentum += amount;
level.team[ team ].momentum = Math::Clamp( level.team[ team ].momentum, momentumFloor, MOMENTUM_MAX );

// notify legacy stage sensors
NotifyLegacyStageSensors( (team_t) team, amount );
Expand Down

0 comments on commit cfe3ed3

Please sign in to comment.