Increase weapon values for a certain period of time

hello, can anyone tell me how to increase the values ​​of all the children contained in a structure?
what you see in the image below are the damage values ​​of the weapons contained in my game


I would like that when the player activates a certain power up the values ​​of all weapons are increased but only for a certain period.
when the time of the powerup ends the values ​​return to the origin again

As always, there are multiple ways.

The easiest way would be to use a multiplier variable. Set the variable to 1. Then when the powerup is collected, change it to say 1.1 for a 10 percent increase. Start a timer. When the time reaches the limit then delete the timer and set the variable back to 1

If you’re using the health behavior then apply a damage of the weapon value times the variable.

A more flixible approach would be to use variable with both values. You could use 2 structure, one with 2 lists of weapons. Or you could use a list of weapons that have 2 children, one for the basic and one for the powerup.

You would then build the object name dynamically using a variable for the child name, similar to how I’m assuming you’re getting the current value.

The array approach would be more complex but would allow you to use different levels of increase.

Say you. Used 2 structures

Then you could apply the damage with

If you used a single list of weapons with structures for basic and powerup

Then you could reverse the child names.

So… For the multiplier, something like…

For the structure, something like

What I love about GD is there are so many ways of doing things. Someone else probably has another few methods.

2 Likes

I was looking into how to handle this and in my events the easiest way to do it seems to be this:


is it possible to add 10% instead of increasing by +10
it only makes me add or subtract
ggg

To subtract an extra 10% just multiply bullets.damage by 1.1. But as @Keith_1357 wrote, you should put that damage multiplier in a variable (say named damageMultiplier) so the damage formula becomes bullets.damage * damageMultiplier.

So in your case, say the current weapon’s name is stored in the variable currentWeapon, it would be danno[currentWeapon] * damageMultiplier.

1 Like

so i put the value 10 to “damage multiplier” in a variable and multiplied when the enemy is hit “bullets.damage * damage multiplier” but it doesn’t work.
where am i going wrong this time?
dam

What is the error message when you edit the value? Do bullets have the variable damage? Is nemici.Hp a number?

Nemici.hp yes it is a value.
bullets is a group where there are all the weapons/projectiles that can create damage

Do all the projectiles or weapons have the variable damage? If not, that may be causing the error. You can try fixing it by adding the damage variable to the object group.

BTW, what is the error message from the red underline?

yes each weapon has a different damage.
this is a typical example inside each object there is the damage variable


while the value is read from this structure variable

this is the error it gives me:

anyway it doesn’t matter, attack increases by +10

I think that’s the wrong thing to do - you should work out why it’s wrong, because the reason could give problems elsewhere. The clue is in the error text:




which means this is incorrect: