Probability of dynamic event? Help code

BrackAttackBrackAttack Member Posts: 22
edited January 2012 in Working with GS (Mac)
How would you code this: My character is awarded a sword once in game. There are 5 possible sword types he might get. But, each type had different rarity. He will either get a diamond sword 5% chance, gold sword 10% chance, a silver sword 10% chance, steel sword 40% chance, or a bronze sword 35% chance.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited January 2012
    you could pull a random number, say random(1,15)

    then have rules if random number is equal to or greater then 1, but equal to or less then 5, get steel sword.
    If random number is greater then 5 but less then or equal to 9, bronze sword.

    and base probablities like that

    youll have to play around with how many numbers for each and stuff, but thats the idea

    cheers

    edit: beat by tshirt, and a fun way to experiment with tables, nice one t ;)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited July 2014
    Hi, basically you'll need an integer attribute (game). Let's call it Chance. This is set to the default 0.

    However your main character adds to his percentage, let's say it's by picking up a coin, in the coin Rule put
    When actor collides or overlaps with main character then
    Change attribute Chance to Chance + 1 ---- (or maybe Chance +5, depending on how much you want).

    In an actor off-screen, put a Rule:
    When Chance = 5 then
    ----ruling for your character to get diamond sword---

    When Chance = 10
    ----ruling for your character to get gold sword---

    etc.

    it's not possible to give more details without seeing your project but hopefully that'll give you a start.

    Edit: John beaten by TSB, both beat me! And by the sound of it they got it right: my suggestion doesn't use random, but allows for the main character to eventually collect all the swords.... I think I misunderstood...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BrackAttackBrackAttack Member Posts: 22
    Thanks peoples for fast reply!
Sign In or Register to comment.