A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] 2 questions about damage dealing using random math

  1. #1
    Member
    Join Date
    Oct 2008
    Posts
    41

    [F8] 2 questions about damage dealing using random math

    In my current combat system, when the character attacks, I use this script.

    Code:
    _root.orchp -= random(40);
    so he only deals 0-40 damage to the orc.

    my question is, I want it to be 20-40 instead of 0-40, also, how can i turn that current attack into a variable so the damage you deal appears above the creatures head?

  2. #2
    Member
    Join Date
    Aug 2006
    Posts
    56
    For the second question, put a dynamic text box above the character's head and change your code to something along these lines:

    Code:
    _root.orchp -= Damage;
    Damage = random(40);
    As for the question about a minimum number of 20, ask somebody else.

  3. #3
    Member
    Join Date
    Oct 2008
    Posts
    41
    Thanks, I got the first one to work, I just used this code

    Code:
    _root.orchp -= Math.round((Math.random()*20)+30);

  4. #4
    do your smiles love u? slicer4ever's Avatar
    Join Date
    Dec 2005
    Location
    in a random occurance
    Posts
    475
    Code:
    _root.orchp -= 20 + random(20);
    pretty simple eh

  5. #5
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    If you want to display the damage of the attack, first put the value in a variable
    PHP Code:
    attackDamage 20+Math.random(20); 
    Then use that variable to decrement the enemy health and display the number where ever
    PHP Code:
    _root.orchp -= attackDamage;
    _root.myTextBox.text attackDamage+" damage delt!"
    Good luck!

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