Object picking has stopped working correctly

For questions about using Classic.

Post » Thu Mar 17, 2011 2:55 am

I've been working on this game off and on for some months now. Now all of a sudden Many of the object picking has stopped working correctly

Such events as this.
On collision between sword and enemy ; Subtract from hp

It causes all enemies to lose health.

Why is this happening??? :(
B
2
G
3
Posts: 16
Reputation: 882

Post » Thu Mar 17, 2011 4:25 am

Whats picked first?
Sword or enemy?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Mar 17, 2011 12:26 pm

[quote="newt":rqe5cwgc]Whats picked first?
Sword or enemy?[/quote:rqe5cwgc]
Tried it both ways with no success.
B
2
G
3
Posts: 16
Reputation: 882

Post » Thu Mar 17, 2011 1:58 pm

In these scenarios it's best to post a .CAP file (uploaded to mediafire or something), or post screencaps of the event sheet in question.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Thu Mar 17, 2011 10:22 pm

[quote="Emperor Ing":3bpf621x]In these scenarios it's best to post a .CAP file (uploaded to mediafire or something), or post screencaps of the event sheet in question.[/quote:3bpf621x]
I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work.

I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

The event basically calls a random value then checks what item it should drop.

I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).
B
2
G
3
Posts: 16
Reputation: 882

Post » Fri Mar 18, 2011 5:16 am

[quote="zero_rogue":242yuwix]I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work. [/quote:242yuwix]
That's absolutely ok and understandable. But most then create a new example cap that shows the error. Helps a lot when several aspects come together that you are not aware of when trying to help.

[quote="zero_rogue":242yuwix]
I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

The event basically calls a random value then checks what item it should drop.

I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).[/quote:242yuwix]
This for example: I don't see the exact event. Basically, using 'else' can explain it.

When it comes to the action destroy, 'else' seems to not pick anything (not picking the opposite as one would expect). And if nothing is picked, Construct always refers to all instances.

[code:242yuwix]Enemy's health <= 0 and Already dropped = 0 -> do something
else -> destroy[/code:242yuwix]
Such a construct does not pick anything on the 'else' part and therefore destroy any enemy

[code:242yuwix]Enemy's health <= 0
Already dropped = 0 -> do something
else and Pick by enemy('health') <= 0 -> destroy[/code:242yuwix]
Such a construct would first make sure that any enemy with health <= 0 will drop and then destroy any enemy with health <= 0

But as I said, I don't see the exact events, so I don't know why 'else' is used. It isn't needed to let them drop and destroy them. This can be done in one step.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Mar 18, 2011 7:43 am

[quote="tulamide":2u5856s9][quote="zero_rogue":2u5856s9]I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work. [/quote:2u5856s9]
That's absolutely ok and understandable. But most then create a new example cap that shows the error. Helps a lot when several aspects come together that you are not aware of when trying to help.

[quote="zero_rogue":2u5856s9]
I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

The event basically calls a random value then checks what item it should drop.

I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).[/quote:2u5856s9]
This for example: I don't see the exact event. Basically, using 'else' can explain it.

When it comes to the action destroy, 'else' seems to not pick anything (not picking the opposite as one would expect). And if nothing is picked, Construct always refers to all instances.

[code:2u5856s9]Enemy's health <= 0 and Already dropped = 0 -> do something
else -> destroy[/code:2u5856s9]
Such a construct does not pick anything on the 'else' part and therefore destroy any enemy

[code:2u5856s9]Enemy's health <= 0
Already dropped = 0 -> do something
else and Pick by enemy('health') <= 0 -> destroy[/code:2u5856s9]
Such a construct would first make sure that any enemy with health <= 0 will drop and then destroy any enemy with health <= 0

But as I said, I don't see the exact events, so I don't know why 'else' is used. It isn't needed to let them drop and destroy them. This can be done in one step.[/quote:2u5856s9]

The event group is basically, this(its a bit bigger but just repeating events)

[code:2u5856s9]Enemy hp <= 0 -> set global variable drop to random(100)
value drop is between 0 and drop_array (1,1) -> destroy enemy
value drop is between drop_array (1,1) and drop_array (1,2) -> create item at (enemy.x, enemy.y), destroy enemy
value drop is between drop_array (1,2) and drop_array (1,3) -> create item2 at (enemy.x, enemy.y), destroy enemy
else -> destroy enemy[/code:2u5856s9]
The concept is that it draws a random number and then uses a drop table to check what drops, 0-x = nothing
x-y = item
y-z = item2
the else is really there in case something goes wrong.

Like i said before this system was limited and didn't have everything I wanted in it so I'm just going to redo it.
B
2
G
3
Posts: 16
Reputation: 882

Post » Sat Mar 19, 2011 2:17 am

A couple things.
Once hp goes to zero your continuously setting your global to random(100) in this scenario.
"Trigger Once" will fix that, as long as that sprite is still picked in the variable comparison in the sub events.
Also there is no "value between" expression so there could be some mix up there as well.
......But, and its a big but, the else is definitely your biggest issue.

Just so you know, you can still reference a destroyed object while still in the same event.
Given that little tidbit, I'd suggest adding a "drop" variable to the enemy object, instead of using a global.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Mar 19, 2011 5:26 am

[quote="newt":22oa4i3b]A couple things.
Once hp goes to zero your continuously setting your global to random(100) in this scenario.
"Trigger Once" will fix that, as long as that sprite is still picked in the variable comparison in the sub events.
Also there is no "value between" expression so there could be some mix up there as well.
......But, and its a big but, the else is definitely your biggest issue.

Just so you know, you can still reference a destroyed object while still in the same event.
Given that little tidbit, I'd suggest adding a "drop" variable to the enemy object, instead of using a global.[/quote:22oa4i3b]

The event group was designed to always destroy the enemy object no matter what. (hence why Iput a else statement into it to prevent the exact situation you mentioned. ) this way any enemy with 0 hp will only stay for one tick.

Also, there IS a value between condition its "Number in between..." In system
(highlighted in blue)
B
2
G
3
Posts: 16
Reputation: 882

Post » Sat Mar 19, 2011 6:04 am

That's correct, but system comparisons do not pick, or place objects into the selected objects list.
For example if you were to compare the enemy's private variable that way it would not pick that instance.
Same goes for system compare, or system evaluate.

Anyways, just pointing out the subtleties that might lead to more errors, like the fact that else doesn't take picked objects into account.
In fact once the else affects an object, and is triggered, including any held in subevents, all events that excluded it beforehand are thrown out the window.

[url:1r2yquyf]http://dl.dropbox.com/u/666516/ohshi.cap[/url:1r2yquyf]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests