Data Realms Fan Forums
http://45.55.195.193/

Mission help
http://45.55.195.193/viewtopic.php?f=1&t=21260
Page 1 of 1

Author:  akblabla [ Tue Jan 25, 2011 8:51 pm ]
Post subject:  Mission help

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 :)

Attachments:
File comment: The rest of the mod
Battlegrounds.rte.rar [3.88 KiB]
Downloaded 122 times

Author:  Abdul Alhazred [ Wed Jan 26, 2011 8:51 am ]
Post subject:  Re: Mission help

The game does not actually crash, but lock up right? Check you while loop.

Author:  akblabla [ Wed Jan 26, 2011 3:20 pm ]
Post subject:  Re: Mission help

Thanks, that worked. God I am a ♥♥♥♥♥♥♥ for not seeing that myself.

Another problem. It locks up randomly when a actor dies. Is this a part of build 24 as I can't remember having those in build 23 and i believe i have met them in skirmish playing with one of my friends a while ago. If not, can someone help me with that too.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/