73
73
* 01/01/1995 JLB - Takes into account distance from damage source.
74
74
* 04/11/1996 JLB - Changed damage fall-off formula for less damage fall-off.
75
75
* ZivDero : Adjustments for Tiberian Sun
76
+ *
77
+ * @note: Originally, the function took `ArmorType armor` instead of `ObjectClass * target`.
78
+ * The single vanilla call site has been patched to take this into account.
79
+ *
76
80
*/
77
- int Vinifera_Modify_Damage (int damage, WarheadTypeClass* warhead, ArmorType armor , int distance)
81
+ int Vinifera_Modify_Damage (int damage, WarheadTypeClass* warhead, ObjectClass * target , int distance)
78
82
{
79
83
/* *
80
84
* If there is no raw damage value to start with, then
@@ -83,6 +87,8 @@ int Vinifera_Modify_Damage(int damage, WarheadTypeClass* warhead, ArmorType armo
83
87
if (!damage || Scen->SpecialFlags .IsInert || warhead == nullptr )
84
88
return 0 ;
85
89
90
+ ArmorType armor = target->Class_Of ()->Armor ;
91
+
86
92
/* *
87
93
* Negative damage (i.e., heal) is always applied full strength, but only if the heal
88
94
* effect is close enough.
@@ -104,15 +110,42 @@ int Vinifera_Modify_Damage(int damage, WarheadTypeClass* warhead, ArmorType armo
104
110
*/
105
111
if (warhead_ext->CellSpread < 0.0 )
106
112
{
107
-
108
113
/* *
109
- * Apply the warhead's modifier to the damage and ensure it's at least MinDamage .
114
+ * Apply the warhead's modifier to the damage.
110
115
*/
111
116
damage *= Verses::Get_Modifier (armor, warhead);
117
+
118
+ /* *
119
+ * Apply an extra modifier based on the object's type.
120
+ */
121
+ switch (target->RTTI )
122
+ {
123
+ case RTTI_INFANTRY:
124
+ damage *= warhead_ext->InfantryMultiplier ;
125
+ break ;
126
+ case RTTI_UNIT:
127
+ damage *= warhead_ext->VehicleMultiplier ;
128
+ break ;
129
+ case RTTI_AIRCRAFT:
130
+ damage *= warhead_ext->AircraftMultiplier ;
131
+ break ;
132
+ case RTTI_BUILDING:
133
+ damage *= warhead_ext->BuildingMultiplier ;
134
+ break ;
135
+ case RTTI_TERRAIN:
136
+ damage *= warhead_ext->TerrainMultiplier ;
137
+ break ;
138
+ default :
139
+ break ;
140
+ }
141
+
142
+ /* *
143
+ * Ensure that the damage is at least MinDamage.
144
+ */
112
145
damage = std::max (min_damage, damage);
113
146
114
147
/* *
115
- * Reduce damage according to the distance from the impact point.
148
+ * Reduce damage according to the distance from the impact point.
116
149
*/
117
150
if (damage)
118
151
{
@@ -164,9 +197,37 @@ int Vinifera_Modify_Damage(int damage, WarheadTypeClass* warhead, ArmorType armo
164
197
damage = std::max (0 , damage);
165
198
166
199
/* *
167
- * Apply the warhead's modifier to the damage and ensure it's at least MinDamage .
200
+ * Apply the warhead's modifier to the damage.
168
201
*/
169
202
damage *= Verses::Get_Modifier (armor, warhead);
203
+
204
+ /* *
205
+ * Apply an extra modifier based on the object's type.
206
+ */
207
+ switch (target->RTTI )
208
+ {
209
+ case RTTI_INFANTRY:
210
+ damage *= warhead_ext->InfantryMultiplier ;
211
+ break ;
212
+ case RTTI_UNIT:
213
+ damage *= warhead_ext->VehicleMultiplier ;
214
+ break ;
215
+ case RTTI_AIRCRAFT:
216
+ damage *= warhead_ext->AircraftMultiplier ;
217
+ break ;
218
+ case RTTI_BUILDING:
219
+ damage *= warhead_ext->BuildingMultiplier ;
220
+ break ;
221
+ case RTTI_TERRAIN:
222
+ damage *= warhead_ext->TerrainMultiplier ;
223
+ break ;
224
+ default :
225
+ break ;
226
+ }
227
+
228
+ /* *
229
+ * Ensure that the damage is at least MinDamage.
230
+ */
170
231
damage = std::max (min_damage, damage);
171
232
}
172
233
@@ -717,6 +778,8 @@ DECLARE_PATCH(_Do_Flash_CombatLightSize_Patch)
717
778
*/
718
779
void CombatExtension_Hooks ()
719
780
{
781
+ Patch_Byte (0x0058604A , 0x56 ); // push eax -> push esi; Modify_Damage originally takes ArmorType as its argument, we instead pass the target object
782
+
720
783
Patch_Jump (0x00460477 , &_Do_Flash_CombatLightSize_Patch);
721
784
Patch_Jump (0x0045EB60 , &Vinifera_Modify_Damage);
722
785
Patch_Jump (0x0045EEB0 , &Vinifera_Explosion_Damage);
0 commit comments