# Melle Combat for top-down game

### » Sun Jul 01, 2012 6:16 pm

I have my enemies chase my player but when they catch him what is the best way to calculate damage. I would like to have it so they take so many hit points per second but I can't figure out how to make that work.

Also does anyone know of any good tutorials for the RTS movement. I got the basics down but I need to get some more complicated functions out of it.

Thanks again you guys are great.fiddilydee2012-07-01 18:17:01
B
4
Posts: 18
Reputation: 336

### » Mon Jul 02, 2012 12:06 am

Try using the System -> Time -> "every x milliseconds" or "every x ticks" event conditions.

For 1 second you can do "every 1000 milliseconds".
I don't know much about ticks and how they work.
B
8
S
2
Posts: 40
Reputation: 2,136

### » Mon Jul 02, 2012 5:42 am

dps is a complex theme.
It involves the player's hit rate and strength, and the enemy's defense:
If the player hits 1 time per second with a strength of 20, the dps is 20. If the enemy has a defense of 50%, it will take 10 hp per second.
If you change the player's hit speed to 5 times per second, the dps is 100 and the enemy would take 50 hp per second.
Or instead change the strength to 10, the dps is 10 and the enemy would take 5 hp per second.
Or change the defense to 20%, dps would still be 20, but enemy would take 16 hp per second.

Another way would be to not have any strength on the player's side, but let the enemy suffer as long as it collides with the player. Then you'd do something like
+ As long as they collide
-> reduce enemy's hp by 20 * TimeDelta
This would let lose the enemy 20 hp per second as long as they collide, no matter how often the player actually hits (animation-wise)

[QUOTE=aznmonkeyboy]I don't know much about ticks and how they work.[/QUOTE]
This post was once written to help people using "else", but deeply explains a tick also :)
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Tue Jul 03, 2012 12:51 am

Thanks alot, what I ended up doing is using the every x milliseconds. I set a private variable to 5 and every 10th of second the variable decreases by 1, you can only hit when the variable is 0, therefore, 2 hits per second. Works like a charm.
B
4
Posts: 18
Reputation: 336