Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameclient): aim attack and attack move with the left button

Olcay Seygan9bfb015c9dbe
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d5f871b2..d44bc7ff6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -129,7 +129,7 @@ found and fixed — EA's own, not port damage.**
- Drag the right button and you draw a line: the selection spreads itself evenly along it, in the order the units already stand, so a column arrives as a firing line instead of a queue. It is the line you actually drew, curves and all, however far you keep drawing it: a long sweep used to give up partway through and finish as one straight run to the cursor, and now it holds its shape to the end. Letting go over the sidebar finishes the order rather than leaving the line stuck to the cursor. Draw the same line with attack move armed and the whole line is an attack move: artillery spread across a front, each gun firing on what walks into it, instead of one clump on one spot. Armed with attack instead, every unit fires on its own station along the line, which is a barrage laid across a ridge in one drag. This is what the right button freed up. `FormationDrag = no` in Options.ini turns it off if you would rather a slipped click did nothing.
- Selected units draw a thread to wherever they are going, and the marker on the spot is the game's own cursor. Every order that has a cursor gets that cursor: move, attack move, attack, force fire, ground fire, enter, dock, repair, heal, capture, hack, guard, a waypoint path. Green for a move, pink for an attack-move, red for anything that shoots, so a group told three different things reads as three different colours. It is not a flash at the moment of the order: the line is asked of the unit every frame, so it lasts until the unit gets there, changes its mind or leaves your selection, and it shows on the formation line while you are still drawing it. A unit that has walked off the edge of the screen still draws its line, which is how you see where the half of your army you cannot see is headed. The animated ring the ground used to sprout wherever you clicked is gone: it flashed for a second and told you nothing the marker sitting on the destination does not, and that marker stays for as long as the order does. A marker that has just appeared slides the last few pixels up out of the bottom right and fades in as it lands, over about an eighth of a second, so a fresh order catches your eye without anything flashing. Aircraft draw their thread from the click, not from the moment they leave the runway. A plane parked on its airfield answers an order by starting its takeoff and puts the order itself aside until the wheels are up, so the taxi and the climb, which is exactly the stretch where you are wondering whether the strike went out at all, used to show nothing.
- A unit standing guard draws its marker on the ground it is guarding. A guard order clears the unit's goal on the way in, so every guard marker used to sit in the bottom left corner of the map with a thread running the whole way across it, whatever the unit was actually watching.
-- A is attack and F is attack move, each arming the next order click. A click on the ground with A held down is a shot at that ground, on your own tank a shot at your own tank, and the mode drops again the moment the order goes out, so nothing stays armed behind your back. The click keeps your group, too: an attack click that was not a drag used to run the same deselect an ordinary left click runs, so the order arrived a moment after the units it was meant for had been dropped. Ctrl still forces fire while you hold it. The two keys turn each other off, and the letters they took were sitting on grid commands that moved.
+- A is attack and F is attack move, each arming the next order click. A click on the ground with A held down is a shot at that ground, on your own tank a shot at your own tank, and the mode drops again the moment the order goes out, so nothing stays armed behind your back. The click keeps your group, too: an attack click that was not a drag used to run the same deselect an ordinary left click runs, so the order arrived a moment after the units it was meant for had been dropped. Both orders are aimed with the left button, the way a special power is, and a right click puts the key down again without giving any order. Holding ctrl no longer forces fire: A is the one way to shoot the ground, and ctrl on a move is only the shared pace. The two keys turn each other off, and the letters they took were sitting on grid commands that moved.
- G is guard, armed the same way. The next order click posts the selection on that spot: they hold it, shoot what walks into range and do not chase it off the post you put them on. Drag the right button with G armed and they post along the line you draw, one unit per station, which is how a hill or a bridge approach gets covered in one gesture instead of a click per tank. Guard has its own colour, blue, on the line while you draw it and on the thread and marker afterwards, so a group told to hold ground reads apart from one told to walk there. Hold position, which posts every unit on the spot it is already standing on, has moved to H.
- With A armed, hold the left button and drag a circle instead: everything hostile you can see inside it becomes a target list, nearest first, and the selection works down that list on its own. When the current target dies the next order goes out the same frame, so a strike group clears a circle without you clicking once per tank. It moves on from a target the group has stopped working on, too, rather than only from a dead one: something none of them can reach or hurt used to sit at the head of the list and hold every other target behind it for the rest of the match. That list is the same queue a shift-clicked attack builds, so you can see it: every target still owed has its own thread and marker, in the order they will be taken, instead of one line to whatever is being shot at this second. Hold shift while you draw the circle and its targets go on the end of what the group is already working through; draw it without shift and the circle replaces the lot. The ground inside the circle is washed the same red while you drag it, painted on the map rather than over it, so it runs up the hills inside the circle and your own tanks stand on top of it. Any order you give by hand ends the list. Losing a unit does not: the list belongs to the group that was told and carries on with whoever is left, which is worth saying because for a while it did not, and one tank dying threw away every target still owed. A target with enough of your fire already in the air to kill it counts as done, so the rest of the group takes the next thing on the list rather than emptying itself into something that is dead and has not fallen over yet. Aircraft are what this is for: a flight fires from range and the missiles are seconds behind, and four planes used to spend all four loads on the first tank in the circle. Running out of ammo does not cost you the list either. A flight that empties its racks flies home, lands, rearms and comes back to the target it left, and the queue waits for it instead of counting the trip as the group giving up: a circle drawn for four planes used to be empty by the time they were back in the air, one entry lost every two seconds they were away. The threads stay on the ground for the whole trip, too. A plane flying home has no target and no order to read, so the list it was still holding used to vanish off the map the moment it turned for base and reappear only when it was shooting again, which looks exactly like the list being thrown away. What the circle picks up is what you can shoot: a shell or a missile crossing it is on the enemy's side like everything else and used to go on the list as a target, costing the group a two second stall on something that was about to stop existing. A target that has driven into the shroud since you picked it keeps its place in the list but stops drawing its thread, so the line cannot be used to trace it through the fog. An attack-move queued behind other orders keeps the force fire it was given rather than losing it when the attack key drops.
- Shift queues an attack now, not only a move. A or F held down while you shift-click adds a force-attack or an attack-move to the line of orders a group is already holding, and it fires the moment the order in front of it is finished - a target dead, or nobody left chasing an attack-move point. The coloured thread that shows a queued order covers it too, so a queue of "go here, then attack that, then attack-move over there" reads as one continuous line in three colours. The game's own white waypoint markings, which used to draw over the same ground the moment shift went down, are gone - they only ever duplicated what the coloured thread already showed, and doing both left a queued attack sitting under two different pictures of itself.
diff --git a/GeneralsMD/Code/Data/INI/CommandMap.ini b/GeneralsMD/Code/Data/INI/CommandMap.ini
index 590267c47..31935402c 100644
--- a/GeneralsMD/Code/Data/INI/CommandMap.ini
+++ b/GeneralsMD/Code/Data/INI/CommandMap.ini
@@ -305,9 +305,10 @@ CommandMap SELECT_NEXT_IDLE_WORKER
DisplayName = GUI:SelectNextIdleWorker
End
-; attack move. 'F' arms the mode, the next order click issues it (CommandXlat
-; clears the mode again right after, so it is single shot). It sits next to the
-; attack key below, and the two turn each other off.
+; attack move. 'F' arms the mode, the next left click issues it (CommandXlat
+; clears the mode again right after, so it is single shot) and a right click
+; puts it down. It sits next to the attack key below, and the two turn each
+; other off.
CommandMap TOGGLE_ATTACKMOVE
Key = KEY_F
Transition = DOWN
@@ -318,8 +319,9 @@ CommandMap TOGGLE_ATTACKMOVE
DisplayName = GUI:ToggleAttackMove
End
-; attack. 'A' arms force fire the same way, so a click on the ground, on rubble
-; or on your own tank is an attack rather than a move. Ctrl held still does it.
+; attack. 'A' arms force fire the same way, so a left click on the ground, on
+; rubble or on your own tank is an attack. It is the only way to force fire:
+; holding ctrl no longer does it.
CommandMap TOGGLE_FORCEATTACK
Key = KEY_A
Transition = DOWN
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 97aa024e9..b8f33a7d5 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -158,7 +158,7 @@ GUI:ToggleAttackMove
END
GUI:ToggleAttackMoveDescription
-"Arms attack move: the next move order makes the selected units fight anything they meet on the way."
+"Arms attack move: left click where the selected units should go, fighting anything they meet on the way. Right click puts it down."
END
GUI:ToggleForceAttack
@@ -166,7 +166,7 @@ GUI:ToggleForceAttack
END
GUI:ToggleForceAttackDescription
-"Arms force fire: the next order click is an attack on whatever is under it, your own units and bare ground included."
+"Arms force fire: the next left click is an attack on whatever is under it, your own units and bare ground included. Right click puts it down."
END
GUI:ToggleGuard
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 2160f2c58..cca2743a8 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -863,6 +863,7 @@ public: // ********************************************************************
// same call that drops attack move
void toggleForceAttackArmed( void ) { m_forceAttackArmed = !m_forceAttackArmed; m_attackMoveToMode = FALSE; m_guardArmed = FALSE; }
Bool isForceAttackArmed( void ) const { return m_forceAttackArmed; }
+ Bool isAttackOrderArmed( void ) const { return m_forceAttackArmed || m_attackMoveToMode; } ///< the next left click is an attack or an attack move
// and the guard key arms guard the same way: the next order click posts the selection on that
// spot, or on that object, and a drag posts them along the line instead of stacking them all
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index b950785c3..0c3cd853e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -3519,7 +3519,7 @@ void InGameUI::queueAttackWaypoint( const Coord3D *pos, Object *targetObj )
// remembered rather than read again when the order goes out: the attack key drops the moment the
// first order of the queue is sent, so everything behind it used to lose its force attack
- order.forceAttack = isInForceAttackMode();
+ order.forceAttack = isForceAttackArmed();
// who the queue belongs to. A selection that is not part of the group holding the queue starts
// a fresh one rather than adding to whatever the old selection was doing
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 0a0da8c79..e6b0b4e22 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -101,22 +101,18 @@
//-------------------------------------------------------------------------------------------------
/**
- * Is the ctrl key asking for force fire right now?
- * While the attack move cursor is up, ctrl means "one shared pace" instead (see
- * issueMoveToLocationCommand), so the targeting code must not read it as force attack - otherwise
- * ctrl + click on the ground fires at the dirt instead of ordering the attack move.
+ * Is the next order click a force fire?
+ * Only the attack key arms it. Holding ctrl used to do the same, and ctrl is the "one shared pace"
+ * modifier on a move (see issueMoveToLocationCommand), so a ctrl click could not ask for both.
*/
-Bool CommandXlat_isForceAttackTargeting( Bool ctrlHeld, Bool attackMoveArmed )
+Bool CommandXlat_isForceAttackTargeting( Bool forceAttackArmed, Bool attackMoveArmed )
{
- return ctrlHeld && !attackMoveArmed;
+ return forceAttackArmed && !attackMoveArmed;
}
static Bool isForceAttackTargeting( void )
{
- // ctrl still does it while held; the attack key arms the same thing for one click, which is
- // what leaves ctrl free to mean something else on a plain move
- return CommandXlat_isForceAttackTargeting( TheInGameUI->isInForceAttackMode()
- || TheInGameUI->isForceAttackArmed(),
+ return CommandXlat_isForceAttackTargeting( TheInGameUI->isForceAttackArmed(),
TheInGameUI->isInAttackMoveToMode() );
}
@@ -4071,6 +4067,16 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
// The right button is the order button, always. It used to depend on UseAlternateMouse,
// which is gone: a click here commands, a drag draws a formation line, and neither of
// them scrolls.
+ //
+ // The one exception is the attack or attack move key. Those orders are aimed with the left
+ // button, so a right click while one is armed puts the key down and gives no order.
+ if( TheInGameUI->isAttackOrderArmed() )
+ {
+ TheInGameUI->clearAttackMoveToMode();
+ disp = DESTROY_MESSAGE;
+ break;
+ }
+
if (TheMouse->isClick(&m_mouseRightDragAnchor, &m_mouseRightDragLift,
NULL, NULL,
m_mouseRightDown, m_mouseRightUp))
@@ -4151,10 +4157,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
|| command->getCommandType() == GUICOMMANDMODE_HIJACK_VEHICLE
|| command->getCommandType() == GUICOMMANDMODE_CONVERT_TO_CARBOMB));
- // The left button selects and nothing else. The one exception is a GUI command that is
- // already armed and waiting for a target, which is aimed with the left button because the
- // right one cancels it.
- if( !isFiringGUICommand )
+ // The left button selects and nothing else. The exceptions are a GUI command that is
+ // already armed and waiting for a target, and the attack and attack move keys: all of them
+ // are aimed with the left button, because the right one cancels them.
+ const Bool isAttackOrder = TheInGameUI->isAttackOrderArmed();
+ if( !isFiringGUICommand && !isAttackOrder )
break;
Bool controllable = TheInGameUI->areSelectedObjectsControllable()
@@ -4175,6 +4182,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
disp = DESTROY_MESSAGE;
TheInGameUI->clearAttackMoveToMode();
+ // the same rule the right button's orders follow: a hand-given attack ends the list the
+ // group was working through, unless shift says it is being added to
+ if( isAttackOrder && !TheInGameUI->isInWaypointMode() )
+ TheInGameUI->clearShiftAttackQueue();
+
//issueMoveToLocationCommand( &pos, draw, DO_COMMAND );
}
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index 51deb424a..57388edca 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -453,7 +453,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
// when we're not in force attackable mode!
UnsignedInt pickType = getPickTypesForContext( true /*TheInGameUI->isInForceAttackMode()*/ );
- Drawable *underCursor = TheTacticalView->pickDrawable( &pixel, TheInGameUI->isInForceAttackMode(), (PickType) pickType );
+ Drawable *underCursor = TheTacticalView->pickDrawable( &pixel, TheInGameUI->isForceAttackArmed(), (PickType) pickType );
//
// a click on a health bar selects its owner, so the cursor has to say so before the
@@ -498,8 +498,8 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
break;
}
- // Pressing ctrl is disallowed for double clicking
- if (TheInGameUI->isInForceAttackMode())
+ // an armed attack key makes this click an order, which CommandXlat gives
+ if (TheInGameUI->isAttackOrderArmed())
break;
const IRegion2D& region = msg->getArgument(0)->pixelRegion;
@@ -648,6 +648,11 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
break;
}
+ // With the attack or attack move key armed and something selected, a point click is the
+ // order and not a selection. It goes on to CommandXlat untouched, drawable under it or not
+ if (TheInGameUI->isAttackOrderArmed() && TheInGameUI->getSelectCount() > 0)
+ break;
+
// Basically, we need to first determine if there are any drawables in the region of interest.
// If there aren't then this click should move forward.
IRegion2D selectionRegion = msg->getArgument(0)->pixelRegion;
@@ -676,7 +681,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
was a way to take things back out and a way to leave the base staff behind: Alt keeps
only what can shoot, Ctrl removes the box from the selection instead of replacing it.
Both are drag-only. A point click has to stay exactly what it was - a filter that eats
- single clicks reads as a broken mouse, and Ctrl on a point click is force fire. */
+ single clicks reads as a broken mouse. */
if (!isPoint)
{
if (TheKeyboard->isAlt())
@@ -1093,7 +1098,9 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
//Added support to cancel the GUI command without deselecting the unit(s) involved
//when you right click.
- if( !TheInGameUI->getGUICommand() && !TheKeyboard->isShift() && !TheKeyboard->isCtrl() && !TheKeyboard->isAlt() )
+ // an armed attack key keeps the group: the click behind this release is its order
+ if( !TheInGameUI->getGUICommand() && !TheInGameUI->isAttackOrderArmed()
+ && !TheKeyboard->isShift() && !TheKeyboard->isCtrl() && !TheKeyboard->isAlt() )
{
//No GUI command mode, so a click on empty ground deselects everyone.
if( TheInGameUI->getPendingPlaceSourceObjectID() == INVALID_ID )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp
index 3ad336741..0c2393057 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp
@@ -74,7 +74,7 @@ PickDrawableStruct::PickDrawableStruct() : drawableListToFill(NULL)
//Initializations inserted
drawableListToFill = FALSE;
//
- forceAttackMode = TheInGameUI->isInForceAttackMode();
+ forceAttackMode = TheInGameUI->isForceAttackArmed();
UnsignedInt pickType = getPickTypesForContext(forceAttackMode);
translatePickTypesToKindof(pickType, kindofsToMatch);
if (!forceAttackMode)
@@ -96,7 +96,7 @@ extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedD
if (!(currentlySelectedDrawables && newlySelectedDrawables && outSelectionInfo))
return FALSE;
- Bool forceFire = TheInGameUI->isInForceAttackMode();
+ Bool forceFire = TheInGameUI->isForceAttackArmed();
Bool forceMove = TheInGameUI->isInForceMoveToMode();
if (forceFire || forceMove) {
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
index d70c9ba9e..70e6afc06 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@@ -2426,7 +2426,7 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion,
if (regionIsPoint)
{
// Allow all drawables to be picked.
- onlyDrawableToTest = pickDrawable(&screenRegion->lo, TRUE, (PickType) getPickTypesForContext(TheInGameUI->isInForceAttackMode()));
+ onlyDrawableToTest = pickDrawable(&screenRegion->lo, TRUE, (PickType) getPickTypesForContext(TheInGameUI->isForceAttackArmed()));
//
// Nothing under the cursor in the scene, so a health bar is allowed to answer for its owner.
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index ad5b759e8..f48af8461 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -974,20 +974,19 @@ TEST(physics_forward_speed_is_the_projection_not_a_per_axis_norm)
CHECK_NEAR( PhysicsBehavior::calcForwardSpeed( climb, up ), 12.0f, 0.01f );
}
-/* CommandXlat.cpp: ctrl is the force fire modifier, but while the attack move cursor is up it
- means "one shared pace" for the group instead. The click dispatch used to read the raw ctrl
- state, so A then ctrl+click fired at the ground rather than issuing the attack move. */
-extern Bool CommandXlat_isForceAttackTargeting( Bool ctrlHeld, Bool attackMoveArmed );
+/* CommandXlat.cpp: only the attack key arms force fire. Holding ctrl did it too, and ctrl is the
+ "one shared pace" modifier, so a ctrl click on the ground shelled the dirt instead of moving. */
+extern Bool CommandXlat_isForceAttackTargeting( Bool forceAttackArmed, Bool attackMoveArmed );
-TEST(ctrl_is_force_fire_only_while_the_attack_move_cursor_is_down)
+TEST(force_fire_is_the_attack_key_and_nothing_else)
{
- /* plain ctrl+click: force fire, as in retail. */
+ /* A armed: the next click is a force fire. */
CHECK( CommandXlat_isForceAttackTargeting( true, false ) );
- /* attack move armed: ctrl is the group speed modifier, so nothing force fires. */
+ /* attack move armed on top of it: the click is the attack move. */
CHECK( !CommandXlat_isForceAttackTargeting( true, true ) );
- /* no ctrl at all, either way. */
+ /* neither key: nothing force fires, which is what ctrl held down now gets. */
CHECK( !CommandXlat_isForceAttackTargeting( false, false ) );
CHECK( !CommandXlat_isForceAttackTargeting( false, true ) );
}