View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:30 am



Reply to topic  [ 5 posts ] 
 I'm having trouble with a script, help please 
Author Message
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post I'm having trouble with a script, help please
Hello everyone. I have been playing with the map C-Storm and I have run into a bit of a problem. Someone requested I make the storm contain small particles that match the terrain, so that it is more realistic and more like a sandstorm. I've done that, but there's a problem. The storm doesn't last nearly long enough. The storm doesn't provide the desired effect in such a short time because they are just single pixels instead of entire crabs like the vanilla version of this map. I have tried to edit all sorts of variables, yet none of them seem to work. Here is the code, could you help me find which variable alters how long the storm lasts? I've tested nearly all of them, so maybe there isn't a time variable... If there isn't could someone add one?

Code:
-----------------------------------------------------------------------------------------
-- Start Activity
-----------------------------------------------------------------------------------------

function Storm:StartActivity()
   print("START! -- Storm:StartActivity()!");
   StormTimer = Timer();
   STime = math.random(30000) + 45000;
   ActivityMan.ActivityState = Activity.EDITING;
   intensity = 1;

    for player = 0, self.PlayerCount - 1 do
        -- Check if we already have a brain assigned
        if not self:GetPlayerBrain(player) then
                self.ActivityState = Activity.EDITING;
                    playerActor = CreateAHuman("Ronin Soldier");
                   playerActor.Pos = Vector(600,450);
                   playerActor.Team = 0;
                   playerActor:AddInventoryItem(CreateHDFirearm("Medium Digger"));
                   MovableMan:AddActor(playerActor);
                   self:SetPlayerBrain(playerActor, 0);
                   self:SetLandingZone(playerActor.Pos, 0);
                   self:SwitchToActor(playerActor, 0, self:GetTeamOfPlayer(0));
            local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(player));
            -- If we can't find an unassigned brain in the scene to give each player, then force to go into editing mode to place one
            if not foundBrain then
                playerActor = CreateAHuman("Ronin Soldier");
               playerActor.Pos = Vector(600,450);
               playerActor.Team = 0;
               playerActor:AddInventoryItem(CreateHDFirearm("Medium Digger"));
               MovableMan:AddActor(playerActor);
               self:SetPlayerBrain(playerActor, 0);
               self:SetLandingZone(playerActor.Pos, 0);
               self:SwitchToActor(playerActor, 0, self:GetTeamOfPlayer(0));
            else
                -- Set the found brain to be the selected actor at start
                self:SetPlayerBrain(foundBrain, player);
                self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player));
                self:SetLandingZone(self:GetPlayerBrain(player).Pos, player);
                -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
                self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player);
            end
        end
    end
end

-----------------------------------------------------------------------------------------
-- Pause Activity
-----------------------------------------------------------------------------------------

function Storm:PauseActivity(pause)
   print("PAUSE! -- Storm:PauseActivity()!");
end

-----------------------------------------------------------------------------------------
-- End Activity
-----------------------------------------------------------------------------------------

function Storm:EndActivity()
   print("END! -- Storm:EndActivity()!");
end

----------------------------------------------------------------------------------------------------------
-- Update Activity
----------------------------------------------------------------------------------------------------------

function Storm:UpdateActivity()
   if StormTimer:LeftTillSimMS(STime) < 10000 and StormTimer:LeftTillSimMS(STime) > 0 then
      FrameMan:ClearScreenText(Activity.PLAYER_1);
      FrameMan:SetScreenText("STORM IN " .. math.ceil(StormTimer:LeftTillSimMS(STime)/1000) .. " SECONDS", Activity.PLAYER_1, 0, 5000, false);
   end

   if StormTimer:LeftTillSimMS(STime) < 500 and StormTimer:LeftTillSimMS(STime) > -500 then
      FrameMan:ClearScreenText(Activity.PLAYER_1);
      FrameMan:SetScreenText("oh god what is happening how did this get here", Activity.PLAYER_1, 0, 5000, false);
   end

   if StormTimer:LeftTillSimMS(STime) < 0 then
      if math.random() < intensity then
         local SandP = CreateMOPixel("Sand Particle");
         SandP.Pos = Vector(0,math.random(SceneMan.Scene.Height/2));
         SandP.Vel.X = -math.random(150) - 50;
         SandP.Team = -1;
         MovableMan:AddMO(SandP);
      end
      if StormTimer:LeftTillSimMS(STime) < -5000 then
         StormTimer:Reset();
         STime = math.random(10000) + 45000;
      end
   end
end


Last edited by Foogooman on Fri Jul 10, 2009 8:44 pm, edited 1 time in total.



Fri Jul 10, 2009 7:20 pm
Profile WWW
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: I'm having trouble with a script, help please
STime = math.random(30000) + 45000;

STime = storm time?


Fri Jul 10, 2009 7:34 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I'm having trouble with a script, help please
Mind wrote:
STime = math.random(30000) + 45000;

STime = storm time?


That's what I thought too but those are variables for the time in between storms.


Fri Jul 10, 2009 8:15 pm
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: I'm having trouble with a script, help please
Code:
if StormTimer:LeftTillSimMS(STime) < -5000

That's the line right here. LeftTillSimMS returns how long, in simulation time milliseconds, until something happens. This code is contained in a block that checks if STime has already passed, so this will give a negative result. So, -5000 is 5 seconds. If you wanted the storm to last 30 seconds, you would change it to -30000.


Fri Jul 10, 2009 11:05 pm
Profile WWW
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: I'm having trouble with a script, help please
mopixels dont have teams.


Fri Jul 10, 2009 11:52 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.043s | 13 Queries | GZIP : Off ]