User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 28

Thread: How to randomly populate treasure chests?

  1. #1
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to randomly populate treasure chests?

    Hello.
    I am building a treasure hunting/dungeon type game where there are:

    - 200 rooms
    - 100 treasure chests in the same places in 100 of the rooms
    - 25 pieces of treasure, randomly distributed at the start of each new game within those 100 chests

    My question is: how do I populate those chests? Some sort of array possibly?

    I have built 2 test rooms linked together and can run between them, have programmed an enemy for testing but just can't get my head around how to populate the chests randomly and ensuring that we only have 25 pieces of treasure in them!

    Thanks in advance,
    Tim.

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLC
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    You will need:

    1) A value or flag indicating whether or not a chest holds a treasure
    2) A fast loop

    *At start of frame
    -> Start loop "populateChests" 25 times
    *On loop populateChests
    +Chests flag 0 off (does not contain treasure)
    +Pick chest at random
    ->Set Flag 0 on

  3. #3
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    Thanks asker, I will start looking into this tonight.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    If you mean that you need to find 25 different treasures?
    You can just instead of populating at beggining. Make a drop table.
    So when you open the chest it picks a random treasure you haven't yet found and gives it to you.

  5. #5
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    Ah that sounds interesting but not heard of them before. So when I open a chest I can do a random roll on whether a piece is in that particular chest and if it is, I can loot it. But if it is not in that chest I move on to the next one?

    And if so, will this also allow us to ensure that there are always 25 pieces spread throughout the game as it is crucially important that the player always ends up with 25 pieces so that they can complete the game?

  6. #6
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    And by drop table, we are talking an array of some sort I am guessing?

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    You can do this rather simpler than using an array.

    You have those treasures as actives you can just do this=

    on chest opened
    chance 25% out of 100%
    treasure flag 0 off?
    pick object treasure at random
    -
    set treasure flag 0 on

    And that's it, you can also do a pre-condition for 100% result if player didn't have much luck on chances.

    before chest open
    (flag 0 was set on to all previously opened chests)

    chest flag 0 off
    treasure flag 0 off
    count no of objects(chests) = count no of objects(treasure)
    Set chance of success to 100%

  8. #8
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    Thanks very much, have just got in and am going to start trying to wrap my head around this!

  9. #9
    No Products Registered

    Join Date
    Dec 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    Hmm, well I can't get my head around either suggestion, but would a way to do this be to use a Global Variable for each chest (although this would lead to 100 of them!)? No idea as yet how to do this randomly, but by setting, say, Chest1 to "0" and Chest2 to "1" ("1" meaning there is a treasure in the chest) this would seem to do the trick. My concern is whether this a long-winded way of doing things, with 200 rooms to do and 1000s of active objects, I am going to need to be as slick as possible!

    Just to reiterate: I basically need to do a mass population of the 25 treasures in 25 of the 100 chests at the start of Frame 1 and do it on a random basis.

  10. #10
    Clicker Multimedia Fusion 2

    Join Date
    Jun 2007
    Location
    Suffolk, UK
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to randomly populate treasure chests?

    I'd go with asker's solution. It's very easy to implement and will give you the 25 treasure chests randomised each time. asker's put the basic code you'll need there as well.
    If you are not sure how to use fast loops, I'm pretty sure there's a tutorial for them on the tutorials page

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Making Treasure Chests
    By ZayLong in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 6th November 2014, 01:40 AM
  2. Treasure Scratch
    By Jeff in forum iOS Released Games & Apps
    Replies: 1
    Last Post: 10th November 2011, 06:17 PM
  3. Populate a combo box with SQL Server databases?
    By RGBreality in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 11th October 2011, 03:14 PM
  4. Random Treasure Example for timcclayton
    By TreeHugger in forum File Archive
    Replies: 3
    Last Post: 11th November 2010, 10:57 AM
  5. Random Treasure
    By tonycrew in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th May 2010, 04:03 AM

Posting Permissions

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