Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missile firing during paused game #5926

Open
dr-pegasus opened this issue Sep 30, 2024 · 2 comments
Open

Missile firing during paused game #5926

dr-pegasus opened this issue Sep 30, 2024 · 2 comments

Comments

@dr-pegasus
Copy link

dr-pegasus commented Sep 30, 2024

Observed behaviour

Missiles can be fired (spawned) when the game is paused.
Instead of seeing a swarm of missiles flying toward the target, there is very high risk of blowing up the player's own ship.

My version of Pioneer:
pioneer-20240710-win

This probably is just an unhappy behavior, rather than a legit bug.
However, I recommend adding pause check like this, in \data\libs\Ship.lua

function Ship:FireMissileAt(which_missile, target)
	local missile_object = false
	local game_paused = (Game.GetTimeAcceleration() == "paused") and true or false
	if type(which_missile) == "number" and (not game_paused) then
		local missile_equip = self:GetEquip("missile", which_missile)
		if missile_equip then
			missile_object = self:SpawnMissile(missile_equip.missile_type)
			if missile_object ~= nil then
				self:SetEquip("missile", which_missile)
			end
		end
	elseif (not game_paused) then
		for i,m in pairs(self:GetEquip("missile")) do
			if which_missile == "any" then
				missile_object = self:SpawnMissile(m.missile_type)
				if missile_object ~= nil then
					self:SetEquip("missile", i)
					break
				end
			end
		end
	end
...
end
@impaktor
Copy link
Member

impaktor commented Oct 1, 2024

Care to do a pull request?

@sturnclaw
Copy link
Member

A better solution would be to fix this in the UI code which implements the missile button. Simply checking for game paused before calling Ship:FireMissileAt() would be fine.

Given that Ship:FireMissileAt() is mid-refactor in #5734 any changes to that function directly are going to cause merge conflicts one way or another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants