Page 1 of 1

Fix to Linked Destroyables (FAQ)

Posted: Sun May 14, 2006 5:42 pm
by xwingguy
Problem is that if you repair the internal critical system and then somebody else blows up the EXTERNAL critical system YOU TAKE THE BLAME FOR THE DEATH OF THE INTERNAL SYSTEM. That's a whopping
-18 points.

IF YOU ARE MAKING A SPACE MODE WITH CRITICAL SYSTEMS, THIS IS VERY IMPORTANT!!!!!!!!

Here's how to fix it. (It's really easy)

Code: Select all

LinkedDestroyables = 
{
objectSets = nil,		
New = function(self, o)
	o = o or {}
	setmetatable(o, self)
	self.__index = self
	return o
	end,
	
	
	Init = function(self)
		--------------------
		-- Local functions
		--
	local ObjectKilled = function(setIndex)
	for _, objectName in pairs(self.objectSets[setIndex]) do
	if IsObjectAlive(objectName) then
		return
		end
	end
			
	--if you reach reach here, all the objects in the set are dead, so 
	--we need to now go and kill all the objects in the other sets
	for setIdx, set in pairs(self.objectSets) do
	if setIdx ~= setIndex then
	for _, objectName in pairs(set) do
	if IsObjectAlive(objectName) then
	SetProperty(objectName, "Team", 0) --<---INSERT THIS LINE!
	KillObject(objectName)
What that single extra line does is make the critical system worth 0 points. Problem Solved!!!

Edit: Clarification: this makes it so when the external system is destroyed the just internal system becomes 0 points and vice versa. So points are only awarded to the player who ultimately triggered the destruction.

Posted: Sun May 14, 2006 6:55 pm
by MercuryNoodles
Edit: This goes in Common/scripts/LinkedDestroyables.lua

Just to save everyone time and spare us questions.