Random Grass script?

Discussion in 'Scripting' started by needarideyo, May 5, 2011.

  1. needarideyo

    needarideyo New Member

    Now, I've been playing Ody for several years now, and I was around during the original days of the Registry.

    I remember the original forums, though I believe they are gone now. The one thing I remember from the original forums was a script that you could attach to an object.

    When you used the object on an empty map, it would generate a Ground layer of grass, using the various grass tiles, as well as throwing in some grass tiles with flowers on them.

    I never did think to save all the scripts I saw on the original forums, so I believe they've all been lost now. Although when you use the built-in Map Editor in Odyssey Classic itself, the "Grass" button does the same thing that the script did. It generates a random Ground layer of grass tiles and grass w/ flower tiles.

    Anyone have that script lying around, or know how to script it?
     
  2. krum

    krum New Member

    I can't remember the exact functions, but the code will work like this:

    I can't remember the width/height of the screen, I am doing this from memory, but this will give you an idea.

    Code:
    Dim Tiles(0 to 6) As int
          
    Tiles(0) = 32                  //grass tile 32
    Tiles(1) = 41                  //grass tile 41
    Tiles(2) = 54
    Tiles(3) = 11
    Tiles(4) = 86
    Tiles(5) = 34
    Tiles(6) = 55
    
    for x = 1 to 16
      for y = 1 to 16
        dim randomval = (int) (Random() * 5)
        
        SetTile(x, y, Tile(randomval))
      next
    next
    I know this is not syntactically correct, but the idea is to loop through the x and the y and pick a random number starting at 0 ending at 5 (although I am unsure if this is the syntax for the random with ody, some return a float between 0 and 1 and some return integers.

    Set tile will most likely have more parameters, but I can't remember what they are, also as I stated above, 16 is most likely the wrong length and height.
     
  3. needarideyo

    needarideyo New Member

    Hmm. Well I'm no genius at scripting (though I do currently do some SourcePawn scripting for making SourceMod plugins, and the basic coding is very similar to the scripting used in Ody), but as far as I can see, the code looks good.

    I'll try it out.

    Any info on why the Registry is down and why I can't connect? Also, any chance of getting an Incog script? :p
     
  4. TheCord

    TheCord New Member

    Grass Script:
    This is the grass script I use although it depends on the grass that you would like to use. I could change it around for you if you'd like.
    Code:
    SUB Main(Player AS LONG)
    Dim Map AS LONG, X AS LONG, Y AS LONG
    Map = GetPlayerMap(Player)
    For X = 0 To 11
    For Y = 0 To 11
    If GetTileSprite(Map, X, Y, 0) = 0 Then
    Select Case Random(4)
       Case 0
          SetTileSprite(Map, X, Y, 0, 10014)
       Case 1
          SetTileSprite(Map, X, Y, 0, 10021)
       Case Else
          SetTileSprite(Map, X, Y, 0, 10016)
    End Select
    End If
    Next X
    Next Y
    UpdateMap(Map)
    End SUB

    Incognito Script:
    [Belongs in USEOBJ#, where the # is the number of the incognito object.]
    Code:
    Sub Main(Player AS LONG)
    SetPlayerSprite(Player, Random(180))
    End Sub
    The 180 can be changed as well to the last sprite available, I just tossed 180 in there.
     
  5. Mycal

    Mycal Staff Member

    I still can't find my scripts from my old servers, but I can probably whip up a new one. I actually wrote several of the auto mapping (auto-grass/link[based on free maps available]/trees based on how many maps x/y you wanted) scripts many people were using for awhile there so I should still have the originals somewhere, just no idea where.

    Speaking on free maps, I do want to put out an update that makes freemap scripts easier. It was unnecessarily complicated back when I made scripts when there are already builtin methods of checking which maps were free.
     
  6. krum

    krum New Member

    as to the script above, lets say you wanted to use more of a certain type of grass, then you would simply put it in more than one case statement to give it a better chance of being called. :D
     
  7. Alpha

    Alpha New Member

    Incognito Script:
    [Belongs in USEOBJ# where # is the object number in the Object Editor.]

    Code:
    Sub Main(Player as LONG)
    If GetPlayerStatus(Player) = 1 Then
        SetPlayerSprite(Player, Random(180))
    Else
        SetPlayerSprite(Player, Random(180))
        SetPlayerStatus(Player, Random(21))
    End If
    End Sub
    
    I used 180 and 21 as examples. Replace them with the maximum sprites/status'. Random might be changed to Rand, not sure, it's been a while. Also this makes it so players that have PK Status from killing another player will not be able to change their status with the incognito until they get rid of their PK Status, only their sprite.

    [ Post made via iPod ] [​IMG]
     

Share This Page