Skip to content

Commit 059e602

Browse files
authored
Merge pull request #51 from Andreas-W/misc_updates3
Misc updates3
2 parents e5a7b69 + 287621d commit 059e602

File tree

12 files changed

+205
-28
lines changed

12 files changed

+205
-28
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/Module/DynamicGeometryClientUpdate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class DynamicGeometryClientUpdate : public ClientUpdateModule
8383
UnsignedInt m_startFrame;
8484
Real m_overrideScale;
8585
Real m_overrideAlpha;
86+
87+
Real m_prevScale;
8688
};
8789

8890
#endif // __DynamicGeometryClientUpdate_H_

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/LifetimeUpdate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class LifetimeUpdateModuleData : public UpdateModuleData
4141
public:
4242
UnsignedInt m_minFrames;
4343
UnsignedInt m_maxFrames;
44+
Bool m_showProgressBar;
4445

4546
LifetimeUpdateModuleData()
4647
{
@@ -55,6 +56,7 @@ class LifetimeUpdateModuleData : public UpdateModuleData
5556
{
5657
{ "MinLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( LifetimeUpdateModuleData, m_minFrames ) },
5758
{ "MaxLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( LifetimeUpdateModuleData, m_maxFrames ) },
59+
{ "ShowProgressBar", INI::parseBool, NULL, offsetof( LifetimeUpdateModuleData, m_showProgressBar ) },
5860
{ 0, 0, 0, 0 }
5961
};
6062
p.add(dataFieldParse);
@@ -80,11 +82,15 @@ class LifetimeUpdate : public UpdateModule
8082

8183
virtual UpdateSleepTime update( void );
8284

85+
Real getProgress();
86+
inline Bool showProgressBar(void) const { return getLifetimeUpdateModuleData()->m_showProgressBar; }
87+
8388
private:
8489

8590
UnsignedInt calcSleepDelay(UnsignedInt minFrames, UnsignedInt maxFrames);
8691

8792
UnsignedInt m_dieFrame;
93+
UnsignedInt m_startDieFrame; ///< for progress bar; When the countdown starts
8894
};
8995

9096
#endif // __LIFETIMEUPDATE_H_

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/OCLSpecialPower.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class OCLSpecialPowerModuleData : public SpecialPowerModuleData
7171
OCLCreateLocType m_createLoc;
7272
Bool m_isOCLAdjustPositionToPassable; ///< Adjust target to nearest Passable cell
7373

74+
Bool m_selectObject; ///< Select first created object
75+
7476
//We need to know what the final product is going to be for script placement calculations
7577
//for construction sites like the sneak attack.
7678
AsciiString m_referenceThingName;

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ScatterShotUpdate.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "GameLogic/Module/UpdateModule.h"
3636
#include "GameLogic/Object.h"
3737
#include "GameLogic/Weapon.h"
38+
#include "GameLogic/Module/DieModule.h"
3839

3940
class FXList;
4041
enum DeathType;
@@ -51,6 +52,8 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
5152
Bool m_preferSimilarTargets;
5253
Bool m_preferNearestTargets;
5354
Real m_noTargetsScatterRadius;
55+
Real m_noTargetsScatterMinRadius;
56+
Real m_noTargetsScatterMaxAngle;
5457
Bool m_attackGroundWhenNoTargets;
5558

5659
Real m_triggerDistanceToTarget;
@@ -61,6 +64,8 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
6164
Bool m_triggerInstantly;
6265

6366
Bool m_stayAliveAfterTrigger;
67+
Bool m_avoidOriginalTarget;
68+
Bool m_avoidPrevTarget;
6469

6570
DeathType m_triggerDeathType;
6671
const FXList* m_scatterFX;
@@ -76,7 +81,7 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
7681

7782
//-------------------------------------------------------------------------------------------------
7883
//-------------------------------------------------------------------------------------------------
79-
class ScatterShotUpdate : public UpdateModule
84+
class ScatterShotUpdate : public UpdateModule, public DieModuleInterface
8085
{
8186

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

9095
virtual UpdateSleepTime update();
9196

97+
static Int getInterfaceMask() { return MODULEINTERFACE_DIE; }
98+
99+
// BehaviorModule
100+
virtual DieModuleInterface* getDie() { return this; }
101+
102+
void onDie(const DamageInfo* damageInfo);
103+
92104
protected:
93105

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

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

102115
Real m_totalTargetDistance;
103116

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable/Update/DynamicGeometryClientUpdate.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ DynamicGeometryClientUpdate::DynamicGeometryClientUpdate( Thing *thing, const Mo
142142
m_startFrame = TheGameLogic->getFrame();
143143
m_overrideScale = 1.0;
144144
m_overrideAlpha = 1.0;
145+
m_prevScale = 1.0;
145146
}
146147

147148
//-------------------------------------------------------------------------------------------------
@@ -194,8 +195,16 @@ void DynamicGeometryClientUpdate::clientUpdate( void )
194195
Real alpha = (1.0 - progress) * alpha0 + progress * alpha1;
195196
Real scale = (1.0 - progress) * scale0 + progress * scale1;
196197

198+
Real newScale = m_overrideScale * scale;
197199

198-
draw->setInstanceScale(m_overrideScale * scale);
200+
Real currentScale = draw->getInstanceScale();
201+
if (m_prevScale != 1.0) {
202+
currentScale = currentScale / MAX(0.001, m_prevScale);
203+
}
204+
205+
draw->setInstanceScale(currentScale * newScale);
206+
207+
m_prevScale = newScale;
199208

200209
// This doesn't work for additive!
201210
draw->setDrawableOpacity(m_overrideAlpha * alpha);

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ UpdateSleepTime DumbProjectileBehavior::update()
591591
return UPDATE_SLEEP_NONE;
592592
}
593593

594-
if( m_currentFlightPathStep >= m_flightPath.size() )
594+
if( m_currentFlightPathStep >= m_flightPath.size() || m_flightPath.size() == 1)
595595
{
596596
// No more steps to use. Would go out of bounds on vector, so have to do something.
597597
// We could allow physics to take over and make us fall, but the point of this whole task

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include "GameLogic/Module/DestroyModule.h"
7878
#include "GameLogic/Module/DieModule.h"
7979
#include "GameLogic/Module/DozerAIUpdate.h"
80+
#include "GameLogic/Module/LifeTimeUpdate.h"
8081
#include "GameLogic/Module/ObjectDefectionHelper.h"
8182
#include "GameLogic/Module/ObjectRepulsorHelper.h"
8283
#include "GameLogic/Module/ObjectSMCHelper.h"
@@ -1515,7 +1516,7 @@ Bool Object::getProgressBarShowingInfo(bool selected, Real& progress, Int& type,
15151516

15161517
type = 0; // TODO
15171518
color = { 255, 255, 255, 255 }; // Default = white
1518-
colorBG = { 255, 255, 255, 255 }; // Default = white
1519+
colorBG = { 0, 0, 0, 255 }; // Default = black
15191520

15201521
// Energy Shields
15211522
// TODO: This is kinda bad, there should be a better way to do this, if we have multiple shield sources.
@@ -1532,6 +1533,15 @@ Bool Object::getProgressBarShowingInfo(bool selected, Real& progress, Int& type,
15321533
return true;
15331534
}
15341535
}
1536+
else if ((*u)->getModuleNameKey() == NAMEKEY("LifetimeUpdate")) {
1537+
LifetimeUpdate* ltu = (LifetimeUpdate*)(*u);
1538+
if (ltu->showProgressBar()) {
1539+
// always show healthbar or when selected?
1540+
progress = 1.0 - ltu->getProgress();
1541+
return true;
1542+
}
1543+
}
1544+
15351545
}
15361546

15371547
return false;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cpp

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "GameLogic/PartitionManager.h"
4040
#include "GameLogic/TerrainLogic.h"
4141
#include "GameLogic/Module/OCLSpecialPower.h"
42+
#include <Common/MessageStream.h>
43+
#include <GameClient/InGameUI.h>
4244

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

186189
// at what point will the "deliverer" come in
187190
Coord3D creationCoord;
191+
192+
Object* createdObject = NULL;
193+
188194
switch (modData->m_createLoc)
189195
{
190196
case CREATE_AT_EDGE_NEAR_SOURCE:
191197
creationCoord = TheTerrainLogic->findClosestEdgePoint( getObject()->getPosition() );
192-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
198+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
193199
break;
194200
case CREATE_AT_EDGE_NEAR_TARGET:
195201
creationCoord = TheTerrainLogic->findClosestEdgePoint(&targetCoord);
196-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
202+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
197203
break;
198204
case CREATE_AT_EDGE_FARTHEST_FROM_TARGET:
199205
creationCoord = TheTerrainLogic->findFarthestEdgePoint(&targetCoord);
200206
creationCoord.z += CREATE_ABOVE_LOCATION_HEIGHT;
201-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
207+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
202208
break;
203209
case CREATE_AT_LOCATION:
204210
// this is the case where the special power stuff originates at the location of the mouse click
205211
creationCoord = targetCoord;
206-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
212+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
207213
break;
208214
case USE_OWNER_OBJECT:
209215
creationCoord.set( &targetCoord );
210-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle, false );
216+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle, false );
211217
break;
212218
case CREATE_ABOVE_LOCATION:
213219
// this is the case where the special power stuff originates above the location of the mouse click
214220
creationCoord = targetCoord;
215221
creationCoord.z += CREATE_ABOVE_LOCATION_HEIGHT;
216-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
222+
createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle );
217223
break;
218224
}
225+
226+
if (createdObject != NULL && modData->m_selectObject && createdObject->isLocallyControlled()) {
227+
Drawable* draw = createdObject->getDrawable();
228+
if (draw)
229+
{
230+
//Create the selection message
231+
GameMessage* teamMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP);
232+
teamMsg->appendBooleanArgument(TRUE);// we are creating a new team so pass true
233+
teamMsg->appendObjectIDArgument(createdObject->getID());
234+
TheInGameUI->selectDrawable(draw);
235+
TheInGameUI->setDisplayedMaxWarning(FALSE);
236+
}
237+
}
219238
}
220239

221240
// ------------------------------------------------------------------------------------------------
@@ -244,7 +263,21 @@ void OCLSpecialPower::doSpecialPower( UnsignedInt commandOptions )
244263
SpecialPowerModule::doSpecialPowerAtLocation( &creationCoord, INVALID_ANGLE, commandOptions );
245264

246265
const ObjectCreationList* ocl = findOCL();
247-
ObjectCreationList::create( ocl, getObject(), &creationCoord, &creationCoord, false );
266+
Object* createdObject = ObjectCreationList::create( ocl, getObject(), &creationCoord, &creationCoord, false );
267+
268+
if (createdObject != NULL && getOCLSpecialPowerModuleData()->m_selectObject
269+
&& createdObject->isLocallyControlled()) {
270+
Drawable* draw = createdObject->getDrawable();
271+
if (draw)
272+
{
273+
//Create the selection message
274+
GameMessage* teamMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP);
275+
teamMsg->appendBooleanArgument(TRUE);// we are creating a new team so pass true
276+
teamMsg->appendObjectIDArgument(createdObject->getID());
277+
TheInGameUI->selectDrawable(draw);
278+
TheInGameUI->setDisplayedMaxWarning(FALSE);
279+
}
280+
}
248281
}
249282

250283
// ------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LifetimeUpdate.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ LifetimeUpdate::LifetimeUpdate( Thing *thing, const ModuleData* moduleData ) : U
4545
// Added By Sadullah Nader
4646
// Initializations needed
4747
m_dieFrame = 0;
48+
m_startDieFrame = 0;
4849
//
4950
UnsignedInt delay;
5051
if( getObject()->isKindOf( KINDOF_HULK ) && TheGameLogic->getHulkMaxLifetimeOverride() != -1 )
@@ -88,10 +89,19 @@ UnsignedInt LifetimeUpdate::calcSleepDelay(UnsignedInt minFrames, UnsignedInt ma
8889
{
8990
UnsignedInt delay = GameLogicRandomValue( minFrames, maxFrames );
9091
if (delay < 1) delay = 1;
91-
m_dieFrame = TheGameLogic->getFrame() + delay;
92+
m_startDieFrame = TheGameLogic->getFrame();
93+
m_dieFrame = m_startDieFrame + delay;
9294
return delay;
9395
}
9496

97+
//-------------------------------------------------------------------------------------------------
98+
//-------------------------------------------------------------------------------------------------
99+
Real LifetimeUpdate::getProgress(void) {
100+
if (m_dieFrame > 0 && m_startDieFrame > 0) {
101+
return INT_TO_REAL(TheGameLogic->getFrame() - m_startDieFrame) / INT_TO_REAL(m_dieFrame - m_startDieFrame);
102+
}
103+
return 0.0f;
104+
}
95105
//-------------------------------------------------------------------------------------------------
96106
//-------------------------------------------------------------------------------------------------
97107
UpdateSleepTime LifetimeUpdate::update( void )
@@ -131,6 +141,9 @@ void LifetimeUpdate::xfer( Xfer *xfer )
131141
// die frame
132142
xfer->xferUnsignedInt( &m_dieFrame );
133143

144+
// start die frame
145+
xfer->xferUnsignedInt( &m_startDieFrame);
146+
134147
} // end xfer
135148

136149
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)