Please help I'm stupid and illiterate

Get help using Construct 2

Post » Sat May 31, 2014 8:00 pm

So basically I have this code, where, when an enemy(aka Hurtables)dies(hp is below or equal 0), they drop an item, like, ammo for missiles, or hp. This event plays BEFORE the event where the enemy destroys itself.

Before, I had instance variables called Drop and DropRandom. Drop was either yes or no, and it basically said if the enemy dropped an item or not. DropRandom was a variable that, when the enemy dies, rolled a number from 0 to 5. If the number is 2, it spawned hp, and if it's 5, it spawned a missile pickup. Yes, it's dumb. But it worked.

What's not working is this. I replaced the Drop variable with a variable called DropProbability. If I wanted a Hurtable to not spawn anything, I would set the DropProbability to 0. And if I wanted a Hurtable to always spawn something, I would set the probability to 100 or 99. And that worked.

However, 98 is a different story. It's a number that is very close to 100, yet, when enemies die with DropProb set to 98, they only spawn anything half the time, and I checked that multiple times. And when I actually set DropProb to 50, IT DOESN'T SPAWN *ANYTHING*. Here's the main event:
Screen Shot 2014-05-31 at 1.50.45 PM.png


There's also only 1 event for each pickup when it is destroyed, that is, when it's picked up. That busts my theory that pickups instantly self-destroy when they spawn for no reason. :/
You do not have the required permissions to view the files attached to this post.
Last edited by fassFlash on Sun Jun 01, 2014 3:19 pm, edited 2 times in total.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sat May 31, 2014 8:20 pm

https://www.dropbox.com/s/htodmstra9gz2 ... er093.capx
Sorry, here's the capx. The code is in the "Common Sense" group.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sun Jun 01, 2014 10:35 am

Bam Bump.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sun Jun 01, 2014 11:21 am

Hey,

I have yet to fully learn how families work but as I understand it a family group is considered a separate object to the objects that are children of it.

What this means is when you have your actions call the families group it does not get your instanced variable for the object that is a child of it but the family object itself.

I have not found a way so far to reference dynamically the child objects of a family. And believe me I have been trying as it would save me about 200 events in my event sheets.
B
7
S
2
Posts: 32
Reputation: 541

Post » Sun Jun 01, 2014 11:35 am

dmurphy wrote:Hey,

I have yet to fully learn how families work but as I understand it a family group is considered a separate object to the objects that are children of it.

What this means is when you have your actions call the families group it does not get your instanced variable for the object that is a child of it but the family object itself.

I have not found a way so far to reference dynamically the child objects of a family. And believe me I have been trying as it would save me about 200 events in my event sheets.

Yes, but families also have instance variables which are given to the objects inside that family. You do that by pressing right click on the family and selecting the "add instance variable". In this case, hp is a variable of the family.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sun Jun 01, 2014 11:40 am

fassFlash wrote:
dmurphy wrote:Hey,

I have yet to fully learn how families work but as I understand it a family group is considered a separate object to the objects that are children of it.

What this means is when you have your actions call the families group it does not get your instanced variable for the object that is a child of it but the family object itself.

I have not found a way so far to reference dynamically the child objects of a family. And believe me I have been trying as it would save me about 200 events in my event sheets.

Yes, but families also have instance variables which are given to the objects inside that family. You do that by pressing right click on the family and selecting the "add instance variable". In this case, hp is a variable of the family.


Yes I know this but you still can not reference dynamically the object inside the family by using the family object as the event object. By doing this you are checking against the instance variables of the family object and not the object you want. I have not found a way as of yet to actually reference the object inside the family without making convoluted if - else if events for each and every object.
B
7
S
2
Posts: 32
Reputation: 541

Post » Sun Jun 01, 2014 11:47 am

dmurphy wrote:
fassFlash wrote:
dmurphy wrote:Hey,

I have yet to fully learn how families work but as I understand it a family group is considered a separate object to the objects that are children of it.

What this means is when you have your actions call the families group it does not get your instanced variable for the object that is a child of it but the family object itself.

I have not found a way so far to reference dynamically the child objects of a family. And believe me I have been trying as it would save me about 200 events in my event sheets.

Yes, but families also have instance variables which are given to the objects inside that family. You do that by pressing right click on the family and selecting the "add instance variable". In this case, hp is a variable of the family.


Yes I know this but you still can not reference dynamically the object inside the family by using the family object as the event object. By doing this you are checking against the instance variables of the family object and not the object you want. I have not found a way as of yet to actually reference the object inside the family without making convoluted if - else if events for each and every object.


Wait, but the code doesn't reference any family objects, only the family variables..
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sun Jun 01, 2014 12:00 pm

fassFlash wrote:
Wait, but the code doesn't reference any family objects, only the family variables..


Exactly, you are grabbing the variables not from the object you want but the arbitrary family object which will have different values to that of the objects variables you want.

Like I said though I am still getting to grips with families but from my experience and testing so far it seems you cannot reference variables on the fly of child objects like you are trying to do when you are looking for the drop probability variable.

The best I have found so far is to make an array such as the following:
Image

And for every monster assign it an NPC ID and look up the values you want in the array.
B
7
S
2
Posts: 32
Reputation: 541

Post » Sun Jun 01, 2014 12:08 pm

[quso far it seems you cannot reference variables on the fly of child objects like you are trying to do when you are looking for the drop probability variable.
OBJECTION! Before, I had both the Drop( yes or no) and DropRandom variable, and it worked perfectly!
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sun Jun 01, 2014 12:19 pm

fassFlash wrote:[quso far it seems you cannot reference variables on the fly of child objects like you are trying to do when you are looking for the drop probability variable.
OBJECTION! Before, I had both the Drop( yes or no) and DropRandom variable, and it worked perfectly!


Maybe I am wrong then, it's just from my tinkering what I have found. I was not able to reference object variables inside a family by doing what you are doing.
B
7
S
2
Posts: 32
Reputation: 541

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests