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(gameengine): handicap scales damage, build time, cooldowns, healing

Olcay Seygan41c2db674062
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 522bc4252..7d56b0e47 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ found and fixed, EA's own, not port damage.**
## A handicap for every seat
-- The skirmish, LAN and online rooms have a Handicap box at the end of every seat's row, from 100% down to 10%. At 50% every unit that player fields has half its health: his Crusader reads 240 where the same tank reads 480 across the map. His buildings stay at full health.
+- The skirmish, LAN and online rooms have a Handicap box at the end of every seat's row, from 100% down to 10%. At 50% that player's units and buildings have half their health and his weapons and superweapons deal half their damage: his Crusader reads 240 where the same tank reads 480 across the map. Building, research and every special power's recharge take twice as long, and flat healing is halved so a smaller body refills no faster. Rate of fire, income, speed, sight and prices stay as they are. A demo truck still dies in its own blast, and a sniper's shot or a pilot kill works as ever.
- You pick for your own seat and the host picks for the computer seats, the way colour and team already work. The pick is in the replay and the saved game, and a room that leaves the column at 100% plays and replays as it did.
- Promotions and armour research still come on top, at the seat's share: an Elite Paladin with Composite Armor reads 364 at 50% against 728 at 100%. A vehicle stolen from a handicapped player moves to its new owner's column and keeps its share of health, so a Humvee at 80 of 120 becomes 160 of 240 with no damage dealt and no repair given.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index dd6870f21..86c96ce34 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -2179,7 +2179,7 @@ GUI:Handicap
END
TOOLTIP:Handicap
-"Lowers the maximum health of this player's units."
+"Weakens this player in proportion. At 50 percent: half the health and damage on units and buildings, half the healing, twice the build, research and special power times."
END
// What a computer player with a personality says in chat: when a wave leaves (two lines), when its
diff --git a/GeneralsMD/Code/Data/Scenarios/handicap.txt b/GeneralsMD/Code/Data/Scenarios/handicap.txt
index bfc6b3984..21b7e02ff 100644
--- a/GeneralsMD/Code/Data/Scenarios/handicap.txt
+++ b/GeneralsMD/Code/Data/Scenarios/handicap.txt
@@ -1,32 +1,45 @@
-# The lobby's handicap, read off the tallies with and without it. Run the same line twice, the second
-# time without -handicap, and seat 0's units read half their max health while its power plant and
-# seat 1's own stock stay the same.
+# The lobby's handicap, read off the tallies. Seat 0 at 50 against seat 1 at 100 in one run: each seat
+# owns the same things and does the same to the other, so every pair of lines is the handicap.
#
# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover
-# -side 0 FactionAmerica -side 1 FactionAmerica -seed 7 -maxframes 6000
+# -side 0 FactionAmerica -side 1 FactionAmerica -seed 7 -maxframes 8000
# -handicap 0 50 -scenario handicap -logPrefix handicap_
#
-# Each seat's stock stands at its own start, out of reach of the other. Crusader: bare, then 100 more
-# from Composite Armor. Paladin: made elite first, then the same armor, whose addition carries both
-# multipliers. The Crusader spawned after the research is a new unit under a finished upgrade.
+# Health: power plant, Crusader, Paladin, Ranger. Composite Armor adds at the seat's multiplier; the Crusader spawned after the research is a new unit under a finished upgrade.
#
-# The Humvee and the Tomahawk are the captures, staged on open ground in the east: a few Rebels wear
-# each vehicle down until a Hijacker of theirs takes it. A tally every half second shows the share of
-# health carried across the capture while the max moves to the new owner's factor.
+# Build time: Composite Armor from frame 70 and an Ambulance from frame 80; the tallies below say when
+# the Crusader's max jumps and when the Ambulance is out, in file frames (30 a second).
#
-# The Battle Bus takes Overlord fire until its second life, an absolute max health in the data.
+# Damage: a Battlemaster shelling a Barracks for 300 file frames, on both seats. A Bomb Truck at a GLA
+# Barracks: half the blast, and the truck dies of it either way.
+#
+# Cooldown: the "power" lines log the ready frame. Burton's charges are the module's own timer, the
+# Particle Cannon a superweapon, the Command Center's Spectre a general's power on the seat's shared timer.
+#
+# Capture: a few Rebels wear a Humvee and a Tomahawk down until a Hijacker takes each. The share of
+# health crosses, the max moves to the new owner's factor. Battle Bus: second life, absolute in the data.
30 spawn 0 AmericaPowerPlant 1 start0:-200:-250
30 spawn 1 AmericaPowerPlant 1 start1:-200:-250
+30 spawn 0 AmericaPowerPlant 1 start0:-200:-400
+30 spawn 1 AmericaPowerPlant 1 start1:-200:-400
+30 spawn 0 AmericaPowerPlant 1 start0:-50:-400
+30 spawn 1 AmericaPowerPlant 1 start1:-50:-400
30 spawn 0 AmericaStrategyCenter 1 start0:250:-250
30 spawn 1 AmericaStrategyCenter 1 start1:250:-250
+30 spawn 0 AmericaWarFactory 1 start0:320:60
+30 spawn 1 AmericaWarFactory 1 start1:320:60
+30 spawn 0 AmericaParticleCannonUplink 1 start0:560:-250
+30 spawn 1 AmericaParticleCannonUplink 1 start1:320:-120
30 spawn 0 AmericaTankCrusader 1 start0:0:300
30 spawn 1 AmericaTankCrusader 1 start1:0:-300
30 spawn 0 AmericaTankPaladin 1 start0:80:300
30 spawn 1 AmericaTankPaladin 1 start1:80:-300
30 spawn 0 AmericaInfantryRanger 1 start0:160:300
30 spawn 1 AmericaInfantryRanger 1 start1:160:-300
+30 spawn 0 AmericaInfantryColonelBurton 1 start0:220:300
+30 spawn 1 AmericaInfantryColonelBurton 1 start1:220:-300
40 tally 0 AmericaPowerPlant
40 tally 1 AmericaPowerPlant
40 tally 0 AmericaTankCrusader
@@ -35,12 +48,52 @@
40 tally 1 AmericaTankPaladin
40 tally 0 AmericaInfantryRanger
40 tally 1 AmericaInfantryRanger
-50 rank 0 AmericaTankPaladin elite
-50 rank 1 AmericaTankPaladin elite
60 tally 0 AmericaTankPaladin
60 tally 1 AmericaTankPaladin
+
+# build time
70 shiftupgrade 0 AmericaStrategyCenter Upgrade_AmericaCompositeArmor
70 shiftupgrade 1 AmericaStrategyCenter Upgrade_AmericaCompositeArmor
+80 produce 0 AmericaWarFactory AmericaVehicleMedic 1
+80 produce 1 AmericaWarFactory AmericaVehicleMedic 1
+200 tally 0 AmericaVehicleMedic
+200 tally 1 AmericaVehicleMedic
+250 tally 0 AmericaVehicleMedic
+250 tally 1 AmericaVehicleMedic
+300 tally 0 AmericaVehicleMedic
+300 tally 1 AmericaVehicleMedic
+350 tally 0 AmericaVehicleMedic
+350 tally 1 AmericaVehicleMedic
+400 tally 0 AmericaVehicleMedic
+400 tally 1 AmericaVehicleMedic
+500 tally 0 AmericaVehicleMedic
+500 tally 1 AmericaVehicleMedic
+600 tally 0 AmericaVehicleMedic
+600 tally 1 AmericaVehicleMedic
+700 tally 0 AmericaVehicleMedic
+700 tally 1 AmericaVehicleMedic
+800 tally 0 AmericaVehicleMedic
+800 tally 1 AmericaVehicleMedic
+300 tally 0 AmericaTankCrusader
+300 tally 1 AmericaTankCrusader
+500 tally 0 AmericaTankCrusader
+500 tally 1 AmericaTankCrusader
+700 tally 0 AmericaTankCrusader
+700 tally 1 AmericaTankCrusader
+900 tally 0 AmericaTankCrusader
+900 tally 1 AmericaTankCrusader
+1100 tally 0 AmericaTankCrusader
+1100 tally 1 AmericaTankCrusader
+1300 tally 0 AmericaTankCrusader
+1300 tally 1 AmericaTankCrusader
+1500 tally 0 AmericaTankCrusader
+1500 tally 1 AmericaTankCrusader
+1700 tally 0 AmericaTankCrusader
+1700 tally 1 AmericaTankCrusader
+1900 tally 0 AmericaTankCrusader
+1900 tally 1 AmericaTankCrusader
+2100 tally 0 AmericaTankCrusader
+2100 tally 1 AmericaTankCrusader
2500 tally 0 AmericaTankCrusader
2500 tally 1 AmericaTankCrusader
2500 tally 0 AmericaTankPaladin
@@ -49,21 +102,56 @@
2510 spawn 1 AmericaTankCrusader 1 start1:0:-360
2520 tally 0 AmericaTankCrusader
2520 tally 1 AmericaTankCrusader
+3300 tally 0 AmericaTankCrusader
+3500 tally 0 AmericaTankCrusader
+3700 tally 0 AmericaTankCrusader
+3900 tally 0 AmericaTankCrusader
+3900 tally 0 AmericaTankPaladin
+
+# cooldowns, fired at the empty ground on the map's far side
+90 power 0 AmericaInfantryColonelBurton start0:220:360
+90 power 1 AmericaInfantryColonelBurton start1:220:-360
+90 power 0 AmericaParticleCannonUplink 2000 900
+90 power 1 AmericaParticleCannonUplink 2000 900
+90 power 0 AmericaCommandCenter 2000 900 SuperweaponSpectreGunship
+90 power 1 AmericaCommandCenter 2000 900 SuperweaponSpectreGunship
+
+# damage dealt, both ways
+100 spawn 0 ChinaTankBattleMaster 1 3050 4103
+100 spawn 1 ChinaBarracks 1 3196 4103
+100 spawn 1 ChinaTankBattleMaster 1 4510 3126
+100 spawn 0 ChinaBarracks 1 4361 3126
+110 attack 0 ChinaTankBattleMaster 1 ChinaBarracks
+110 attack 1 ChinaTankBattleMaster 0 ChinaBarracks
+110 tally 0 ChinaBarracks
+110 tally 1 ChinaBarracks
+410 tally 0 ChinaBarracks
+410 tally 1 ChinaBarracks
+
+# a Bomb Truck at a Barracks, both ways: the truck must die, at 50 too
+100 spawn 0 GLAVehicleBombTruck 1 4000 3650
+100 spawn 1 GLABarracks 1 4150 3650
+100 spawn 1 GLAVehicleBombTruck 1 4000 3100
+100 spawn 0 GLABarracks 1 4150 3100
+110 attack 0 GLAVehicleBombTruck 1 GLABarracks
+110 attack 1 GLAVehicleBombTruck 0 GLABarracks
+110 tally 0 GLABarracks
+110 tally 1 GLABarracks
+410 tally 0 GLABarracks
+410 tally 1 GLABarracks
+410 tally 0 GLAVehicleBombTruck
+410 tally 1 GLAVehicleBombTruck
# seat 0's Humvee goes to seat 1
100 spawn 0 AmericaVehicleHumvee 1 2450 3650
100 spawn 1 GLAInfantryRebel 3 2570 3650 20
160 spawn 1 GLAInfantryHijacker 1 2480 3650
165 enter 1 GLAInfantryHijacker 0 AmericaVehicleHumvee
-150 tally 0 AmericaVehicleHumvee
165 tally 0 AmericaVehicleHumvee
180 tally 0 AmericaVehicleHumvee
180 tally 1 AmericaVehicleHumvee
195 tally 0 AmericaVehicleHumvee
195 tally 1 AmericaVehicleHumvee
-210 tally 0 AmericaVehicleHumvee
-210 tally 1 AmericaVehicleHumvee
-240 tally 1 AmericaVehicleHumvee
300 tally 1 AmericaVehicleHumvee
# seat 1's Tomahawk goes to seat 0
@@ -71,33 +159,17 @@
100 spawn 0 GLAInfantryRebel 3 3120 3650 20
160 spawn 0 GLAInfantryHijacker 1 3030 3650
165 enter 0 GLAInfantryHijacker 1 AmericaVehicleTomahawk
-150 tally 1 AmericaVehicleTomahawk
165 tally 1 AmericaVehicleTomahawk
180 tally 1 AmericaVehicleTomahawk
180 tally 0 AmericaVehicleTomahawk
195 tally 1 AmericaVehicleTomahawk
195 tally 0 AmericaVehicleTomahawk
-210 tally 1 AmericaVehicleTomahawk
-210 tally 0 AmericaVehicleTomahawk
-240 tally 0 AmericaVehicleTomahawk
300 tally 0 AmericaVehicleTomahawk
# seat 0's Battle Bus, into its second life
100 spawn 0 GLAVehicleBattleBus 1 1135 3696
100 spawn 1 ChinaTankOverlord 1 1290 3696
-110 tally 0 GLAVehicleBattleBus*
-120 tally 0 GLAVehicleBattleBus*
-130 tally 0 GLAVehicleBattleBus*
-140 tally 0 GLAVehicleBattleBus*
-150 tally 0 GLAVehicleBattleBus*
-160 tally 0 GLAVehicleBattleBus*
-170 tally 0 GLAVehicleBattleBus*
-180 tally 0 GLAVehicleBattleBus*
-190 tally 0 GLAVehicleBattleBus*
200 tally 0 GLAVehicleBattleBus*
-210 tally 0 GLAVehicleBattleBus*
-220 tally 0 GLAVehicleBattleBus*
240 tally 0 GLAVehicleBattleBus*
-260 tally 0 GLAVehicleBattleBus*
280 tally 0 GLAVehicleBattleBus*
-300 tally 0 GLAVehicleBattleBus*
+320 tally 0 GLAVehicleBattleBus*
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 119f45564..a9c9718bf 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -16570,7 +16570,7 @@ GUI:Handicap
END
TOOLTIP:Handicap
-"Bu oyuncunun birimlerinin en yüksek canını düşürür."
+"Bu oyuncuyu orantılı olarak zayıflatır. Yüzde 50'de birim ve binalarda can ve hasar yarıya, iyileşme yarıya iner; yapım, araştırma ve özel güç süreleri iki katına çıkar."
END
// Kişilikli bir bilgisayar oyuncusunun sohbete yazdıkları: bir dalga çıkarken (iki satır), üssü
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Handicap.h b/GeneralsMD/Code/GameEngine/Include/Common/Handicap.h
index 0220335cb..708c569d8 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Handicap.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Handicap.h
@@ -76,7 +76,7 @@ public:
{
BUILDCOST,
BUILDTIME,
- MAXHEALTH, // the lobby's handicap; set for GENERIC only, so a structure stays whole
+ MAXHEALTH, // the lobby's handicap p; damage, healing and cooldowns take the same p, BUILDTIME 1/p
HANDICAP_TYPE_COUNT
};
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
index 668646748..1915db1a1 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
@@ -400,6 +400,10 @@ public:
/// return the Player's Handicap sub-object
inline const Handicap *getHandicap() const { return &m_handicap; }
inline Handicap *getHandicap() { return &m_handicap; }
+ /// the lobby's handicap as a factor, exactly 1 for a seat without one
+ inline Real getLobbyHandicap() const { return m_handicap.getGenericHandicap( Handicap::MAXHEALTH ); }
+ /// a special power's reload in frames for this seat: the template's own at no handicap
+ UnsignedInt getSpecialPowerReloadTime( const SpecialPowerTemplate *temp ) const;
/// return the Player's Money sub-object
inline Money *getMoney() { return &m_money; }
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
index 14a543bd4..4b9393b46 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
@@ -325,7 +325,8 @@ public:
void setTemporaryTeam( Team* team ); ///< sets the unit's team BUT NOT its original team
Player* getControllingPlayer() const;
- Real getHandicapHealthFactor() const; ///< what the owner's lobby handicap makes of this object's max health
+ Real getHandicapHealthFactor() const; ///< what the owner's lobby handicap makes of this object's max health and of flat healing into it
+ Real getOwnerHandicap() const; ///< the owner's lobby handicap for what this object deals, whatever it is; 1 with no owner
void friend_ownerChangedHandicap( const Player *oldOwner ); ///< a new owner's factor, its share of health kept: no damage, no heal
Relationship getRelationship(const Object *that) const;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index a69c8722e..072e61aba 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -4152,6 +4152,12 @@ void Player::addNewSharedSpecialPowerTimer( const SpecialPowerTemplate *temp, Un
}
+UnsignedInt Player::getSpecialPowerReloadTime( const SpecialPowerTemplate *temp ) const
+{
+ const Real handicap = getLobbyHandicap();
+ return handicap == 1.0f ? temp->getReloadTime() : (UnsignedInt)( temp->getReloadTime() / handicap );
+}
+
void Player::resetOrStartSpecialPowerReadyFrame( const SpecialPowerTemplate *temp )
{
@@ -4165,7 +4171,7 @@ void Player::resetOrStartSpecialPowerReadyFrame( const SpecialPowerTemplate *tem
timer = &(*it);
if ( timer->m_templateID == lookupID )
{
- timer->m_readyFrame = now + temp->getReloadTime();
+ timer->m_readyFrame = now + getSpecialPowerReloadTime( temp );
return;
}
}
@@ -4906,7 +4912,7 @@ void Player::crc( Xfer *xfer )
xfer->xferSnapshot( &m_money );
// The lobby's handicap, only on a seat that has one, so every other replay keeps the CRC it has.
- Real healthHandicap = m_handicap.getGenericHandicap( Handicap::MAXHEALTH );
+ Real healthHandicap = getLobbyHandicap();
if( healthHandicap != 1.0f )
xfer->xferReal( &healthHandicap );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
index 643bbc385..0acfd40d7 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
@@ -170,6 +170,9 @@ Int UpgradeTemplate::calcTimeToBuild( Player *player ) const
}
///@todo modify this by power state of player
+ const Real handicap = player->getHandicap()->getGenericHandicap( Handicap::BUILDTIME );
+ if( handicap != 1.0f )
+ return m_buildTime * LOGICFRAMES_PER_SECOND * handicap;
return m_buildTime * LOGICFRAMES_PER_SECOND;
} // end calcTimeToBuild
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index 44936152e..5d202ef79 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -5391,7 +5391,7 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
if( needed != SCIENCE_INVALID && (owner == NULL || !owner->hasScience( needed )) )
continue;
- Real full = INT_TO_REAL( tmpl->getReloadTime() );
+ Real full = INT_TO_REAL( owner ? owner->getSpecialPowerReloadTime( tmpl ) : tmpl->getReloadTime() );
if( full <= 0.0f )
continue;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp
index d5e01d2dc..3d705eb63 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp
@@ -308,10 +308,13 @@ void AutoHealBehavior::pulseHealObject( Object *obj )
// A single burst is one heal, not a source that could stack pulse on pulse, so it skips the
// one-healer-at-a-time rule. Under it an Emergency Repair landing on vehicles an Ambulance or a
// Propaganda Tower was already tending healed nothing, and the burst never comes again.
+ // A flat amount, so a body the lobby's handicap shrank refills no faster. Heals that are a share of max
+ // health shrink with it by themselves and take no factor.
+ const Real amount = data->m_healingAmount * obj->getHandicapHealthFactor();
if ( data->m_radius == 0.0f || data->m_singleBurst )
- obj->attemptHealing(data->m_healingAmount, getObject());
+ obj->attemptHealing(amount, getObject());
else
- obj->attemptHealingFromSoleBenefactor( data->m_healingAmount, getObject(), data->m_healingDelay );
+ obj->attemptHealingFromSoleBenefactor( amount, getObject(), data->m_healingDelay );
if( data->m_unitHealPulseParticleSystemTmpl )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp
index ebf4563ae..9b7682d34 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp
@@ -1135,7 +1135,7 @@ UpdateSleepTime FlightDeckBehavior::update()
healInfo.in.m_damageType = DAMAGE_HEALING;
healInfo.in.m_deathType = DEATH_NONE;
healInfo.in.m_sourceID = getObject()->getID();
- healInfo.in.m_amount = HEAL_RATE_FRAMES * data->m_healAmount * SECONDS_PER_LOGICFRAME_REAL;
+ healInfo.in.m_amount = HEAL_RATE_FRAMES * data->m_healAmount * SECONDS_PER_LOGICFRAME_REAL * objToHeal->getHandicapHealthFactor();
BodyModuleInterface *body = objToHeal->getBodyModule();
body->attemptHealing( &healInfo );
++it;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
index 438ba0b27..1a63cf18f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
@@ -878,7 +878,7 @@ UpdateSleepTime ParkingPlaceBehavior::update()
healInfo.in.m_damageType = DAMAGE_HEALING;
healInfo.in.m_deathType = DEATH_NONE;
healInfo.in.m_sourceID = getObject()->getID();
- healInfo.in.m_amount = HEAL_RATE_FRAMES * d->m_healAmount * SECONDS_PER_LOGICFRAME_REAL;
+ healInfo.in.m_amount = HEAL_RATE_FRAMES * d->m_healAmount * SECONDS_PER_LOGICFRAME_REAL * objToHeal->getHandicapHealthFactor();
// if ( objToHeal->isKindOf( KINDOF_PRODUCED_AT_HELIPAD ) )
// healInfo.in.m_amount += HEAL_RATE_FRAMES * d->m_extraHealAmount4Helicopters * SECONDS_PER_LOGICFRAME_REAL;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SupplyWarehouseCripplingBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SupplyWarehouseCripplingBehavior.cpp
index 49c2e78af..e28e557f7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SupplyWarehouseCripplingBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SupplyWarehouseCripplingBehavior.cpp
@@ -103,7 +103,7 @@ UpdateSleepTime SupplyWarehouseCripplingBehavior::update()
UnsignedInt now = TheGameLogic->getFrame();
m_nextHealingFrame = now + md->m_selfHealDelay;
- getObject()->attemptHealing(md->m_selfHealAmount, NULL);
+ getObject()->attemptHealing(md->m_selfHealAmount * getObject()->getHandicapHealthFactor(), NULL);
if( getObject()->getBodyModule()->getHealth() == getObject()->getBodyModule()->getMaxHealth() )
return UPDATE_SLEEP_FOREVER;// this can't be in onHealing, as the healing comes from here
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
index 6f135f9e5..3c2c33bd1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
@@ -402,6 +402,8 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )
{
if( !damageInfo->in.m_kill )
{
+ // A healing weapon's amount is flat; the one healed takes his own handicap, never the healer's.
+ damageInfo->in.m_amount *= getObject()->getHandicapHealthFactor();
// Healing and Damage are separate, so this shouldn't happen
attemptHealing( damageInfo );
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/RebuildHoleExposeDie.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/RebuildHoleExposeDie.cpp
index 8a928eb82..477aed5e1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/RebuildHoleExposeDie.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/RebuildHoleExposeDie.cpp
@@ -162,7 +162,7 @@ void RebuildHoleExposeDie::onDie( const DamageInfo *damageInfo )
// set the health of the hole to that defined by our data
BodyModuleInterface *body = hole->getBodyModule();
- body->setMaxHealth( modData->m_holeMaxHealth );
+ body->setMaxHealth( modData->m_holeMaxHealth * hole->getHandicapHealthFactor() );
// set the information in the hole about what to build
RebuildHoleBehaviorInterface *rhbi = RebuildHoleBehavior::getRebuildHoleBehaviorInterfaceFromObject( hole );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index e34b7fdb1..eb86e89c6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -195,10 +195,11 @@ static void scaleMaxHealth( Object *obj, Real factor )
body->setMaxHealth( body->getMaxHealth() * factor, PRESERVE_RATIO );
}
-// what walks, drives or flies: a seat's missiles, mines and parachutes are not its units
+// units and structures: a seat's missiles, mines and parachutes keep what the data gives them, since a
+// mine at half health is no weaker a mine and a missile only reads its health against a laser
static Real handicapHealthFactor( const Object *obj, const Player *owner )
{
- if( owner == NULL || ( !obj->isKindOf( KINDOF_INFANTRY ) && !obj->isKindOf( KINDOF_VEHICLE ) ) )
+ if( owner == NULL || ( !obj->isKindOf( KINDOF_INFANTRY ) && !obj->isKindOf( KINDOF_VEHICLE ) && !obj->isKindOf( KINDOF_STRUCTURE ) ) )
return 1.0f;
return owner->getHandicap()->getHandicap( Handicap::MAXHEALTH, obj->getTemplate() );
}
@@ -1764,6 +1765,13 @@ Real Object::getHandicapHealthFactor() const
return handicapHealthFactor( this, getControllingPlayer() );
}
+//=============================================================================
+Real Object::getOwnerHandicap() const
+{
+ const Player *owner = getControllingPlayer();
+ return owner ? owner->getLobbyHandicap() : 1.0f;
+}
+
//=============================================================================
// Object::friend_ownerChangedHandicap
//=============================================================================
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
index e4a1291ad..9e39d91b3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
@@ -390,8 +390,9 @@ Real SpecialPowerModule::getPercentReady() const
}
// calculate the percent
- Real percent = 1.0f - ((readyFrame - TheGameLogic->getFrame()) /
- (Real)modData->m_specialPowerTemplate->getReloadTime());
+ const Player *owner = getObject()->getControllingPlayer();
+ const UnsignedInt reload = owner ? owner->getSpecialPowerReloadTime( modData->m_specialPowerTemplate ) : modData->m_specialPowerTemplate->getReloadTime();
+ Real percent = 1.0f - ((readyFrame - TheGameLogic->getFrame()) / (Real)reload);
return percent;
}
@@ -454,7 +455,10 @@ void SpecialPowerModule::startPowerRecharge()
if( modData->m_startsReady && m_availableOnFrame == 0 )
m_availableOnFrame = TheGameLogic->getFrame();
else
- m_availableOnFrame = TheGameLogic->getFrame() + getSpecialPowerTemplate()->getReloadTime();
+ {
+ const Player *owner = getObject()->getControllingPlayer();
+ m_availableOnFrame = TheGameLogic->getFrame() + (owner ? owner->getSpecialPowerReloadTime( getSpecialPowerTemplate() ) : getSpecialPowerTemplate()->getReloadTime());
+ }
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FirestormDynamicGeometryInfoUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FirestormDynamicGeometryInfoUpdate.cpp
index e28bf2c60..055f688c1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FirestormDynamicGeometryInfoUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FirestormDynamicGeometryInfoUpdate.cpp
@@ -232,7 +232,7 @@ void FirestormDynamicGeometryInfoUpdate::doDamageScan( void )
damageInfo.in.m_damageType = DAMAGE_FLAME;
damageInfo.in.m_deathType = DEATH_BURNED;
damageInfo.in.m_sourceID = firestorm->getID();
- damageInfo.in.m_amount = modData->m_damageAmount;
+ damageInfo.in.m_amount = modData->m_damageAmount * firestorm->getOwnerHandicap();
// get the current bounding circle size for the firestorm
Real boundingCircle = firestorm->getGeometryInfo().getBoundingCircleRadius();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp
index 343843628..57d7e7636 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp
@@ -395,6 +395,8 @@ void NeutronMissileSlowDeathBehavior::doBlast( const BlastInfo *blastInfo, Real
} // end else
+ damageInfo.in.m_amount *= missile->getOwnerHandicap();
+
// do actual damage
if( damageInfo.in.m_amount )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
index e4152ad06..b5bd21b1a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
@@ -714,7 +714,7 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
Real totalFiringSeconds = data->m_totalFiringFrames / LOGICFRAMES_PER_SECOND;
Real damagePerPulse = (Real)(totalFiringSeconds * data->m_damagePerSecond) / (Real)data->m_totalDamagePulses;
- damageInfo.in.m_amount = damagePerPulse;
+ damageInfo.in.m_amount = damagePerPulse * me->getOwnerHandicap();
damageInfo.in.m_sourceID = me->getID();
damageInfo.in.m_damageType = data->m_damageType;
damageInfo.in.m_deathType = data->m_deathType;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp
index 9773eed3d..57cb02c3d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp
@@ -514,7 +514,7 @@ void SlavedUpdate::doRepairLogic()
if( body )
{
//Calculate the repair rate per frame.
- Real repairAmount = data->m_repairRatePerSecond / LOGICFRAMES_PER_SECOND;
+ Real repairAmount = data->m_repairRatePerSecond / LOGICFRAMES_PER_SECOND * master->getHandicapHealthFactor();
DamageInfo healingInfo;
healingInfo.in.m_amount = repairAmount;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
index a817b1712..a8ae037fc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
@@ -265,7 +265,7 @@ void StickyBombUpdate::detonate()
for (; curVictim != NULL; curVictim = iter ? iter->nextWithNumeric(&curVictimDistSqr) : NULL)
{
- damageInfo.in.m_amount = (curVictimDistSqr <= primaryDamageRangeSqr) ? primaryDamage : secondaryDamage;
+ damageInfo.in.m_amount = ((curVictimDistSqr <= primaryDamageRangeSqr) ? primaryDamage : secondaryDamage) * getObject()->getOwnerHandicap();
curVictim->attemptDamage(&damageInfo);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index 600c6bc1a..878795e74 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -2097,6 +2097,38 @@ Weapon& Weapon::operator=(const Weapon& that)
//-------------------------------------------------------------------------------------------------
Weapon::~Weapon()
+// Damage that takes health off. The rest read the amount as a count or a yes, or end something outright:
+// a Kill Garrisoned of 1 at half is nobody, and healing scales on the one healed. Sniper is here because
+// its one shot, one man is the unit; a suicide's own death is HUGE_DAMAGE_AMOUNT, past any bonus.
+static Bool lobbyHandicapScalesDamage( DamageType type )
+{
+ switch( type )
+ {
+ case DAMAGE_SNIPER:
+ case DAMAGE_HEALING:
+ case DAMAGE_UNRESISTABLE:
+ case DAMAGE_WATER:
+ case DAMAGE_DEPLOY:
+ case DAMAGE_SURRENDER:
+ case DAMAGE_HACK:
+ case DAMAGE_KILLPILOT:
+ case DAMAGE_PENALTY:
+ case DAMAGE_FALLING:
+ case DAMAGE_DISARM:
+ case DAMAGE_HAZARD_CLEANUP:
+ case DAMAGE_TOPPLING:
+ case DAMAGE_SUBDUAL_MISSILE:
+ case DAMAGE_SUBDUAL_VEHICLE:
+ case DAMAGE_SUBDUAL_BUILDING:
+ case DAMAGE_SUBDUAL_UNRESISTABLE:
+ case DAMAGE_KILL_GARRISONED:
+ case DAMAGE_STATUS:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
{
}
@@ -2117,6 +2149,16 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraB
}
// a unit on a rank ladder takes its grade's rate of fire, damage and range instead of the global
+
+ // The lobby's handicap. In the bonus, so a shell or a delayed hit carries it past its firer's death.
+ // A point defense laser only shoots missiles, 100 damage at 100 health: one hit, one missile at any p.
+ const Int MISSILES_ONLY = WEAPON_ANTI_PROJECTILE | WEAPON_ANTI_SMALL_MISSILE | WEAPON_ANTI_BALLISTIC_MISSILE;
+ if (lobbyHandicapScalesDamage(m_template->getDamageType()) && (m_template->getAntiMask() & ~MISSILES_ONLY) != 0)
+ {
+ const Real handicap = source->getOwnerHandicap();
+ if (handicap != 1.0f)
+ bonus.setField(WeaponBonus::DAMAGE, bonus.getField(WeaponBonus::DAMAGE) * handicap);
+ }
// VETERAN, ELITE and HERO lines, and from the Veteran pin its side's own lines (China's horde)
const ThingTemplate* sourceTemplate = source->getTemplate();
const RankLadder* ladder = TheGlobalData->getRankLadder(sourceTemplate);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
index d7f6da1b0..951cd2a0c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
@@ -1560,7 +1560,13 @@ void GameLogic::startNewGame( Bool loadingSaveGame )
d.setInt(TheKey_multiplayerStartIndex, slot->getStartPos());
// Player's Handicap reads it; absent at full health, so such a seat's dict is the one it always was
if (slot->getHandicap() != HANDICAP_FULL)
- d.setReal(TheNameKeyGenerator->nameToKey("HANDICAP_MAXHEALTH_GENERIC"), slot->getHandicap() / (Real)HANDICAP_FULL);
+ {
+ const Real handicap = slot->getHandicap() / (Real)HANDICAP_FULL;
+ d.setReal(TheNameKeyGenerator->nameToKey("HANDICAP_MAXHEALTH_GENERIC"), handicap);
+ d.setReal(TheNameKeyGenerator->nameToKey("HANDICAP_MAXHEALTH_BUILDINGS"), handicap);
+ d.setReal(TheNameKeyGenerator->nameToKey("HANDICAP_BUILDTIME_GENERIC"), 1.0f / handicap);
+ d.setReal(TheNameKeyGenerator->nameToKey("HANDICAP_BUILDTIME_BUILDINGS"), 1.0f / handicap);
+ }
// d.setBool(TheKey_multiplayerIsLocal, slot->isLocalPlayer());
// d.setBool(TheKey_multiplayerIsLocal, slot->getIP() == game->getLocalIP());
//
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
index 2cf93fb07..eab2da4f6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
@@ -1465,6 +1465,8 @@ static Bool executePower( const ScenarioAction &action, Player *player, const Co
}
if (obj->isDisabled())
+ DEBUG_LOG(("SCENARIO: frame %d power slot %d '%s' %s: logic frame %u, ready on %u\n", action.frame, action.slot,
+ action.selector.str(), power->getPowerName().str(), TheGameLogic->getFrame(), power->getReadyFrame()));
{
// the seat's whole grid, since one building that draws more than its plants make is the usual cause
DEBUG_LOG(("SCENARIO: frame %d power: '%s' is disabled (underpowered %d: seat makes %d, draws %d)\n",