Page 1 of 3 123 LastLast
Results 1 to 10 of 22

  Click here to go to the first Developer post in this thread.  

Thread: Random Weather in MP

  1.   Click here to go to the next Developer post in this thread.   #1
    In one of my MP missions I have:
    1. ceated random time of day after loading mission
    2. created a random length fog in the morning
    3. a random overcast to occur during a 24h period

    The problem is that the Random() function is used to generate random times for all these functions. If I put a Random() in a trigger or script, it is executed on all client machines seperatly giving different random numbers.

    I tried using PublicVariable and that does not help. ***Is there a simple way to pass Variables in this sim?

    The solution I came up with is placing a GameLogic Object at some known coords on the map with a placement radius of 1/2 of what I want the maximum random number to be. ***Reading the X ***or Z coords of the GameLogic objects after the mission starts and doing some subtracting will provide a random number that all clients can access.

    Anyway, there should and probably is a proper way to pass variables to all clients.

  2. #2
    Lance Corporal
    Join Date
    Nov 6 2001
    Location
    deepdown in the bowls of ####
    Posts
    52
    This is a very simple script to change the weather, fog level, date and time of day at the start of the mission. It can be useful to add variability to missions.

    Script "environment.sqs"

    -----

    ; Set weather type:
    _W = Random 1
    0 setovercast _W

    ; Set fog level:
    _F = Random 1
    0 setfog _F

    ; Change date (note 8760 = 365days * 24 hours):
    _D = Random 8760
    skiptime _D

    ; Exit the script
    exit

    ------

    It is important to set the date and time of the level in which you use this script to January 1st, at 0000hrs as it uses the SkipTime function to add a random number of hours to this time.

    You can call this through another initialise script, or by placing the following line into a "true" trigger or unit's Initialize line:

    [] exec "environment.sqs"

    One thing I'll add is that you might want to change the fog random number to 0.5 instead of 1. I tried a mission last night which had a fog level of 0.98 - it was practically impossible to play - I couldn't see 3ft in front of me!

    i found this somewhere might be helpfull to ya

  3.   Click here to go to the next Developer post in this thread.   #3
    O=FP^2
    Join Date
    Nov 7 2001
    Location
    Canada
    Posts
    6,757
    Author of the Thread
    Thanks but this script will still create different weather and time for every client in a MP game. As far as I know.

    The trick I am looking for is to make sure it is the same on all clients.

  4. #4
    Lance Corporal
    Join Date
    Nov 6 2001
    Location
    deepdown in the bowls of ####
    Posts
    52
    ahh ok ill look into that

  5. #5
    </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Quote: from bn880 on 8:39 am on Nov. 8, 2001
    Thanks but this script will still create different weather and time for every client in a MP game. As far as I know.

    The trick I am looking for is to make sure it is the same on all clients.
    [/QUOTE]<span id='postcolor'>

    Try this idea.

    Create two 5t trucks named tFog and tOvercast and place far away. (or put underground)
    After start mission start script
    [tFog, tOvercast] exec "enviroment.sqs"
    ;-------------------------
    _Fog = _this select 0
    _Over = _thist select 1
    _fog setdammage random 1
    _Over setdammage random 1
    ;
    ~1
    0 setfog getdammage _fog
    0 setovercast getdammage _Over
    exit
    ;-------------------------

    Heh. šUsing two trucks for global variables.

    P.S. How u using publicVariable?

    Like this?
    ;-------------------------
    _fog=random1
    _over = random 1
    PublicVariable _fog
    PublicVariable _over
    ~1
    0 setfog _fog
    0 setover _fog
    exit
    ;-------------------------



    (Edited by Shirson at 6:52 pm on Nov. 8, 2001)

  6.   Click here to go to the next Developer post in this thread.   #6
    O=FP^2
    Join Date
    Nov 7 2001
    Location
    Canada
    Posts
    6,757
    Author of the Thread
    Yes well that's alot like placing GameLogic objects in a random pos and getting their X&#0124;Y&#0124;Z. I think your way is simpler but generates a number from 0 to 1, I actually need different maximum value random numbers such as 0-2 and 0-24.
    I guess I can just multiply the truck damage by 2 or 24.

    I used public variable like this:
    ---------------------------------
    PublicVariable "startOvercast"

    startOvercast = Random 24
    .
    .
    ---------------------------------

    Even your method is just a workaround to something that should or is implemented in the game (passing variables) 8¬)

  7. #7
    Staff Sergeant
    Join Date
    Sep 20 2001
    Location
    Angwin, CA, USA
    Posts
    260
    How exactly does it work in MP when everyone has different random numbers? Everyone gets different time/weather/fog and play continues normally? What happens if you try to do something like a SetPos with a random number? The bad guy is in a different spot for everyone? Seems like this would start to break things...

  8.   Click here to go to the next Developer post in this thread.   #8
    O=FP^2
    Join Date
    Nov 7 2001
    Location
    Canada
    Posts
    6,757
    Author of the Thread
    Yes, this means there is different time/rain/fog for everyone...

    If you do SetPos then the object position will be the same for everyone. If two clients do a SetPos then the one that executes later is going to determine the final position of the object. I am sure even this can break multiplayer games.

  9. #9
    I also have the same problem. I think that solution with vehicles is quite s**tty, also in 24 players game there would be 24 clients trying to change the position of the vehicle... Is there any chance to check out if script is running on server or on client, so we could perform random functions only on server? I would also like to get the answer from one of the developers...

  10. #10
    Staff Sergeant
    Join Date
    Sep 20 2001
    Location
    Angwin, CA, USA
    Posts
    260
    </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Quote: from HappyG on 6:51 pm on Nov. 19, 2001
    I also have the same problem. I think that solution with vehicles is quite s**tty, also in 24 players game there would be 24 clients trying to change the position of the vehicle... Is there any chance to check out if script is running on server or on client, so we could perform random functions only on server? I would also like to get the answer from one of the developers...[/QUOTE]<span id='postcolor'>

    I saw this on one of the boards. I haven't had a chance to try it yet, so hopefully someone more knowledgable will comment if I make a mistake with it

    Make a game logic item on your map, call it Server. Now, you can use the Local command to see if the map is on the server or not

    ? (local Server) : goto "Server"
    ? !(local Server) : goto "Client"

    #Server
    //Server Code Here

    #Client
    //Client code here

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •