Damage Display [SOLVED>PROBLEM WITH AZU]

For questions about using Classic.

Post » Thu May 26, 2011 3:34 pm

Tulamide answered all questions perfectly. It was probably a bit shortsighted to make the example "hardcoded" with the 'BadGuy'-Sprite. I was mostly concerned with the method of displaying the numbers correctly. :?

But yes, Tulamide said it all. :D
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu May 26, 2011 4:42 pm

Actually, I managed to do that with Families. It's very useful ! You can put the damage on Enemy (family) position and not the "badboy" itself. Then of course, you have to put every enemies with the "Enemy"family.


I have several global variables for that :
Target_X
Target_Y
TargetHealth
TargetHealthMAX
TargetPower
TargetResist
TargetState
TargetWeakness
TargetEXP
TargetMoney


Here is some screens from my cap file :





B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Thu May 26, 2011 5:03 pm

Families are also a good way to solve this. Eventually you won't be able to put everything that is supposed to have damage displayed into the same family though, or you just plain don't like to bother with families. Personally I'd probably prefer to simply pass parameteres of whatever is being damaged to the function. But you know, whatever works. :)

The way you used a lot of globals there though confuses me a little to be honest. You use them to temporarily store the data of the current enemy? Of course I don't see the whole picture here, as there are only snippets of the event sheet, but I think you could be more efficient about it.

The enemy being attacked is going to be picked anyway, why is there the need to temporarily store its stats in globals and calculate the actual damage from that? It seems like an unnecessary step. :?
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu May 26, 2011 5:06 pm

I haven't think about this when I first code everything. I'm still a beginner with Construct ^^'. But thanks for the advice, I'll change it immedialty. But I'll keep "Target_X" and "Target_Y" because I need them for other things ;-).


Azu, I hope that you've solved your problem !
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Sat May 28, 2011 9:23 pm

Sorry to double post... but I still have a problem :(.

It seems that negative value (-5 for example) or float value (0.3 for example) will make strange things...

It will look like this :



I try to fix this with that condition :




Here is my damage formula:
[code:3avyqf8o]
round(((Hero.Value('Power')*1.2)-Enemy.Value('Resist')+random(15))*global('Factor'))+1
[/code:3avyqf8o]

[( (Power*1.2)-EnemyResist+random(0...14) )*Factor]+1
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Sat May 28, 2011 11:27 pm

[quote="Shiru":1wl6v3sx]
It seems that negative value (-5 for example) or float value (0.3 for example) will make strange things... [/quote:1wl6v3sx]

Well, the example is geared towards whole numbers, which is what you would normally want (and I guess you don't want it to actually have 0.6 or negative damage displayed).

This means you need to clamp the result of your calculation so it can't go below 0 and also round it in order to get whole numbers. Or floor/ceil it, depending on how you want it to behave. Check out the math expressions in the wiki.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat May 28, 2011 11:52 pm

Floor, Ceil, and I think you can use int, which will convert and float value to a integer.
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Sun May 29, 2011 12:23 am

Thanks to both of you ;-). It works like a charm ! :wink:
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Tue Jun 14, 2011 6:53 pm

Don't mean to raise the topic again. But, I have a question. I don't if anyone here has played disgaea. In disgaea, damage over 99,999 is display in 3 digits, with a K at the end of the number.


K=1000. 123,145 / 1000 = 123k. Like that. Over 100millionm is displayed by a "M". 100M = 100,000,000. So basically, I want to do something like that.
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Tue Jun 14, 2011 8:20 pm

[quote:2ll78eyg]Left(string, N)
Returns a string with the left N characters of string, eg. Left("Hello", 2) gives "He" [/quote:2ll78eyg]

That with a few subevents should work.
-if damage is greater than 1000 set text to left(variable "damage",3)&" k"
--if damage is greater than 1000000 set text to left(variable "damage",9)&" m"
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests