How do I manage events on objects not created yet ?

Get help using Construct 2

Post » Sat Nov 12, 2016 3:01 am

Hi guys, here's a hard one :

I'm trying to create a Tower Defense game.

Currently, I have only one type of turret possible, the basic gun turret with a turret behavior, which shoots bullets with a bullet behavior. So far so good.

As in 99% of Tower defense games, you may place more than one of the same turret type, right ? Right.
But I also would like to be able to upgrade my turrets individually, and not all the same turrets of the same type at once.

So I have to create a container with all upgrade buttons I have, and associate them with my tower, to make each same upgrade buttons associated with their own tower, and all distinct from each others, right ?

This way, every single tower (of the same type) will have its own upgrade options, and their variables will be independent too (range, speed, power, etc...)

______________________________________________

Now comes the hard part : The only way I can think of to upgrade bullet power is to set a variable somewhere (supposedly inside the bullet) that reduces the enemies life by the value of that variable, which represent the damage the bullet does. Which mean I need the bullets to be in the same containers as the turrets, because if not, every single bullet is gonna share a single power variable, and upgrading towers individually will work, but not for bullet power, because turret firepower is not relative to the tower, but to its bullet. (stop me if i'm wrong so far)

BUT ! If I include bullets in the same container as the turret, then the turret is gonna be destroyed as soon as the bullet gets destroyed/another turret may spawn when a turret shoots (spawns) a bullet...

So I am cornered. No way to make bullets separate from each other in properties without including the tower they originate from in the same container, which creates various problems.

So here is the question : How do I make my bullets make a certain amount of damage to enemies , depending of which tower they have been fired from ?

Good luck.... And thank you very much to anyone who will try to help :)
B
9
S
3
G
1
Posts: 21
Reputation: 1,167

Post » Sat Nov 12, 2016 4:41 am

You can potentially do this by making different bullet objects for different levels of turret. So something like,

On Turret shoot
[sub-event] Turret lvl=1 --> Shoot Bullet1
[sub-event] Turret lvl=2 --> Shoot Bullet2
etc.
B
49
S
23
G
17
Posts: 291
Reputation: 12,407

Post » Sat Nov 12, 2016 5:01 am

Hi SupWithThat? :)

Thank you for you answer. This is a solution indeed, however this would mean having as many bullets objects as I have of levels of power, times the numbers of turret I will have in the future, which could be maybe 10 (no idea yet), resulting in hundreds of bullets and hundreds of events...

Not suitable i'm afraid. But thanks for your reply !
B
9
S
3
G
1
Posts: 21
Reputation: 1,167

Post » Sat Nov 12, 2016 5:21 am

You don't need the bullets in a container. Spawn the bullet and store the turret's UID, so you can pick it again in the future when you need to reference the master object (turret).
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Nov 12, 2016 9:33 am

For my main game, which is quite large, I have a layout called "Layout of Things" here I place all the things that spawn at some point in the game so that I can reference them. In smaller games I just place them in the layout but outside, on the grey area so that it's there but can't be seen.
B
13
S
2
Posts: 15
Reputation: 1,555

Post » Sat Nov 12, 2016 2:24 pm

blackhornet wrote:You don't need the bullets in a container. Spawn the bullet and store the turret's UID, so you can pick it again in the future when you need to reference the master object (turret).


Hmmm Im afraid I dont quite understand that. Im very new to this software... Could you explain a little bit for me please ?

Thank you :)
B
9
S
3
G
1
Posts: 21
Reputation: 1,167

Post » Sat Nov 12, 2016 5:03 pm

ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Nov 12, 2016 7:29 pm

Hi @blackhornet

Thank you so much for your reply ! I had a look on the finished product without looking a lot at the events yet, because I am trying to figure out things myself (as I wait for the answer), and Im actually pretty close !

I managed to select any turret I want (whether it has been created before or after start of layout), I managed to upgrade the "strength" of any turret I want independently, and now I'm just starting trying to apply "instance turret strength value" to "spawned bullet from same instance tower damage value".

However, I still have some trouble understanding the difference between "=" and "<>", but I do understand there is a difference between them, since "=" doesnt work and "<>" does work when I am clicking on a tower to select it, using a global variable "SelectedUID" set to the selected tower UID, and a boolean for towers to make the difference between a selected tower and the rest.

Another thing I have trouble with is the difference between "pick instance BY COMPARAISON" and "pick instance BY EVALUATE"... Any light on that matter would be absolutely delighful.

I did notice the "ParentUID" value in your event sheet, this might be the key to my upcoming challenge. :)

I will try to manage this myself for now, and if I really cannot do it, I will explore your event sheet. Copying things does not mean understanding it, and if I really want to be good at using this software, I need to understand it thoroughly.

But thank you so much for your answer, you demonstrated exactly what I wanted to do !
B
9
S
3
G
1
Posts: 21
Reputation: 1,167

Post » Sat Nov 12, 2016 11:18 pm

Why so difficult ?

Upgrade the towers. Including an instance variable for damage done by a bullet. Bullet has instance variable damage.
Right after spawning the bullet set its instance variable to the (up-gradable one) from the tower.
Compare on impact.
B
33
S
18
G
27
Posts: 2,436
Reputation: 20,336

Post » Sun Nov 13, 2016 6:33 pm

99Instances2Go wrote:Why so difficult ?

Upgrade the towers. Including an instance variable for damage done by a bullet. Bullet has instance variable damage.
Right after spawning the bullet set its instance variable to the (up-gradable one) from the tower.
Compare on impact.


This would make sense if I only had a single tower, no ?
If I create additionnal similar towers once the game is launched, I need to associate bullets to their parents tower in order to make a difference between bullet powers, fired by different towers with different power values. Im working on this right now.
B
9
S
3
G
1
Posts: 21
Reputation: 1,167

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests