Rpg inflict damage

Get help using Construct 2

Post » Mon Aug 20, 2012 3:02 pm

I create system of damaging enemy, when value attacks is 10 substract 10 from hp by hit. But it is possible to add expression which this change damaging type i mean substract 10 (+- 1) or + 10 % ?

https://dl.dropbox.com/u/44710358/rpg.capx
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Mon Aug 20, 2012 3:07 pm

if you mean randomly subtract 9 to 11 then:

subtract ATTACK - 1 + floor(random(3)) from HP

or if you want 10%:

subtract ATTACK - floor(ATTACK * 0.1) + floor(random(ATTACK * 0.3)) from HP
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Aug 20, 2012 3:14 pm

when my value damage shows 10 substract 10 + something when i add attack points to 15 substract 15 + something.

What means 'floor' before ()? i first time see this
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Mon Aug 20, 2012 3:21 pm

floor is rounding down - it acts like round() but when you have floor(1.9) it rounds down to 1 when round() rounds to 2, while ceil is the opposite it rounds always up, so ceil(1.1) becomes 2. useful with random().

back to your question, you can simply subtract 10 + something from HP you dont have to limit yourself to a value you can subtract a whole expression like 10 + variable1 * 2 - variable2 from HP.

or maybe i don't get the real issue here :(
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Aug 20, 2012 3:29 pm

Well it starts to work always substract 10 from hp + something like 1-4 :)

Ok when i check your option "floor(ATTACK * 0.1) + floor(random(ATTACK * 0.3)"


I change "floor(random(ATTACK * 0.3)" to "floor(random(1,5)"

And this is it! :) MANY THANKS !!!

Dziekuje :)delgado2012-08-20 15:35:31
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Aug 21, 2012 1:36 am

@ranma i have last question to you or anyone. How display text who tell us how many damage has been inflicted ?

Capx is updated
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Aug 21, 2012 8:59 am

you can create a text object and set its text to the same value that you subtracted from HP. give it a fade behavior with fade in 0, wait 1 and fade out 1, destroy after fade checked, and it will fade nicely every time you inflict damage.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Aug 21, 2012 11:32 am

@ranma yes i have this without right displayed text. I dont know how do this 'set text to the same value that you substracted from HP'
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Aug 21, 2012 12:30 pm

there is an event for text object: Set Text, you are using it on "dam" and "hp" objects.

create new text objects and set its text to floor(ATTACK * 1) + floor(random(1,5)) like you do for "dam".
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Aug 21, 2012 12:41 pm

@ranma I have already set substract 'floor(ATTACK * 1) + floor(random(1,5))'
now when i add this same expresions to 'set text' numbers displayed and substracted will be always different. I check this before
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Next

Return to How do I....?

Who is online

Users browsing this forum: Kagubro and 22 guests