@@ -22,7 +22,7 @@ local replenishGrenade = function(self, forceEquipGrenade)
22
22
if forceEquipGrenade or self .grenadeReplenishDelay < 100 then
23
23
self :modifyGrenadeCount (- 1 );
24
24
self .rootParent .UpperBodyState = AHuman .WEAPON_READY ;
25
- -- Only actually equip the grenade if the root parent was previously holding one, or we're forcing it to equip it. This avoids issues when, for example, removing a grenade from the root paren'ts inventory via Lua.
25
+ -- Only actually equip the grenade if the root parent was previously holding one, or we're forcing it to equip it. This avoids issues when, for example, removing a grenade from the root parent's inventory via Lua.
26
26
return (forceEquipGrenade or self .grenadePreviouslyHeldByRootParent ) and self .rootParent :EquipNamedDevice (self .grenadeTech , self .grenadeName , true );
27
27
else
28
28
self .grenadeReplenishGUITimer :Reset ();
@@ -91,7 +91,7 @@ function Create(self)
91
91
end
92
92
93
93
function Update (self )
94
- if self .rootParent and self .rootParent .Health > 0 and MovableMan :IsActor (self .rootParent ) then
94
+ if self .rootParent and self .rootParent .Health > 0 and MovableMan :ValidMO (self .rootParent ) then
95
95
local rootParentEquippedItemModuleAndPresetName = self .rootParent .EquippedItem ~= nil and self .rootParent .EquippedItem :GetModuleAndPresetName () or nil ;
96
96
local rootParentIsHoldingGrenade = rootParentEquippedItemModuleAndPresetName == self .grenadeObject :GetModuleAndPresetName ();
97
97
@@ -154,16 +154,37 @@ function Update(self)
154
154
end
155
155
156
156
function Destroy (self )
157
- if self .rootParent and MovableMan :IsActor (self .rootParent ) then
157
+ if self .rootParent and MovableMan :ValidMO (self .rootParent ) then
158
158
self .rootParent :RemoveNumberValue (self .bandolierKey );
159
159
end
160
160
if self .currentGrenadeCount > 0 then
161
+ local bandolierPosition = self .Pos ;
162
+ local bandolierVel = self .Vel ;
163
+ local bandolierRotAngle = self .RotAngle ;
164
+ local bandolierAngularVel = self .AngularVel ;
165
+
161
166
if self .grenadePreviouslyHeldByRootParent then
162
- self .grenadePreviouslyHeldByRootParent .ToDelete = true ;
167
+ if MovableMan :ValidMO (self .grenadePreviouslyHeldByRootParent ) and not self .grenadePreviouslyHeldByRootParent :IsActivated () then
168
+ self .grenadePreviouslyHeldByRootParent .ToDelete = true ;
169
+ self :modifyGrenadeCount (1 );
170
+
171
+ bandolierPosition = self .grenadePreviouslyHeldByRootParent .Pos ;
172
+ bandolierVel = self .grenadePreviouslyHeldByRootParent .Vel ;
173
+ bandolierRotAngle = self .grenadePreviouslyHeldByRootParent .RotAngle ;
174
+ bandolierAngularVel = self .grenadePreviouslyHeldByRootParent .AngularVel ;
175
+ end
176
+ end
177
+ if self .currentGrenadeCount > 0 then
178
+ self .bandolierObjectForDropping :SetNumberValue (" GrenadesRemainingInBandolier" , self .currentGrenadeCount );
179
+
180
+ self .bandolierObjectForDropping .Pos = bandolierPosition ;
181
+ self .bandolierObjectForDropping .Vel = bandolierVel ;
182
+ self .bandolierObjectForDropping .RotAngle = bandolierRotAngle ;
183
+ self .bandolierObjectForDropping .AngularVel = bandolierAngularVel ;
184
+
185
+ self .bandolierObjectForDropping .Mass = self .bandolierMass + (self .grenadeMass * self .currentGrenadeCount );
186
+
187
+ MovableMan :AddItem (self .bandolierObjectForDropping );
163
188
end
164
- self .bandolierObjectForDropping :SetNumberValue (" GrenadesRemainingInBandolier" , self .currentGrenadeCount + 1 );
165
- self .bandolierObjectForDropping .Pos = self .Pos ;
166
- self .bandolierObjectForDropping .Mass = self .bandolierMass + (self .grenadeMass * self .currentGrenadeCount );
167
- MovableMan :AddItem (self .bandolierObjectForDropping );
168
189
end
169
190
end
0 commit comments