Conditional Subtype on Unit X
Posted: Sun Sep 05, 2021 1:52 pm
				
				 Hi All
 
I'm rusty. With the code below I'm trying to simulate a 50% chance of a bailout from an aircraft that isn't the subtype 8201 (UAV). Problem is it is not excluding 8201. Code runs fine if I take out the if destroyedUnit.subtype ~= 8201. Feels like I'm missing something stupid. Can somebody take a look?
 
 
 
			I'm rusty. With the code below I'm trying to simulate a 50% chance of a bailout from an aircraft that isn't the subtype 8201 (UAV). Problem is it is not excluding 8201. Code runs fine if I take out the if destroyedUnit.subtype ~= 8201. Feels like I'm missing something stupid. Can somebody take a look?
local destroyedUnit = ScenEdit_UnitX()
if destroyedUnit.subtype ~= 8201 then
local aircrewsurvival = math.random(1,2)
if aircrewsurvival==1 then
local crew = ScenEdit_AddUnit({
type='Facility',
dbid=2441,
side=destroyedUnit.side,
name=destroyedUnit.name .. " " .. "Aircrew",
latitude=destroyedUnit.latitude,
longitude=destroyedUnit.longitude
})
end
end