Random damage and attr.

BellowBellow BartenderMember, PRO Posts: 227
Hello i am trying to make random damage system but i cant find anything so i will try to make that actor hit random dmg 2,6

and also trying to make there is a stat called str ( like rpg games) if you give it 1 stat your attack take +2 so if you got 1 str your dmg random 2,6 and if you make your str 2 you dmg will be 4,8 how can i make something like that ?

Thank you for your help and sorry for my bad english :)

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    There is a function in the expression window called random and you use it like this:

    random(2, 6)

    If you want to add a modifier to it you could do this:

    random(2, 6) + game.str
  • BellowBellow Bartender Member, PRO Posts: 227
    Ok i did it. I create a health bar and i said when it collide with enemy change health bar random(2,6) and when health bar gets 0 destroy actor and its working. So i now i want to show how much damage enemy hit so how can i do that ? I try to use display text show heath bar dmg but its not working.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Put the damage done that attack into another attribute, game or self, depending on how you want to show the damage i.e.

    Change Attribute: game.attackDamage = random(2, 6) + game.str

    Then deduct that from your health/health bar:

    Change Attribute: game.health = game.health - game.attackDamage

    You now have stored in a variable the damage done that attack (game.attackDamage) which you can show either in a display with a display text behaviour or use to spawn a graphical number above or around the player/enemy, like you see in RPGs.
  • BellowBellow Bartender Member, PRO Posts: 227
    Thank you :)
Sign In or Register to comment.