Please help I'm stupid and illiterate

Get help using Construct 2

Post » 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
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » 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

Post » Wed Jun 04, 2014 5:36 pm

Well, just print the variables just before you destroy them
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » 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.

Try this instead:

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
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » 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.

Try this instead:

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

Post » 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 :D
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests