IsValid on a spawned creative_prop, never returns false. So currently we cannot check if a spawned prop was destroyed by a player.
Steps to Reproduce
Destroy a spawned prop.
Test is Valid
notice it returns true even after it is destroyed.
Expected Result
Is Valid returns false.
Observed Result
Is valid never returns false.
Platform(s)
All.
Additional Notes
We can no longer damage or bosses /props/objects based on weapon damage.
we cannot check if it’s destroyed unless it’s attached to a prop_manipulator_device which we can only attach in the editor. So atm we cannot know at runtime if our spawned prop is destroyed.
I managed a rather hacky workaround for this issue. My props in question move around the map. I now check if they moved successfully to the new location after a call to TeleportTo[]. If they did not, I assume they are no longer valid and I call Dispose(). After calling Dispose() on a prop, any call to IsValid[] now correctly returns true.
Pseudo code:
OldPosition := Prop.GetTransform().Translation
NewPosition := OldPosition + vector3{X:=1.0, Y:=0.0, Z:=0.0}
if (Prop.TeleportTo[NewPosition, IdentityRotation()]):
CheckPosition := Prop.GetTransform().Translation
Diff := CheckPosition - OldPosition
if (Diff.Length = 0):
# We didn't teleport to new position!
Prop.Dispose()
:
:
# somewhere else in code, this will now return true for disposed prop
if (not Prop.IsValid[]):
# do stuff
Note: TeleportTo[] does not seem to fail if a prop is not valid.
I realize this is less than ideal and won’t work for everyone. If you are already moving props within your game loops, this could help.
Thank you for jumping on this so quickly! Here’s the code for our tycoon: 5200-1145-5588. The firing range section is impacted by this. When you eliminate a FOAD prop in the range, it is supposed to increase a players money and increment the two UI elements below. It still triggers the explosion effect showing the sprite for money awarded, but money is not actually added to your score and the range does not level up.