A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: The use of 'random' in an RPG

  1. #1
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128

    The use of 'random' in an RPG

    Hi all!

    What I am trying to do is to make a final fantasy/pokemon RPG type battle scene where you selected the attack u want then the computer chooses theirs.

    But how do I go about the random attack made by the computer?

    Hope you understand what I mean!

    Regards,
    Stibily

  2. #2
    Lurker at Heart EgoAnt's Avatar
    Join Date
    Apr 2004
    Location
    The basement
    Posts
    314
    I would give a weight to each type of attack for each monster and then work from there. For example, if a monster had two types of attacks, physical and magical, you could give a weight of 70 to physical and 30 to magical, and then pick from there based on a random number.

    It would look something like this:

    code:

    physicalChance = 70;
    magicalChance = 30;
    monsterAttack = random(99)+1;
    if (monsterAttack <= physicalChance){
    showMonsterAttack("physical");
    }else{
    showMonsterAttack("magical");
    }



    Now this is just a loose sort of example. A lot more could be added to it that would make it a lot cooler.

    If you are using MX 2004 then I could go into a whole way of doing it that would be way better, as well as allow for more attack types, by using an object for the attack types, but I think that's for another day... Or at least for later in the day once I've had some coffee.
    Speed up your development time with well documented and easy to implement Flash components.
    That's what I do, I save people.... Save them from work. I'm like a slacker superhero, standing for truth, justice, and the consumption of sugary pastries.

  3. #3
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    thx a lot for ur help!

  4. #4
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    although...reading through wot u've said....im still not sure how I would set it up...could u send a .fla file?

    it would really help

    Regards,
    Stibily

  5. #5
    Lurker at Heart EgoAnt's Avatar
    Join Date
    Apr 2004
    Location
    The basement
    Posts
    314
    Hahaha, yeah, I could totally do that. Actually I have an RPG sample online that might prove useful to you, just go here:

    Xenotrader RPG Sample

    Bear in mind that this probably isn't exactly what you are looking for, but it might have some things in it you can use. I will try to get a sample .fla posted that will show exactly what you are looking for. Oh, by the way, what version of flash are you using?
    Speed up your development time with well documented and easy to implement Flash components.
    That's what I do, I save people.... Save them from work. I'm like a slacker superhero, standing for truth, justice, and the consumption of sugary pastries.

  6. #6
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    Thx...Im using Flash MX, not 2004.

    Hope this isn't too much trouble!

    Regards,
    Stibily

  7. #7
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    v6.0 in fact

  8. #8
    .: Weirded Out :. The_Xell's Avatar
    Join Date
    Nov 2002
    Location
    Under the table and dreaming...
    Posts
    802
    How about you take some time out to look at some tutorials, maybe not specifically for making final fantasy in flash, but each aspect of the game. For example, movement, randomization, etc.

    I'm sure if you try you could come up with something without relying on someone giving you a .fla.

    Oh, and you can EDIT posts.

  9. #9
    Lurker at Heart EgoAnt's Avatar
    Join Date
    Apr 2004
    Location
    The basement
    Posts
    314
    Ah, but if someone is willing to give him the .fla file, why not? I'll never understand why everyone gets so upset when people ask for help.

    Anyway, it's late, I just got home, and I still have work to do before bed, but I will try to get something online tomorrow.
    Speed up your development time with well documented and easy to implement Flash components.
    That's what I do, I save people.... Save them from work. I'm like a slacker superhero, standing for truth, justice, and the consumption of sugary pastries.

  10. #10
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    thx guys!

  11. #11
    x2i GingaNinja's Avatar
    Join Date
    Feb 2004
    Location
    England
    Posts
    217
    I have nearly finished an FFX-2 style ATB engine, i used the example i have included to tell enemies which character to attack using a random number (1 being character 1, 2 being character 2).

    You will hopefully be able to incorporate this method into other things like how much HP to take off in 1 hit.

    For Example:

    hp = random(100)+101;

    Will generate a random number between 100 and 200

    Hope this helps!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center