Get help using Construct 2

### » Sun Jun 01, 2014 2:27 pm

How about you debug a bit?
Print DropRandom and Hurtables.DropProbability, I would bet you're not picking the right Hurtables
B
44
S
18
G
17
Posts: 2,249
Reputation: 17,585

### » Mon Jun 02, 2014 11:41 am

Whiteclaws wrote:How about you debug a bit?
Print DropRandom and Hurtables.DropProbability, I would bet you're not picking the right Hurtables

I tried, but nothing prints, probably because enemies die.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

### » Wed Jun 04, 2014 5:36 pm

Well, just print the variables just before you destroy them
B
44
S
18
G
17
Posts: 2,249
Reputation: 17,585

### » Thu Jun 05, 2014 1:21 pm

There seems to be a logic flaw in your probability/drop code

Set DropRandom to round(random(Hurtable.DropProbability,100))

This is setting DropRandom to a number between DropProbability and 100

With DropProbability = 98, DropRandom will be 98, 99 or 100

With DropProbability = 50, DropRandom will be 50, 51, 52, ... , 98, 99 or 100

That is DropRandom >= DropProbability

You are then checking:

DropRandom <= DropProbability

but it will never be less, and only sometimes equal.

Basically, at 98 you have a 1 in 3 chance of a drop and at 50 you have a 1 in 51 chance of a drop.

Set DropRandom to round(random(0,100))

DropRandom <= DropProbability

DropRandom will be a number from 0 to 100 and DropProbability should then work like the percentage chance you seem to have intended and if DropProbability is greater than or equal to DropRandom it will drop an item.
Find all the Construct 2 games that were on Steam Greenlight here
B
41
S
11
G
7
Posts: 511
Reputation: 7,326

### » Sat Jun 07, 2014 9:45 am

OddConfection wrote:There seems to be a logic flaw in your probability/drop code

Set DropRandom to round(random(Hurtable.DropProbability,100))

This is setting DropRandom to a number between DropProbability and 100

With DropProbability = 98, DropRandom will be 98, 99 or 100

With DropProbability = 50, DropRandom will be 50, 51, 52, ... , 98, 99 or 100

That is DropRandom >= DropProbability

You are then checking:

DropRandom <= DropProbability

but it will never be less, and only sometimes equal.

Basically, at 98 you have a 1 in 3 chance of a drop and at 50 you have a 1 in 51 chance of a drop.

Set DropRandom to round(random(0,100))

DropRandom <= DropProbability

DropRandom will be a number from 0 to 100 and DropProbability should then work like the percentage chance you seem to have intended and if DropProbability is greater than or equal to DropRandom it will drop an item.

Thank you very much! How do I give you cookies for this?
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

### » Tue Jun 10, 2014 3:08 pm

Thank you very much!

You're welcome.

How do I give you cookies for this?

Make a cookie eating game with C2 for me to play
Find all the Construct 2 games that were on Steam Greenlight here
B
41
S
11
G
7
Posts: 511
Reputation: 7,326

Previous

### Who is online

Users browsing this forum: ultrafop and 3 guests