Discuss Scratch

xavilongo3
Scratcher
63 posts

Help with scrips

Hello!
I'm making a “tower defense” game.
I have a problem with a new tower I invented, it freezes enemies, it slows them down in 2 seconds. But I don't know why when they freeze for the second time they freeze for the whole time.
Here is the game:
https://scratch.mit.edu/projects/965491373
I've set it to start at $500 so you can see what's going on.
xavilongo3
Scratcher
63 posts

Help with scrips

And the same thing happened with the fire turret that has to take damage little by little. Both only work on strong enemies and normal enemies.
deck26
Scratcher
1000+ posts

Help with scrips

This is an odd one. If you change the wait to 1.5 seconds it works OK for me but fails if I increase the time above that which suggests there is something else happening in that time. Any ideas - you know your project better than anyone else does?

Note that the way you've coded it the speed is remembered at the start of a freeze so if an enemy is hit again while still frozen the old speed will be lost. Eg if speed is 5 and you're hit so the speed goes down to 3 the old speed of 5 is remembered but if hit again the variable is now overwritten with 3 so the speed goes down to 1 but only goes back up to 3, never back to 5. That may not be what you want.
xavilongo3
Scratcher
63 posts

Help with scrips

Thank you!
I've changed a few things and now the whole time stays frozen except for the last non-frozen enemy, who hit the ice. I think it's a TimeFreeze thing.
Can you also help me with the fire turret please?
deck26
Scratcher
1000+ posts

Help with scrips

What's the problem with the fire turret?
xavilongo3
Scratcher
63 posts

Help with scrips

What does each turret have to do?
Fire turret: causes damage little by little, as if the enemies were on fire.
Freezing turret: freezes enemies, slows them down for 2 seconds.
Problems:
Fire turret: only works on some enemies.
Freezing turret: freezes enemies permanently.
xavilongo3
Scratcher
63 posts

Help with scrips

Freezing turret: only happens if a turret freezes an enemy while it,s frozen, (2 freezing turrets are required).
xavilongo3
Scratcher
63 posts

Help with scrips

Please someone's help?
deck26
Scratcher
1000+ posts

Help with scrips

So where's the script that handles the fire damage?

My main problem in trying to help is that there is so much going on at once in your project. My preferred method of debugging such problems is to make a copy of the project and get rid of as much as I can that isn't relevant to the problem which makes it much easier to concentrate on the issue at hand and actually work out what is going on. I'd strongly recommend you do that. Another useful trick is to use the say block with clones to get an idea what they're doing - eg a clone can constantly say its HP value and you cna see when damage occurs.
xavilongo3
Scratcher
63 posts

Help with scrips

It is in Enemy and starts with when I receive FireHitsEnemy
when I receive [FireHitsenemy]
if <<touching [Fire] ?> and <not <touching [edge] ?>>> then
replace item (Clone#) of [EnemyHealth] with ((item (Clone#) of [EnemyHealth] :: list) - (fireDamage))
repeat (20)
wait (1) secs
replace item (Clone#) of [EnemyHealth] with ((item (Clone#) of [EnemyHealth] :: list) - ((fireDamage) / (10)))
end
end

xavilongo3
Scratcher
63 posts

Help with scrips

now I think the fire turret is working now and the ice turret is still to be fixed.

Last edited by xavilongo3 (March 19, 2024 14:01:52)

xavilongo3
Scratcher
63 posts

Help with scrips

I don't know how to fix the ice turret.
It only works when you only have one, if a frozen enemy is hit twice, it freezes permanently.
Does anyone know how to fix it, please?
deck26
Scratcher
1000+ posts

Help with scrips

Don't just change the speed of an enemy when you freeze it - check the current speed and only adjust if appropriate.
xavilongo3
Scratcher
63 posts

Help with scrips

How can I do that?
xavilongo3
Scratcher
63 posts

Help with scrips

I don't know why, but every time I do something new, there are more bugs or things that I don't know how to do, and I don't know how to fix them.
At the moment, there is the turret bug that when an enemy is hit twice with the ice turret, it freezes permanently. And when improving the turrets, in the ice turret, instead of improving the firing speed like the others, you can improve the freezing time.
(I have changed it because of the previous bug, because if the firing speed was faster with only one turret, I would have the permanent freezing bug)
But when trying to do that, new bugs have appeared, but I have been able to fix some, except the following ones:
The first one is that the option to improve the freeze time only appears with the ice turret, but with my script, it does what it wants; sometimes it appears and sometimes it does not.
And the second is that I don't know how to change the number that the enemy has to wait to defrost, which is in a list, to
wait () secs
I have written comments to the scripts that I think are wrong to make it easier for you and if you press q it give you money.
I hope you can answer me fast.
Thank you.
xavilongo3
Scratcher
63 posts

Help with scrips

The comments are in the sprites “millorar” “torreta” “enemy”
LushCaveGod
New to Scratch
28 posts

Help with scrips

xavilongo3 wrote:

I don't know how to fix the ice turret.
It only works when you only have one, if a frozen enemy is hit twice, it freezes permanently.
Does anyone know how to fix it, please?
Make A Broadcast Message To Wait Seconds Before Unfreezing And Make A Var To Dectect How Many Times It Got Shot

My Name Is My Minecraft Name (§aLush Cave God)
And I Love Pineapple on Pizza
xavilongo3
Scratcher
63 posts

Help with scrips

LushCaveGod wrote:

xavilongo3 wrote:

I don't know how to fix the ice turret.
It only works when you only have one, if a frozen enemy is hit twice, it freezes permanently.
Does anyone know how to fix it, please?
Make A Broadcast Message To Wait Seconds Before Unfreezing And Make A Var To Dectect How Many Times It Got Shot
And how can I do that?
loolooqq831
Scratcher
4 posts

Help with scrips

xavilongo3 wrote:

LushCaveGod wrote:

xavilongo3 wrote:

I don't know how to fix the ice turret.
It only works when you only have one, if a frozen enemy is hit twice, it freezes permanently.
Does anyone know how to fix it, please?
Make A Broadcast Message to Wait Seconds Before Unfreezing and Make a Var To Detect How Many Times It Got Shot
And how can I do that?

Just as soon as the laser from turret Equals 2 shots use variables then broadcast message freeze enemy or kill enemy and then in the enemy sprite put delete this clone when receive message.
xavilongo3
Scratcher
63 posts

Help with scrips

loolooqq831 wrote:

xavilongo3 wrote:

LushCaveGod wrote:

xavilongo3 wrote:

I don't know how to fix the ice turret.
It only works when you only have one, if a frozen enemy is hit twice, it freezes permanently.
Does anyone know how to fix it, please?
Make A Broadcast Message to Wait Seconds Before Unfreezing and Make a Var To Detect How Many Times It Got Shot
And how can I do that?

Just as soon as the laser from turret Equals 2 shots use variables then broadcast message freeze enemy or kill enemy and then in the enemy sprite put delete this clone when receive message.
Thank you
I've done it a bit differently, but it's working now.

Powered by DjangoBB