Display text expression for displaying random dmg

natzuurnatzuur Member Posts: 304
edited November -1 in Working with GS (Mac)
Hey guys, hoping someone can help me with this because my brain is all mathed out right now.

Essentially I want to have a text displayed showing the actual random dmg done every time an actor ( in this case we'll call it enemy1) takes a random amount of dmg from another actor (missle1).

So what I have is a game attribute (real) for enemy HP which is set to 10. Then a rule in the the missile that says when overlaps or collides with enemy1 change attribute enemy.hp to enemy.hp-random(1,4). What expression can i use to get this to display the random amount of dmg done as a text every time it hits. The closest I got was creating another hp actor called max and then setting the value to 10 then doing (enemy.hp.max-enemy.hp) which will then count the dmg up, but not display the unique random dmg every hit without adding to the previous.

Anyway hope this makes sense and someone knows a solution.

Comments

  • wormilwormil Member Posts: 127
    attribute tmp = random(1,4)
    attribute enemy.hp = tmp
    display text tmp

    If this was actual code, you'd want to do one calculation and store it rather than do it several times, same applies here.
  • natzuurnatzuur Member Posts: 304
    wormil said:
    attribute tmp = random(1,4)
    attribute enemy.hp = tmp
    display text tmp

    If this was actual code, you'd want to do one calculation and store it rather than do it several times, same applies here.

    Hey thanks for the input! That seems likes it's on the right track, but when I put this in it's essentially changing the hp to a random 1-4 and then displaying that number every time (not sure if i did it wrong).

    What I need it to do is subtract from the attribute hp each time ( hp-random(1,4)) but show only the value of the random number being subtracted every time in the display text (text=random number that was subtracted from hp) this way it can still take a set amount of dmg before it dies, and you know how much dmg is being done each time the random hits..
  • wormilwormil Member Posts: 127
    yeah, sorry, just subtract, I was focused on the message and not the code.

    attribute tmp = random(1,4)
    attribute enemy.hp = attribute enemy.hp - tmp
    display text tmp
  • natzuurnatzuur Member Posts: 304
    Ohhhh that makes so much sense now! Can't believe I didn't see it before, this seems like it will come in handy for a lot of things when adapted. Thanks a ton!
Sign In or Register to comment.