Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class DynamicGeometryClientUpdate : public ClientUpdateModule
UnsignedInt m_startFrame;
Real m_overrideScale;
Real m_overrideAlpha;

Real m_prevScale;
};

#endif // __DynamicGeometryClientUpdate_H_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class LifetimeUpdateModuleData : public UpdateModuleData
public:
UnsignedInt m_minFrames;
UnsignedInt m_maxFrames;
Bool m_showProgressBar;

LifetimeUpdateModuleData()
{
Expand All @@ -55,6 +56,7 @@ class LifetimeUpdateModuleData : public UpdateModuleData
{
{ "MinLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( LifetimeUpdateModuleData, m_minFrames ) },
{ "MaxLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( LifetimeUpdateModuleData, m_maxFrames ) },
{ "ShowProgressBar", INI::parseBool, NULL, offsetof( LifetimeUpdateModuleData, m_showProgressBar ) },
{ 0, 0, 0, 0 }
};
p.add(dataFieldParse);
Expand All @@ -80,11 +82,15 @@ class LifetimeUpdate : public UpdateModule

virtual UpdateSleepTime update( void );

Real getProgress();
inline Bool showProgressBar(void) const { return getLifetimeUpdateModuleData()->m_showProgressBar; }

private:

UnsignedInt calcSleepDelay(UnsignedInt minFrames, UnsignedInt maxFrames);

UnsignedInt m_dieFrame;
UnsignedInt m_startDieFrame; ///< for progress bar; When the countdown starts
};

#endif // __LIFETIMEUPDATE_H_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class OCLSpecialPowerModuleData : public SpecialPowerModuleData
OCLCreateLocType m_createLoc;
Bool m_isOCLAdjustPositionToPassable; ///< Adjust target to nearest Passable cell

Bool m_selectObject; ///< Select first created object

//We need to know what the final product is going to be for script placement calculations
//for construction sites like the sneak attack.
AsciiString m_referenceThingName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "GameLogic/Module/UpdateModule.h"
#include "GameLogic/Object.h"
#include "GameLogic/Weapon.h"
#include "GameLogic/Module/DieModule.h"

class FXList;
enum DeathType;
Expand All @@ -51,6 +52,8 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
Bool m_preferSimilarTargets;
Bool m_preferNearestTargets;
Real m_noTargetsScatterRadius;
Real m_noTargetsScatterMinRadius;
Real m_noTargetsScatterMaxAngle;
Bool m_attackGroundWhenNoTargets;

Real m_triggerDistanceToTarget;
Expand All @@ -61,6 +64,8 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
Bool m_triggerInstantly;

Bool m_stayAliveAfterTrigger;
Bool m_avoidOriginalTarget;
Bool m_avoidPrevTarget;

DeathType m_triggerDeathType;
const FXList* m_scatterFX;
Expand All @@ -76,7 +81,7 @@ class ScatterShotUpdateModuleData : public UpdateModuleData

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
class ScatterShotUpdate : public UpdateModule
class ScatterShotUpdate : public UpdateModule, public DieModuleInterface
{

MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ScatterShotUpdate, "ScatterShotUpdate")
Expand All @@ -89,6 +94,13 @@ class ScatterShotUpdate : public UpdateModule

virtual UpdateSleepTime update();

static Int getInterfaceMask() { return MODULEINTERFACE_DIE; }

// BehaviorModule
virtual DieModuleInterface* getDie() { return this; }

void onDie(const DamageInfo* damageInfo);

protected:

Weapon* m_weapon;
Expand All @@ -98,6 +110,7 @@ class ScatterShotUpdate : public UpdateModule

Coord3D m_goalPos;
Object* m_goalObj;
ObjectID m_prevTargetID; //< target of previous attack. only used for special case when chaining multiple targets

Real m_totalTargetDistance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ DynamicGeometryClientUpdate::DynamicGeometryClientUpdate( Thing *thing, const Mo
m_startFrame = TheGameLogic->getFrame();
m_overrideScale = 1.0;
m_overrideAlpha = 1.0;
m_prevScale = 1.0;
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -194,8 +195,16 @@ void DynamicGeometryClientUpdate::clientUpdate( void )
Real alpha = (1.0 - progress) * alpha0 + progress * alpha1;
Real scale = (1.0 - progress) * scale0 + progress * scale1;

Real newScale = m_overrideScale * scale;

draw->setInstanceScale(m_overrideScale * scale);
Real currentScale = draw->getInstanceScale();
if (m_prevScale != 1.0) {
currentScale = currentScale / MAX(0.001, m_prevScale);
}

draw->setInstanceScale(currentScale * newScale);

m_prevScale = newScale;

// This doesn't work for additive!
draw->setDrawableOpacity(m_overrideAlpha * alpha);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ UpdateSleepTime DumbProjectileBehavior::update()
return UPDATE_SLEEP_NONE;
}

if( m_currentFlightPathStep >= m_flightPath.size() )
if( m_currentFlightPathStep >= m_flightPath.size() || m_flightPath.size() == 1)
{
// No more steps to use. Would go out of bounds on vector, so have to do something.
// We could allow physics to take over and make us fall, but the point of this whole task
Expand Down
12 changes: 11 additions & 1 deletion GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include "GameLogic/Module/DestroyModule.h"
#include "GameLogic/Module/DieModule.h"
#include "GameLogic/Module/DozerAIUpdate.h"
#include "GameLogic/Module/LifeTimeUpdate.h"
#include "GameLogic/Module/ObjectDefectionHelper.h"
#include "GameLogic/Module/ObjectRepulsorHelper.h"
#include "GameLogic/Module/ObjectSMCHelper.h"
Expand Down Expand Up @@ -1515,7 +1516,7 @@ Bool Object::getProgressBarShowingInfo(bool selected, Real& progress, Int& type,

type = 0; // TODO
color = { 255, 255, 255, 255 }; // Default = white
colorBG = { 255, 255, 255, 255 }; // Default = white
colorBG = { 0, 0, 0, 255 }; // Default = black

// Energy Shields
// TODO: This is kinda bad, there should be a better way to do this, if we have multiple shield sources.
Expand All @@ -1532,6 +1533,15 @@ Bool Object::getProgressBarShowingInfo(bool selected, Real& progress, Int& type,
return true;
}
}
else if ((*u)->getModuleNameKey() == NAMEKEY("LifetimeUpdate")) {
LifetimeUpdate* ltu = (LifetimeUpdate*)(*u);
if (ltu->showProgressBar()) {
// always show healthbar or when selected?
progress = 1.0 - ltu->getProgress();
return true;
}
}

}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "GameLogic/PartitionManager.h"
#include "GameLogic/TerrainLogic.h"
#include "GameLogic/Module/OCLSpecialPower.h"
#include <Common/MessageStream.h>
#include <GameClient/InGameUI.h>

///////////////////////////////////////////////////////////////////////////////////////////////////
// MODULE DATA ////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -98,6 +100,7 @@ static void parseOCLUpgradePair( INI* ini, void * /*instance*/, void *store, con
{ "CreateLocation", INI::parseIndexList, TheOCLCreateLocTypeNames, offsetof( OCLSpecialPowerModuleData, m_createLoc ) },
{ "ReferenceObject", INI::parseAsciiString, NULL, offsetof( OCLSpecialPowerModuleData, m_referenceThingName ) },
{ "OCLAdjustPositionToPassable", INI::parseBool, NULL, offsetof( OCLSpecialPowerModuleData, m_isOCLAdjustPositionToPassable ) },
{ "SelectCreatedObject", INI::parseBool, NULL, offsetof( OCLSpecialPowerModuleData, m_selectObject ) },
{ 0, 0, 0, 0 }
};
p.add(dataFieldParse);
Expand Down Expand Up @@ -185,37 +188,53 @@ void OCLSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle,

// at what point will the "deliverer" come in
Coord3D creationCoord;

Object* createdObject = NULL;

switch (modData->m_createLoc)
{
case CREATE_AT_EDGE_NEAR_SOURCE:
creationCoord = TheTerrainLogic->findClosestEdgePoint( getObject()->getPosition() );
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
break;
case CREATE_AT_EDGE_NEAR_TARGET:
creationCoord = TheTerrainLogic->findClosestEdgePoint(&targetCoord);
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
break;
case CREATE_AT_EDGE_FARTHEST_FROM_TARGET:
creationCoord = TheTerrainLogic->findFarthestEdgePoint(&targetCoord);
creationCoord.z += CREATE_ABOVE_LOCATION_HEIGHT;
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
break;
case CREATE_AT_LOCATION:
// this is the case where the special power stuff originates at the location of the mouse click
creationCoord = targetCoord;
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
break;
case USE_OWNER_OBJECT:
creationCoord.set( &targetCoord );
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle, false );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle, false );
break;
case CREATE_ABOVE_LOCATION:
// this is the case where the special power stuff originates above the location of the mouse click
creationCoord = targetCoord;
creationCoord.z += CREATE_ABOVE_LOCATION_HEIGHT;
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
break;
}

if (createdObject != NULL && modData->m_selectObject && createdObject->isLocallyControlled()) {
Drawable* draw = createdObject->getDrawable();
if (draw)
{
//Create the selection message
GameMessage* teamMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP);
teamMsg->appendBooleanArgument(TRUE);// we are creating a new team so pass true
teamMsg->appendObjectIDArgument(createdObject->getID());
TheInGameUI->selectDrawable(draw);
TheInGameUI->setDisplayedMaxWarning(FALSE);
}
}
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -244,7 +263,21 @@ void OCLSpecialPower::doSpecialPower( UnsignedInt commandOptions )
SpecialPowerModule::doSpecialPowerAtLocation( &creationCoord, INVALID_ANGLE, commandOptions );

const ObjectCreationList* ocl = findOCL();
ObjectCreationList::create( ocl, getObject(), &creationCoord, &creationCoord, false );
Object* createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &creationCoord, false );

if (createdObject != NULL && getOCLSpecialPowerModuleData()->m_selectObject
&& createdObject->isLocallyControlled()) {
Drawable* draw = createdObject->getDrawable();
if (draw)
{
//Create the selection message
GameMessage* teamMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP);
teamMsg->appendBooleanArgument(TRUE);// we are creating a new team so pass true
teamMsg->appendObjectIDArgument(createdObject->getID());
TheInGameUI->selectDrawable(draw);
TheInGameUI->setDisplayedMaxWarning(FALSE);
}
}
}

// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ LifetimeUpdate::LifetimeUpdate( Thing *thing, const ModuleData* moduleData ) : U
// Added By Sadullah Nader
// Initializations needed
m_dieFrame = 0;
m_startDieFrame = 0;
//
UnsignedInt delay;
if( getObject()->isKindOf( KINDOF_HULK ) && TheGameLogic->getHulkMaxLifetimeOverride() != -1 )
Expand Down Expand Up @@ -88,10 +89,19 @@ UnsignedInt LifetimeUpdate::calcSleepDelay(UnsignedInt minFrames, UnsignedInt ma
{
UnsignedInt delay = GameLogicRandomValue( minFrames, maxFrames );
if (delay < 1) delay = 1;
m_dieFrame = TheGameLogic->getFrame() + delay;
m_startDieFrame = TheGameLogic->getFrame();
m_dieFrame = m_startDieFrame + delay;
return delay;
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
Real LifetimeUpdate::getProgress(void) {
if (m_dieFrame > 0 && m_startDieFrame > 0) {
return INT_TO_REAL(TheGameLogic->getFrame() - m_startDieFrame) / INT_TO_REAL(m_dieFrame - m_startDieFrame);
}
return 0.0f;
}
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
UpdateSleepTime LifetimeUpdate::update( void )
Expand Down Expand Up @@ -131,6 +141,9 @@ void LifetimeUpdate::xfer( Xfer *xfer )
// die frame
xfer->xferUnsignedInt( &m_dieFrame );

// start die frame
xfer->xferUnsignedInt( &m_startDieFrame);

} // end xfer

// ------------------------------------------------------------------------------------------------
Expand Down
Loading