Hey
I have a small problem with a gamemode i am working on. It is an extremely early build (if you even can call it that) and i can't seem to check if an MOSRotating is destroyed without a crash. It annoys me deeply as i have done it before but now it doesn't seem to work what ever i do.
Here is the code
Code:
function Battlegrounds:StartActivity()
-- Player brains
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if self:PlayerActive(player) and self:PlayerHuman(player) then
local Brain = CreateActor("Brain Case", "Base.rte")
Brain.Team = Activity.TEAM_1
Brain.Pos = Vector(120 + player * 16, 876)
MovableMan:AddActor(Brain)
self:SetPlayerBrain(Brain, player)
--self:SetObservationTarget(Brain.Pos, player)
self.activePlayer = player
end
end
self.Generators = {};
self.GeneratorsLight = {};
self.GeneratorsHeavy = {};
self.GeneratorsSniper = {};
self.GeneratorsTimer = {};
for i = 1 , 2 do
self.Generators[i] = CreateMOSRotating("Clone Generator" , "Battlegrounds.rte");
MovableMan:AddParticle(self.Generators[i]);
self.GeneratorsLight[i] = 4
self.GeneratorsHeavy[i] = 4
self.GeneratorsSniper[i] = 4
self.GeneratorsTimer[i] = 0
self.Generators[i].Team = 0
end
self.Generators[1].Pos = Vector(3984, 1008);
self.Generators[2].Pos = Vector(264, 1008);
ActivityMan:GetActivity():SetTeamFunds(0,0)
self.LZ = SceneMan.Scene:GetArea("LZ Team 1")
self.EnemyLZ = SceneMan.Scene:GetArea("LZ All")
collectgarbage("collect")
end
function Battlegrounds:UpdateActivity()
local i = 1;
while i == 1 or i == 2 do
if MovableMan:IsParticle(self.Generators[i]) and string.find(self.Generators[i].PresetName, "Clone Generator") then
local Spawnrate = self.GeneratorsLight[i] + self.GeneratorsHeavy[i] + self.GeneratorsSniper[i]
if Spawnrate ~= 0 then
self.GeneratorsTimer[i] = self.GeneratorsTimer[i] - Spawnrate
if self.GeneratorsTimer[i] < 0 then
self.Generators[i].Frame = self.Generators[i].Frame + 1
if self.Generators[i].Frame == 9 then
self.Generators[i].Frame = 0
--Spawn dude
local actor = CreateAHuman("Soldier Light");
actor.Team = self.Generators[i].Team;
actor:AddInventoryItem(CreateHDFirearm("Compact Assault Rifle","Coalition.rte"));
actor.Pos = self.Generators[i].Pos + Vector(0 , 100);
MovableMan:AddActor(actor);
end
self.GeneratorsTimer[i] = self.GeneratorsTimer[i] + 500
end
end
i = i + 1
end
end
if self.ActivityState ~= Activity.OVER then
ActivityMan:GetActivity():SetTeamFunds(0,0)
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if self:PlayerActive(player) and self:PlayerHuman(player) then
-- The current player's team
local team = self:GetTeamOfPlayer(player)
-- Check if any player's brain is dead
if not MovableMan:IsActor(self:GetPlayerBrain(player)) then
self:SetPlayerBrain(nil, player)
self:ResetMessageTimer(player)
FrameMan:ClearScreenText(player)
FrameMan:SetScreenText("Your brain has been destroyed!", player, 333, -1, false)
-- Now see if all brains of self player's team are dead, and if so, end the game
if not MovableMan:GetClosestBrainActor(team) then
self.WinnerTeam = self:OtherTeam(team)
ActivityMan:EndActivity()
end
end
end
end
end
end
Can anybody help me? Would be very appreciated