View unanswered posts | View active topics It is currently Mon Dec 30, 2024 11:09 pm



Reply to topic  [ 3 posts ] 
 Mission help 
Author Message
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post 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
Tue Jan 25, 2011 8:51 pm
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Mission help
The game does not actually crash, but lock up right? Check you while loop.


Wed Jan 26, 2011 8:51 am
Profile
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post 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.


Wed Jan 26, 2011 3:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.039s | 14 Queries | GZIP : Off ]