pioneerspacesim/pioneer — Issue #735: Crash and other oddity involving missiles
Author: Ziusudra
Created: 2011-10-27 10:05:28+00:00
State: open

* add the following script to modules folder
* start new game
* head out into space
* use console to call missile_test()
* then missile_test2()

After both missiles explode, the game crashes with a completely uninformative runtime error. (The first missiles explodes on reaching its target, the other because its owner was destroyed.)

For the other oddity, uncomment line 12. Missiles are spawned and then disappear and spam stdout with "missile leaves frame System".

```lua

local ships = {}

missile_test = function ()
local ship = Space.SpawnShipNear('Eagle Long Range Fighter', Game.player, 1, 3)
ship:SetHullPercent(1)
ship:AddEquip('MISSILE_NAVAL', 1)
ships[1] = ship
ship = Space.SpawnShipNear('Eagle Long Range Fighter', Game.player, 1, 3)
ship:SetHullPercent(1)
ship:AddEquip('MISSILE_NAVAL', 1)
ships[2] = ship
--	missile_test2()
end

missile_test2 = function ()
if ships[1]:FireMissileAt('MISSILE_NAVAL', ships[2]) then
print('missile_test: '..ships[1].label..' fired missile at '..ships[2].label)
end
if ships[2]:FireMissileAt('MISSILE_NAVAL', ships[1]) then
print('missile_test: '..ships[2].label..' fired missile at '..ships[1].label)
end
end

local onShipDestroyed = function (ship, attacker)
if ships[1] == ship or ships[2] == ship then
print('missile_test: '..ship.label..' destroyed by '..attacker.label)
end
end
EventQueue.onShipDestroyed:Connect(onShipDestroyed)
```